Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4.3] Show "Unavailable" status for products with a future Available On date #5743

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading