-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdrupal-priority-count.js
More file actions
40 lines (38 loc) · 1.35 KB
/
drupal-priority-count.js
File metadata and controls
40 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
let src = chrome.runtime.getURL("toolbarRowFilterer.js");
const { toolbarRowFilterer } = await import(src);
/**
* Creates a toolbar item that lists how many issues are in each priority and allows filtering by priority.
*
* @type {{createElement: (function(): HTMLDivElement)}}
*/
class priorityCountFilter extends toolbarRowFilterer {
createElement() {
// On issue queue search page
const prioritySelect = document.getElementById("edit-priorities");
// Attempt get all selected priorities.
let priorityLabels = Array.from(prioritySelect.options)
.map((option) => {
if (option.selected) {
return option.innerText;
}
return false;
})
.filter((selected) => selected);
if (priorityLabels.length === 1) {
// If there is only on priority shown on the page add an empty element.
return document.createElement("div");
}
if (priorityLabels.length === 0) {
// If no items have been selected show all priorities.
priorityLabels = Array.from(prioritySelect.options).map(
(option) => option.innerText
);
}
const priorityFields = document.querySelectorAll(
"td.views-field-field-issue-priority"
);
return this.setUpFilter(priorityFields, "assigned", priorityLabels);
}
}
const priorityCount = new priorityCountFilter();
export { priorityCount };