Commit 1750fe32 authored by Bryce's avatar Bryce Committed by Bryce Johnson

Add issues filters reset btn (ES6-ified).

(Also refactored checkChanged slightly.)
parent fda07a25
...@@ -107,6 +107,7 @@ v 8.11.3 ...@@ -107,6 +107,7 @@ v 8.11.3
- Fix external issue tracker "Issues" link leading to 404s - Fix external issue tracker "Issues" link leading to 404s
- Don't try to show merge conflict resolution info if a merge conflict contains non-UTF-8 characters - Don't try to show merge conflict resolution info if a merge conflict contains non-UTF-8 characters
- Automatically expand hidden discussions when accessed by a permalink !5585 (Mike Greiling) - Automatically expand hidden discussions when accessed by a permalink !5585 (Mike Greiling)
- Issues filters reset button
v 8.11.2 v 8.11.2
- Show "Create Merge Request" widget for push events to fork projects on the source project. !5978 - Show "Create Merge Request" widget for push events to fork projects on the source project. !5978
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
Issuable.initTemplates(); Issuable.initTemplates();
Issuable.initSearch(); Issuable.initSearch();
Issuable.initChecks(); Issuable.initChecks();
Issuable.initResetFilters();
return Issuable.initLabelFilterRemove(); return Issuable.initLabelFilterRemove();
}, },
initTemplates: function() { initTemplates: function() {
...@@ -55,6 +56,17 @@ ...@@ -55,6 +56,17 @@
return Turbolinks.visit(issuesUrl); return Turbolinks.visit(issuesUrl);
}; };
})(this), })(this),
initResetFilters: function() {
$('.reset-filters').on('click', function(e) {
e.preventDefault();
const target = e.target;
const $form = $(target).parents('.js-filter-form');
const baseIssuesUrl = target.href;
$form.attr('action', baseIssuesUrl);
Turbolinks.visit(baseIssuesUrl);
});
},
initChecks: function() { initChecks: function() {
this.issuableBulkActions = $('.bulk-update').data('bulkActions'); this.issuableBulkActions = $('.bulk-update').data('bulkActions');
$('.check_all_issues').off('click').on('click', function() { $('.check_all_issues').off('click').on('click', function() {
...@@ -64,19 +76,22 @@ ...@@ -64,19 +76,22 @@
return $('.selected_issue').off('change').on('change', Issuable.checkChanged.bind(this)); return $('.selected_issue').off('change').on('change', Issuable.checkChanged.bind(this));
}, },
checkChanged: function() { checkChanged: function() {
var checked_issues, ids; const $checkedIssues = $('.selected_issue:checked');
checked_issues = $('.selected_issue:checked'); const $updateIssuesIds = $('#update_issues_ids');
if (checked_issues.length > 0) { const $issuesOtherFilters = $('.issues-other-filters');
ids = $.map(checked_issues, function(value) { const $issuesBulkUpdate = $('.issues_bulk_update');
if ($checkedIssues.length > 0) {
let ids = $.map($checkedIssues, function(value) {
return $(value).data('id'); return $(value).data('id');
}); });
$('#update_issues_ids').val(ids); $updateIssuesIds.val(ids);
$('.issues-other-filters').hide(); $issuesOtherFilters.hide();
$('.issues_bulk_update').show(); $issuesBulkUpdate.show();
} else { } else {
$('#update_issues_ids').val([]); $updateIssuesIds.val([]);
$('.issues_bulk_update').hide(); $issuesBulkUpdate.hide();
$('.issues-other-filters').show(); $issuesOtherFilters.show();
this.issuableBulkActions.willUpdateLabels = false; this.issuableBulkActions.willUpdateLabels = false;
} }
return true; return true;
......
.filter-item { .filter-item {
margin-right: 6px; margin-right: 6px;
vertical-align: top; vertical-align: top;
&.reset-filters {
padding: 7px;
}
} }
@media (min-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
.filter-item.inline.labels-filter .filter-item.inline.labels-filter
= render "shared/issuable/label_dropdown" = render "shared/issuable/label_dropdown"
.filter-item.inline.reset-filters
%a{href: page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :issue_search])} Reset filters
.pull-right .pull-right
- if controller.controller_name == 'boards' - if controller.controller_name == 'boards'
#js-boards-seach.issue-boards-search #js-boards-seach.issue-boards-search
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment