@@ -87,6 +87,7 @@ function initVueComponents(app) {
8787 }
8888
8989 return {
90+ hasMounted : false , // accessing $refs in computed() need to wait for mounted
9091 tab,
9192 repos : [ ] ,
9293 reposTotalCount : 0 ,
@@ -134,7 +135,19 @@ function initVueComponents(app) {
134135 } ,
135136 repoTypeCount ( ) {
136137 return this . counts [ `${ this . reposFilter } :${ this . archivedFilter } :${ this . privateFilter } ` ] ;
137- }
138+ } ,
139+ checkboxArchivedFilterTitle ( ) {
140+ return this . hasMounted && this . $refs . checkboxArchivedFilter ?. getAttribute ( `data-title-${ this . archivedFilter } ` ) ;
141+ } ,
142+ checkboxArchivedFilterProps ( ) {
143+ return { checked : this . archivedFilter === 'archived' , indeterminate : this . archivedFilter === 'both' } ;
144+ } ,
145+ checkboxPrivateFilterTitle ( ) {
146+ return this . hasMounted && this . $refs . checkboxPrivateFilter ?. getAttribute ( `data-title-${ this . privateFilter } ` ) ;
147+ } ,
148+ checkboxPrivateFilterProps ( ) {
149+ return { checked : this . privateFilter === 'private' , indeterminate : this . privateFilter === 'both' } ;
150+ } ,
138151 } ,
139152
140153 mounted ( ) {
@@ -144,10 +157,11 @@ function initVueComponents(app) {
144157 initTooltip ( elTooltip ) ;
145158 }
146159 $ ( el ) . find ( '.dropdown' ) . dropdown ( ) ;
147- this . setCheckboxes ( ) ;
148160 nextTick ( ( ) => {
149161 this . $refs . search . focus ( ) ;
150162 } ) ;
163+
164+ this . hasMounted = true ;
151165 } ,
152166
153167 methods : {
@@ -156,39 +170,6 @@ function initVueComponents(app) {
156170 this . updateHistory ( ) ;
157171 } ,
158172
159- setCheckboxes ( ) {
160- switch ( this . archivedFilter ) {
161- case 'unarchived' :
162- $ ( '#archivedFilterCheckbox' ) . checkbox ( 'set unchecked' ) ;
163- break ;
164- case 'archived' :
165- $ ( '#archivedFilterCheckbox' ) . checkbox ( 'set checked' ) ;
166- break ;
167- case 'both' :
168- $ ( '#archivedFilterCheckbox' ) . checkbox ( 'set indeterminate' ) ;
169- break ;
170- default :
171- this . archivedFilter = 'unarchived' ;
172- $ ( '#archivedFilterCheckbox' ) . checkbox ( 'set unchecked' ) ;
173- break ;
174- }
175- switch ( this . privateFilter ) {
176- case 'public' :
177- $ ( '#privateFilterCheckbox' ) . checkbox ( 'set unchecked' ) ;
178- break ;
179- case 'private' :
180- $ ( '#privateFilterCheckbox' ) . checkbox ( 'set checked' ) ;
181- break ;
182- case 'both' :
183- $ ( '#privateFilterCheckbox' ) . checkbox ( 'set indeterminate' ) ;
184- break ;
185- default :
186- this . privateFilter = 'both' ;
187- $ ( '#privateFilterCheckbox' ) . checkbox ( 'set indeterminate' ) ;
188- break ;
189- }
190- } ,
191-
192173 changeReposFilter ( filter ) {
193174 this . reposFilter = filter ;
194175 this . repos = [ ] ;
@@ -245,45 +226,29 @@ function initVueComponents(app) {
245226 } ,
246227
247228 toggleArchivedFilter ( ) {
248- switch ( this . archivedFilter ) {
249- case 'both' :
250- this . archivedFilter = 'unarchived' ;
251- break ;
252- case 'unarchived' :
253- this . archivedFilter = 'archived' ;
254- break ;
255- case 'archived' :
256- this . archivedFilter = 'both' ;
257- break ;
258- default :
259- this . archivedFilter = 'unarchived' ;
260- break ;
229+ if ( this . archivedFilter === 'unarchived' ) {
230+ this . archivedFilter = 'archived' ;
231+ } else if ( this . archivedFilter === 'archived' ) {
232+ this . archivedFilter = 'both' ;
233+ } else { // including both
234+ this . archivedFilter = 'unarchived' ;
261235 }
262236 this . page = 1 ;
263237 this . repos = [ ] ;
264- this . setCheckboxes ( ) ;
265238 this . counts [ `${ this . reposFilter } :${ this . archivedFilter } :${ this . privateFilter } ` ] = 0 ;
266239 this . searchRepos ( ) ;
267240 } ,
268241
269242 togglePrivateFilter ( ) {
270- switch ( this . privateFilter ) {
271- case 'both' :
272- this . privateFilter = 'public' ;
273- break ;
274- case 'public' :
275- this . privateFilter = 'private' ;
276- break ;
277- case 'private' :
278- this . privateFilter = 'both' ;
279- break ;
280- default :
281- this . privateFilter = 'both' ;
282- break ;
243+ if ( this . privateFilter === 'both' ) {
244+ this . privateFilter = 'public' ;
245+ } else if ( this . privateFilter === 'public' ) {
246+ this . privateFilter = 'private' ;
247+ } else { // including private
248+ this . privateFilter = 'both' ;
283249 }
284250 this . page = 1 ;
285251 this . repos = [ ] ;
286- this . setCheckboxes ( ) ;
287252 this . counts [ `${ this . reposFilter } :${ this . archivedFilter } :${ this . privateFilter } ` ] = 0 ;
288253 this . searchRepos ( ) ;
289254 } ,
0 commit comments