-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #5434 from nebulab/rainerd/base-order-creation-com…
…ponents [Admin] Construct base components for order creation in admin interface
- Loading branch information
Showing
10 changed files
with
78 additions
and
2 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
20 changes: 20 additions & 0 deletions
20
admin/app/components/solidus_admin/orders/new/component.html.erb
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,20 @@ | ||
<div class="px-4 relative" data-controller="<%= stimulus_id %>"> | ||
<header class="py-6 flex items-center gap-4"> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
title: t(".back"), | ||
icon: "arrow-left-line", | ||
scheme: :secondary, | ||
href: solidus_admin.orders_path | ||
) %> | ||
<h1 class="flex items-center gap-2"> | ||
<span class="body-title"><%= t(".create_order") %></span> | ||
</h1> | ||
|
||
<div class="ml-auto flex gap-2 items-center"> | ||
<%= 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) %> | ||
</div> | ||
</header> | ||
</div> |
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,5 @@ | ||
import { Controller } from '@hotwired/stimulus' | ||
|
||
export default class extends Controller { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
admin/app/components/solidus_admin/orders/new/component.rb
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::New::Component < SolidusAdmin::BaseComponent | ||
def initialize(order:) | ||
@order = order | ||
end | ||
|
||
def form_id | ||
@form_id ||= "#{stimulus_id}--form-#{@order.id}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 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 |
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 |
---|---|---|
|
@@ -13,5 +13,5 @@ | |
put :activate | ||
end | ||
end | ||
resources :orders, only: :index | ||
resources :orders, only: [:index, :new, :create] | ||
end |
10 changes: 10 additions & 0 deletions
10
admin/spec/components/previews/solidus_admin/orders/new/component_preview.rb
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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
# @component "orders/new" | ||
class SolidusAdmin::Orders::New::ComponentPreview < ViewComponent::Preview | ||
include SolidusAdmin::Preview | ||
|
||
def overview | ||
render_with_template(locals: { order: Spree::Order.new }) | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
admin/spec/components/previews/solidus_admin/orders/new/component_preview/overview.html.erb
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 @@ | ||
<div class="mb-8"> | ||
<%= render current_component.new(order: order) %> | ||
</div> |
9 changes: 9 additions & 0 deletions
9
admin/spec/components/solidus_admin/orders/new/component_spec.rb
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe SolidusAdmin::Orders::New::Component, type: :component do | ||
it "renders the overview preview" do | ||
render_preview(:overview) | ||
end | ||
end |