diff --git a/app/assets/javascripts/dashboard/current_tasks.js b/app/assets/javascripts/dashboard/current_tasks.js index 62f8e8ff7..88bbf0a97 100644 --- a/app/assets/javascripts/dashboard/current_tasks.js +++ b/app/assets/javascripts/dashboard/current_tasks.js @@ -3,7 +3,7 @@ var DasboardCurrentTasksWidget = (function() { var sortFilter = '.curent-tasks-filters .sort-filter'; - var statusFilter = '.curent-tasks-filters .view-filter'; + var viewFilter = '.curent-tasks-filters .view-filter'; var projectFilter = '.curent-tasks-filters .project-filter'; var experimentFilter = '.curent-tasks-filters .experiment-filter'; @@ -36,7 +36,7 @@ var DasboardCurrentTasksWidget = (function() { params.project_id = dropdownSelector.getValues(projectFilter); params.experiment_id = dropdownSelector.getValues(experimentFilter); params.sort = dropdownSelector.getValues(sortFilter); - params.statuses = dropdownSelector.getValues(statusFilter); + params.view = dropdownSelector.getValues(viewFilter); params.query = $('.current-tasks-widget .task-search-field').val(); params.mode = $('.current-tasks-navbar .active').data('mode'); return params; @@ -48,7 +48,7 @@ var DasboardCurrentTasksWidget = (function() { return dropdownSelector.getValues(experimentFilter) || dropdownSelector.getValues(projectFilter) || $('.current-tasks-widget .task-search-field').val().length > 0 - || dropdownSelector.getValues(statusFilter) !== 'uncompleted'; + || dropdownSelector.getValues(viewFilter) !== 'uncompleted'; } function loadCurrentTasksList(newList) { @@ -57,7 +57,7 @@ var DasboardCurrentTasksWidget = (function() { project_id: dropdownSelector.getValues(projectFilter), experiment_id: dropdownSelector.getValues(experimentFilter), sort: dropdownSelector.getValues(sortFilter), - statuses: dropdownSelector.getValues(statusFilter), + view: dropdownSelector.getValues(viewFilter), query: $('.current-tasks-widget .task-search-field').val(), mode: $('.current-tasks-navbar .active').data('mode') }; @@ -84,7 +84,8 @@ var DasboardCurrentTasksWidget = (function() { $('.curent-tasks-filters .clear-button').click((e) => { e.stopPropagation(); e.preventDefault(); - dropdownSelector.selectValue(sortFilter, 'due_date'); + dropdownSelector.selectValue(sortFilter, 'date_asc'); + dropdownSelector.selectValue(viewFilter, 'uncompleted'); dropdownSelector.clearData(projectFilter); dropdownSelector.clearData(experimentFilter); }); @@ -97,9 +98,12 @@ var DasboardCurrentTasksWidget = (function() { disableSearch: true }); - dropdownSelector.init(statusFilter, { + dropdownSelector.init(viewFilter, { + noEmptyOption: true, + singleSelect: true, + closeOnSelect: true, selectAppearance: 'simple', - optionClass: 'checkbox-icon' + disableSearch: true }); dropdownSelector.init(projectFilter, { @@ -139,7 +143,7 @@ var DasboardCurrentTasksWidget = (function() { e.stopPropagation(); e.preventDefault(); dropdownSelector.closeDropdown(sortFilter); - dropdownSelector.closeDropdown(statusFilter); + dropdownSelector.closeDropdown(viewFilter); dropdownSelector.closeDropdown(projectFilter); dropdownSelector.closeDropdown(experimentFilter); }); diff --git a/app/assets/javascripts/sitewide/dropdown_selector.js b/app/assets/javascripts/sitewide/dropdown_selector.js index 4c045dbe4..da29489a9 100644 --- a/app/assets/javascripts/sitewide/dropdown_selector.js +++ b/app/assets/javascripts/sitewide/dropdown_selector.js @@ -179,20 +179,9 @@ var dropdownSelector = (function() { } // Add selected option to value - function addSelectedOptions(selector, container) { - var selectedOptions = []; - $.each($(selector).find('option:selected'), function(i, option) { - selectedOptions.push(convertOptionToJson(option)); - if (selector.data('config').singleSelect) return false; - return true; - }); - - if (!selectedOptions.length) return false; - - setData(selector, selectedOptions, true); - return true; + function addSelectedOption(selector, container) { + setData(selector, [convertOptionToJson($(selector).find('option:selected')[0])], true); } - // // Prepare custom dropdown icon function prepareCustomDropdownIcon(config) { @@ -433,8 +422,8 @@ var dropdownSelector = (function() { } // Select default value - if (!selectElement.data('ajax-url')) { - addSelectedOptions(selectElement, dropdownContainer); + if (config.noEmptyOption && config.singleSelect) { + addSelectedOption(selectElement, dropdownContainer); } // Enable simple mode for dropdown selector diff --git a/app/controllers/dashboard/current_tasks_controller.rb b/app/controllers/dashboard/current_tasks_controller.rb index b8741d667..30cd0b22a 100644 --- a/app/controllers/dashboard/current_tasks_controller.rb +++ b/app/controllers/dashboard/current_tasks_controller.rb @@ -25,7 +25,7 @@ module Dashboard tasks = tasks.left_outer_joins(:user_my_modules).where(user_my_modules: { user_id: current_user.id }) end - #tasks = filter_by_state(tasks) + tasks = filter_by_state(tasks) case task_filters[:sort] when 'start_date' diff --git a/app/views/dashboards/_current_tasks.html.erb b/app/views/dashboards/_current_tasks.html.erb index 409a7eaf7..99d278056 100644 --- a/app/views/dashboards/_current_tasks.html.erb +++ b/app/views/dashboards/_current_tasks.html.erb @@ -20,18 +20,9 @@
- + +
@@ -89,4 +80,4 @@

<%= I18n.t('dashboard.current_tasks.no_tasks.search_result.title') %>

- + \ No newline at end of file diff --git a/config/locales/dashboard/en.yml b/config/locales/dashboard/en.yml index 4ac70a53a..0fa346e4e 100644 --- a/config/locales/dashboard/en.yml +++ b/config/locales/dashboard/en.yml @@ -14,11 +14,7 @@ en: due_date: "Due date" atoz: "From A to Z" ztoa: "From Z to A" - display: "Display statuses" - statuses: - placeholder: "Select statuses" - all_selected: "All selected" - selected: "selected" + display: "Display" uncompleted_tasks: "Tasks in progress" completed_tasks: "Tasks completed" project: "Project"