-
-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12504 from dacook/buu/edit-image-turbo-12399
[BUU] Remove StimulusReflex from Image Edit
- Loading branch information
Showing
14 changed files
with
69 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
module ProductsHelper | ||
def product_image_form_path(product) | ||
if product.image.present? | ||
edit_admin_product_image_path(product.id, product.image.id) | ||
else | ||
new_admin_product_image_path(product.id) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%a.image-field{ href: product_image_form_path(product), 'data-turbo-stream': true } | ||
= image_tag product.image&.url(:mini) || Spree::Image.default_image_url(:mini), width: 40, height: 40 | ||
.button.secondary.mini= t('admin.products_page.image.edit') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
= turbo_stream.update "edit_image_modal" do | ||
= render ModalComponent.new id: "#modal_edit_product_image", instant: true, close_button: false, modal_class: :fit do | ||
%h2= t(".title") | ||
|
||
-# Display image in the same way it appears in the shopfront popup | ||
%p= image_tag @image.persisted? ? @image.url(:large) : Spree::Image.default_image_url(:large), width: 433, height: 433 | ||
|
||
-# Submit as turbo stream to avoid full page reload. | ||
-# TODO: show loading indicator. | ||
= form_for [:admin, @product, @image], | ||
html: { multipart: true }, data: { controller: "form" } do |f| | ||
%input{ type: :hidden, name: :return_url, value: request.referer } | ||
= f.hidden_field :viewable_id, value: @product.id | ||
|
||
.modal-actions.justify-end | ||
%input{ class: "secondary relaxed", type: 'button', value: t('.close'), "data-action": "click->modal#close" } | ||
-# label.button provides a handy shortcut to open the file selector on click. Unfortunately this trick isn't keyboard accessible though.. | ||
= f.label :attachment, t(".upload"), class: "button primary relaxed icon-upload-alt" | ||
= f.file_field :attachment, accept: "image/*", style: "display: none", "data-action": "change->form#submit change->modal#close" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= turbo_stream.update "image-#{@product.id}" do | ||
= render partial: "admin/products_v3/product_image", locals: { product: @product } | ||
= render partial: "admin/shared/flashes", locals: { flashes: flash } if defined? flash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters