From 4b264db34337356f9d81b83a6c306b2d25ff7756 Mon Sep 17 00:00:00 2001 From: sboursen-scinote Date: Tue, 14 Feb 2023 14:59:05 +0100 Subject: [PATCH 1/9] Update the text of the inlink protocol modal [SCI-7909] --- .../javascripts/my_modules/protocols.js | 19 +++++++++++++++---- app/controllers/protocols_controller.rb | 1 + config/locales/en.yml | 5 +++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/my_modules/protocols.js b/app/assets/javascripts/my_modules/protocols.js index 1e909460c..bd04b990f 100644 --- a/app/assets/javascripts/my_modules/protocols.js +++ b/app/assets/javascripts/my_modules/protocols.js @@ -99,12 +99,23 @@ function initLinkUpdate() { var updateBtn = modal.find(".modal-footer [data-action='submit']"); $("[data-action='unlink'], [data-action='revert'], [data-action='update-parent'], [data-action='update-self']") .on('ajax:success', function(e, data) { - modalTitle.html(data.title); - modalBody.html(data.message); - updateBtn.text(data.btn_text); - modal.attr('data-url', data.url); + const modalBodyTemplate = (message, warning) => `

${message}

+

${warning || ''}

`; + const { + title, + message, + warning, + btn_text: btnText, + url + } = data; + + modalTitle.html(title); + modalBody.html(modalBodyTemplate(message, warning)); + updateBtn.text(btnText); + modal.attr('data-url', url); modal.modal('show'); }); + modal.on('hidden.bs.modal', function() { modalBody.html(''); }); diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 72eb25a2e..c5d461dfd 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -881,6 +881,7 @@ class ProtocolsController < ApplicationController render json: { title: t('my_modules.protocols.confirm_link_update_modal.unlink_title'), message: t('my_modules.protocols.confirm_link_update_modal.unlink_message'), + warning: t('my_modules.protocols.confirm_link_update_modal.unlink_warning'), btn_text: t('my_modules.protocols.confirm_link_update_modal.unlink_btn_text'), url: unlink_protocol_path(@protocol) } diff --git a/config/locales/en.yml b/config/locales/en.yml index 019b535d7..f8f0a3084 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1074,8 +1074,9 @@ en: update_self_title: "Update this protocol with the version stored in the templates" confirm_link_update_modal: unlink_title: "Unlink protocol template" - unlink_message: "Are you sure you want to unlink the task protocol from the templates version? This will stop any tracking of changes." - unlink_btn_text: "Unlink" + unlink_message: "This will stop tracking changes of protocol templates. We can’t link it back once you unlink it." + unlink_warning: "Are you sure?" + unlink_btn_text: "Yes, unlink it" revert_title: "Revert protocol" revert_message: "Are you sure you want to revert the task protocol to the templates version? This will override any local changes you made." revert_btn_text: "Revert" From 0f9dcda99bde58f833b7230ef0f40714dc69ee9c Mon Sep 17 00:00:00 2001 From: sboursen-scinote Date: Tue, 14 Feb 2023 16:26:06 +0100 Subject: [PATCH 2/9] Update the style of the unlink protocol modal [SCI-7909] --- .../javascripts/my_modules/protocols.js | 2 +- .../my_modules/protocols/index.scss | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/my_modules/protocols.js b/app/assets/javascripts/my_modules/protocols.js index bd04b990f..d667caaeb 100644 --- a/app/assets/javascripts/my_modules/protocols.js +++ b/app/assets/javascripts/my_modules/protocols.js @@ -100,7 +100,7 @@ function initLinkUpdate() { $("[data-action='unlink'], [data-action='revert'], [data-action='update-parent'], [data-action='update-self']") .on('ajax:success', function(e, data) { const modalBodyTemplate = (message, warning) => `

${message}

-

${warning || ''}

`; +

${warning || ''}

`; const { title, message, diff --git a/app/assets/stylesheets/my_modules/protocols/index.scss b/app/assets/stylesheets/my_modules/protocols/index.scss index f6a4e2079..861fe5f77 100644 --- a/app/assets/stylesheets/my_modules/protocols/index.scss +++ b/app/assets/stylesheets/my_modules/protocols/index.scss @@ -6,6 +6,8 @@ @import "constants"; @import "mixins"; +$modal-spacing: 16px; + .content-pane.my-modules-protocols-index { background-color: $color-alto; margin: 0 -16px; @@ -680,3 +682,54 @@ display: inline-block; margin-left: 4px; } + +#confirm-link-update-modal { + .modal-content { + .modal-header { + border-bottom-color: transparent; + position: relative; + padding: $modal-spacing; + + &::after { + border-bottom: 1px solid $color-concrete; + bottom: 0; + left: $modal-spacing; + position: absolute; + width: calc(100% - 2* #{$modal-spacing}); + } + + .close { + color: $color-volcano; + } + } + + .modal-body { + padding: $modal-spacing; + + .message { + margin-bottom: $modal-spacing; + } + + .warning { + font-weight: bold; + margin: 0; + } + } + + .modal-footer { + border-top-color: transparent; + padding: $modal-spacing; + position: relative; + + &::after { + border-top: 1px solid $color-concrete; + left: $modal-spacing; + position: absolute; + top: 0; + width: calc(100% - 2* #{$modal-spacing}); + } + } + } + + +} From 043cb6f5fbfa5632c9ff4a389fd9a18601de938d Mon Sep 17 00:00:00 2001 From: sboursen-scinote Date: Tue, 14 Feb 2023 16:43:57 +0100 Subject: [PATCH 3/9] Fix hound issues [SCI-7909] --- app/assets/stylesheets/my_modules/protocols/index.scss | 6 ++---- .../protocols/_confirm_link_update_modal.html.erb | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/my_modules/protocols/index.scss b/app/assets/stylesheets/my_modules/protocols/index.scss index 861fe5f77..defcb7ba7 100644 --- a/app/assets/stylesheets/my_modules/protocols/index.scss +++ b/app/assets/stylesheets/my_modules/protocols/index.scss @@ -683,12 +683,12 @@ $modal-spacing: 16px; margin-left: 4px; } -#confirm-link-update-modal { +.confirm-link-update-modal { .modal-content { .modal-header { border-bottom-color: transparent; - position: relative; padding: $modal-spacing; + position: relative; &::after { border-bottom: 1px solid $color-concrete; @@ -730,6 +730,4 @@ $modal-spacing: 16px; } } } - - } diff --git a/app/views/my_modules/protocols/_confirm_link_update_modal.html.erb b/app/views/my_modules/protocols/_confirm_link_update_modal.html.erb index 350a4d69f..4fd7677ff 100644 --- a/app/views/my_modules/protocols/_confirm_link_update_modal.html.erb +++ b/app/views/my_modules/protocols/_confirm_link_update_modal.html.erb @@ -1,4 +1,4 @@ -