forked from tedbow/drupal-gitlab-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drupal-user-count.js
29 lines (27 loc) · 973 Bytes
/
drupal-user-count.js
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
let src = chrome.runtime.getURL("toolbarRowFilterer.js");
const { toolbarRowFilterer } = await import(src);
/**
* Creates a toolbar item that lists how many issues each user has and allows filtering by user.
*
* @type {{createElement: (function(): HTMLDivElement)}}
*/
class userCountFilter extends toolbarRowFilterer {
createElement() {
// On issue queue search page
const assignedInput = document.getElementById("edit-assigned");
const assignedText = assignedInput.getAttribute("value").trim();
const assignedFields = document.querySelectorAll(
"td.views-field-field-issue-assigned"
);
if (assignedText) {
const filterValues = assignedText.split(",").map((name) => name.trim());
return this.setUpFilter(assignedFields, "user", filterValues);
}
return this.setUpFilter(assignedFields, "user");
}
getNoValueLabel() {
return "Unassigned";
}
}
const userCount = new userCountFilter();
export { userCount };