Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
enabled multiple highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed Aug 5, 2021
1 parent 01e02bf commit 643e7c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/change-enable-multiple-highlighting
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change: Enable multiple highlighting for OcTableFiles

We changed the highlighting in a way that now every selected file
is highlighted automatically. The `highlighted` prop has been removed as it's not used anymore.

https://github.com/owncloud/web/issues/5164
https://github.com/owncloud/owncloud-design-system/pull/1568
26 changes: 9 additions & 17 deletions src/components/table/OcTableFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<oc-table
:data="resources"
:fields="fields"
:highlighted="highlighted"
:highlighted="selectedIds"
:disabled="disabled"
:sticky="true"
:header-position="headerPosition"
Expand Down Expand Up @@ -197,14 +197,6 @@ export default {
required: false,
default: true,
},
/**
* The ids of highlighted resources. Null or an empty string/array for no highlighting.
*/
highlighted: {
type: [String, Array],
required: false,
default: null,
},
/**
* Target route path used to build the link when navigating into a resource
*/
Expand Down Expand Up @@ -379,11 +371,15 @@ export default {
areAllResourcesSelected() {
return this.selection.length === this.resources.length
},
selectedIds() {
return this.selectedResources.map(r => r.id)
},
},
methods: {
fileDragged(file) {
const selectedResourceInResources = this.selectedResources.some(e => e.id === file.id)
if (selectedResourceInResources) {
if (!selectedResourceInResources) {
this.selectedResources.push(file)
}
this.$emit("select", this.selectedResources)
Expand Down Expand Up @@ -565,8 +561,8 @@ export default {
```js
<template>
<div>
<oc-table-files :resources="resources" :highlighted="highlighted" disabled="notes" v-model="selected" class="oc-mb"
@showDetails="highlightResource" @action="handleAction" @fileDropped="fileDropped" :drag-drop="true">
<oc-table-files :resources="resources" disabled="notes" v-model="selected" class="oc-mb"
@action="handleAction" @fileDropped="fileDropped" :drag-drop="true">
<template v-slot:quickActions="props">
<oc-button @click.stop variation="passive" appearance="raw" aria-label="Share with other people">
<oc-icon name="group-add" />
Expand All @@ -590,8 +586,7 @@ export default {
<script>
export default {
data: () => ({
selected: [],
highlighted: "forest"
selected: []
}),
computed: {
resources() {
Expand Down Expand Up @@ -654,9 +649,6 @@ export default {
const selectedString = this.selectedIds.join(`, `)
alert(selectedString + ` -> ` + fileId);
},
highlightResource(resource) {
this.highlighted = resource.id
},
handleAction(resource) {
alert(`Clicked ${resource.name}`)
}
Expand Down

0 comments on commit 643e7c0

Please sign in to comment.