forked from SpinaCMS/Spina
-
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.
Exclude view templates from page collections/resources (SpinaCMS#769)
* Add exclude_from to view_templates * No more preview on hover * Add exclude_from example to demo theme
- Loading branch information
1 parent
96386f9
commit e3bc02f
Showing
8 changed files
with
63 additions
and
29 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
app/components/spina/pages/new_page_button_component.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,32 @@ | ||
<% if view_templates.many? %> | ||
|
||
<%= render Spina::UserInterface::DropdownComponent.new do |dropdown| %> | ||
<% dropdown.button(classes: "btn btn-primary w-full") do %> | ||
<%= helpers.heroicon("plus", style: :solid, class: "w-7 h-7 -ml-2") %> | ||
<%=t 'spina.pages.new' %> | ||
<% end %> | ||
|
||
<% dropdown.menu do %> | ||
<% view_templates.each do |template| %> | ||
<%= link_to helpers.spina.new_admin_page_path(view_template: template.name, resource_id: @resource&.id), class: "block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900", data: {turbo_frame: "modal", action: "reveal#hide"} do %> | ||
<div class="font-medium text-gray-700"> | ||
<%= template.title %> | ||
|
||
<% if template.recommended %> | ||
<span class="text-green-500 text-xs"><%=t 'spina.pages.recommended' %></span> | ||
<% end %> | ||
</div> | ||
<div class="text-gray-400"><%= template.description %></div> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% else %> | ||
|
||
<%= link_to helpers.spina.new_admin_page_path(view_template: view_template.name, resource_id: resource&.id), class: "btn btn-primary w-full", data: {turbo_frame: "modal"} do %> | ||
<%= helpers.heroicon("plus", style: :solid, class: "w-7 h-7 -ml-2") %> | ||
<%=t 'spina.pages.new' %> | ||
<% 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,19 @@ | ||
module Spina::Pages | ||
class NewPageButtonComponent < Spina::ApplicationComponent | ||
attr_reader :view_templates, :resource | ||
|
||
def initialize(view_templates = [], resource: nil) | ||
@view_templates = view_templates | ||
@resource = resource | ||
end | ||
|
||
def view_template | ||
view_templates.first | ||
end | ||
|
||
def render? | ||
view_templates.any? | ||
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
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