@@ -87,6 +87,7 @@ function initVueComponents(app) {
87
87
}
88
88
89
89
return {
90
+ hasMounted : false , // accessing $refs in computed() need to wait for mounted
90
91
tab,
91
92
repos : [ ] ,
92
93
reposTotalCount : 0 ,
@@ -134,7 +135,19 @@ function initVueComponents(app) {
134
135
} ,
135
136
repoTypeCount ( ) {
136
137
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
+ } ,
138
151
} ,
139
152
140
153
mounted ( ) {
@@ -144,10 +157,11 @@ function initVueComponents(app) {
144
157
initTooltip ( elTooltip ) ;
145
158
}
146
159
$ ( el ) . find ( '.dropdown' ) . dropdown ( ) ;
147
- this . setCheckboxes ( ) ;
148
160
nextTick ( ( ) => {
149
161
this . $refs . search . focus ( ) ;
150
162
} ) ;
163
+
164
+ this . hasMounted = true ;
151
165
} ,
152
166
153
167
methods : {
@@ -156,39 +170,6 @@ function initVueComponents(app) {
156
170
this . updateHistory ( ) ;
157
171
} ,
158
172
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
-
192
173
changeReposFilter ( filter ) {
193
174
this . reposFilter = filter ;
194
175
this . repos = [ ] ;
@@ -245,45 +226,29 @@ function initVueComponents(app) {
245
226
} ,
246
227
247
228
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' ;
261
235
}
262
236
this . page = 1 ;
263
237
this . repos = [ ] ;
264
- this . setCheckboxes ( ) ;
265
238
this . counts [ `${ this . reposFilter } :${ this . archivedFilter } :${ this . privateFilter } ` ] = 0 ;
266
239
this . searchRepos ( ) ;
267
240
} ,
268
241
269
242
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' ;
283
249
}
284
250
this . page = 1 ;
285
251
this . repos = [ ] ;
286
- this . setCheckboxes ( ) ;
287
252
this . counts [ `${ this . reposFilter } :${ this . archivedFilter } :${ this . privateFilter } ` ] = 0 ;
288
253
this . searchRepos ( ) ;
289
254
} ,
0 commit comments