Skip to content

Commit

Permalink
Disable currently selected resources
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Jan 24, 2025
1 parent 58f9ff6 commit 82cf6cf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
type: Array,
required: true,
},
noSelectableResourcesIds: {
type: Array,
required: false,
default: null,
},
disabled: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -155,12 +160,15 @@
}
},
contentCheckboxDisabled(resource) {
if (this.disabled) {
if (this.disabled || this.noSelectableResourcesIds?.includes(resource.id)) {
return true;
}
return !this.selectionRules.every(rule => rule(resource) === true);
},
contentIsChecked(resource) {
if (this.noSelectableResourcesIds?.includes(resource.id)) {
return true;
}
return this.selectedResources.some(res => res.id === resource.id);
},
toggleSelected({ content, checked }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
:treeFetch="treeFetch"
:selectionRules="selectionRules"
:selectedResources="selectedResources"
:noSelectableResourcesIds="noSelectableResourcesIds"
:selectedResourcesSize="selectedResourcesSize"
@selectResources="selectResources"
@deselectResources="deselectResources"
Expand Down Expand Up @@ -170,6 +171,9 @@
bytesText: bytesForHumans(this.selectedResourcesSize),
});
},
noSelectableResourcesIds() {
return this.workingResources.map(resource => resource.contentnode_id);
},
},
methods: {
...mapActions('lessonSummary', ['saveLessonResources', 'addToResourceCache']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:loadingMore="loadingMore"
:selectionRules="selectionRules"
:selectedResources="selectedResources"
:noSelectableResourcesIds="noSelectableResourcesIds"
@selectResources="$emit('selectResources', $event)"
@deselectResources="$emit('deselectResources', $event)"
/>
Expand Down Expand Up @@ -80,6 +81,11 @@
type: Array,
required: true,
},
noSelectableResourcesIds: {
type: Array,
required: false,
default: null,
},
disabled: {
type: Boolean,
default: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
:loadingMore="loadingMore"
:selectionRules="selectionRules"
:selectedResources="selectedResources"
:noSelectableResourcesIds="noSelectableResourcesIds"
@selectResources="$emit('selectResources', $event)"
@deselectResources="$emit('deselectResources', $event)"
/>
Expand Down Expand Up @@ -113,6 +114,11 @@
type: Array,
required: true,
},
noSelectableResourcesIds: {
type: Array,
required: false,
default: null,
},
disabled: {
type: Boolean,
default: false,
Expand Down

0 comments on commit 82cf6cf

Please sign in to comment.