Create ShipOrder component

This commit is contained in:
binarygit
2023-12-09 15:28:16 +05:45
parent aa7a4fb5a2
commit e83fd5bd83
4 changed files with 16 additions and 15 deletions

View File

@@ -0,0 +1,7 @@
= render ConfirmModalComponent.new(id: "ship_order", confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
%div{class: "margin-bottom-30"}
%p= t('spree.admin.orders.shipment.mark_as_shipped_message')
%div{class: "margin-bottom-30"}
= hidden_field_tag :id, @order.id
= check_box_tag :send_shipment_email, "1", true
= label_tag :send_shipment_email, t('spree.admin.orders.shipment.mark_as_shipped_label_message')

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
class ShipOrderComponent < ViewComponent::Base
def initialize(order:)
@order = order
end
end

View File

@@ -11,13 +11,7 @@
%button{"class": "ship button icon-arrow-right","data-controller": "modal-link",
"data-action": "click->modal-link#open", "data-modal-link-target-value": "ship_order" }= t(:ship)
%form
= render ConfirmModalComponent.new(id: "ship_order", confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
%div{class: "margin-bottom-30"}
%p= t('.mark_as_shipped_message')
%div{class: "margin-bottom-30"}
= hidden_field_tag :id, order.id
= check_box_tag :send_shipment_email
= label_tag :send_shipment_email, t('.mark_as_shipped_label_message')
= render ShipOrderComponent.new(order: order)
%table.stock-contents.index
%colgroup

View File

@@ -48,14 +48,7 @@
= render partial: 'admin/shared/tooltip', locals: {link_class: "icon_link with-tip icon-edit no-text" ,link: edit_admin_order_path(order), link_text: "", tooltip_text: t('spree.admin.orders.index.edit')}
- if order.ready_to_ship?
%form
= render ConfirmModalComponent.new(id: "ship_order", confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
%div{class: "margin-bottom-30"}
%p= t('spree.admin.orders.shipment.mark_as_shipped_message')
%div{class: "margin-bottom-30"}
= hidden_field_tag :id, order.id
= check_box_tag :send_shipment_email, "1", true
= label_tag :send_shipment_email, t('spree.admin.orders.shipment.mark_as_shipped_label_message')
= render ShipOrderComponent.new(order: order)
= render partial: 'admin/shared/tooltip_button', locals: {button_class: "icon-road icon_link with-tip no-text", reflex_data_id: order.id.to_s, tooltip_text: t('spree.admin.orders.index.ship'), shipment: true}
- if order.payment_required? && order.pending_payments.reject(&:requires_authorization?).any?