Merge pull request #5734 from SuperGoodSoft/feature/solidus_admin/show-unavailable-status-products

Show "Unavailable" status for products with a future `Available On` date
This commit is contained in:
Thomas von Deyen 2024-05-02 18:41:33 +02:00 committed by GitHub
commit 5b65373270
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 4 deletions

View File

@ -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]",

View File

@ -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)
@ -13,8 +14,10 @@ class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent
:deleted
elsif product.discontinued?
:discontinued
else
elsif product.available?
:available
else
:unavailable
end
new(status: status)

View File

@ -2,3 +2,4 @@ en:
available: 'Available'
discontinued: 'Discontinued'
deleted: 'Deleted'
unavailable: 'Unavailable'

View File

@ -34,5 +34,11 @@ RSpec.describe SolidusAdmin::UI::Forms::Input::Component, type: :component do
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