forked from AlchemyCMS/alchemy_cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new menu tab to page configuration dialog. This is a shortcut to create a menu entry for the current page. It is also the first try to provide Turbo Frames inside of Alchemy, which is coming with a few challenges (flash messages, and updated tab headline)
- Loading branch information
1 parent
b3569db
commit 56e183f
Showing
11 changed files
with
134 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Alchemy | ||
module Admin | ||
class Growl < ViewComponent::Base | ||
delegate :flash, to: :helpers | ||
|
||
attr_reader :message, :type | ||
|
||
def before_render | ||
@message = nil | ||
if flash.any? | ||
key = flash.keys.first | ||
@message = flash[key] | ||
@type = key | ||
flash.delete(key) | ||
end | ||
end | ||
|
||
def call | ||
return unless message | ||
|
||
content_tag("alchemy-growl", nil, {message: message, type: type}) | ||
end | ||
end | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export class Growl extends HTMLElement { | ||
connectedCallback() { | ||
if (this.message) { | ||
Alchemy.growl(this.message, this.type) | ||
} | ||
} | ||
|
||
get message() { | ||
return this.getAttribute("message") | ||
} | ||
|
||
get type() { | ||
return this.getAttribute("type") || "notice" | ||
} | ||
} | ||
|
||
customElements.define("alchemy-growl", Growl) |
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,50 @@ | ||
<%= turbo_frame_tag("page_nodes") do %> | ||
<table class="list" id="connected_nodes"> | ||
<tr> | ||
<th class="name"> | ||
<%= Alchemy::Node.model_name.human %> | ||
</th> | ||
<th class="tools"></th> | ||
</tr> | ||
<% if @page.nodes.length > 0 %> | ||
<% @page.nodes.each do |node| %> | ||
<tr class="even"> | ||
<td><%= "#{node.ancestors.map(&:name).join(" / ")} / #{node.name}" %></td> | ||
<td class="tools"> | ||
<sl-tooltip content="<%= Alchemy.t("delete_node") %>"> | ||
<%= link_to render_icon(:minus), | ||
admin_node_path(node), | ||
class: "icon_button", | ||
data: { turbo_method: :delete, turbo_confirm: Alchemy.t('confirm_to_delete_node') } %> | ||
</sl-tooltip> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<% else %> | ||
<tr class="even"> | ||
<td><%= Alchemy.t('No menu node for this page found') %></td> | ||
<td class="tools"></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<fieldset> | ||
<legend><%= Alchemy.t('Create node on parent:') %></legend> | ||
|
||
<%= alchemy_form_for([:admin, @page.nodes.build], id: "new_node_form") do |f| %> | ||
<%= f.hidden_field :page_id, value: @page.id %> | ||
<%= f.hidden_field :language_id, value: @page.language_id %> | ||
|
||
<%= render Alchemy::Admin::NodeSelect.new(nil, url: alchemy.api_nodes_path(language_id: @page.language_id, include: :ancestors)) do %> | ||
<%= f.text_field :parent_id, class: 'alchemy_selectbox full_width' %> | ||
<% end %> | ||
|
||
<div class="submit"> | ||
<button is="alchemy-button"><%= Alchemy.t(:create_node) %></button> | ||
</div> | ||
<% end %> | ||
</fieldset> | ||
<%= render Alchemy::Admin::Growl.new %> | ||
<% 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 "page_nodes" %> |
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 "page_nodes" %> |
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