Skip to content

Commit

Permalink
Rename the orders/new component to orders/show
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Oct 23, 2023
1 parent 3360e05 commit 382bdf2
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<%= render component("ui/button").new(
tag: :a,
text: t('.create_order'),
href: solidus_admin.new_order_path,
href: spree.new_admin_order_path,
icon: "add-line",
) %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<%= page do %>
<%= page_header do %>
<%= page_header_back solidus_admin.orders_path %>

<%= page_header_title t(".create_order") %>

<%= page_header_back(solidus_admin.orders_path) %>
<%= page_header_title("Order #{@order.number}") %>
<%= page_header_actions do %>
<%= render component("feedback").new %>
<%= render component("ui/button").new(tag: :button, scheme: :secondary, text: t(".discard"), form: form_id) %>
<%= render component("ui/button").new(tag: :button, text: t(".save"), form: form_id) %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class SolidusAdmin::Orders::New::Component < SolidusAdmin::BaseComponent
class SolidusAdmin::Orders::Show::Component < SolidusAdmin::BaseComponent
include SolidusAdmin::Layout::PageHelpers

def initialize(order:)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Add your component translations here.
# Use the translation in the example in your template with `t(".hello")`.
en:
create_order: Create Order
save: Save
discard: Discard
17 changes: 10 additions & 7 deletions admin/app/controllers/solidus_admin/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ def index
end
end

def new
@order = Spree::Order.new(
created_by: current_solidus_admin_user,
frontend_viewable: false,
store_id: current_store.try(:id)
)
def show
load_order

respond_to do |format|
format.html { render component('orders/new').new(order: @order) }
format.html { render component('orders/show').new(order: @order) }
end
end

private

def load_order
@order = Spree::Order.find_by!(number: params[:id])
authorize! action_name, @order
end
end
end
6 changes: 5 additions & 1 deletion admin/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
put :activate
end
end
resources :orders, only: [:index, :new, :create]
resources :orders, only: [:index] do
member do
get :cart, to: "orders#show"
end
end
end

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 382bdf2

Please sign in to comment.