From 90199d35909d9aa6f982be5a1aa532bb6aff3de4 Mon Sep 17 00:00:00 2001 From: Ivan Kljun Date: Thu, 24 Aug 2023 14:52:11 +0200 Subject: [PATCH] Add method light_color? to my_module_status [SCI-9007] --- app/assets/javascripts/experiments/table.js | 2 +- app/assets/stylesheets/dashboard/current_tasks.scss | 2 +- app/assets/stylesheets/experiment/canvas.scss | 2 +- app/assets/stylesheets/experiment/table.scss | 2 +- app/assets/stylesheets/my_modules/status_flow.scss | 6 +++--- app/controllers/dashboard/current_tasks_controller.rb | 1 + app/models/my_module_status.rb | 4 ++++ app/services/experiments/table_view_service.rb | 3 ++- app/services/reports/docx/draw_my_module.rb | 2 +- app/views/canvas/full_zoom/_my_module.html.erb | 2 +- app/views/dashboards/current_tasks/_task.html.erb | 2 +- .../my_modules/modals/_status_flow_modal_body.html.erb | 2 +- app/views/my_modules/status_flow/_task_flow_button.html.erb | 4 ++-- app/views/reports/elements/_my_module_element.html.erb | 2 +- 14 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/experiments/table.js b/app/assets/javascripts/experiments/table.js index a6e950d72..8a9aa9c5c 100644 --- a/app/assets/javascripts/experiments/table.js +++ b/app/assets/javascripts/experiments/table.js @@ -43,7 +43,7 @@ var ExperimnetTable = { return `${data.count}`; }, status: function(data) { - return `
${data.name}
`; }, assigned: function(data) { diff --git a/app/assets/stylesheets/dashboard/current_tasks.scss b/app/assets/stylesheets/dashboard/current_tasks.scss index 136b5d7a1..2186d154a 100644 --- a/app/assets/stylesheets/dashboard/current_tasks.scss +++ b/app/assets/stylesheets/dashboard/current_tasks.scss @@ -212,7 +212,7 @@ font-weight: bold; padding: .25em .5em; - &.btn-not-started { + &.status-light { @include not-started; } } diff --git a/app/assets/stylesheets/experiment/canvas.scss b/app/assets/stylesheets/experiment/canvas.scss index ccbc5efa9..3028a7df6 100644 --- a/app/assets/stylesheets/experiment/canvas.scss +++ b/app/assets/stylesheets/experiment/canvas.scss @@ -36,7 +36,7 @@ text-overflow: ellipsis; white-space: nowrap; - &.btn-not-started { + &.status-light { @include not-started; } } diff --git a/app/assets/stylesheets/experiment/table.scss b/app/assets/stylesheets/experiment/table.scss index dcc31613b..f31415f3f 100644 --- a/app/assets/stylesheets/experiment/table.scss +++ b/app/assets/stylesheets/experiment/table.scss @@ -360,7 +360,7 @@ text-overflow: ellipsis; white-space: nowrap; - &.btn-not-started { + &.status-light { @include not-started; } } diff --git a/app/assets/stylesheets/my_modules/status_flow.scss b/app/assets/stylesheets/my_modules/status_flow.scss index 087c41c39..ba726c29c 100644 --- a/app/assets/stylesheets/my_modules/status_flow.scss +++ b/app/assets/stylesheets/my_modules/status_flow.scss @@ -12,7 +12,7 @@ text-align: left; width: 100%; - &.btn-not-started { + &.status-light { @include not-started; } @@ -72,7 +72,7 @@ white-space: nowrap; } - .btn-not-started { + .status-light { @include not-started; } @@ -136,7 +136,7 @@ padding: .5em; white-space: nowrap; - &.btn-not-started { + &.status-light { @include not-started; } } diff --git a/app/controllers/dashboard/current_tasks_controller.rb b/app/controllers/dashboard/current_tasks_controller.rb index 703935006..e257f1a3b 100644 --- a/app/controllers/dashboard/current_tasks_controller.rb +++ b/app/controllers/dashboard/current_tasks_controller.rb @@ -121,6 +121,7 @@ module Dashboard tasks = tasks.search_by_name(current_user, current_team, task_filters[:query]) if task_filters[:query].present? tasks.joins(:my_module_status) + .includes(:my_module_status) .select( 'my_modules.*', 'my_module_statuses.name AS status_name', diff --git a/app/models/my_module_status.rb b/app/models/my_module_status.rb index 64e13c237..de19eceef 100644 --- a/app/models/my_module_status.rb +++ b/app/models/my_module_status.rb @@ -67,6 +67,10 @@ class MyModuleStatus < ApplicationRecord mm_copy.errors.messages&.values&.flatten end + def light_color? + color == '#FFFFFF' + end + private def next_in_same_flow diff --git a/app/services/experiments/table_view_service.rb b/app/services/experiments/table_view_service.rb index 9b99de934..df77fe152 100644 --- a/app/services/experiments/table_view_service.rb +++ b/app/services/experiments/table_view_service.rb @@ -154,7 +154,8 @@ module Experiments def status_presenter(my_module) { name: escape_input(my_module.my_module_status.name), - color: escape_input(my_module.my_module_status.color) + color: escape_input(my_module.my_module_status.color), + light_color: escape_input(my_module.my_module_status.light_color?) } end diff --git a/app/services/reports/docx/draw_my_module.rb b/app/services/reports/docx/draw_my_module.rb index 6b72a03f6..f79896093 100644 --- a/app/services/reports/docx/draw_my_module.rb +++ b/app/services/reports/docx/draw_my_module.rb @@ -42,7 +42,7 @@ module Reports::Docx::DrawMyModule @docx.p do text I18n.t('projects.reports.elements.module.status') text ' ' - text "[#{status.name}]", color: (status.name == 'Not started' ? '000000' : status.color.delete('#')) + text "[#{status.name}]", color: (status.light_color? ? '000000' : status.color.delete('#')) if my_module.completed? text " #{I18n.t('my_modules.states.completed')} #{I18n.l(my_module.completed_on, format: :full)}" end diff --git a/app/views/canvas/full_zoom/_my_module.html.erb b/app/views/canvas/full_zoom/_my_module.html.erb index faa32a901..a4a38a72e 100644 --- a/app/views/canvas/full_zoom/_my_module.html.erb +++ b/app/views/canvas/full_zoom/_my_module.html.erb @@ -65,7 +65,7 @@ -
<% if my_module.status_changing %> diff --git a/app/views/dashboards/current_tasks/_task.html.erb b/app/views/dashboards/current_tasks/_task.html.erb index f8c479274..c0f4b1424 100644 --- a/app/views/dashboards/current_tasks/_task.html.erb +++ b/app/views/dashboards/current_tasks/_task.html.erb @@ -16,7 +16,7 @@ <% end %>
- <%= task.status_name %> diff --git a/app/views/my_modules/modals/_status_flow_modal_body.html.erb b/app/views/my_modules/modals/_status_flow_modal_body.html.erb index e86cf1cae..803ef4c57 100644 --- a/app/views/my_modules/modals/_status_flow_modal_body.html.erb +++ b/app/views/my_modules/modals/_status_flow_modal_body.html.erb @@ -11,7 +11,7 @@ <%= t('my_modules.modals.status_flow_modal.current_status') %> <% end %>
-
<%= status[:name] %>
diff --git a/app/views/my_modules/status_flow/_task_flow_button.html.erb b/app/views/my_modules/status_flow/_task_flow_button.html.erb index 165b49e82..ff23f7d52 100644 --- a/app/views/my_modules/status_flow/_task_flow_button.html.erb +++ b/app/views/my_modules/status_flow/_task_flow_button.html.erb @@ -24,7 +24,7 @@ data-status-check-url="<%= status_state_my_module_path(my_module) %>">