-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nodes to page dialog #2699
Merged
tvdeyen
merged 2 commits into
AlchemyCMS:main
from
sascha-karnatz:node-tab-in-page-configuration
Feb 5, 2024
Merged
Add nodes to page dialog #2699
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Render path contains parameter value