tramway-landing 3.0.3 → 3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/decorators/tramway/landing/block_decorator.rb +9 -5
- data/app/decorators/tramway/landing/form_decorator.rb +5 -0
- data/app/decorators/tramway/landing/navbar/link_decorator.rb +9 -0
- data/app/forms/admin/tramway/landing/block_form.rb +2 -3
- data/app/forms/admin/tramway/landing/form_form.rb +15 -0
- data/app/helpers/tramway/landing/application_helper.rb +6 -0
- data/app/models/tramway/landing/block.rb +1 -1
- data/app/models/tramway/landing/form.rb +5 -0
- data/app/views/layouts/tramway/landing/_navbar.html.haml +9 -11
- data/app/views/layouts/tramway/landing/navbar/_link.html.haml +9 -0
- data/app/views/tramway/landing/blocks/block_types/_header_with_form.html.haml +47 -18
- data/config/locales/ru.models.yml +6 -0
- data/lib/tramway/landing/generates/install_generator.rb +2 -0
- data/lib/tramway/landing/generates/templates/create_tramway_landing_blocks_forms.rb +13 -0
- data/lib/tramway/landing/generates/templates/create_tramway_landing_forms.rb +13 -0
- data/lib/tramway/landing/version.rb +1 -1
- metadata +9 -3
- data/app/decorators/tramway/landing/link_decorator.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1d9f3f7fd008ccc5b7bf6e10d92157d06a2d43bcfa06d4626eb50376eab1ff
|
4
|
+
data.tar.gz: bce155b9e752abf9ceb692d7cdd8aaf7f03ab62fa99b6ae061f07b7e7e2a076c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab36c3b758559543c77678054d6284eabc6b9e6050e864203b12ab2851fe62e3a1d6651091f1210b096859123529b6cb79ccf12a7b790a8efb8a7ac211a314c5
|
7
|
+
data.tar.gz: 1e4c6c583436c421e8548f0e757a194bafe36f225203e8dc8394c4a312c64fc92e6cc6eeb148d370c8481485431ac658ccd1e81a9849805f08d631a7e7796edf
|
@@ -9,15 +9,23 @@ class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
|
|
9
9
|
def list_attributes
|
10
10
|
%i[page_title position view_state block_type]
|
11
11
|
end
|
12
|
+
|
13
|
+
def show_associations
|
14
|
+
[ :forms ]
|
15
|
+
end
|
12
16
|
|
13
17
|
delegate :human_view_state_event_name, to: :model_class
|
14
18
|
end
|
15
19
|
|
20
|
+
decorate_association :forms
|
21
|
+
|
16
22
|
delegate_attributes :position, :title, :background, :anchor, :description, :view_name
|
17
23
|
|
18
24
|
def public_path
|
19
25
|
if object.published?
|
20
|
-
|
26
|
+
if object.page.slug.present?
|
27
|
+
Tramway::Page::Engine.routes.url_helpers.page_path slug: object.page.slug
|
28
|
+
end
|
21
29
|
else
|
22
30
|
Tramway::Page::Engine.routes.url_helpers.preview_path id: object.page.id
|
23
31
|
end
|
@@ -39,10 +47,6 @@ class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
|
|
39
47
|
"##{object.anchor}"
|
40
48
|
end
|
41
49
|
|
42
|
-
def form_url
|
43
|
-
object.values['form_url']
|
44
|
-
end
|
45
|
-
|
46
50
|
def view_state_button_color(event)
|
47
51
|
case event
|
48
52
|
when :publish
|
@@ -4,7 +4,7 @@ class Admin::Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationF
|
|
4
4
|
association :page
|
5
5
|
|
6
6
|
properties :title, :background, :view_state_event, :block_type, :position, :navbar_link, :anchor, :description,
|
7
|
-
:link_object_type, :link_object_id, :button_title, :button_link, :view_name
|
7
|
+
:link_object_type, :link_object_id, :button_title, :button_link, :view_name
|
8
8
|
|
9
9
|
def initialize(object = nil)
|
10
10
|
super(object).tap do
|
@@ -23,8 +23,7 @@ class Admin::Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationF
|
|
23
23
|
description: :ckeditor,
|
24
24
|
button_title: :string,
|
25
25
|
button_link: :string,
|
26
|
-
view_name: :string
|
27
|
-
form_url: :string
|
26
|
+
view_name: :string
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Admin::Tramway::Landing::FormForm < Tramway::Core::ApplicationForm
|
2
|
+
association :block
|
3
|
+
|
4
|
+
properties :title, :url, :form_name, :position
|
5
|
+
|
6
|
+
def initialize(object)
|
7
|
+
super(object).tap do
|
8
|
+
form_properties block: :association,
|
9
|
+
title: :string,
|
10
|
+
url: :string,
|
11
|
+
form_name: :default,
|
12
|
+
position: :integer
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -5,6 +5,12 @@ module Tramway
|
|
5
5
|
module ApplicationHelper
|
6
6
|
include Tramway::Admin::RussianCasesHelper
|
7
7
|
include Tramway::Profiles::LinksHelper if defined?(::Tramway::Profiles)
|
8
|
+
|
9
|
+
def actual_forms(forms)
|
10
|
+
forms = forms.select { |f| f.form_name != 'user_sign_up' } if @signed_in
|
11
|
+
forms = forms.select { |f| f.form_name != 'user_sign_in' } if @signed_in
|
12
|
+
forms
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
|
4
4
|
belongs_to :page, class_name: 'Tramway::Page::Page'
|
5
|
+
has_many :forms, -> { order(position: :asc) }, class_name: 'Tramway::Landing::Form'
|
5
6
|
|
6
7
|
enumerize :block_type, in: %i[header header_with_form footer page cards features contacts link page_with_button just_text view]
|
7
8
|
enumerize :navbar_link, in: %i[exist not_exist], default: :not_exist
|
@@ -22,7 +23,6 @@ class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
store_accessor :values, :form_url
|
26
26
|
store_accessor :button, :button_link
|
27
27
|
store_accessor :button, :button_title
|
28
28
|
|
@@ -4,15 +4,13 @@
|
|
4
4
|
- if @links&.any?
|
5
5
|
= fa_icon :bars
|
6
6
|
.collapse.navbar-collapse#navbarSupportedContent
|
7
|
-
-
|
7
|
+
- left_links = @links.is_a?(Hash) ? @links[:left] : @links
|
8
|
+
- if left_links&.any?
|
8
9
|
%ul.navbar-nav.mr-auto
|
9
|
-
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
= link_to menu_item.title, menu_item.link, class: 'dropdown-item'
|
17
|
-
- else
|
18
|
-
= menu_item link.title, link.link
|
10
|
+
- left_links.each do |link|
|
11
|
+
= render 'layouts/tramway/landing/navbar/link', link: link
|
12
|
+
- right_links = @links.is_a?(Hash) ? @links.dig(:right) : []
|
13
|
+
- if right_links&.any?
|
14
|
+
%ul.navbar-nav.ml-auto
|
15
|
+
- right_links.each do |link|
|
16
|
+
= render 'layouts/tramway/landing/navbar/link', link: link
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- if link.is_a? Hash
|
2
|
+
.nav-item.dropdown
|
3
|
+
%a.nav-link.dropdown-toggle{ id: "dropdown_menu_button_#{link.keys.first}", aria: { expanded: :false, haspopup: :true }, data: { toggle: :dropdown } }
|
4
|
+
= link.keys.first
|
5
|
+
.dropdown-menu.dropdown-primary{ aria: { labelledby: "dropdown_menu_button_#{link.keys.first}" } }
|
6
|
+
- link.values.first.each do |menu_item|
|
7
|
+
= link_to menu_item.title, menu_item.link, class: 'dropdown-item'
|
8
|
+
- else
|
9
|
+
= menu_item link.title, link.link
|
@@ -14,23 +14,52 @@
|
|
14
14
|
%p.mb-4.d-none.d-md-block
|
15
15
|
%strong
|
16
16
|
= @page&.body || @application.short_description
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
=
|
17
|
+
- forms = actual_forms(block.forms)
|
18
|
+
- if forms.any?
|
19
|
+
.col-md-6.col-xl-5.mb-4
|
20
|
+
- if params[:flash] == 'success_user_sign_up'
|
21
|
+
= render 'tramway/landing/templates/alert', alert_type: :success do
|
22
|
+
Sign up successful!
|
23
|
+
- if params[:flash] == 'success_user_sign_in'
|
24
|
+
= render 'tramway/landing/templates/alert', alert_type: :success do
|
25
|
+
Sign In successful!
|
26
|
+
- if params[:flash] == 'error_user_sign_up'
|
27
|
+
= render 'tramway/landing/templates/alert', alert_type: :danger do
|
28
|
+
There is some errors
|
29
|
+
- if params[:flash] == 'error_user_sign_in'
|
30
|
+
= render 'tramway/landing/templates/alert', alert_type: :danger do
|
31
|
+
There is some errors
|
32
|
+
.card
|
33
|
+
.card-body
|
34
|
+
- raise 'Initialize @header_with_form in a controller with something like that `@header_with_form = UserSignUpForm.new User.new`. `User` is your model which you want to Sign Up' unless defined?(@header_with_form)
|
28
35
|
%h3.dark-grey-text.text-center
|
29
|
-
|
30
|
-
|
36
|
+
- forms.each_with_index do |form, index|
|
37
|
+
- unless index == 0
|
38
|
+
|
|
39
|
+
= link_to '#', class: :form_activation_link, id: form.id do
|
40
|
+
%strong
|
41
|
+
= form.title
|
31
42
|
%hr
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
43
|
+
- forms.each do |form|
|
44
|
+
- current_form = @header_with_form[form.form_name]
|
45
|
+
= simple_form_for current_form, url: form.url, method: :post, input_html: { class: "form-vertical form_#{form.id} header_with_form" }, html: { class: "form_#{form.id} header_with_form" } do |f|
|
46
|
+
= hidden_field_tag :model, @header_with_form[form.form_name].model.class.to_s
|
47
|
+
= hidden_field_tag :success_redirect, request.path
|
48
|
+
= hidden_field_tag :error_redirect, request.path
|
49
|
+
- current_form.properties.each do |property|
|
50
|
+
= render 'tramway/core/shared/input', property: property[0], object: :user, type: property[1], form: f, destination: :landing, record: current_form, value: (params[:record].present? ? params[:record][property[0]] : '')
|
51
|
+
= f.button :submit, current_form.submit_message
|
52
|
+
:javascript
|
53
|
+
$(document).ready(function() {
|
54
|
+
$("form.header_with_form").each(function(index) {
|
55
|
+
if (index != 0) {
|
56
|
+
$(this).hide();
|
57
|
+
}
|
58
|
+
});
|
59
|
+
$('a.form_activation_link').click(function() {
|
60
|
+
$("form.header_with_form").each(function() {
|
61
|
+
$(this).hide();
|
62
|
+
});
|
63
|
+
$(`form.form_${$(this).first()[0].id}`).show();
|
64
|
+
});
|
65
|
+
});
|
@@ -19,10 +19,16 @@ ru:
|
|
19
19
|
button_link: Ссылка кнопки (только для Типа блока "Свободный блок с кнопкой")
|
20
20
|
view_name: Название вьюхи
|
21
21
|
button: Наименование кнопки
|
22
|
+
tramway/landing/form:
|
23
|
+
title: Название формы
|
24
|
+
form_name: Класс формы
|
22
25
|
cases:
|
23
26
|
tramway/landing/block:
|
24
27
|
plural: Блоки
|
25
28
|
genitive: блок
|
29
|
+
tramway/landing/form:
|
30
|
+
plural: Публичные формы
|
31
|
+
genitive: публичную форму
|
26
32
|
enumerize:
|
27
33
|
tramway/landing/block:
|
28
34
|
block_type:
|
@@ -25,6 +25,8 @@ module Tramway::Landing::Generators
|
|
25
25
|
add_view_name_to_tramway_landing_blocks
|
26
26
|
add_values_to_tramway_landing_blocks
|
27
27
|
add_page_id_to_tramway_landing_blocks
|
28
|
+
create_tramway_landing_forms
|
29
|
+
create_tramway_landing_blocks_forms
|
28
30
|
]
|
29
31
|
|
30
32
|
migrations.each do |migration|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateTramwayLandingBlocksForms < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :tramway_landing_blocks_forms do |t|
|
6
|
+
t.integer :block_id
|
7
|
+
t.integer :form_id
|
8
|
+
t.text :state
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateTramwayLandingForms < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :tramway_landing_forms do |t|
|
6
|
+
t.text :title
|
7
|
+
t.text :form_name
|
8
|
+
t.text :state, default: :active
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
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: 3.
|
4
|
+
version: '3.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moshinaan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Landing Engine for your Rails projects
|
14
14
|
email:
|
@@ -35,19 +35,23 @@ files:
|
|
35
35
|
- app/decorators/tramway/landing/block_types/cards_decorator.rb
|
36
36
|
- app/decorators/tramway/landing/block_types/features_decorator.rb
|
37
37
|
- app/decorators/tramway/landing/block_types/page_with_button_decorator.rb
|
38
|
-
- app/decorators/tramway/landing/
|
38
|
+
- app/decorators/tramway/landing/form_decorator.rb
|
39
|
+
- app/decorators/tramway/landing/navbar/link_decorator.rb
|
39
40
|
- app/decorators/tramway/landing/navbar_decorator.rb
|
40
41
|
- app/forms/admin/tramway/landing/block_form.rb
|
42
|
+
- app/forms/admin/tramway/landing/form_form.rb
|
41
43
|
- app/helpers/tramway/landing/application_helper.rb
|
42
44
|
- app/jobs/tramway/landing/application_job.rb
|
43
45
|
- app/mailers/tramway/landing/application_mailer.rb
|
44
46
|
- app/models/tramway/landing/application_record.rb
|
45
47
|
- app/models/tramway/landing/block.rb
|
48
|
+
- app/models/tramway/landing/form.rb
|
46
49
|
- app/uploaders/tramway/landing/photo_versions.rb
|
47
50
|
- app/views/layouts/tramway/landing/_meta.html.haml
|
48
51
|
- app/views/layouts/tramway/landing/_navbar.html.haml
|
49
52
|
- app/views/layouts/tramway/landing/_yandex_metrika.html.haml
|
50
53
|
- app/views/layouts/tramway/landing/application.html.haml
|
54
|
+
- app/views/layouts/tramway/landing/navbar/_link.html.haml
|
51
55
|
- app/views/tramway/landing/blocks/block_types/_cards.html.haml
|
52
56
|
- app/views/tramway/landing/blocks/block_types/_contacts.html.haml
|
53
57
|
- app/views/tramway/landing/blocks/block_types/_features.html.haml
|
@@ -88,6 +92,8 @@ files:
|
|
88
92
|
- lib/tramway/landing/generates/templates/add_values_to_tramway_landing_blocks.rb
|
89
93
|
- lib/tramway/landing/generates/templates/add_view_name_to_tramway_landing_blocks.rb
|
90
94
|
- lib/tramway/landing/generates/templates/create_tramway_landing_blocks.rb
|
95
|
+
- lib/tramway/landing/generates/templates/create_tramway_landing_blocks_forms.rb
|
96
|
+
- lib/tramway/landing/generates/templates/create_tramway_landing_forms.rb
|
91
97
|
- lib/tramway/landing/version.rb
|
92
98
|
homepage: https://github.com/kalashnikovisme/tramway-landing
|
93
99
|
licenses:
|