tramway-page 1.5 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/tramway/page/pages_controller.rb +1 -1
- data/app/decorators/tramway/page/page_decorator.rb +15 -1
- data/app/forms/admin/tramway/page/page_form.rb +1 -1
- data/app/models/tramway/page/page.rb +13 -0
- data/lib/tramway/page/generators/install_generator.rb +1 -0
- data/lib/tramway/page/generators/templates/add_view_state_to_tramway_page_pages.rb +7 -0
- data/lib/tramway/page/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2622bd3884f6f45d9fab76c28470d7860e79c82a651e06c18753218af61ebd74
|
4
|
+
data.tar.gz: df632bee7c37b02efdc57f67e077857572f99aa797820e18893d50d3d50093b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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"
|
data/lib/tramway/page/version.rb
CHANGED
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:
|
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-
|
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
|