Add clear functionallity to projects filters

This commit is contained in:
Urban Rotnik 2020-11-26 09:23:22 +01:00
parent 6df0e83bf1
commit 34fbcb8f56
3 changed files with 32 additions and 6 deletions

View file

@ -576,8 +576,34 @@
});
}
function initCardsFilter() {
dropdownSelector.init($('.assignee-filter'));
function initProjectsFilter() {
let $projectsFilter = $('#projectsToolbar .projects-filters');
let $membersFilter = $('.assignee-filter', $projectsFilter);
let $foldersCB = $('#folder_search', $projectsFilter);
let $createdOnFilter = $('#calendarStartDate', $projectsFilter);
let $dueFilter = $('#calendarDueDate', $projectsFilter);
dropdownSelector.init($membersFilter);
// Clear filters
$('.clear-button', $projectsFilter).click((e) => {
e.stopPropagation();
e.preventDefault();
dropdownSelector.clearData($membersFilter);
$createdOnFilter.data('DateTimePicker').clear();
$dueFilter.data('DateTimePicker').clear();
$foldersCB.prop('checked', false);
});
// Prevent filter window close
$($projectsFilter).click((e) => {
if (!$(e.target).is('input')) {
e.stopPropagation();
e.preventDefault();
dropdownSelector.closeDropdown($membersFilter);
}
});
}
// Updates "Select all" control in a data table
@ -792,5 +818,5 @@
initProjectsViewModeSwitch();
initSorting();
loadCardsView();
initCardsFilter();
initProjectsFilter();
}(window));

View file

@ -912,7 +912,7 @@ li.module-hover {
.projects-toolbar {
.filter-container {
.current-tasks-filters {
.projects-filters {
padding: 0;
width: 230px;
@ -994,7 +994,7 @@ li.module-hover {
@media (min-width: 768px) {
.current-tasks-filters {
.projects-filters {
width: 460px;
}

View file

@ -48,7 +48,7 @@
<!-- project filter -->
<div class="filter-container dropdown">
<div class="btn btn-light icon-btn filter-button" data-toggle="dropdown"><i class="fas fa-filter"></i></div>
<div class="dropdown-menu dropdown-menu-right current-tasks-filters" role="menu" data-team-id="<%= current_team.id %>">
<div class="dropdown-menu dropdown-menu-right projects-filters" role="menu" data-team-id="<%= current_team.id %>">
<div class="header">
<div class="title"><%= t("projects.index.filters_modal.title") %></div>
<div class="btn btn-light clear-button">