-
-
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.
Merge pull request #2699 from sascha-karnatz/node-tab-in-page-configu…
…ration Add nodes to page dialog
- Loading branch information
Showing
16 changed files
with
206 additions
and
7 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
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,10 @@ | ||
class Growl extends HTMLElement { | ||
connectedCallback() { | ||
Alchemy.growl( | ||
this.getAttribute("message"), | ||
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 @@ | ||
(<%= count %>) <%= Alchemy::Node.model_name.human(count: count) %> |
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,48 @@ | ||
<%= turbo_frame_tag("page_nodes") do %> | ||
<table class="list"> | ||
<tr> | ||
<th class="name"> | ||
<%= Alchemy::Node.model_name.human %> | ||
</th> | ||
<th class="tools"></th> | ||
</tr> | ||
<% nodes = @page.nodes.select(&:persisted?) %> | ||
<% if nodes.length > 0 %> | ||
<% 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> | ||
<% 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,9 @@ | ||
<% key = flash.keys.first %> | ||
<alchemy-growl message="<%= flash[key] %>" type="<%= key %>"></alchemy-growl> | ||
|
||
<%= turbo_stream.replace "page_nodes" do %> | ||
<%= render "page_nodes" %> | ||
<% end %> | ||
<%= turbo_stream.update_all '[panel="nodes"]' do %> | ||
<%= render('alchemy/admin/nodes/label', count: @page.nodes.select(&:persisted?).length) %> | ||
<% 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 "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 @@ | ||
<%= 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
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,70 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Nodes management", type: :system, js: true do | ||
before do | ||
authorize_user(:as_admin) | ||
end | ||
|
||
let!(:a_page) { create(:alchemy_page) } | ||
let!(:a_menu) { create(:alchemy_node, name: "Menu") } | ||
|
||
def open_page_properties | ||
visit admin_pages_path | ||
expect(page.find("alchemy-overlay").style("display")["display"]).to have_content("none") | ||
page.find("a[href='#{configure_admin_page_path(a_page)}']", wait: 10).click | ||
find("[panel='nodes']").click | ||
end | ||
|
||
def add_menu_item | ||
find("#new_node_form .select2-choice").click | ||
find(".select2-result:first-child").click | ||
|
||
click_button "Add a menu node" | ||
end | ||
|
||
it "lets a user add a menu node" do | ||
open_page_properties | ||
add_menu_item | ||
|
||
within "#page_nodes table" do | ||
expect(page).to have_content("Menu node Menu / A Page 1") | ||
end | ||
within "[panel='nodes']" do | ||
expect(page).to have_content("(1) Menu node") | ||
end | ||
end | ||
|
||
context "without parent id" do | ||
it "displays error message" do | ||
open_page_properties | ||
|
||
click_button "Add a menu node" | ||
within ".flash.error" do | ||
expect(page).to have_content("Menu Type can't be blank") | ||
end | ||
end | ||
end | ||
|
||
context "with menu node present" do | ||
before do | ||
open_page_properties | ||
add_menu_item | ||
end | ||
|
||
it "lets a user remove a menu node" do | ||
page.accept_alert "Do you really want to delete this menu node?" do | ||
click_link_with_tooltip("Delete this menu node") | ||
end | ||
|
||
within "#page_nodes table" do | ||
expect(page).to_not have_content("Menu node Menu / A Page 1") | ||
expect(page).to have_content(Alchemy.t("No menu node for this page found")) | ||
end | ||
within "[panel='nodes']" do | ||
expect(page).to have_content("(0) Menu nodes") | ||
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