tramway-landing 2.2.3.1 → 3.0

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: 37d17d94df671894a4eb82fc19e1f43d5d64125a47fbffefe57d6febc5cb9055
4
- data.tar.gz: 4b57c9813612b38be1386e3e0f58495a9048b370fe064134aadcf4df127fbb34
3
+ metadata.gz: 5c53d44bd00c343f41a392098028bedd928f33a0a9305e50c50d426fa76ba9c3
4
+ data.tar.gz: 23ab8448186dc62de60f8a2a26762097f8741225bdcdb21cc95d2852288c6705
5
5
  SHA512:
6
- metadata.gz: a5f14560969a6220ae9e5ea2ea7b02a7655be8aaca7e780a23c3a544242ecf1381e3d7c1dd70ae4cee9be7d13290f11d3328c8ef509d544a3423b469aa07dec1
7
- data.tar.gz: 6ae76e329b9a439035486d3f728e4058707df7d10f1bb70f45dfd537940fd2753913ee8d96558d971c530fff9d1b8a73138a4414b512b88876661f3566e70022
6
+ metadata.gz: cc1a6376e6e9d4bc23d4fbed7810712088be120c9ea452cd56b804b3035110d40d1faefc68c9c1f66b61d3a5eaf71124987ad0afdaf2631be6be9837ea102e7e
7
+ data.tar.gz: 3ddfcf47ad89f8ee03f9625ecc72ffaaf9fc35a28c80ee7cc2159d2a5b8cb5648bef981c6eac26da773e60af99f917e1c183fbced3a22c0320c615dd9bcc7d57
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Admin::Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationForm
4
+ association :page
5
+
4
6
  properties :title, :background, :view_state_event, :block_type, :position, :navbar_link, :anchor, :description,
5
- :link_object_type, :link_object_id, :button_title, :button_link, :view_name, :form_url, :page
7
+ :link_object_type, :link_object_id, :button_title, :button_link, :view_name, :form_url
6
8
 
7
9
  def initialize(object = nil)
8
10
  super(object).tap do
9
- form_properties title: :string,
11
+ form_properties page: :association,
12
+ title: :string,
10
13
  background: :file,
