tramway-page 1.5 → 1.5.1

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: 9948e96dfbfea49716f38a9aac7279dfbbcd65add33ac110a6e79d04c74565c8
4
- data.tar.gz: aa2bcc1dec2f02e431a5ca085c1ecdb5b8d2740c483746a7def1239a125e0f2a
3
+ metadata.gz: 2622bd3884f6f45d9fab76c28470d7860e79c82a651e06c18753218af61ebd74
4
+ data.tar.gz: df632bee7c37b02efdc57f67e077857572f99aa797820e18893d50d3d50093b6
5
5
  SHA512:
6
- metadata.gz: 32c31c105061b762ba9f871d226234b6a1ef3fd56ee29536e7ea161cec3bdbecb0ea8ce3178195ece82764ea3521ddffe9864c9df05e8ba8108fe2f53563cfa8
7
- data.tar.gz: 28106f875e2f094a9895e1f47a208d6fcbab59ed44710e613814318d569da97e7759921ca08938029d45c716cbe51c9061c59a7ab82bbee31153c0a94ad3cde7
6
+ metadata.gz: 04eec31cb41d863ef6c722b9512ab2e02d50137d496b56807dea39b2b9958f7e4ea861e07312ed939fc97704fba5d7c225b33dc379ef44beaa8e0b603a354515
7
+ data.tar.gz: 8e1d86ef690dad016850af00a60500740ea89bd4c2c9d77a39d11f1b64d23136408e6bc1868ce93a626f82af8a7198dff4f675ed0aa0e401fd51424dcb288606
@@ -4,7 +4,7 @@ class ::Tramway::Page::PagesController < ::Tramway::Page::ApplicationController
4
4
  layout 'tramway/landing/application'
5
5
 
6
6
  def show
7
- @page = ::Tramway::Page::Page.find_by slug: params[:slug]
7
+ @page = ::Tramway::Page::Page.published.find_by slug: params[:slug]
8
8
  @blocks = @page.blocks.published.active.map do |block|
9
9
  if block.block_type.header_with_form? && block.form_url.present?
10
10
  # FIXME in future
@@ -9,6 +9,7 @@ class Tramway::Page::PageDecorator < ::Tramway::Core::ApplicationDecorator
9
9
  def show_associations
10
10
  [:blocks]
11
11
  end
12
+ delegate :human_view_state_event_name, to: :model_class
12
13
  end
13
14
 
14
15
  delegate :title, to: :object
@@ -24,6 +25,19 @@ class Tramway::Page::PageDecorator < ::Tramway::Core::ApplicationDecorator
24
25
  end
25
26
 
26
27
  def public_path
27
- Tramway::Page::Engine.routes.url_helpers.page_path slug: object.slug
28
+ if object.published?
29
+ Tramway::Page::Engine.routes.url_helpers.page_path slug: object.slug
30
+ else
31
+ Tramway::Page::Engine.routes.url_helpers.preview_path id: object.id
32
+ end
33
+ end
34
+
35
+ def view_state_button_color(event)
36
+ case event
37
+ when :publish
38
+ :success
39
+ when :hide
40
+ :default
41
+ end
28
42
  end
29
43
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Admin::Tramway::Page::PageForm < ::Tramway::Core::ApplicationForm
4
- properties :title, :body, :slug, :view, :page_type
4
+ properties :title, :body, :slug, :view, :page_type, :view_state_event
5
5
 
6
6
  def initialize(object)
7
7
  super(object).tap do
@@ -6,4 +6,17 @@ class Tramway::Page::Page < ::Tramway::Core::ApplicationRecord
6
6
  enumerize :page_type, in: %i[main other], default: :other
7
7
 
8
8
  scope :landings, -> { where page_type: :landing }
9
+
10
+ state_machine :view_state, initial: :unpublished do
11
+ state :unpublished
12
+ state :published
13
+
14
+ event :publish do
15
+ transition unpublished: :published
16
+ end
17
+
18
+ event :hide do
19
+ transition published: :unpublished
20
+ end
21
+ end
9
22
  end
@@ -20,6 +20,7 @@ module Tramway::Page::Generators
20
20
  create_tramway_page_pages
21
21
  add_view_to_tramway_page_pages
22
22
  add_page_type_to_tramway_page_pages
23
+ add_view_state_to_tramway_page_pages
23
24
  ]
24
25
  migrations.each do |migration|
25
26
  migration_template "#{migration}.rb", "db/migrate/#{migration}.rb"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddViewStateToTramwayPagePages < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :tramway_page_pages, :view_state, :text, default: :unpublished
6
+ end
7
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Page
5
- VERSION = '1.5'
5
+ VERSION = '1.5.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-page
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.5'
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Description of Tramway::Page.
14
14
  email:
@@ -44,6 +44,7 @@ files:
44
44
  - lib/tramway/page/engine.rb
45
45
  - lib/tramway/page/generators/install_generator.rb
46
46
  - lib/tramway/page/generators/templates/add_page_type_to_tramway_page_pages.rb
47
+ - lib/tramway/page/generators/templates/add_view_state_to_tramway_page_pages.rb
47
48
  - lib/tramway/page/generators/templates/add_view_to_tramway_page_pages.rb
48
49
  - lib/tramway/page/generators/templates/create_tramway_page_pages.rb
49
50
  - lib/tramway/page/version.rb