diff --git a/app/controllers/alchemy/admin/pages_controller.rb b/app/controllers/alchemy/admin/pages_controller.rb index 36716c5f8d..d25a603fd6 100644 --- a/app/controllers/alchemy/admin/pages_controller.rb +++ b/app/controllers/alchemy/admin/pages_controller.rb @@ -57,9 +57,9 @@ def info def new @page ||= Page.new(layoutpage: params[:layoutpage] == 'true', parent_id: params[:parent_id]) - @page_layouts = PageLayout.layouts_for_select(@current_language.id, @page.layoutpage?) + @page_layouts = PageLayout.layouts_for_select(@current_language.id, @page.layoutpage?, @page.parent.page_layout) @clipboard = get_clipboard('pages') - @clipboard_items = Page.all_from_clipboard_for_select(@clipboard, @current_language.id, @page.layoutpage?) + @clipboard_items = Page.all_from_clipboard_for_select(@clipboard, @current_language.id, @page.layoutpage?, @page.parent.page_layout) end def create diff --git a/app/models/alchemy/page.rb b/app/models/alchemy/page.rb index f4d6b051d9..b4495f8ca7 100644 --- a/app/models/alchemy/page.rb +++ b/app/models/alchemy/page.rb @@ -254,11 +254,11 @@ def all_from_clipboard(clipboard) where(id: clipboard.collect { |p| p['id'] }) end - def all_from_clipboard_for_select(clipboard, language_id, layoutpage = false) + def all_from_clipboard_for_select(clipboard, language_id, layoutpage = false, page_layout_name = nil) return [] if clipboard.blank? clipboard_pages = all_from_clipboard(clipboard) - allowed_page_layouts = Alchemy::PageLayout.selectable_layouts(language_id, layoutpage) + allowed_page_layouts = Alchemy::PageLayout.selectable_layouts(language_id, layoutpage, page_layout_name) allowed_page_layout_names = allowed_page_layouts.collect { |p| p['name'] } clipboard_pages.select { |cp| allowed_page_layout_names.include?(cp.page_layout) } end diff --git a/app/serializers/alchemy/page_tree_serializer.rb b/app/serializers/alchemy/page_tree_serializer.rb index f6a36b6d29..d3a95ad378 100644 --- a/app/serializers/alchemy/page_tree_serializer.rb +++ b/app/serializers/alchemy/page_tree_serializer.rb @@ -56,6 +56,7 @@ def page_hash(page, has_children, level, folded) visible: page.visible?, restricted: page.restricted?, page_layout: page.page_layout, + allowing_sub_pages: page.definition['sub_pages'] != false, slug: page.slug, urlname: page.urlname, level: level, diff --git a/app/views/alchemy/admin/pages/_new_page_form.html.erb b/app/views/alchemy/admin/pages/_new_page_form.html.erb index b44f5ed276..aac0b0fc49 100644 --- a/app/views/alchemy/admin/pages/_new_page_form.html.erb +++ b/app/views/alchemy/admin/pages/_new_page_form.html.erb @@ -4,8 +4,9 @@ <%= f.input :page_layout, collection: @page_layouts, label: Alchemy.t(:page_type), - include_blank: Alchemy.t('Please choose'), + include_blank: @page_layouts.length == 1 ? nil : Alchemy.t('Please choose'), required: true, + selected: @page_layouts.length == 1 ? @page_layouts.first : nil, input_html: {class: 'alchemy_selectbox'} %> <%= f.input :name %> <%= f.submit Alchemy.t(:create) %> diff --git a/app/views/alchemy/admin/pages/_page.html.erb b/app/views/alchemy/admin/pages/_page.html.erb index 9ddda23f77..12ee441d63 100644 --- a/app/views/alchemy/admin/pages/_page.html.erb +++ b/app/views/alchemy/admin/pages/_page.html.erb @@ -124,17 +124,21 @@ {{/if}} {{#if permissions.create}} -