@@ -13,6 +13,7 @@ class Groups {
1313 constructor ( api , state , target ) {
1414 this . api = api ;
1515 this . state = state ;
16+ this . baseNode ;
1617 this . groupsDictionary ;
1718 this . root = document . getElementById ( target ) ;
1819 this . activeLabel = document . getElementById ( 'active-group' ) ;
@@ -27,7 +28,7 @@ class Groups {
2728 * collected groups and use this method to just re-generate the base html.
2829 */
2930 generateRootHtml ( ) {
30- let html = _GroupHelper . generateNodeHtml ( groupsFilter . groupsDictionary , 'GroupCompanyId' ) ;
31+ let html = _GroupHelper . generateNodeHtml ( groupsFilter . groupsDictionary , this . baseNode ) ;
3132 groupsFilter . root . innerHTML = html ;
3233 }
3334
@@ -53,7 +54,7 @@ class Groups {
5354
5455 /**
5556 * Removes all group names from the 'Active Groups' header.
56- * Removes all groups except for the root group 'GroupCompanyId' from the state.
57+ * Removes all groups from the state.
5758 * Unselects any previously selected groups in the groupsDictionary.
5859 * Resets the HTML to remove any checked attributes.
5960 */
@@ -66,7 +67,7 @@ class Groups {
6667
6768 this . writeActiveGroups ( ) ;
6869
69- let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , 'GroupCompanyId' ) ;
70+ let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , this . baseNode ) ;
7071 this . root . innerHTML = html ;
7172
7273 geotab . addin . < %= root % > . focus ( this . api , this . state ) ;
@@ -145,7 +146,7 @@ class Groups {
145146 */
146147 changeFocus ( previous , current ) {
147148 this . previousGroupStack . push ( previous ) ;
148- let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , current ) ;
149+ let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , current , this . baseNode ) ;
149150 this . root . innerHTML = html ;
150151 }
151152
@@ -155,7 +156,7 @@ class Groups {
155156 */
156157 goToPreviousFolder ( ) {
157158 let previousFolder = this . previousGroupStack . pop ( ) ;
158- let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , previousFolder ) ;
159+ let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , previousFolder , this . baseNode ) ;
159160 this . root . innerHTML = html ;
160161 }
161162
@@ -166,8 +167,9 @@ class Groups {
166167 */
167168 _groupSuccessCallback ( result , resolve ) {
168169 let groupInput = document . getElementById ( 'group-input' ) ;
170+ this . baseNode = result [ 0 ] . id ;
169171 this . groupsDictionary = _GroupHelper . convertGroupsListToDictionary ( result ) ;
170- let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , 'GroupCompanyId' ) ;
172+ let html = _GroupHelper . generateNodeHtml ( this . groupsDictionary , this . baseNode ) ;
171173 this . root . innerHTML = html ;
172174
173175 // If we had any errors, we want to reset the placeholder text.
@@ -188,7 +190,7 @@ class Groups {
188190
189191 setTimeout ( ( ) => {
190192 groupInput . placeholder = "Retrying..." ;
191- this . groupsFilter . getAllGroupsInDatabase ( ) ;
193+ groupsFilter . getAllGroupsInDatabase ( ) ;
192194 } , 60000 ) ;
193195 }
194196}
0 commit comments