-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add product properties create/edit flow to admin
This builds off of the excellent work done by @Astr0surf3r in #5885 and by @forkata in #5926 to build out the create/edit/update flow for product properties in the new admin. I've added a request spec that was missing and tweaked a few other things.
- Loading branch information
1 parent
18fba3e
commit 22b5594
Showing
12 changed files
with
396 additions
and
11 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
admin/app/components/solidus_admin/properties/edit/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= turbo_frame_tag :edit_property_modal do %> | ||
<%= render component("ui/modal").new(title: t(".title")) do |modal| %> | ||
<%= form_for @property, url: solidus_admin.property_path(@property), html: { id: form_id } do |f| %> | ||
<div class="flex flex-col gap-6 pb-4"> | ||
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> | ||
<%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %> | ||
</div> | ||
<% modal.with_actions do %> | ||
<form method="dialog"> | ||
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %> | ||
</form> | ||
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= render component("properties/index").new(page: @page) %> |
12 changes: 12 additions & 0 deletions
12
admin/app/components/solidus_admin/properties/edit/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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Properties::Edit::Component < SolidusAdmin::BaseComponent | ||
def initialize(page:, property:) | ||
@page = page | ||
@property = property | ||
end | ||
|
||
def form_id | ||
dom_id(@property, "#{stimulus_id}_edit_property_form") | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/properties/edit/component.yml
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,4 @@ | ||
en: | ||
title: "Edit Property" | ||
cancel: "Cancel" | ||
submit: "Update Property" |
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
18 changes: 18 additions & 0 deletions
18
admin/app/components/solidus_admin/properties/new/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= turbo_frame_tag :new_property_modal do %> | ||
<%= render component("ui/modal").new(title: t(".title")) do |modal| %> | ||
<%= form_for @property, url: solidus_admin.properties_path, html: { id: form_id } do |f| %> | ||
<div class="flex flex-col gap-6 pb-4"> | ||
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> | ||
<%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %> | ||
</div> | ||
<% modal.with_actions do %> | ||
<form method="dialog"> | ||
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %> | ||
</form> | ||
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= render component("properties/index").new(page: @page) %> |
12 changes: 12 additions & 0 deletions
12
admin/app/components/solidus_admin/properties/new/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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Properties::New::Component < SolidusAdmin::BaseComponent | ||
def initialize(page:, property:) | ||
@page = page | ||
@property = property | ||
end | ||
|
||
def form_id | ||
dom_id(@property, "#{stimulus_id}_new_property_form") | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
admin/app/components/solidus_admin/properties/new/component.yml
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,4 @@ | ||
en: | ||
title: "New Property" | ||
cancel: "Cancel" | ||
submit: "Add Property" |
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
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
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
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
Oops, something went wrong.