|
28 | 28 |
|
29 | 29 | <!-- Affected Monitors --> |
30 | 30 | <h2 class="mt-5">{{ $t("Affected Monitors") }}</h2> |
31 | | - {{ $t("affectedMonitorsDescription") }} |
32 | 31 |
|
33 | 32 | <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 | + |
34 | 37 | <VueMultiselect |
35 | 38 | id="affected_monitors" |
36 | 39 | v-model="affectedMonitors" |
37 | | - :options="affectedMonitorsOptions" |
| 40 | + :options="affectedMonitorsOptionsWithSelectAll" |
38 | 41 | track-by="id" |
39 | 42 | label="pathName" |
40 | 43 | :multiple="true" |
|
45 | 48 | :preselect-first="false" |
46 | 49 | :max-height="600" |
47 | 50 | :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> |
49 | 61 | </div> |
50 | 62 |
|
51 | 63 | <!-- Status pages to display maintenance info on --> |
@@ -353,6 +365,21 @@ export default { |
353 | 365 | }); |
354 | 366 | }, |
355 | 367 |
|
| 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 | +
|
356 | 383 | pageName() { |
357 | 384 | let name = "Schedule Maintenance"; |
358 | 385 |
|
@@ -494,6 +521,24 @@ export default { |
494 | 521 | } |
495 | 522 | }, |
496 | 523 |
|
| 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 | +
|
497 | 542 | /** |
498 | 543 | * Create new maintenance |
499 | 544 | * @returns {Promise<void>} |
|
0 commit comments