forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 3
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 solidusio#5791 from mamhoff/admin-adjustable-compo…
…nents Admin adjustable components
- Loading branch information
Showing
15 changed files
with
171 additions
and
90 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
admin/app/components/solidus_admin/orders/show/adjustments/index/adjustable/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,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component < SolidusAdmin::BaseComponent | ||
attr_reader :adjustment, :adjustable, :model_name | ||
|
||
def initialize(adjustment) | ||
@adjustment = adjustment | ||
@adjustable = adjustment.adjustable | ||
@model_name = adjustable&.model_name&.human | ||
end | ||
|
||
def call | ||
render component("ui/thumbnail_with_caption").new(caption: caption, detail: detail) do | ||
thumbnail | ||
end | ||
end | ||
|
||
def thumbnail | ||
render(component("ui/thumbnail").for(adjustment.adjustable, class: "basis-10")) | ||
end | ||
|
||
def caption | ||
end | ||
|
||
def detail | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
...nents/solidus_admin/orders/show/adjustments/index/adjustable/spree_line_item/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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::SpreeLineItem::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component | ||
delegate :variant, to: :adjustable | ||
|
||
def caption | ||
options_text = variant.options_text.presence | ||
options_text || variant.sku | ||
end | ||
|
||
def detail | ||
link_to(variant.product.name, solidus_admin.product_path(variant.product), class: "body-link") | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
...omponents/solidus_admin/orders/show/adjustments/index/adjustable/spree_order/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::Show::Adjustments::Index::Adjustable::SpreeOrder::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component | ||
def caption | ||
"#{Spree::Order.model_name.human} ##{adjustable.number}" | ||
end | ||
|
||
def detail | ||
adjustable.display_total | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
...onents/solidus_admin/orders/show/adjustments/index/adjustable/spree_shipment/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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::SpreeShipment::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component | ||
def caption | ||
"#{t('spree.shipment')} ##{adjustable.number}" | ||
end | ||
|
||
def detail | ||
link_to( | ||
adjustable.shipping_method.name, | ||
spree.edit_admin_shipping_method_path(adjustable.shipping_method), | ||
class: "body-link" | ||
) | ||
end | ||
end |
14 changes: 0 additions & 14 deletions
14
admin/app/components/solidus_admin/orders/show/adjustments/index/adjustment/component.rb
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...onents/solidus_admin/orders/show/adjustments/index/adjustment/spree_tax_rate/component.rb
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...nts/solidus_admin/orders/show/adjustments/index/adjustment/spree_unit_cancel/component.rb
This file was deleted.
Oops, something went wrong.
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
26 changes: 26 additions & 0 deletions
26
admin/app/components/solidus_admin/orders/show/adjustments/index/source/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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Adjustments::Index::Source::Component < SolidusAdmin::BaseComponent | ||
attr_reader :adjustment, :source, :model_name | ||
|
||
def initialize(adjustment) | ||
@adjustment = adjustment | ||
@source = adjustment.source | ||
@model_name = source&.model_name&.human | ||
end | ||
|
||
def call | ||
render component("ui/thumbnail_with_caption").new(icon: icon, caption: caption, detail: detail) | ||
end | ||
|
||
def caption | ||
adjustment.label | ||
end | ||
|
||
def detail | ||
end | ||
|
||
def icon | ||
"question-line" | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
...components/solidus_admin/orders/show/adjustments/index/source/spree_tax_rate/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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Adjustments::Index::Source::SpreeTaxRate::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Source::Component | ||
def icon | ||
"percent-line" | ||
end | ||
|
||
def detail | ||
link_to("#{model_name}: #{zone_name}", spree.edit_admin_tax_rate_path(adjustment.source_id), class: "body-link") | ||
end | ||
|
||
private | ||
|
||
def zone_name | ||
source.zone&.name || t("spree.all_zones") | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
...ponents/solidus_admin/orders/show/adjustments/index/source/spree_unit_cancel/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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Adjustments::Index::Source::SpreeUnitCancel::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Source::Component | ||
def icon | ||
"close-circle-line" | ||
end | ||
end |
7 changes: 6 additions & 1 deletion
7
...ments/index/adjustment/component.html.erb → ...thumbnail_with_caption/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
15 changes: 15 additions & 0 deletions
15
admin/app/components/solidus_admin/ui/thumbnail_with_caption/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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::UI::ThumbnailWithCaption::Component < SolidusAdmin::BaseComponent | ||
attr_reader :icon, :caption, :detail | ||
|
||
def initialize(icon: "question-line", caption: "", detail: nil) | ||
@icon = icon | ||
@caption = caption | ||
@detail = detail | ||
end | ||
|
||
def icon_thumbnail | ||
render component("ui/thumbnail").new(icon: icon) | ||
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
6 changes: 5 additions & 1 deletion
6
...tment/spree_promotion_action/component.rb → ...ource/spree_promotion_action/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