Skip to content

Commit 7afa10e

Browse files
authored
Merge pull request #5743 from solidusio/backport/v4.3/pr-5734
[v4.3] Show "Unavailable" status for products with a future `Available On` date
2 parents de92fa4 + ba3b251 commit 7afa10e

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

admin/app/components/solidus_admin/products/show/component.html.erb

+14-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,20 @@
100100

101101
<%= page_with_sidebar_aside do %>
102102
<%= render component('ui/panel').new(title: "Publishing") do %>
103-
<%= render component("ui/forms/field").text_field(f, :available_on, hint: t(".available_on_html"), type: :date) %>
104-
<%= render component("ui/forms/field").text_field(f, :discontinue_on, hint: t(".discontinue_on_html"), type: :date) %>
105-
103+
<%= render component("ui/forms/field").text_field(
104+
f,
105+
:available_on,
106+
hint: t(".available_on_html"),
107+
type: :date,
108+
value: f.object.available_on&.to_date
109+
) %>
110+
<%= render component("ui/forms/field").text_field(
111+
f,
112+
:discontinue_on,
113+
hint: t(".discontinue_on_html"),
114+
type: :date,
115+
value: f.object.discontinue_on&.to_date
116+
) %>
106117
<label class="flex gap-2 items-center">
107118
<%= render component("ui/forms/checkbox").new(
108119
name: "#{f.object_name}[promotionable]",

admin/app/components/solidus_admin/products/status/component.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent
55
available: :green,
66
discontinued: :yellow,
77
deleted: :red,
8+
unavailable: :yellow
89
}.freeze
910

1011
def self.from_product(product)
@@ -13,8 +14,10 @@ def self.from_product(product)
1314
:deleted
1415
elsif product.discontinued?
1516
:discontinued
16-
else
17+
elsif product.available?
1718
:available
19+
else
20+
:unavailable
1821
end
1922

2023
new(status: status)

admin/app/components/solidus_admin/products/status/component.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ en:
22
available: 'Available'
33
discontinued: 'Discontinued'
44
deleted: 'Deleted'
5+
unavailable: 'Unavailable'

admin/spec/components/solidus_admin/ui/forms/input/component_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,11 @@
3434

3535
expect(page).to have_css("input[type='number'][name='name'][value='value']")
3636
end
37+
38+
it "renders a date input" do
39+
render_inline(described_class.new(type: :date, name: "name", value: "2020-01-01"))
40+
41+
expect(page).to have_css("input[type='date'][name='name'][value='2020-01-01']")
42+
end
3743
end
3844
end

0 commit comments

Comments
 (0)