11
14
  position: {
12
15
  type: :numeric,
@@ -21,58 +24,7 @@ class Admin::Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationF
21
24
  button_title: :string,
22
25
  button_link: :string,
23
26
  view_name: :string,
24
- form_url: :string,
25
- page: {
26
- type: :select,
27
- input_options: {
28
- hint: I18n.t('hints.tramway.landing.block.page'),
29
- collection: Tramway::Page::Page.landings.active.reduce({}) do |hash, page|
30
- hash.merge! page.title => page.id
31
- end
32
- }
33
- }
27
+ form_url: :string
34
28
  end
35
29
  end
36
-
37
- def button_title
38
- model.button ||= {}
39
- model.button['title'] || ''
40
- end
41
-
42
- def button_link
43
- model.button ||= {}
44
- model.button['link'] || ''
45
- end
46
-
47
- def button_title=(value)
48
- model.button ||= {}
49
- model.button[:title] = value
50
- model.save
51
- end
52
-
53
- def button_link=(value)
54
- model.button ||= {}
55
- model.button[:link] = value
56
- model.save
57
- end
58
-
59
- def form_url=(value)
60
- model.values ||= {}
61
- model.values.merge! form_url: value
62
- model.save
63
- end
64
-
65
- def form_url
66
- model.values&.dig 'form_url'
67
- end
68
-
69
- def page=(value)
70
- model.values ||= {}
71
- model.values.merge! page: value
72
- model.save
73
- end
74
-
75
- def page
76
- model.values&.dig 'page'
77
- end
78
30
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
4
+ belongs_to :page, class_name: 'Tramway::Page::Page'
5
+
4
6
  enumerize :block_type, in: %i[header header_with_form footer page cards features contacts link page_with_button just_text view]
5
7
  enumerize :navbar_link, in: %i[exist not_exist], default: :not_exist
6
8
  enumerize :link_object_type, in: ['Tramway::SportSchool::Document', 'Tramway::Page::Page']
@@ -20,11 +22,12 @@ class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
20
22
  end
21
23
  end
22
24
 
23
- store_accessor :values, :page
24
25
  store_accessor :values, :form_url
26
+ store_accessor :button, :button_link
27
+ store_accessor :button, :button_title
25
28
 
26
29
  scope :on_main_page, -> do
27
- active.where(view_state: :published).where("(values -> 'page') IS NULL").order :position
30
+ active.joins(:page).where(view_state: :published).where('tramway_page_pages.page_type = ?', :main).order :position
28
31
  end
29
32
  scope :with_navbar_link, -> { where navbar_link: :exist }
30
33
  scope :header, -> { on_main_page.where(block_type: :header).first }
@@ -41,4 +44,11 @@ class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
41
44
  def footer?
42
45
  block_type.footer?
43
46
  end
47
+
48
+ def form_to_render
49
+ case self.form_url
50
+ when '/auth/sign_up'
51
+ "#{Tramway::Auth.authenticable_models.first}SignUpForm".constantize
52
+ end
53
+ end
44
54
  end
@@ -4,14 +4,15 @@
4
4
  .row.wow.fadeIn
5
5
  .col-md-6.mb-4.white-text.text-center.text-md-left
6
6
  %h1.display-4.font-weight-bold
7
- = @application.public_name
7
+ = @page&.title || @application.public_name
8
8
  %hr.hr-light
9
9
  %p
10
- %strong
11
- = @application.tagline
10
+ - unless @page.present?
11
+ %strong
12
+ = @application.tagline
12
13
  %p.mb-4.d-none.d-md-block
13
14
  %strong
14
- = @application.short_description
15
+ = @page&.body || @application.short_description
15
16
  .col-md-6.col-xl-5.mb-4
16
17
  - if params[:flash] == 'success'
17
18
  = render 'tramway/landing/templates/alert', alert_type: :success do
@@ -4,4 +4,3 @@ en:
4
4
  landing:
5
5
  block:
6
6
  position: "Busy positions. Block type 'Header' should be always the first. Block type 'Footer' should be always the last"
7
- page: "Leave it empty, if you want this block on a main page"
@@ -24,6 +24,7 @@ module Tramway::Landing::Generators
24
24
  add_button_to_tramway_landing_blocks
25
25
  add_view_name_to_tramway_landing_blocks
26
26
  add_values_to_tramway_landing_blocks
27
+ add_page_id_to_tramway_landing_blocks
27
28
  ]
28
29
 
29
30
  migrations.each do |migration|
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddPageIdToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :tramway_landing_blocks, :page_id, :integer
6
+ end
7
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Landing
5
- VERSION = '2.2.3.1'
5
+ VERSION = '3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-landing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3.1
4
+ version: '3.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - moshinaan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Landing Engine for your Rails projects
14
14
  email:
@@ -84,6 +84,7 @@ files:
84
84
  - lib/tramway/landing/generates/templates/add_link_object_id_to_tramway_landing_blocks.rb
85
85
  - lib/tramway/landing/generates/templates/add_link_object_type_to_tramway_landing_blocks.rb
86
86
  - lib/tramway/landing/generates/templates/add_navbar_link_to_tramway_landing_blocks.rb
87
+ - lib/tramway/landing/generates/templates/add_page_id_to_tramway_landing_blocks.rb
87
88
  - lib/tramway/landing/generates/templates/add_values_to_tramway_landing_blocks.rb
88
89
  - lib/tramway/landing/generates/templates/add_view_name_to_tramway_landing_blocks.rb
89
90
  - lib/tramway/landing/generates/templates/create_tramway_landing_blocks.rb