Skip to content

Commit e146825

Browse files
committed
fix filter checkbox in dashboard
1 parent d5fa2e7 commit e146825

File tree

2 files changed

+46
-30
lines changed

2 files changed

+46
-30
lines changed

templates/user/dashboard/repolist.tmpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@
4848
<div class="menu">
4949
<div class="item">
5050
<a @click="toggleArchivedFilter()">
51-
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_both_archived_unarchived"}}" v-if="archivedFilter === 'both'">
52-
<input type="checkbox">
51+
<div class="ui checkbox indeterminate" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_both_archived_unarchived"}}" v-if="archivedFilter === 'both'">
52+
<input type="checkbox" v-bind.prop="getArchivedFilterCheckboxState()">
5353
<label>
5454
{{svg "octicon-archive" 16 "mr-2"}}
5555
{{.locale.Tr "home.show_archived"}}
5656
</label>
5757
</div>
5858
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_unarchived"}}" v-if="archivedFilter === 'unarchived'">
59-
<input type="checkbox">
59+
<input type="checkbox" v-bind.prop="getArchivedFilterCheckboxState()">
6060
<label>
6161
{{svg "octicon-archive" 16 "mr-2"}}
6262
{{.locale.Tr "home.show_archived"}}
6363
</label>
6464
</div>
65-
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_archived"}}" v-if="archivedFilter === 'archived'">
66-
<input type="checkbox">
65+
<div class="ui checkbox checked" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_archived"}}" v-if="archivedFilter === 'archived'">
66+
<input type="checkbox" v-bind.prop="getArchivedFilterCheckboxState()">
6767
<label>
6868
{{svg "octicon-archive" 16 "mr-2"}}
6969
{{.locale.Tr "home.show_archived"}}
@@ -73,22 +73,22 @@
7373
</div>
7474
<div class="item">
7575
<a @click="togglePrivateFilter()">
76-
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_both_private_public"}}" v-if="privateFilter === 'both'">
77-
<input type="checkbox">
76+
<div class="ui checkbox indeterminate" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_both_private_public"}}" v-if="privateFilter === 'both'">
77+
<input type="checkbox" v-bind.prop="getPrivateFilterCheckboxState()">
7878
<label>
7979
{{svg "octicon-lock" 16 "mr-2"}}
8080
{{.locale.Tr "home.show_private"}}
8181
</label>
8282
</div>
8383
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_public"}}" v-if="privateFilter === 'public'">
84-
<input type="checkbox">
84+
<input type="checkbox" v-bind.prop="getPrivateFilterCheckboxState()">
8585
<label>
8686
{{svg "octicon-lock" 16 "mr-2"}}
8787
{{.locale.Tr "home.show_private"}}
8888
</label>
8989
</div>
90-
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_private"}}" v-if="privateFilter === 'private'">
91-
<input type="checkbox">
90+
<div class="ui checkbox checked" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_private"}}" v-if="privateFilter === 'private'">
91+
<input type="checkbox" v-bind.prop="getPrivateFilterCheckboxState()">
9292
<label>
9393
{{svg "octicon-lock" 16 "mr-2"}}
9494
{{.locale.Tr "home.show_private"}}

web_src/js/components/DashboardRepoList.js

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ function initVueComponents(app) {
144144
initTooltip(elTooltip);
145145
}
146146
$(el).find('.dropdown').dropdown();
147-
this.setCheckboxes();
148147
nextTick(() => {
149148
this.$refs.search.focus();
150149
});
@@ -156,36 +155,55 @@ function initVueComponents(app) {
156155
this.updateHistory();
157156
},
158157

159-
setCheckboxes() {
158+
getArchivedFilterCheckboxState() {
160159
switch (this.archivedFilter) {
161160
case 'unarchived':
162-
$('#archivedFilterCheckbox').checkbox('set unchecked');
163-
break;
161+
return {
162+
checked: false,
163+
indeterminate: false
164+
}
164165
case 'archived':
165-
$('#archivedFilterCheckbox').checkbox('set checked');
166-
break;
166+
return {
167+
checked: true,
168+
indeterminate: false
169+
}
167170
case 'both':
168-
$('#archivedFilterCheckbox').checkbox('set indeterminate');
169-
break;
171+
return {
172+
checked: false,
173+
indeterminate: true
174+
}
170175
default:
171176
this.archivedFilter = 'unarchived';
172-
$('#archivedFilterCheckbox').checkbox('set unchecked');
173-
break;
177+
return {
178+
checked: false,
179+
indeterminate: true
180+
}
174181
}
182+
},
183+
184+
getPrivateFilterCheckboxState() {
175185
switch (this.privateFilter) {
176186
case 'public':
177-
$('#privateFilterCheckbox').checkbox('set unchecked');
178-
break;
187+
return {
188+
checked: false,
189+
indeterminate: false
190+
}
179191
case 'private':
180-
$('#privateFilterCheckbox').checkbox('set checked');
181-
break;
192+
return {
193+
checked: true,
194+
indeterminate: false
195+
}
182196
case 'both':
183-
$('#privateFilterCheckbox').checkbox('set indeterminate');
184-
break;
197+
return {
198+
checked: false,
199+
indeterminate: true
200+
}
185201
default:
186202
this.privateFilter = 'both';
187-
$('#privateFilterCheckbox').checkbox('set indeterminate');
188-
break;
203+
return {
204+
checked: false,
205+
indeterminate: true
206+
}
189207
}
190208
},
191209

@@ -261,7 +279,6 @@ function initVueComponents(app) {
261279
}
262280
this.page = 1;
263281
this.repos = [];
264-
this.setCheckboxes();
265282
this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
266283
this.searchRepos();
267284
},
@@ -283,7 +300,6 @@ function initVueComponents(app) {
283300
}
284301
this.page = 1;
285302
this.repos = [];
286-
this.setCheckboxes();
287303
this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
288304
this.searchRepos();
289305
},

0 commit comments

Comments
 (0)