-
-
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 #5536 from solidusio/elia/admin/shipping
[admin] Add index pages for the settings / shipping area
- Loading branch information
Showing
23 changed files
with
557 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
admin/app/components/solidus_admin/shipping/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,30 @@ | ||
<%= page do %> | ||
<%= page_header do %> | ||
<%= page_header_title safe_join([ | ||
tag.div(t(".title")), | ||
tag.div(t(".subtitle"), class: "body-small text-gray-500"), | ||
]) %> | ||
<% end %> | ||
|
||
<%= page_header do %> | ||
<% title = capture do %> | ||
<% tabs.each do |tab_class, href|%> | ||
<%= render component('ui/button').new( | ||
tag: :a, | ||
scheme: :ghost, | ||
href: href, | ||
text: tab_class.model_name.human.pluralize, | ||
"aria-current" => tab_class == @current_class, | ||
) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= page_header_title title %> | ||
|
||
<%= page_header_actions do %> | ||
<%= actions %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= content %> | ||
<% 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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Shipping::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
renders_one :actions | ||
|
||
def initialize(current_class:) | ||
@current_class = current_class | ||
end | ||
|
||
def tabs | ||
{ | ||
Spree::ShippingMethod => solidus_admin.shipping_methods_path, | ||
Spree::ShippingCategory => solidus_admin.shipping_categories_path, | ||
Spree::StockLocation => solidus_admin.stock_locations_path, | ||
} | ||
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,3 @@ | ||
en: | ||
title: "Shipping" | ||
subtitle: "Configure shipping methods, categories, and stock locations for customer orders." |
32 changes: 32 additions & 0 deletions
32
admin/app/components/solidus_admin/shipping_categories/index/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,32 @@ | ||
<%= render component('shipping').new(current_class: Spree::ShippingCategory) do |layout| %> | ||
<% layout.with_actions do %> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
text: t('.add'), | ||
href: spree.new_admin_shipping_category_path, | ||
icon: "add-line", | ||
class: "align-self-end w-full", | ||
) %> | ||
<% end %> | ||
|
||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::ShippingCategory, | ||
rows: @page.records, | ||
url: ->(shipping_category) { spree.edit_admin_shipping_category_path(shipping_category) }, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.shipping_categories_path, | ||
searchbar_key: :name_or_description_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
46 changes: 46 additions & 0 deletions
46
admin/app/components/solidus_admin/shipping_categories/index/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,46 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::ShippingCategories::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::ShippingCategory.model_name.human.pluralize | ||
end | ||
|
||
def prev_page_path | ||
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first? | ||
end | ||
|
||
def next_page_path | ||
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last? | ||
end | ||
|
||
def batch_actions | ||
[ | ||
{ | ||
display_name: t('.batch_actions.delete'), | ||
action: solidus_admin.shipping_categories_path, | ||
method: :delete, | ||
icon: 'delete-bin-7-line', | ||
}, | ||
] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
:name | ||
] | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/shipping_categories/index/component.yml
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,4 @@ | ||
en: | ||
add: 'Add new' | ||
batch_actions: | ||
delete: 'Delete' |
32 changes: 32 additions & 0 deletions
32
admin/app/components/solidus_admin/shipping_methods/index/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,32 @@ | ||
<%= render component('shipping').new(current_class: Spree::ShippingMethod) do |layout| %> | ||
<% layout.with_actions do %> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
text: t('.add'), | ||
href: spree.new_admin_shipping_method_path, | ||
icon: "add-line", | ||
class: "align-self-end w-full", | ||
) %> | ||
<% end %> | ||
|
||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::ShippingMethod, | ||
rows: @page.records, | ||
url: ->(shipping_method) { spree.edit_admin_shipping_method_path(shipping_method) }, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.shipping_methods_path, | ||
searchbar_key: :name_or_description_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
61 changes: 61 additions & 0 deletions
61
admin/app/components/solidus_admin/shipping_methods/index/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,61 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::ShippingMethods::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::ShippingMethod.model_name.human.pluralize | ||
end | ||
|
||
def prev_page_path | ||
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first? | ||
end | ||
|
||
def next_page_path | ||
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last? | ||
end | ||
|
||
def batch_actions | ||
[ | ||
{ | ||
display_name: t('.batch_actions.delete'), | ||
action: solidus_admin.shipping_methods_path, | ||
method: :delete, | ||
icon: 'delete-bin-7-line', | ||
}, | ||
] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
{ | ||
header: :name, | ||
data: -> { [_1.admin_name.presence, _1.name].compact.join(' / ') }, | ||
}, | ||
{ | ||
header: :zone, | ||
data: -> { _1.zones.pluck(:name).to_sentence }, | ||
}, | ||
{ | ||
header: :calculator, | ||
data: -> { _1.calculator&.description }, | ||
}, | ||
{ | ||
header: :available_to_users, | ||
data: -> { _1.available_to_users? ? component('ui/badge').yes : component('ui/badge').no }, | ||
}, | ||
] | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/shipping_methods/index/component.yml
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,4 @@ | ||
en: | ||
add: 'Add new' | ||
batch_actions: | ||
delete: 'Delete' |
32 changes: 32 additions & 0 deletions
32
admin/app/components/solidus_admin/stock_locations/index/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,32 @@ | ||
<%= render component('shipping').new(current_class: Spree::StockLocation) do |layout| %> | ||
<% layout.with_actions do %> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
text: t('.add'), | ||
href: spree.new_admin_stock_location_path, | ||
icon: "add-line", | ||
class: "align-self-end w-full", | ||
) %> | ||
<% end %> | ||
|
||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::StockLocation, | ||
rows: @page.records, | ||
url: ->(stock_location) { spree.edit_admin_stock_location_path(stock_location) }, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.stock_locations_path, | ||
searchbar_key: :name_or_description_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
81 changes: 81 additions & 0 deletions
81
admin/app/components/solidus_admin/stock_locations/index/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,81 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::StockLocations::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::StockLocation.model_name.human.pluralize | ||
end | ||
|
||
def prev_page_path | ||
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first? | ||
end | ||
|
||
def next_page_path | ||
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last? | ||
end | ||
|
||
def batch_actions | ||
[ | ||
{ | ||
display_name: t('.batch_actions.delete'), | ||
action: solidus_admin.stock_locations_path, | ||
method: :delete, | ||
icon: 'delete-bin-7-line', | ||
}, | ||
] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
:name, | ||
:code, | ||
:admin_name, | ||
{ | ||
header: :state, | ||
data: -> { | ||
color = _1.active? ? :green : :graphite_light | ||
text = _1.active? ? t('.active') : t('.inactive') | ||
|
||
component('ui/badge').new(name: text, color: color) | ||
}, | ||
}, | ||
{ | ||
header: :backorderable, | ||
data: -> { | ||
_1.backorderable_default ? component('ui/badge').yes : component('ui/badge').no | ||
} | ||
}, | ||
{ | ||
header: :default, | ||
data: -> { | ||
_1.default ? component('ui/badge').yes : component('ui/badge').no | ||
} | ||
}, | ||
{ | ||
header: :stock_movements, | ||
data: -> { | ||
count = _1.stock_movements.count | ||
|
||
link_to( | ||
"#{count} #{Spree::StockMovement.model_name.human(count: count).downcase}", | ||
spree.admin_stock_location_stock_movements_path(_1), | ||
class: 'body-link' | ||
) | ||
} | ||
} | ||
] | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
admin/app/components/solidus_admin/stock_locations/index/component.yml
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 @@ | ||
en: | ||
active: 'Active' | ||
inactive: 'Inactive' | ||
add: 'Add new' | ||
batch_actions: | ||
delete: 'Delete' |
Oops, something went wrong.