Skip to content

Commit ebf1a5b

Browse files
feat: allow "Select all" monitors on the maintenance page (#6528)
2 parents 827ba07 + b294dd6 commit ebf1a5b

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

src/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,8 @@
11491149
"Money": "Money",
11501150
"Scifi": "Scifi",
11511151
"Clear": "Clear",
1152+
"Select All": "Select All",
1153+
"Deselect All": "Deselect All",
11521154
"Elevator": "Elevator",
11531155
"Guitar": "Guitar",
11541156
"Pop": "Pop",

src/pages/EditMaintenance.vue

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828

2929
<!-- Affected Monitors -->
3030
<h2 class="mt-5">{{ $t("Affected Monitors") }}</h2>
31-
{{ $t("affectedMonitorsDescription") }}
3231

3332
<div class="my-3">
33+
<div class="d-flex justify-content-between align-items-center mb-2">
34+
<div class="form-text">{{ $t("affectedMonitorsDescription") }}</div>
35+
</div>
36+
3437
<VueMultiselect
3538
id="affected_monitors"
3639
v-model="affectedMonitors"
37-
:options="affectedMonitorsOptions"
40+
:options="affectedMonitorsOptionsWithSelectAll"
3841
track-by="id"
3942
label="pathName"
4043
:multiple="true"
@@ -45,7 +48,16 @@
4548
:preselect-first="false"
4649
:max-height="600"
4750
:taggable="false"
48-
></VueMultiselect>
51+
@select="onMonitorSelect"
52+
@remove="onMonitorRemove"
53+
>
54+
<template #option="props">
55+
<span v-if="props.option.id === 'select-all'">
56+
{{ affectedMonitorsAllSelected ? $t('Deselect All') : $t('Select All') }}
57+
</span>
58+
<span v-else>{{ props.option.pathName }}</span>
59+
</template>
60+
</VueMultiselect>
4961
</div>
5062

5163
<!-- Status pages to display maintenance info on -->
@@ -353,6 +365,21 @@ export default {
353365
});
354366
},
355367
368+
affectedMonitorsOptionsWithSelectAll() {
369+
return [
370+
{
371+
id: "select-all",
372+
pathName: this.affectedMonitorsAllSelected ? this.$t("Deselect All") : this.$t("Select All")
373+
},
374+
...this.affectedMonitorsOptions
375+
];
376+
},
377+
378+
affectedMonitorsAllSelected() {
379+
return this.affectedMonitors.length > 0 &&
380+
this.affectedMonitors.length === this.affectedMonitorsOptions.length;
381+
},
382+
356383
pageName() {
357384
let name = "Schedule Maintenance";
358385
@@ -494,6 +521,24 @@ export default {
494521
}
495522
},
496523
524+
onMonitorSelect(selectedOption) {
525+
if (selectedOption.id === "select-all") {
526+
this.affectedMonitors = this.affectedMonitors.filter(m => m.id !== "select-all");
527+
528+
if (this.affectedMonitorsAllSelected) {
529+
this.affectedMonitors = [];
530+
} else {
531+
this.affectedMonitors = this.affectedMonitorsOptions.slice();
532+
}
533+
}
534+
},
535+
536+
onMonitorRemove(removedOption) {
537+
if (removedOption.id === "select-all") {
538+
this.affectedMonitors = this.affectedMonitors.filter(m => m.id !== "select-all");
539+
}
540+
},
541+
497542
/**
498543
* Create new maintenance
499544
* @returns {Promise<void>}

0 commit comments

Comments
 (0)