-
-
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.
Allow page visible toggle (4.6) (#1838)
* Use translated menu name in page form * Format admin pages helper with Rufo * Allow to pass a label to page_status_checkox helper * Only check for menus having same language as page We should only check if any menus are present to attach a page to for the same language. * Allow to toggle visible on pages attached to menus The Page#visible status is used to build the urlname of child pages. If a page is attached to a menu we should still be able to toggle that flag. * Add active button style * Reduce horizontal padding of small button
- Loading branch information
Showing
4 changed files
with
52 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
<% if @page.menus.any? %> | ||
<label class="checkbox"> | ||
<input type="checkbox" disabled checked> | ||
<%= Alchemy.t(:attached_to) %> | ||
</label> | ||
<% @page.menus.each do |menu| %> | ||
<span class="page-menu-name label"> | ||
<%= menu.name %> | ||
</span> | ||
<% if Alchemy::Node.roots.where(language: @page.language).any? %> | ||
<% unless @page.language_root %> | ||
<%= page_status_checkbox(@page, :visible, label: Alchemy.t("show in url of child pages")) %> | ||
<% end %> | ||
<% if @page.menus.any? %> | ||
<label style="vertical-align: middle"> | ||
<%= Alchemy.t(:attached_to) %> | ||
</label> | ||
<% @page.menus.each do |menu| %> | ||
<span class="page-menu-name label"> | ||
<%= I18n.t(menu.name, scope: [:alchemy, :menu_names]) %> | ||
</span> | ||
<% end %> | ||
<% else %> | ||
<a class="button small" id="attach-page"><%= Alchemy.t("attach to a menu") %></a> | ||
<%= f.input :menu_id, collection: Alchemy::Node.roots.map { |n| | ||
[I18n.t(n.name, scope: [:alchemy, :menu_names]), n.id] | ||
}, | ||
prompt: Alchemy.t("Please choose a menu"), | ||
input_html: { class: "alchemy_selectbox" }, | ||
wrapper_html: { class: "hidden" }, | ||
label: false %> | ||
<script> | ||
(function() { | ||
var wrapper = document.querySelector(".input.page_menu_id") | ||
document.querySelector("#attach-page").addEventListener("click", function() { | ||
var select = wrapper.querySelector("select") | ||
this.classList.toggle("active") | ||
wrapper.classList.toggle("hidden") | ||
$(select).select2("val", "") | ||
}) | ||
})() | ||
</script> | ||
<% end %> | ||
<% elsif Alchemy::Node.roots.any? %> | ||
<%= page_status_checkbox(@page, :visible) %> | ||
<%= f.input :menu_id, collection: Alchemy::Node.roots.map { |n| [n.name, n.id] }, | ||
prompt: Alchemy.t('Please choose a menu'), | ||
input_html: { class: 'alchemy_selectbox' }, | ||
wrapper_html: { style: @page.visible? ? 'display: block' : 'display: none' }, | ||
label: false %> | ||
<script> | ||
(function() { | ||
var $wrapper = $('.input.page_menu_id') | ||
$('#page_visible').click(function() { | ||
if ($(this).is(':checked')) { | ||
$wrapper.show() | ||
} else { | ||
$wrapper.find('select').val('') | ||
$wrapper.hide() | ||
} | ||
}) | ||
})() | ||
</script> | ||
<% else %> | ||
<%= page_status_checkbox(@page, :visible) %> | ||
<% end %> |