Added template select to the pages admin form (#5952) [deploy]

This commit is contained in:
Anna Buianova 2020-02-07 22:59:05 +03:00 committed by GitHub
parent faad0b83e6
commit 1c94ffb38e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -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?

View file

@ -21,6 +21,11 @@
<%= form.label :description %>
<%= form.text_field :description, class: "form-control" %>
</div>
<div class="form-group">
<%= form.label :template %>
<%= form.select :template, Page::TEMPLATE_OPTIONS, class: "form-control" %>
<p>(Determines the way page's body will be embedded in the layout)</p>
</div>
<div class="form-group">
<%= form.label :is_top_level_path %>
<%= form.check_box :is_top_level_path %>