-
-
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 #5539 from nebulab/rainerd/admin/add-reasons-index…
…-page [Admin] Add `Refunds and Returns` section with correlated index pages
- Loading branch information
Showing
39 changed files
with
807 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
admin/app/components/solidus_admin/adjustment_reasons/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,31 @@ | ||
<%= render component('refunds_and_returns').new(current_class: Spree::AdjustmentReason) do |layout| %> | ||
<% layout.with_actions do %> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
text: t('.add'), | ||
href: spree.new_admin_adjustment_reason_path, | ||
icon: "add-line", | ||
class: "align-self-end w-full", | ||
) %> | ||
<% end %> | ||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::AdjustmentReason, | ||
rows: @page.records, | ||
url: ->(adjustment_reason) { spree.edit_admin_adjustment_reason_path(adjustment_reason) }, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.adjustment_reasons_path, | ||
searchbar_key: :name_or_code_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
53 changes: 53 additions & 0 deletions
53
admin/app/components/solidus_admin/adjustment_reasons/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,53 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::AdjustmentReason.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.adjustment_reasons_path, | ||
method: :delete, | ||
icon: 'delete-bin-7-line', | ||
}, | ||
] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
:name, | ||
:code, | ||
{ | ||
header: :active, | ||
data: ->(adjustment_reason) do | ||
adjustment_reason.active? ? component('ui/badge').yes : component('ui/badge').no | ||
end | ||
}, | ||
] | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/adjustment_reasons/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' |
31 changes: 31 additions & 0 deletions
31
admin/app/components/solidus_admin/refund_reasons/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,31 @@ | ||
<%= render component('refunds_and_returns').new(current_class: Spree::RefundReason) do |layout| %> | ||
<% layout.with_actions do %> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
text: t('.add'), | ||
href: spree.new_admin_refund_reason_path, | ||
icon: "add-line", | ||
class: "align-self-end w-full", | ||
) %> | ||
<% end %> | ||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::RefundReason, | ||
rows: @page.records, | ||
url: ->(refund_reason) { spree.edit_admin_refund_reason_path(refund_reason) }, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.refund_reasons_path, | ||
searchbar_key: :name_or_code_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
53 changes: 53 additions & 0 deletions
53
admin/app/components/solidus_admin/refund_reasons/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,53 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::RefundReason.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.refund_reasons_path, | ||
method: :delete, | ||
icon: 'delete-bin-7-line', | ||
}, | ||
] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
:name, | ||
:code, | ||
{ | ||
header: :active, | ||
data: ->(refund_reason) do | ||
refund_reason.active? ? component('ui/badge').yes : component('ui/badge').no | ||
end | ||
}, | ||
] | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/refund_reasons/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' |
26 changes: 26 additions & 0 deletions
26
admin/app/components/solidus_admin/refunds_and_returns/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,26 @@ | ||
<%= 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 %> |
20 changes: 20 additions & 0 deletions
20
admin/app/components/solidus_admin/refunds_and_returns/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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::RefundsAndReturns::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
renders_one :actions | ||
|
||
def initialize(current_class:) | ||
@current_class = current_class | ||
end | ||
|
||
def tabs | ||
{ | ||
Spree::RefundReason => solidus_admin.refund_reasons_path, | ||
Spree::ReimbursementType => solidus_admin.reimbursement_types_path, | ||
Spree::ReturnReason => solidus_admin.return_reasons_path, | ||
Spree::AdjustmentReason => solidus_admin.adjustment_reasons_path, | ||
Spree::StoreCreditReason => solidus_admin.store_credit_reasons_path, | ||
} | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
admin/app/components/solidus_admin/refunds_and_returns/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,3 @@ | ||
en: | ||
title: "Refunds and Returns" | ||
subtitle: "Configure refund reasons, reimbursement types, return reasons, adjustment reasons and store credit reasons" |
22 changes: 22 additions & 0 deletions
22
admin/app/components/solidus_admin/reimbursement_types/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,22 @@ | ||
<%= render component('refunds_and_returns').new(current_class: Spree::ReimbursementType) do |layout| %> | ||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::ReimbursementType, | ||
rows: @page.records, | ||
url: nil, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.reimbursement_types_path, | ||
searchbar_key: :name_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
45 changes: 45 additions & 0 deletions
45
admin/app/components/solidus_admin/reimbursement_types/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,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::ReimbursementTypes::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::ReimbursementType.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 | ||
[] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
:name, | ||
{ | ||
header: :active, | ||
data: ->(reimbursement_type) do | ||
reimbursement_type.active? ? component('ui/badge').yes : component('ui/badge').no | ||
end | ||
}, | ||
] | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/reimbursement_types/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' |
31 changes: 31 additions & 0 deletions
31
admin/app/components/solidus_admin/return_reasons/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,31 @@ | ||
<%= render component('refunds_and_returns').new(current_class: Spree::ReturnReason) do |layout| %> | ||
<% layout.with_actions do %> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
text: t('.add'), | ||
href: spree.new_admin_return_reason_path, | ||
icon: "add-line", | ||
class: "align-self-end w-full", | ||
) %> | ||
<% end %> | ||
<%= render component('ui/table').new( | ||
id: stimulus_id, | ||
data: { | ||
class: Spree::ReturnReason, | ||
rows: @page.records, | ||
url: ->(return_reason) { spree.edit_admin_return_reason_path(return_reason) }, | ||
prev: prev_page_path, | ||
next: next_page_path, | ||
columns: columns, | ||
batch_actions: batch_actions, | ||
}, | ||
search: { | ||
name: :q, | ||
value: params[:q], | ||
url: solidus_admin.return_reasons_path, | ||
searchbar_key: :name_cont, | ||
filters: filters, | ||
scopes: scopes, | ||
}, | ||
) %> | ||
<% end %> |
52 changes: 52 additions & 0 deletions
52
admin/app/components/solidus_admin/return_reasons/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,52 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::ReturnReasons::Index::Component < SolidusAdmin::BaseComponent | ||
include SolidusAdmin::Layout::PageHelpers | ||
|
||
def initialize(page:) | ||
@page = page | ||
end | ||
|
||
def title | ||
Spree::ReturnReason.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.return_reasons_path, | ||
method: :delete, | ||
icon: 'delete-bin-7-line', | ||
}, | ||
] | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
|
||
def scopes | ||
[] | ||
end | ||
|
||
def columns | ||
[ | ||
:name, | ||
{ | ||
header: :active, | ||
data: ->(return_reason) do | ||
return_reason.active? ? component('ui/badge').yes : component('ui/badge').no | ||
end | ||
}, | ||
] | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/return_reasons/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' |
Oops, something went wrong.