trusty-cms 7.0.9 → 7.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90afffae83c31538f9db86d664a6cf86d4a29b1e910a7bd9644d795949908a8a
4
- data.tar.gz: 2ed58dea81ef5468bf67ccbac8af93e0fee4918a4937cce840ef39846306e886
3
+ metadata.gz: 449fe5133cb47597ee1a6088a2104532570912d8741e5d6b59b486b4ed74a470
4
+ data.tar.gz: 41500d82c661b36dd039d5157029f25a1695b85b5aff10f57a92e8931bdb0be5
5
5
  SHA512:
6
- metadata.gz: 9c7197a1dde572a4b5280165ea6fcfa13be02c3830ff4bd3e5b0038d1ea4ddede69739b76f9373d575517b85fc3925022e357e0aa7efc3678de50aa5ed17faf3
7
- data.tar.gz: 99658f3bbb7c65c3fdb2e02ddbc2eab6f6cf02b757a332211b81a154eb45e0080c3b61d93d07497d38e4d0f2daa5b74425434cf18875b4ab69358a20d70ffa92
6
+ metadata.gz: cd847aa08fbda487d3ef6e216858ac4f643e15291ed52e03c4f4a2a545a48459e2ef55a289b3773b7b416cfac6fd97940a80857514888952e095ccf3d8100849
7
+ data.tar.gz: e383a81c109eff12e51d99d09b9afb1a28af22fd5d6bc78741921ccba4257e4d70643b6361c2b7c7ead11e717bd1529b8cef04d0ff5c80f21650a49089c07758
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (7.0.9)
4
+ trusty-cms (7.0.11)
5
5
  RedCloth (= 4.3.3)
6
6
  activestorage-validator
7
7
  acts_as_list (>= 0.9.5, < 1.3.0)
@@ -3,6 +3,7 @@ class Admin::PagesController < Admin::ResourceController
3
3
  before_action :count_deleted_pages, only: [:destroy]
4
4
  before_action :set_page, only: %i[edit restore]
5
5
  rescue_from ActiveRecord::RecordInvalid, with: :validation_error
6
+ include Admin::PagesHelper
6
7
 
7
8
  class PreviewStop < ActiveRecord::Rollback
8
9
  def message
@@ -113,13 +114,13 @@ class Admin::PagesController < Admin::ResourceController
113
114
  versions
114
115
  .sort_by(&:created_at).reverse
115
116
  .map do |version|
116
- {
117
- index: version&.index,
118
- update_date: version&.created_at&.strftime('%B %d, %Y'),
119
- update_time: version&.created_at&.strftime('%I:%M %p'),
120
- updated_by: User.unscoped.find_by(id: version&.whodunnit)&.name || 'Unknown User',
121
- }
122
- end
117
+ {
118
+ index: version&.index,
119
+ update_date: version&.created_at&.strftime('%B %d, %Y'),
120
+ update_time: version&.created_at&.strftime('%I:%M %p'),
121
+ updated_by: User.unscoped.find_by(id: version&.whodunnit)&.name || 'Unknown User',
122
+ }
123
+ end
123
124
  end
124
125
 
125
126
  def restore_page_version(page, index)
@@ -32,7 +32,8 @@ class PageStatusController < ApplicationController
32
32
 
33
33
  pages.each do |page|
34
34
  page_id = page.id
35
- if page.published_at <= Time.now
35
+ published_at = page.published_at
36
+ if published_at && published_at <= Time.now
36
37
  page.update(status_id: Status[:published].id)
37
38
  updated_pages << page_id
38
39
  else
@@ -17,4 +17,10 @@ module Admin::PagesHelper
17
17
  def clean_page_description(page)
18
18
  page.description.to_s.strip.gsub(/\t/, '').gsub(/\s+/, ' ')
19
19
  end
20
+
21
+ def parent_page_options(current_site, page)
22
+ parent_pages = Page.parent_pages(current_site.homepage_id)
23
+ selected_page_id = page.id.presence_in(parent_pages.pluck(:id)) || page.parent_id.presence_in(parent_pages.pluck(:id))
24
+ options_for_select(parent_pages.map { |p| [p.title, p.id] }, selected_page_id)
25
+ end
20
26
  end
data/app/models/page.rb CHANGED
@@ -159,6 +159,10 @@ class Page < ActiveRecord::Base
159
159
  ['site_id', 'title']
160
160
  end
161
161
 
162
+ def self.parent_pages(homepage_id)
163
+ where(parent_id: homepage_id).or(where(id: homepage_id))
164
+ end
165
+
162
166
  private :set_response_headers
163
167
 
164
168
  def set_content_type(response)
@@ -1,7 +1,6 @@
1
1
  = fields.hidden_field :lock_version
2
2
  = fields.hidden_field :parent_id
3
3
  = fields.hidden_field :class_name
4
-
5
4
  = render_region :form_top, :locals => {:f => fields}
6
5
 
7
6
  - render_region :form, :locals => {:f => fields} do |form|
@@ -43,6 +42,10 @@
43
42
  .page-type
44
43
  = fields.label :class_name, t('page_type')
45
44
  = fields.select :class_name, [[t('select.normal'), '']] + Page.descendants.map { |p| [p.display_name, p.name] }.sort_by { |p| p.first }
45
+ - layout.edit_parent do
46
+ .parent-page
47
+ = fields.label :parent_id, t('parent_page')
48
+ = fields.select :parent_id, parent_page_options(current_site, @page)
46
49
  - layout.edit_status do
47
50
  - if current_user.admin? || current_user.editor?
48
51
  .status
@@ -56,6 +59,7 @@
56
59
  class: 'datetime',
57
60
  type: 'datetime-local',
58
61
  value: (@page.published_at? ? @page.published_at.strftime('%Y-%m-%dT%H:%M') : nil)
62
+
59
63
  = render_region :layout_row, :locals => {:f => fields}
60
64
 
61
65
  .error.hidden
@@ -231,6 +231,7 @@ en:
231
231
  removed_many: "The pages were successfully removed from the site."
232
232
  removed_one: "The page was successfully removed from the site."
233
233
  saved: "Your page has been saved below."
234
+ parent_page: 'Parent Page'
234
235
  password: 'Password'
235
236
  password_confirmation: 'Confirm New Password'
236
237
  personal: 'Personal'
@@ -170,7 +170,7 @@ module TrustyCms
170
170
  page.edit = RegionSet.new do |edit|
171
171
  edit.main.concat %w{edit_header edit_form edit_popups}
172
172
  edit.form.concat %w{edit_title edit_extended_metadata edit_page_parts}
173
- edit.layout.concat %w{edit_layout edit_type edit_status edit_published_at}
173
+ edit.layout.concat %w{edit_layout edit_type edit_parent edit_status edit_published_at}
174
174
  edit.form_bottom.concat %w{edit_buttons edit_timestamp}
175
175
  end
176
176
  page.index = RegionSet.new do |index|
@@ -1,4 +1,4 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.9'.freeze
2
+ VERSION = '7.0.11'.freeze
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.9
4
+ version: 7.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-16 00:00:00.000000000 Z
11
+ date: 2025-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator