Skip to content

Commit

Permalink
Fix bulk menu conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Feb 12, 2024
1 parent 79fee2a commit 811f8cf
Showing 1 changed file with 60 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
<b-dropdown-text>
<span v-localize data-description="selected count">With {{ numSelected }} selected...</span>
</b-dropdown-text>
<b-dropdown-item v-if="showHidden" v-b-modal:show-selected-content data-description="unhide option">
<b-dropdown-item
v-if="canUnhideSelection"
v-b-modal:show-selected-content
data-description="unhide option">
<span v-localize>Unhide</span>
</b-dropdown-item>
<b-dropdown-item v-else v-b-modal:hide-selected-content data-description="hide option">
<b-dropdown-item v-if="canHideSelection" v-b-modal:hide-selected-content data-description="hide option">
<span v-localize>Hide</span>
</b-dropdown-item>
<b-dropdown-item
Expand All @@ -26,7 +29,7 @@
<span v-localize>Undelete</span>
</b-dropdown-item>
<b-dropdown-item
v-if="!showStrictDeleted"
v-if="canDeleteSelection"
v-b-modal:delete-selected-content
data-description="delete option">
<span v-localize>Delete</span>
Expand Down Expand Up @@ -195,20 +198,37 @@ export default {
},
computed: {
/** @returns {Boolean} */
showHidden() {
return !HistoryFilters.checkFilter(this.filterText, "visible", true);
canUnhideSelection() {
return (
this.areAllSelectedHidden ||
(HistoryFilters.checkFilter(this.filterText, "visible", "any") && !this.areAllSelectedVisible)
);
},
/** @returns {Boolean} */
canHideSelection() {
return (
this.areAllSelectedVisible ||
(HistoryFilters.checkFilter(this.filterText, "visible", "any") && !this.areAllSelectedHidden)
);
},
/** @returns {Boolean} */
showDeleted() {
return !HistoryFilters.checkFilter(this.filterText, "deleted", false);
},
/** @returns {Boolean} */
showStrictDeleted() {
return HistoryFilters.checkFilter(this.filterText, "deleted", true);
canDeleteSelection() {
return (
this.areAllSelectedActive ||
(HistoryFilters.checkFilter(this.filterText, "deleted", "any") && !this.areAllSelectedDeleted)
);
},
/** @returns {Boolean} */
canUndeleteSelection() {
return this.showDeleted && (this.isQuerySelection || !this.areAllSelectedPurged);
},
/** @returns {Boolean} */
showBuildOptions() {
return !this.isQuerySelection && !this.showHidden && !this.showDeleted;
return !this.isQuerySelection && this.areAllSelectedActive && !this.showDeleted;
},
/** @returns {Boolean} */
showBuildOptionForAll() {
Expand All @@ -229,9 +249,6 @@ export default {
noTagsSelected() {
return this.selectedTags.length === 0;
},
canUndeleteSelection() {
return this.showDeleted && (this.isQuerySelection || !this.areAllSelectedPurged);
},
areAllSelectedPurged() {
for (const item of this.contentSelection.values()) {
if (Object.prototype.hasOwnProperty.call(item, "purged") && !item["purged"]) {
Expand All @@ -240,6 +257,38 @@ export default {
}
return true;
},
areAllSelectedVisible() {
for (const item of this.contentSelection.values()) {
if (Object.prototype.hasOwnProperty.call(item, "visible") && !item["visible"]) {
return false;
}
}
return true;
},
areAllSelectedHidden() {
for (const item of this.contentSelection.values()) {
if (Object.prototype.hasOwnProperty.call(item, "visible") && item["visible"]) {
return false;
}
}
return true;
},
areAllSelectedActive() {
for (const item of this.contentSelection.values()) {
if (Object.prototype.hasOwnProperty.call(item, "deleted") && item["deleted"]) {
return false;
}
}
return true;
},
areAllSelectedDeleted() {
for (const item of this.contentSelection.values()) {
if (Object.prototype.hasOwnProperty.call(item, "deleted") && !item["deleted"]) {
return false;
}
}
return true;
},
},
watch: {
hasSelection(newVal) {
Expand Down

0 comments on commit 811f8cf

Please sign in to comment.