Skip to content

Commit

Permalink
Merge pull request #5539 from nebulab/rainerd/admin/add-reasons-index…
Browse files Browse the repository at this point in the history
…-page

[Admin] Add `Refunds and Returns` section with correlated index pages
  • Loading branch information
elia committed Dec 6, 2023
2 parents ae6e2f3 + b2d4a7c commit ff563e1
Show file tree
Hide file tree
Showing 39 changed files with 807 additions and 0 deletions.
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 %>
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
add: 'Add new'
batch_actions:
delete: 'Delete'
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 %>
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
add: 'Add new'
batch_actions:
delete: 'Delete'
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 %>
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
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"
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 %>
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
add: 'Add new'
batch_actions:
delete: 'Delete'
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 %>
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
add: 'Add new'
batch_actions:
delete: 'Delete'
Loading

0 comments on commit ff563e1

Please sign in to comment.