Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty checkbox in dashboard repolist's filter #22813

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions templates/user/dashboard/repolist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@
<div class="menu">
<div class="item">
<a @click="toggleArchivedFilter()">
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_both_archived_unarchived"}}" v-if="archivedFilter === 'both'">
<input type="checkbox">
<div class="ui checkbox indeterminate" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_both_archived_unarchived"}}" v-if="archivedFilter === 'both'">
<input type="checkbox" v-bind.prop="getArchivedFilterCheckboxState()">
<label>
{{svg "octicon-archive" 16 "mr-2"}}
{{.locale.Tr "home.show_archived"}}
</label>
</div>
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_unarchived"}}" v-if="archivedFilter === 'unarchived'">
<input type="checkbox">
<input type="checkbox" v-bind.prop="getArchivedFilterCheckboxState()">
<label>
{{svg "octicon-archive" 16 "mr-2"}}
{{.locale.Tr "home.show_archived"}}
</label>
</div>
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_archived"}}" v-if="archivedFilter === 'archived'">
<input type="checkbox">
<div class="ui checkbox checked" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_archived"}}" v-if="archivedFilter === 'archived'">
<input type="checkbox" v-bind.prop="getArchivedFilterCheckboxState()">
<label>
{{svg "octicon-archive" 16 "mr-2"}}
{{.locale.Tr "home.show_archived"}}
Expand All @@ -73,22 +73,22 @@
</div>
<div class="item">
<a @click="togglePrivateFilter()">
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_both_private_public"}}" v-if="privateFilter === 'both'">
<input type="checkbox">
<div class="ui checkbox indeterminate" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_both_private_public"}}" v-if="privateFilter === 'both'">
<input type="checkbox" v-bind.prop="getPrivateFilterCheckboxState()">
<label>
{{svg "octicon-lock" 16 "mr-2"}}
{{.locale.Tr "home.show_private"}}
</label>
</div>
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_public"}}" v-if="privateFilter === 'public'">
<input type="checkbox">
<input type="checkbox" v-bind.prop="getPrivateFilterCheckboxState()">
<label>
{{svg "octicon-lock" 16 "mr-2"}}
{{.locale.Tr "home.show_private"}}
</label>
</div>
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_private"}}" v-if="privateFilter === 'private'">
<input type="checkbox">
<div class="ui checkbox checked" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_private"}}" v-if="privateFilter === 'private'">
<input type="checkbox" v-bind.prop="getPrivateFilterCheckboxState()">
<label>
{{svg "octicon-lock" 16 "mr-2"}}
{{.locale.Tr "home.show_private"}}
Expand Down
56 changes: 36 additions & 20 deletions web_src/js/components/DashboardRepoList.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ function initVueComponents(app) {
initTooltip(elTooltip);
}
$(el).find('.dropdown').dropdown();
this.setCheckboxes();
nextTick(() => {
this.$refs.search.focus();
});
Expand All @@ -156,36 +155,55 @@ function initVueComponents(app) {
this.updateHistory();
},

setCheckboxes() {
getArchivedFilterCheckboxState() {
switch (this.archivedFilter) {
case 'unarchived':
$('#archivedFilterCheckbox').checkbox('set unchecked');
break;
return {
checked: false,
indeterminate: false
};
case 'archived':
$('#archivedFilterCheckbox').checkbox('set checked');
break;
return {
checked: true,
indeterminate: false
};
case 'both':
$('#archivedFilterCheckbox').checkbox('set indeterminate');
break;
return {
checked: false,
indeterminate: true
};
default:
this.archivedFilter = 'unarchived';
$('#archivedFilterCheckbox').checkbox('set unchecked');
break;
return {
checked: false,
indeterminate: true
};
}
},

getPrivateFilterCheckboxState() {
switch (this.privateFilter) {
case 'public':
$('#privateFilterCheckbox').checkbox('set unchecked');
break;
return {
checked: false,
indeterminate: false
};
case 'private':
$('#privateFilterCheckbox').checkbox('set checked');
break;
return {
checked: true,
indeterminate: false
};
case 'both':
$('#privateFilterCheckbox').checkbox('set indeterminate');
break;
return {
checked: false,
indeterminate: true
};
default:
this.privateFilter = 'both';
$('#privateFilterCheckbox').checkbox('set indeterminate');
break;
return {
checked: false,
indeterminate: true
};
}
},

Expand Down Expand Up @@ -261,7 +279,6 @@ function initVueComponents(app) {
}
this.page = 1;
this.repos = [];
this.setCheckboxes();
this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
this.searchRepos();
},
Expand All @@ -283,7 +300,6 @@ function initVueComponents(app) {
}
this.page = 1;
this.repos = [];
this.setCheckboxes();
this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
this.searchRepos();
},
Expand Down