Skip to content

Commit

Permalink
Use ui/pages/index component tabbed index components
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Jan 2, 2024
1 parent 5deacc2 commit 3812f8c
Show file tree
Hide file tree
Showing 28 changed files with 246 additions and 600 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# frozen_string_literal: true

class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::BaseComponent
include SolidusAdmin::Layout::PageHelpers

def initialize(page:)
@page = page
class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::RefundsAndReturns::Component
def model_class
Spree::AdjustmentReason
end

def title
Spree::AdjustmentReason.model_name.human.pluralize
def search_url
solidus_admin.adjustment_reasons_path
end

def prev_page_path
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
def search_key
:name_or_code_cont
end

def next_page_path
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
def row_url(adjustment_reason)
spree.edit_admin_adjustment_reason_path(adjustment_reason)
end

def batch_actions
Expand All @@ -30,14 +28,6 @@ def batch_actions
]
end

def scopes
[]
end

def filters
[]
end

def columns
[
:name,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
# frozen_string_literal: true

class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::BaseComponent
include SolidusAdmin::Layout::PageHelpers
class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::RefundsAndReturns::Component
def model_class
Spree::RefundReason
end

def initialize(page:)
@page = page
def search_url
solidus_admin.refund_reasons_path
end

def title
Spree::RefundReason.model_name.human.pluralize
def search_key
:name_or_code_cont
end

def prev_page_path
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
def row_url(refund_reason)
spree.edit_admin_refund_reason_path(refund_reason)
end

def next_page_path
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
def actions
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

def batch_actions
Expand All @@ -30,14 +38,6 @@ def batch_actions
]
end

def scopes
[]
end

def filters
[]
end

def columns
[
:name,
Expand Down

This file was deleted.

46 changes: 33 additions & 13 deletions admin/app/components/solidus_admin/refunds_and_returns/component.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
# 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
class SolidusAdmin::RefundsAndReturns::Component < SolidusAdmin::UI::Pages::Index::Component
def title
page_header_title safe_join([
tag.div(t(".title")),
tag.div(t(".subtitle"), class: "font-normal text-sm text-gray-500"),
])
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,
}
[
{
text: Spree::RefundReason.model_name.human(count: 2),
href: solidus_admin.refund_reasons_path,
current: model_class == Spree::RefundReason,
},
{
text: Spree::ReimbursementType.model_name.human(count: 2),
href: solidus_admin.reimbursement_types_path,
current: model_class == Spree::ReimbursementType,
},
{
text: Spree::ReturnReason.model_name.human(count: 2),
href: solidus_admin.return_reasons_path,
current: model_class == Spree::ReturnReason,
},
{
text: Spree::AdjustmentReason.model_name.human(count: 2),
href: solidus_admin.adjustment_reasons_path,
current: model_class == Spree::AdjustmentReason,
},
{
text: Spree::StoreCreditReason.model_name.human(count: 2),
href: solidus_admin.store_credit_reasons_path,
current: model_class == Spree::StoreCreditReason,
},
]
end
end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
# 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
[]
class SolidusAdmin::ReimbursementTypes::Index::Component < SolidusAdmin::RefundsAndReturns::Component
def model_class
Spree::ReimbursementType
end

def scopes
[]
def search_url
solidus_admin.reimbursement_types_path
end

def filters
[]
def search_key
:name_cont
end

def columns
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# frozen_string_literal: true

class SolidusAdmin::ReturnReasons::Index::Component < SolidusAdmin::BaseComponent
include SolidusAdmin::Layout::PageHelpers

def initialize(page:)
@page = page
class SolidusAdmin::ReturnReasons::Index::Component < SolidusAdmin::RefundsAndReturns::Component
def model_class
Spree::ReturnReason
end

def title
Spree::ReturnReason.model_name.human.pluralize
def search_url
solidus_admin.return_reasons_path
end

def prev_page_path
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
def search_key
:name_cont
end

def next_page_path
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
def row_url(return_reason)
spree.edit_admin_return_reason_path(return_reason)
end

def batch_actions
Expand All @@ -30,14 +28,6 @@ def batch_actions
]
end

def scopes
[]
end

def filters
[]
end

def columns
[
:name,
Expand Down
Loading

0 comments on commit 3812f8c

Please sign in to comment.