From e221d960e75f646b6c7c8783a1d2271e1bdb0f61 Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Tue, 4 Aug 2020 15:07:22 +0200 Subject: [PATCH] Revert "Merge pull request #2767 from aignatov-bio/ai-sci-4899-add-new-statuses-filters-on-dashboard" This reverts commit 8b6d57058c3d9b32a0697e0b67203557273bec78, reversing changes made to 957ac92669907b4eb9e8ec2bb25ee2d9c71ee378. --- .../javascripts/dashboard/current_tasks.js | 18 +++++++++++------- .../javascripts/sitewide/dropdown_selector.js | 19 ++++--------------- .../dashboard/current_tasks_controller.rb | 2 +- app/views/dashboards/_current_tasks.html.erb | 17 ++++------------- config/locales/dashboard/en.yml | 6 +----- 5 files changed, 21 insertions(+), 41 deletions(-) diff --git a/app/assets/javascripts/dashboard/current_tasks.js b/app/assets/javascripts/dashboard/current_tasks.js index 7c295925e..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') }; @@ -85,6 +85,7 @@ var DasboardCurrentTasksWidget = (function() { e.stopPropagation(); e.preventDefault(); 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 72143d06e..d6be71484 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 'date_desc' diff --git a/app/views/dashboards/_current_tasks.html.erb b/app/views/dashboards/_current_tasks.html.erb index c09d0366a..5d3dde5ee 100644 --- a/app/views/dashboards/_current_tasks.html.erb +++ b/app/views/dashboards/_current_tasks.html.erb @@ -19,18 +19,9 @@
- + +
@@ -88,4 +79,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 c6567e128..1c1aab5e2 100644 --- a/config/locales/dashboard/en.yml +++ b/config/locales/dashboard/en.yml @@ -13,11 +13,7 @@ en: date_asc: "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"