From a6a3a02d79ea318f54c850ef5427cd57e0de09ec Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 10 Jan 2024 15:54:43 +1100 Subject: [PATCH 01/13] Use padding to set button size It's more flexible. Also reduced the overall size to suit the desired table row sizes. --- app/components/vertical_ellipsis_menu/component.scss | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/components/vertical_ellipsis_menu/component.scss b/app/components/vertical_ellipsis_menu/component.scss index 03b5cb39d8..9e8bc9d878 100644 --- a/app/components/vertical_ellipsis_menu/component.scss +++ b/app/components/vertical_ellipsis_menu/component.scss @@ -1,16 +1,13 @@ .vertical-ellipsis-menu { position: relative; - width: $btn-relaxed-height; i.fa-ellipsis-v { cursor: pointer; display: block; - height: $btn-relaxed-height; - width: $btn-relaxed-height; - line-height: $btn-relaxed-height; text-align: center; border-radius: 3px; background-color: white; + padding: 10px 14px; } .vertical-ellipsis-menu-content { From ca73a9ab62529bcf2fa6c5ad6ec4294329e165ea Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 10 Jan 2024 15:55:40 +1100 Subject: [PATCH 02/13] Reduce space used by image --- app/webpacker/css/admin/products_v3.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/webpacker/css/admin/products_v3.scss b/app/webpacker/css/admin/products_v3.scss index 4d6450e23f..c03f8ee016 100644 --- a/app/webpacker/css/admin/products_v3.scss +++ b/app/webpacker/css/admin/products_v3.scss @@ -131,6 +131,10 @@ td { border-bottom: 2px solid $color-tbl-bg; + + &.with-image { + padding: 8px; + } } tr:first-child td { @@ -379,6 +383,7 @@ position: relative; img { + display: block; border-radius: $border-radius; } From c584d639cc1c6d656c81cd8a917cc3aa4513b590 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 10 Jan 2024 15:55:56 +1100 Subject: [PATCH 03/13] Show default image if none set --- app/views/admin/products_v3/_table.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index dcdec95520..68dfa43cff 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -48,10 +48,10 @@ = form.fields_for("products", product, index: product_index) do |product_form| %tbody.relaxed{ 'data-record-id': product_form.object.id } %tr - %td - - if product.image.present? - .image-field - = image_tag product.image.url(:mini), width: 40 + %td.with-image + .image-field + = image_tag product.image&.url(:mini) || Spree::Image.default_image_url(:mini), width: 40, height: 40 + - if product.image.present? = link_to t('admin.products_page.image.edit'), edit_admin_product_image_path(product, product.image), class: "button secondary mini" %td.field.align-left.header = product_form.hidden_field :id From 91abb856a628419a3d420c14eb397687ebbb0718 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 11 Jan 2024 12:07:50 +1100 Subject: [PATCH 04/13] DRY Refactor to use the (previously unused) shared method. --- app/controllers/spree/admin/images_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/spree/admin/images_controller.rb b/app/controllers/spree/admin/images_controller.rb index 4fed1aba31..89e2087c0b 100644 --- a/app/controllers/spree/admin/images_controller.rb +++ b/app/controllers/spree/admin/images_controller.rb @@ -32,7 +32,7 @@ module Spree if @object.save flash[:success] = flash_message_for(@object, :successfully_created) - redirect_to spree.admin_product_images_url(params[:product_id], @url_filters) + redirect_to location_after_save else respond_with(@object) end @@ -44,7 +44,7 @@ module Spree if @object.update(permitted_resource_params) flash[:success] = flash_message_for(@object, :successfully_updated) - redirect_to spree.admin_product_images_url(params[:product_id], @url_filters) + redirect_to location_after_save else respond_with(@object) end @@ -58,7 +58,7 @@ module Spree flash[:success] = flash_message_for(@object, :successfully_removed) end - redirect_to spree.admin_product_images_url(params[:product_id], @url_filters) + redirect_to location_after_save end private @@ -76,7 +76,7 @@ module Spree end def location_after_save - spree.admin_product_images_url(@product) + spree.admin_product_images_url(params[:product_id], @url_filters) end def load_data From 137489f492e92b34fe8ad934682dc6bd0f496f0c Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 11 Jan 2024 13:33:06 +1100 Subject: [PATCH 05/13] Refactor: move basic modal styles to generic parent component The style was already being shared with a sibling component. Now we can instantiate a plain old 'modal'. --- .../confirm_modal_component.html.haml | 2 +- .../help_modal_component/help_modal_component.html.haml | 2 +- app/components/modal_component/modal_component.html.haml | 8 ++++++++ .../modal_component.scss} | 3 ++- .../spree/admin/orders/bulk/_invoice_modal.html.haml | 2 +- app/webpacker/css/admin/all.scss | 2 +- app/webpacker/css/admin_v3/all.scss | 2 +- app/webpacker/css/darkswarm/all.scss | 2 +- spec/javascripts/stimulus/help_modal_controller_test.js | 2 +- spec/system/admin/enterprise_roles_spec.rb | 2 +- 10 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 app/components/modal_component/modal_component.html.haml rename app/components/{help_modal_component/help_modal_component.scss => modal_component/modal_component.scss} (69%) diff --git a/app/components/confirm_modal_component/confirm_modal_component.html.haml b/app/components/confirm_modal_component/confirm_modal_component.html.haml index 5fe1d1300b..1184602a67 100644 --- a/app/components/confirm_modal_component/confirm_modal_component.html.haml +++ b/app/components/confirm_modal_component/confirm_modal_component.html.haml @@ -1,6 +1,6 @@ %div{ id: @id, "data-controller": "modal #{@controller}", "data-action": "keyup@document->modal#closeIfEscapeKey", "data-#{@controller}-reflex-value": @reflex } .reveal-modal-bg.fade{ "data-modal-target": "background", "data-action": "click->modal#close" } - .reveal-modal.fade.tiny.help-modal{ "data-modal-target": "modal" } + .reveal-modal.fade.tiny.modal-component{ "data-modal-target": "modal" } = content = render @message if @message diff --git a/app/components/help_modal_component/help_modal_component.html.haml b/app/components/help_modal_component/help_modal_component.html.haml index af7d602724..adc6c54822 100644 --- a/app/components/help_modal_component/help_modal_component.html.haml +++ b/app/components/help_modal_component/help_modal_component.html.haml @@ -1,6 +1,6 @@ %div{ id: @id, "data-controller": "help-modal", "data-action": "keyup@document->help-modal#closeIfEscapeKey" } .reveal-modal-bg.fade{ "data-help-modal-target": "background", "data-action": "click->help-modal#close" } - .reveal-modal.fade.small.help-modal{ "data-help-modal-target": "modal" } + .reveal-modal.fade.small.modal-component{ "data-help-modal-target": "modal" } = content - if close_button? diff --git a/app/components/modal_component/modal_component.html.haml b/app/components/modal_component/modal_component.html.haml new file mode 100644 index 0000000000..8c13b1dee0 --- /dev/null +++ b/app/components/modal_component/modal_component.html.haml @@ -0,0 +1,8 @@ +%div{ id: @id, "data-controller": "modal", "data-action": "keyup@document->modal#closeIfEscapeKey" } + .reveal-modal-bg.fade{ "data-modal-target": "background", "data-action": "click->modal#close" } + .reveal-modal.fade.small.modal-component{ "data-modal-target": "modal" } + = content + + - if close_button? + .text-center + %input{ class: "button icon-plus #{close_button_class}", type: 'button', value: t('js.admin.modals.close'), "data-action": "click->modal#close" } diff --git a/app/components/help_modal_component/help_modal_component.scss b/app/components/modal_component/modal_component.scss similarity index 69% rename from app/components/help_modal_component/help_modal_component.scss rename to app/components/modal_component/modal_component.scss index d323b47992..5223d23824 100644 --- a/app/components/help_modal_component/help_modal_component.scss +++ b/app/components/modal_component/modal_component.scss @@ -1,4 +1,5 @@ -.help-modal { +// class name 'modal' is already taken by 'custom-alert' and 'custom-confirm'. +.modal-component { visibility: visible; position: fixed; top: 3em; diff --git a/app/views/spree/admin/orders/bulk/_invoice_modal.html.haml b/app/views/spree/admin/orders/bulk/_invoice_modal.html.haml index 07c2f30121..53f7982f25 100644 --- a/app/views/spree/admin/orders/bulk/_invoice_modal.html.haml +++ b/app/views/spree/admin/orders/bulk/_invoice_modal.html.haml @@ -1,6 +1,6 @@ %div{ id: "bulk_invoices_modal", "data-controller": "modal", "data-modal-instant-value": true, "data-action": "keyup@document->modal#closeIfEscapeKey" } .reveal-modal-bg.fade{ "data-modal-target": "background", "data-action": "click->modal#remove" } - .reveal-modal.fade.tiny.help-modal{ "data-modal-target": "modal" } + .reveal-modal.fade.tiny.modal-component{ "data-modal-target": "modal" } %div.fullwidth.align-center %h4.modal-title = t('js.admin.orders.index.compiling_invoices') diff --git a/app/webpacker/css/admin/all.scss b/app/webpacker/css/admin/all.scss index 56d522ae75..2cb175b8f7 100644 --- a/app/webpacker/css/admin/all.scss +++ b/app/webpacker/css/admin/all.scss @@ -124,6 +124,6 @@ @import "~tom-select/src/scss/tom-select.default"; @import "components/tom_select"; -@import "app/components/help_modal_component/help_modal_component"; +@import "app/components/modal_component/modal_component"; @import "app/components/confirm_modal_component/confirm_modal_component"; @import "app/webpacker/css/admin/trix.scss"; diff --git a/app/webpacker/css/admin_v3/all.scss b/app/webpacker/css/admin_v3/all.scss index 664a4fda11..274e76a76e 100644 --- a/app/webpacker/css/admin_v3/all.scss +++ b/app/webpacker/css/admin_v3/all.scss @@ -128,7 +128,7 @@ @import "~tom-select/src/scss/tom-select.default"; @import "components/tom_select"; // admin_v3 -@import "app/components/help_modal_component/help_modal_component"; +@import "app/components/modal_component/modal_component"; @import "app/components/confirm_modal_component/confirm_modal_component"; @import "app/components/vertical_ellipsis_menu/component"; // admin_v3 and only V3 @import "app/webpacker/css/admin/trix.scss"; diff --git a/app/webpacker/css/darkswarm/all.scss b/app/webpacker/css/darkswarm/all.scss index a78b2c30e2..be25b548d5 100644 --- a/app/webpacker/css/darkswarm/all.scss +++ b/app/webpacker/css/darkswarm/all.scss @@ -77,5 +77,5 @@ ofn-modal { @import "../shared/question-mark-icon"; @import '../admin/shared/scroll_bar'; -@import 'app/components/help_modal_component/help_modal_component'; +@import 'app/components/modal_component/modal_component'; @import 'app/components/confirm_modal_component/confirm_modal_component'; diff --git a/spec/javascripts/stimulus/help_modal_controller_test.js b/spec/javascripts/stimulus/help_modal_controller_test.js index 1120ede695..944cdea04c 100644 --- a/spec/javascripts/stimulus/help_modal_controller_test.js +++ b/spec/javascripts/stimulus/help_modal_controller_test.js @@ -34,7 +34,7 @@ describe("HelpModalController", () => { data-action="click->help-modal#close">