-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert legacy page urls panel into Turbo Frame
Uses turbo frames instead of a remote form to get rid js.erb templates and use turbo streams instead.
- Loading branch information
Showing
16 changed files
with
125 additions
and
71 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
21 changes: 10 additions & 11 deletions
21
app/views/alchemy/admin/legacy_page_urls/_legacy_page_url.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 |
---|---|---|
@@ -1,17 +1,16 @@ | ||
<tr class="even" id="<%= dom_id(legacy_page_url) %>"> | ||
<td class="name"><%= legacy_page_url.urlname %></td> | ||
<td class="tools"> | ||
<%= turbo_frame_tag(legacy_page_url, class: ["row", cycle("even", "odd")]) do %> | ||
<div class="col name"><%= legacy_page_url.urlname %></div> | ||
<div class="col tools"> | ||
<sl-tooltip content="<%= Alchemy.t(:edit) %>"> | ||
<%= link_to_dialog render_icon(:edit), | ||
<%= link_to render_icon(:edit), | ||
edit_admin_legacy_page_url_path(legacy_page_url, page_id: @page.id), | ||
{size: '400x125', title: Alchemy.t('Edit link')}, | ||
class: "icon_button" %> | ||
class: "icon_button", data: { turbo_frame: dom_id(legacy_page_url)} %> | ||
</sl-tooltip> | ||
<sl-tooltip content="<%= Alchemy.t(:remove) %>"> | ||
<%= link_to_confirm_dialog render_icon(:minus), | ||
Alchemy.t('Are you sure?'), | ||
<%= link_to render_icon(:minus), | ||
admin_legacy_page_url_path(legacy_page_url, page_id: @page.id), | ||
class: "icon_button" %> | ||
class: "icon_button", | ||
data: { turbo_method: :delete, turbo_confirm: Alchemy.t('Are you sure?') } %> | ||
</sl-tooltip> | ||
</td> | ||
</tr> | ||
</div> | ||
<% end %> |
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 |
---|---|---|
@@ -1,20 +1,18 @@ | ||
<%= alchemy_form_for [:admin, @legacy_page_url ||= @page.legacy_urls.build], | ||
id: 'new_legacy_page_url' do |f| %> | ||
<% if @legacy_page_url.errors.any? %> | ||
<%= render_message :error do %> | ||
<%= @legacy_page_url.errors.full_messages.join %> | ||
<%= turbo_frame_tag "new_legacy_page_url" do %> | ||
<%= alchemy_form_for [:admin, legacy_page_url] do |f| %> | ||
<% if legacy_page_url.errors.any? %> | ||
<%= render_message :error do %> | ||
<%= legacy_page_url.errors.full_messages.join %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= hidden_field_tag :page_id, @page.id %> | ||
<div class="inline-input"> | ||
<div class="left-column"> | ||
<%= f.text_field :urlname, placeholder: Alchemy::LegacyPageUrl.human_attribute_name(:urlname) %> | ||
</div> | ||
<div class="right-column"> | ||
<button class="with_icon"> | ||
<%= render_icon(:plus) %> | ||
<%= Alchemy.t(:add) %> | ||
</button> | ||
<%= hidden_field_tag :page_id, @page.id %> | ||
<div class="inline-input"> | ||
<div class="left-column"> | ||
<%= f.text_field :urlname, placeholder: Alchemy::LegacyPageUrl.human_attribute_name(:urlname) %> | ||
</div> | ||
<div class="right-column"> | ||
<button><%= Alchemy.t(:add) %></button> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> |
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,16 @@ | ||
<div class="table"> | ||
<% if legacy_page_urls.any? %> | ||
<header> | ||
<div class="col name"> | ||
<%= Alchemy::LegacyPageUrl.human_attribute_name(:urlname) %> | ||
</div> | ||
</header> | ||
<%= render partial: 'alchemy/admin/legacy_page_urls/legacy_page_url', | ||
collection: legacy_page_urls %> | ||
<% else %> | ||
<div class="row even"> | ||
<div class="col"><%= Alchemy.t('No page links for this page found') %></div> | ||
<div class="col tools"></div> | ||
</div> | ||
<% end %> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
app/views/alchemy/admin/legacy_page_urls/_update.turbo_stream.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,12 @@ | ||
<%= turbo_stream.update "legacy_urls_label" do %> | ||
<%= render "label", count: @page.legacy_urls.size %> | ||
<% end %> | ||
<%= turbo_stream.update "legacy_page_urls" do %> | ||
<%= render "table", legacy_page_urls: @page.legacy_urls %> | ||
<% end %> | ||
<%= turbo_stream.update "new_legacy_page_url" do %> | ||
<%= render 'new', legacy_page_url: @page.legacy_urls.build %> | ||
<% end %> | ||
<alchemy-growl> | ||
<%= @message %> | ||
</alchemy-growl> |
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
app/views/alchemy/admin/legacy_page_urls/create.turbo_stream.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,8 @@ | ||
<% if @legacy_page_url.valid? %> | ||
<%= render "update" %> | ||
<% else %> | ||
<%= turbo_stream.update "new_legacy_page_url" do %> | ||
<%= render 'new', | ||
legacy_page_url: @legacy_page_url %> | ||
<% end %> | ||
<% end %> |
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
app/views/alchemy/admin/legacy_page_urls/destroy.turbo_stream.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 @@ | ||
<%= render "update" %> |
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,27 @@ | ||
<%= turbo_frame_tag(@legacy_page_url, class: "row") do %> | ||
<div class="col p-0"> | ||
<%= form_for [:admin, @legacy_page_url] do |f| %> | ||
<%= content_tag :div, class: @legacy_page_url.errors.any? ? "field_with_errors" : nil do %> | ||
<%= f.text_field :urlname, placeholder: Alchemy::LegacyPageUrl.human_attribute_name(:urlname), autofocus: true %> | ||
<% if @legacy_page_url.errors.any? %> | ||
<small class="error"> | ||
<%= @legacy_page_url.errors.full_messages_for(:urlname).join %> | ||
</small> | ||
<% end %> | ||
<% end %> | ||
<%= hidden_field_tag :page_id, @legacy_page_url.page_id %> | ||
<% end %> | ||
</div> | ||
<div class="col tools"> | ||
<sl-tooltip content="<%= Alchemy.t(:save) %>"> | ||
<%= button_tag type: "submit", form: dom_id(@legacy_page_url, :edit), class: "icon_button" do %> | ||
<%= render_icon :check %> | ||
<% end %> | ||
</sl-tooltip> | ||
<sl-tooltip content="<%= Alchemy.t(:cancel) %>"> | ||
<%= link_to admin_legacy_page_url_path(@legacy_page_url, page_id: @legacy_page_url.page_id), class: "icon_button" do %> | ||
<%= render_icon :close %> | ||
<% end %> | ||
</sl-tooltip> | ||
</div> | ||
<% end %> |
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 @@ | ||
<%= render "legacy_page_url", legacy_page_url: @legacy_page_url %> |
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
app/views/alchemy/admin/legacy_page_urls/update.turbo_stream.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 @@ | ||
<%= render "update" %> |
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