From 1c94ffb38e416e33230bfad78433949f14deafb4 Mon Sep 17 00:00:00 2001 From: Anna Buianova Date: Fri, 7 Feb 2020 22:59:05 +0300 Subject: [PATCH] Added template select to the pages admin form (#5952) [deploy] --- app/models/page.rb | 4 +++- app/views/internal/pages/_form.html.erb | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/page.rb b/app/models/page.rb index 26e1ce24b..8d1cdb8c7 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,8 +1,10 @@ class Page < ApplicationRecord + TEMPLATE_OPTIONS = %w[contained full_within_layout full_page].freeze + validates :title, presence: true validates :description, presence: true validates :slug, presence: true, format: /\A[0-9a-z\-_]*\z/ - validates :template, inclusion: { in: %w[contained full_within_layout full_page] } + validates :template, inclusion: { in: TEMPLATE_OPTIONS } validate :body_present validate :unique_slug_including_users_and_orgs, if: :slug_changed? diff --git a/app/views/internal/pages/_form.html.erb b/app/views/internal/pages/_form.html.erb index 785bc1433..bcae9c98a 100644 --- a/app/views/internal/pages/_form.html.erb +++ b/app/views/internal/pages/_form.html.erb @@ -21,6 +21,11 @@ <%= form.label :description %> <%= form.text_field :description, class: "form-control" %> +
+ <%= form.label :template %> + <%= form.select :template, Page::TEMPLATE_OPTIONS, class: "form-control" %> +

(Determines the way page's body will be embedded in the layout)

+
<%= form.label :is_top_level_path %> <%= form.check_box :is_top_level_path %>