From bf7bd34bc0d3fa8d6d322cec3d35d82886746137 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 18 May 2020 22:54:39 +0200 Subject: [PATCH 1/7] Use translated menu name in page form --- app/views/alchemy/admin/pages/_menu_fields.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/alchemy/admin/pages/_menu_fields.html.erb b/app/views/alchemy/admin/pages/_menu_fields.html.erb index dadb0f2641..80a452700e 100644 --- a/app/views/alchemy/admin/pages/_menu_fields.html.erb +++ b/app/views/alchemy/admin/pages/_menu_fields.html.erb @@ -5,12 +5,14 @@ <% @page.menus.each do |menu| %> - <%= menu.name %> + <%= I18n.t(menu.name, scope: [:alchemy, :menu_names]) %> <% 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] }, + <%= 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: { style: @page.visible? ? 'display: block' : 'display: none' }, From b85c0482ac41e2135af7ed8f47b3a9cf930ee6fa Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 18 May 2020 23:20:40 +0200 Subject: [PATCH 2/7] 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. --- app/views/alchemy/admin/pages/_menu_fields.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/alchemy/admin/pages/_menu_fields.html.erb b/app/views/alchemy/admin/pages/_menu_fields.html.erb index 80a452700e..42f2ebf264 100644 --- a/app/views/alchemy/admin/pages/_menu_fields.html.erb +++ b/app/views/alchemy/admin/pages/_menu_fields.html.erb @@ -8,7 +8,7 @@ <%= I18n.t(menu.name, scope: [:alchemy, :menu_names]) %> <% end %> -<% elsif Alchemy::Node.roots.any? %> +<% elsif Alchemy::Node.roots.where(language: @page.language).any? %> <%= page_status_checkbox(@page, :visible) %> <%= f.input :menu_id, collection: Alchemy::Node.roots.map { |n| [I18n.t(n.name, scope: [:alchemy, :menu_names]), n.id] From 7bf5ed185c3dfc70b0cd240359f4ce5537027b14 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 18 May 2020 23:14:28 +0200 Subject: [PATCH 3/7] Format admin pages helper with Rufo --- app/helpers/alchemy/admin/pages_helper.rb | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/helpers/alchemy/admin/pages_helper.rb b/app/helpers/alchemy/admin/pages_helper.rb index f46664bff3..af2037bf3e 100644 --- a/app/helpers/alchemy/admin/pages_helper.rb +++ b/app/helpers/alchemy/admin/pages_helper.rb @@ -9,13 +9,13 @@ module PagesHelper # def preview_sizes_for_select options_for_select([ - 'auto', - [Alchemy.t('240', scope: 'preview_sizes'), 240], - [Alchemy.t('320', scope: 'preview_sizes'), 320], - [Alchemy.t('480', scope: 'preview_sizes'), 480], - [Alchemy.t('768', scope: 'preview_sizes'), 768], - [Alchemy.t('1024', scope: 'preview_sizes'), 1024], - [Alchemy.t('1280', scope: 'preview_sizes'), 1280] + "auto", + [Alchemy.t("240", scope: "preview_sizes"), 240], + [Alchemy.t("320", scope: "preview_sizes"), 320], + [Alchemy.t("480", scope: "preview_sizes"), 480], + [Alchemy.t("768", scope: "preview_sizes"), 768], + [Alchemy.t("1024", scope: "preview_sizes"), 1024], + [Alchemy.t("1280", scope: "preview_sizes"), 1280], ]) end @@ -27,8 +27,8 @@ def page_layout_label(page) if page.persisted? && page.definition.blank? [ page_layout_missing_warning, - Alchemy.t(:page_type) - ].join(' ').html_safe + Alchemy.t(:page_type), + ].join(" ").html_safe else Alchemy.t(:page_type) end @@ -39,10 +39,10 @@ def page_status_checkbox(page, attribute) if page.attribute_fixed?(attribute) checkbox = check_box(:page, attribute, disabled: true) - hint = content_tag(:span, class: 'hint-bubble') do + hint = content_tag(:span, class: "hint-bubble") do Alchemy.t(:attribute_fixed, attribute: attribute) end - content = content_tag(:span, class: 'with-hint') do + content = content_tag(:span, class: "with-hint") do "#{checkbox}\n#{label}\n#{hint}".html_safe end else @@ -50,7 +50,7 @@ def page_status_checkbox(page, attribute) content = "#{checkbox}\n#{label}".html_safe end - content_tag(:label, class: 'checkbox') { content } + content_tag(:label, class: "checkbox") { content } end end end From 2896dfb80b103308bf836069c67c5b4acf6dc2c8 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 18 May 2020 23:15:08 +0200 Subject: [PATCH 4/7] Allow to pass a label to page_status_checkox helper --- app/helpers/alchemy/admin/pages_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/alchemy/admin/pages_helper.rb b/app/helpers/alchemy/admin/pages_helper.rb index af2037bf3e..60f2922537 100644 --- a/app/helpers/alchemy/admin/pages_helper.rb +++ b/app/helpers/alchemy/admin/pages_helper.rb @@ -34,8 +34,8 @@ def page_layout_label(page) end end - def page_status_checkbox(page, attribute) - label = page.class.human_attribute_name(attribute) + def page_status_checkbox(page, attribute, label: nil) + label_text = label || page.class.human_attribute_name(attribute) if page.attribute_fixed?(attribute) checkbox = check_box(:page, attribute, disabled: true) @@ -43,11 +43,11 @@ def page_status_checkbox(page, attribute) Alchemy.t(:attribute_fixed, attribute: attribute) end content = content_tag(:span, class: "with-hint") do - "#{checkbox}\n#{label}\n#{hint}".html_safe + "#{checkbox}\n#{label_text}\n#{hint}".html_safe end else checkbox = check_box(:page, attribute) - content = "#{checkbox}\n#{label}".html_safe + content = "#{checkbox}\n#{label_text}".html_safe end content_tag(:label, class: "checkbox") { content } From e56a4852704cb5cb8c571313319930043fe78981 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 19 May 2020 00:12:21 +0200 Subject: [PATCH 5/7] Add active button style --- app/assets/stylesheets/alchemy/_mixins.scss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/alchemy/_mixins.scss b/app/assets/stylesheets/alchemy/_mixins.scss index f68687d3f4..2251b133b6 100644 --- a/app/assets/stylesheets/alchemy/_mixins.scss +++ b/app/assets/stylesheets/alchemy/_mixins.scss @@ -49,9 +49,8 @@ border-color: $hover-border-color; } - &:active, &:active:focus { - border-color: $hover-border-color; - box-shadow: none; + &:active, &.active { + box-shadow: inset $button-box-shadow; } &:focus { From a82f6c4d4045f6670c83510f5d79ae4dcf476855 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 19 May 2020 00:16:44 +0200 Subject: [PATCH 6/7] Reduce horizontal padding of small button --- app/assets/stylesheets/alchemy/_variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/alchemy/_variables.scss b/app/assets/stylesheets/alchemy/_variables.scss index 343c204b5e..a690a60fab 100644 --- a/app/assets/stylesheets/alchemy/_variables.scss +++ b/app/assets/stylesheets/alchemy/_variables.scss @@ -76,7 +76,7 @@ $button-text-shadow: none !default; $button-box-shadow: 0px 1px 1px -1px #333 !default; $button-focus-box-shadow: 0px 1px 1px 0px $button-focus-border-color !default; $button-padding: 0.55em 2em !default; -$small-button-padding: 0.4em 1.25em !default; +$small-button-padding: 0.4em 0.8em !default; $button-margin: $form-field-margin !default; $secondary-button-bg-color: transparent !default; From e2e295367fb3afb002a4c0fc9be7feca766c44a6 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 18 May 2020 23:19:07 +0200 Subject: [PATCH 7/7] 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. --- .../alchemy/admin/pages/_menu_fields.html.erb | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/app/views/alchemy/admin/pages/_menu_fields.html.erb b/app/views/alchemy/admin/pages/_menu_fields.html.erb index 42f2ebf264..3d091e4271 100644 --- a/app/views/alchemy/admin/pages/_menu_fields.html.erb +++ b/app/views/alchemy/admin/pages/_menu_fields.html.erb @@ -1,35 +1,37 @@ -<% if @page.menus.any? %> - - <% @page.menus.each do |menu| %> - - <%= I18n.t(menu.name, scope: [:alchemy, :menu_names]) %> - +<% 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? %> + + <% @page.menus.each do |menu| %> + + <%= I18n.t(menu.name, scope: [:alchemy, :menu_names]) %> + + <% end %> + <% else %> + <%= Alchemy.t("attach to a menu") %> + <%= 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 %> + <% end %> -<% elsif Alchemy::Node.roots.where(language: @page.language).any? %> - <%= page_status_checkbox(@page, :visible) %> - <%= 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: { style: @page.visible? ? 'display: block' : 'display: none' }, - label: false %> - <% else %> <%= page_status_checkbox(@page, :visible) %> <% end %>