Skip to content

Commit fc88999

Browse files
author
Erwin Dondorp
committed
implement all of all/none/reverse
1 parent 5c5006d commit fc88999

8 files changed

Lines changed: 46 additions & 25 deletions

File tree

docs/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,12 @@ But note that there might be more possible solutions, some of which may actually
402402
* A navigation-command to go to a page for more details.
403403

404404
## Minion selection
405-
Pages that show a simple list of minions allow individual miniuns to be selected.
405+
Pages that show a simple list of minions allow individual minions to be selected.
406406
Use panel button [] to show an extra column with checkboxes in the table.
407-
Minions can be selected one-by-one or the selection can be inverted by clicking on the column header.
407+
Minions can be selected one-by-one or you can use select-all, select-none by clicking on the column header.
408+
The selection can be inverted by using CTRL-click.
408409
The list of selected minions will be used in the command-box and for commands from a panel-menu.
409-
When the column is hidden, the selection-values are ignored.
410+
When the column is hidden, the selection-values are just ignored.
410411

411412
## Command documentation
412413

saltgui/static/scripts/panels/Beacons.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global */
22

3-
import {Character} from "../Character.js";
43
import {Panel} from "./Panel.js";
54
import {Utils} from "../Utils.js";
65

@@ -23,7 +22,7 @@ export class BeaconsPanel extends Panel {
2322
const localBeaconsListPromise = this.api.getLocalBeaconsList(null);
2423

2524
const selectVisible = Utils.getStorageItemBoolean("session", "select_visible", false);
26-
this.showColumn(Character.HEAVY_CHECK_MARK, selectVisible);
25+
this.showSelectColumn(selectVisible);
2726

2827
this.nrMinions = 0;
2928

saltgui/static/scripts/panels/Grains.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global jsonPath */
22

3-
import {Character} from "../Character.js";
43
import {Output} from "../output/Output.js";
54
import {Panel} from "./Panel.js";
65
import {Utils} from "../Utils.js";
@@ -29,7 +28,7 @@ export class GrainsPanel extends Panel {
2928

3029
onShow () {
3130
const selectVisible = Utils.getStorageItemBoolean("session", "select_visible", false);
32-
this.showColumn(Character.HEAVY_CHECK_MARK, selectVisible);
31+
this.showSelectColumn(selectVisible);
3332

3433
if (this.previewColumsAdded !== true) {
3534
// collect the list of displayed extra grains

saltgui/static/scripts/panels/HighState.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class HighStatePanel extends Panel {
5050
const wheelKeyListAllPromise = this.api.getWheelKeyListAll();
5151

5252
const selectVisible = Utils.getStorageItemBoolean("session", "select_visible", false);
53-
this.showColumn(Character.HEAVY_CHECK_MARK, selectVisible);
53+
this.showSelectColumn(selectVisible);
5454

5555
this.nrMinions = 0;
5656

saltgui/static/scripts/panels/Minions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class MinionsPanel extends Panel {
4444
const runnerManageVersionsPromise = this.api.getRunnerManageVersions();
4545

4646
const selectVisible = Utils.getStorageItemBoolean("session", "select_visible", false);
47-
this.showColumn(Character.HEAVY_CHECK_MARK, selectVisible);
47+
this.showSelectColumn(selectVisible);
4848

4949
this.loadMinionsTxt();
5050

saltgui/static/scripts/panels/Panel.js

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Panel {
7979
span.addEventListener("click", (pClickEvent) => {
8080
const selectVisible = !Utils.getStorageItemBoolean("session", "select_visible", false);
8181
Utils.setStorageItem("session", "select_visible", selectVisible);
82-
this.showColumn (Character.HEAVY_CHECK_MARK, selectVisible);
82+
this.showSelectColumn(selectVisible);
8383
const tbody = this.table.tBodies[0];
8484
const selectMinions = Utils.getStorageItem("session", "select_minions", "");
8585
for (const tr of tbody.rows) {
@@ -221,6 +221,33 @@ export class Panel {
221221
this.updateFooter();
222222
}
223223

224+
selectAllNone () {
225+
const lst = CommandBox.getSelectedMinionList();
226+
227+
let selectAll;
228+
if (lst === null) {
229+
selectAll = true;
230+
} else {
231+
const nrSelected = lst.split(",").length;
232+
selectAll = nrSelected !== this.nrMinions;
233+
}
234+
235+
let selectMinions = ",";
236+
for (const tr of this.table.tBodies[0].children) {
237+
const td = tr.children[0];
238+
if (selectAll) {
239+
td.innerText = Character.BALLOT_BOX_WITH_CHECK;
240+
selectMinions += tr.dataset.minionId + ",";
241+
} else {
242+
td.innerText = Character.BALLOT_BOX_UNCHECKED;
243+
}
244+
}
245+
246+
Utils.setStorageItem("session", "select_minions", selectMinions);
247+
248+
this.updateFooter();
249+
}
250+
224251
addTable (pColumnNames, pFieldList = null) {
225252
const table = Utils.createElem("table", this.key, "", this.key + "-table");
226253

@@ -242,8 +269,13 @@ export class Panel {
242269
if (!selectVisible) {
243270
th.style.display = "none";
244271
}
272+
Utils.addToolTip(th, "Click here to select all/none\nCTRL-click to invert selection", "bottom-left");
245273
th.addEventListener("click", (pClickEvent) => {
246-
this.toggleSelection();
274+
if (pClickEvent.ctrlKey || pClickEvent.altKey) {
275+
this.toggleSelection();
276+
} else {
277+
this.selectAllNone();
278+
}
247279
pClickEvent.stopPropagation();
248280
});
249281
} else if (!columnName.startsWith("-")) {
@@ -1072,17 +1104,9 @@ export class Panel {
10721104
}
10731105
}
10741106

1075-
showColumn (pColTitle, pShow) {
1107+
showSelectColumn (pShow) {
10761108

1077-
let colNr = -1;
1078-
// find a column with this name
1079-
for (let i = 0; i < this.table.tHead.children[0].children.length; i++) {
1080-
const th = this.table.tHead.children[0].children[i];
1081-
if (th.innerText === pColTitle) {
1082-
colNr = i;
1083-
break;
1084-
}
1085-
}
1109+
const colNr = 0;
10861110

10871111
// title
10881112
for (const tr of this.table.tHead.children) {

saltgui/static/scripts/panels/Pillars.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global */
22

3-
import {Character} from "../Character.js";
43
import {Panel} from "./Panel.js";
54
import {Utils} from "../Utils.js";
65

@@ -27,7 +26,7 @@ export class PillarsPanel extends Panel {
2726
const localPillarObfuscatePromise = useCachePillar ? this.api.getRunnerCachePillar(null) : this.api.getLocalPillarObfuscate(null);
2827

2928
const selectVisible = Utils.getStorageItemBoolean("session", "select_visible", false);
30-
this.showColumn(Character.HEAVY_CHECK_MARK, selectVisible);
29+
this.showSelectColumn(selectVisible);
3130

3231
this.nrMinions = 0;
3332

saltgui/static/scripts/panels/Schedules.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global */
22

3-
import {Character} from "../Character.js";
43
import {Panel} from "./Panel.js";
54
import {Utils} from "../Utils.js";
65

@@ -23,7 +22,7 @@ export class SchedulesPanel extends Panel {
2322
const localScheduleListPromise = this.api.getLocalScheduleList(null);
2423

2524
const selectVisible = Utils.getStorageItemBoolean("session", "select_visible", false);
26-
this.showColumn(Character.HEAVY_CHECK_MARK, selectVisible);
25+
this.showSelectColumn(selectVisible);
2726

2827
this.nrMinions = 0;
2928

0 commit comments

Comments
 (0)