1
1
function setBranchOptions ( branches , selectedBranchNames , allBranches ) {
2
2
var branchesContainer = document . getElementById ( "branches-list-parent" ) ;
3
3
var existingChild = branchesContainer . children [ 0 ] ;
4
+ var branchesDropdownButton = document . getElementById ( "branches-dropdown-button" ) ;
4
5
5
6
var branchNames = new Set ( )
6
7
for ( var branch in allBranches ) {
@@ -11,6 +12,12 @@ function setBranchOptions(branches, selectedBranchNames, allBranches) {
11
12
var newChild = existingChild . cloneNode ( true ) ;
12
13
newChild . children [ 1 ] . innerHTML = branch ;
13
14
newChild . setAttribute ( "branch-name" , branch ) ;
15
+ if ( selectedBranchNames . includes ( branch ) ) {
16
+ newChild . setAttribute ( "aria-checked" , "true" ) ;
17
+ }
18
+ else {
19
+ newChild . setAttribute ( "aria-checked" , "false" ) ;
20
+ }
14
21
newChild . addEventListener ( "click" , ( ) => {
15
22
var thisItem = document . querySelector ( `[branch-name="${ branch } "]` ) ;
16
23
@@ -33,6 +40,15 @@ function setBranchOptions(branches, selectedBranchNames, allBranches) {
33
40
branchesContainer . appendChild ( newChild ) ;
34
41
} ) ;
35
42
43
+ if ( branchNames . size == selectedBranchNames . length ) {
44
+ branchesContainer . children [ 0 ] . setAttribute ( "aria-checked" , "true" ) ;
45
+ branchesDropdownButton . innerHTML = "All Branches" ;
46
+ }
47
+ else {
48
+ branchesContainer . children [ 0 ] . setAttribute ( "aria-checked" , "false" ) ;
49
+ branchesDropdownButton . innerHTML = "Select Branches" ;
50
+ }
51
+
36
52
// Action for the "All branches" button
37
53
branchesContainer . children [ 0 ] . addEventListener ( "click" , ( ) => {
38
54
if ( branchesContainer . children [ 0 ] . getAttribute ( "aria-checked" ) == "true" ) {
0 commit comments