-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use turbo frame and stream to create element
By responding with a turbo-stream instead of js.erb, we can replace the old Rail-UJS data-remote with a turbo-frame.
- Loading branch information
Showing
10 changed files
with
88 additions
and
74 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 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
14 changes: 14 additions & 0 deletions
14
app/views/alchemy/admin/elements/_clipboard_button.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,14 @@ | ||
<%= render Alchemy::Admin::ToolbarButton.new( | ||
url: alchemy.admin_clipboard_path(remarkable_type: "elements"), | ||
label: Alchemy.t("Show clipboard"), | ||
icon: :clipboard, | ||
icon_style: clipboard_empty?("elements") ? "line" : "fill", | ||
dialog_options: { | ||
title: Alchemy.t("Clipboard"), | ||
size: "400x305" | ||
}, | ||
link_options: { | ||
id: "clipboard_button" | ||
}, | ||
if_permitted_to: [:index, :alchemy_admin_clipboard] | ||
) %> |
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 was deleted.
Oops, something went wrong.
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,34 @@ | ||
<% opts = { | ||
partial: "alchemy/admin/elements/element", | ||
locals: { | ||
element: Alchemy::ElementEditor.new(@element), | ||
created: true | ||
} | ||
} %> | ||
<% if @element.fixed? %> | ||
<% target = "fixed_element_#{@element.id}" %> | ||
<% elsif @element.parent_element %> | ||
<% target = "element_#{@element.parent_element_id}_nested_elements" %> | ||
<% else %> | ||
<% target = "main-content-elements" %> | ||
<% end %> | ||
<%- if @cut_element_id -%> | ||
<%= turbo_stream.remove "element_#{@cut_element_id}" %> | ||
<% end %> | ||
<% if @insert_at_top %> | ||
<%= turbo_stream.prepend target, **opts %> | ||
<% else %> | ||
<%= turbo_stream.append target, **opts %> | ||
<% end %> | ||
<%= turbo_stream.replace "clipboard_button", | ||
partial: "alchemy/admin/elements/clipboard_button" %> | ||
|
||
<alchemy-growl> | ||
<%= Alchemy.t(:successfully_added_element) %> | ||
</alchemy-growl> | ||
|
||
<alchemy-action name="closeCurrentDialog"></alchemy-action> |
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