From 4c15c89cf5b10dce1ee611592f84d28808236049 Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Fri, 15 May 2020 00:49:23 +0200 Subject: [PATCH 1/2] Add New Task layout Collapsed/Expanded States saving --- app/assets/javascripts/my_modules.js | 34 +++++++++++++++++++++++++ app/views/my_modules/protocols.html.erb | 10 ++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/my_modules.js b/app/assets/javascripts/my_modules.js index a275d1420..b97c20fa9 100644 --- a/app/assets/javascripts/my_modules.js +++ b/app/assets/javascripts/my_modules.js @@ -1,6 +1,39 @@ /* global I18n dropdownSelector */ /* eslint-disable no-use-before-define */ +function initTaskCollapseState() { + let taskView = '.my-modules-protocols-index'; + let taskSection = '.task-section-caret'; + let taskId = $(taskView).data('task-id'); + + function collapseStateSave() { + $(taskView).on('click', taskSection, function() { + let collapsed = $(this).attr('aria-expanded'); + let taskSectionType = $(this).attr('aria-controls'); + + if (collapsed === 'true') { + localStorage.setItem('task_section_collapsed/' + taskId + '/' + taskSectionType, collapsed); + } else { + localStorage.removeItem('task_section_collapsed/' + taskId + '/' + taskSectionType); + } + }); + } + + function collapseStateLoad() { + $(taskSection).each(function() { + let taskSectionType = $(this).attr('aria-controls'); + var collapsed = localStorage.getItem('task_section_collapsed/' + taskId + '/' + taskSectionType); + + if (JSON.parse(collapsed)) { + $('#' + taskSectionType).collapse('hide'); + } + }); + } + + collapseStateSave(); + collapseStateLoad(); +} + function updateStartDate() { let updateUrl = $('#startDateContainer').data('update-url'); let val = $('#calendarStartDate').val(); @@ -345,6 +378,7 @@ function initAssignedUsersSelector() { initUsersEditLink(); } +initTaskCollapseState(); applyTaskCompletedCallBack(); initTagsSelector(); bindEditTagsAjax(); diff --git a/app/views/my_modules/protocols.html.erb b/app/views/my_modules/protocols.html.erb index a146caa34..183b5a27f 100644 --- a/app/views/my_modules/protocols.html.erb +++ b/app/views/my_modules/protocols.html.erb @@ -4,7 +4,7 @@ <%= render partial: "shared/sidebar", locals: { current_task: @my_module, page: 'task' } %> <%= render partial: "shared/secondary_navigation" %> -
+
-
<%= render partial: "my_modules/repositories/repositories_list" %>
@@ -73,7 +73,7 @@
-
+
<%= render partial: "my_module_protocol" %>
From 515d90a530865c7467c6fbce6e396e4b85eacb6b Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Fri, 15 May 2020 07:37:53 +0200 Subject: [PATCH 2/2] Fix tests --- features/protocol_step.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/protocol_step.feature b/features/protocol_step.feature index 8dcb1e0bd..19afe9783 100644 --- a/features/protocol_step.feature +++ b/features/protocol_step.feature @@ -43,7 +43,7 @@ Scenario: Successful add new step to a task Scenario: Successful add new step to a task Given I'm on the Protocols page of a "qPCR" task And I click "Protocol" link - And I click first "New Step" link + And I click first "New step" link Then I fill in "PES" in "#step_name" field Then I fill in "zivali pa so se odpravile dalje po svetu." in "#step_description_textarea" rich text editor field And I click "Files" link