Skip to content

Commit

Permalink
Merge pull request solidusio#5734 from SuperGoodSoft/feature/solidus_…
Browse files Browse the repository at this point in the history
…admin/show-unavailable-status-products

Show "Unavailable" status for products with a future `Available On` date
  • Loading branch information
tvdeyen authored May 2, 2024
2 parents f2c12f6 + 1fdb686 commit 5b65373
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,20 @@
<%= page_with_sidebar_aside do %>
<%= render component('ui/panel').new(title: "Publishing") do %>
<%= render component("ui/forms/field").text_field(f, :available_on, hint: t(".available_on_html"), type: :date) %>
<%= render component("ui/forms/field").text_field(f, :discontinue_on, hint: t(".discontinue_on_html"), type: :date) %>

<%= render component("ui/forms/field").text_field(
f,
:available_on,
hint: t(".available_on_html"),
type: :date,
value: f.object.available_on&.to_date
) %>
<%= render component("ui/forms/field").text_field(
f,
:discontinue_on,
hint: t(".discontinue_on_html"),
type: :date,
value: f.object.discontinue_on&.to_date
) %>
<label class="flex gap-2 items-center">
<%= render component("ui/forms/checkbox").new(
name: "#{f.object_name}[promotionable]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent
available: :green,
discontinued: :yellow,
deleted: :red,
unavailable: :yellow
}.freeze

def self.from_product(product)
Expand All @@ -13,8 +14,10 @@ def self.from_product(product)
:deleted
elsif product.discontinued?
:discontinued
else
elsif product.available?
:available
else
:unavailable
end

new(status: status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ en:
available: 'Available'
discontinued: 'Discontinued'
deleted: 'Deleted'
unavailable: 'Unavailable'
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@

expect(page).to have_css("input[type='number'][name='name'][value='value']")
end

it "renders a date input" do
render_inline(described_class.new(type: :date, name: "name", value: "2020-01-01"))

expect(page).to have_css("input[type='date'][name='name'][value='2020-01-01']")
end
end
end

0 comments on commit 5b65373

Please sign in to comment.