tramway-event 0.5 → 0.6

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: 30a66f92c1d8f181b1620aa1a024178e479066e2dd015ab9994809ebeaca04f8
4
- data.tar.gz: e1b97b81a35c3f3ce092f6e5a7ee2280637463947506d789a683e03e78916c6b
3
+ metadata.gz: 0b2fdb2461f25bcc59c92c8775b5b3968ca209196b6995136f86403c058d1e00
4
+ data.tar.gz: 78dabdb189958cc8e29f4b98462558a7aea93a0d4abc8cd3977d8ad1b4eb9ab0
5
5
  SHA512:
6
- metadata.gz: 92b4b9d04b5bebd1f748caca9e94a7760bd41774cd79163d80ed1fe94f9f7084dfa223354b0375b66cb814b500d7ccdb961071daa186bdf41f704acb14f28d61
7
- data.tar.gz: b11ca2ea6fdb17a8f5f7bd8e3c7b52bf04ee2a9cad08f6091fc62c26b5a05f399affc6a3912dd535bd3feeb01d35f3b135bf8ee0c53bec58a276e954cce3d6b3
6
+ metadata.gz: 59cb50910c2b61ccbd5f8cd7a1ba49097b690ec00a89f0c9812269f62fc6425aaa70569ee37c6db397fd4edc36ccb02de254e388218f35bcb47bed8ca6ec415a
7
+ data.tar.gz: b099a0ea2122f482e734e51b42426d7d3204029798d69246fb843b50328c82d8e3522a3d772a50ce4be03e2c359b5d1ae6fbf6c09041cb7f3c092c7766f7dc14
@@ -3,7 +3,8 @@ class Tramway::Event::EventsController < Tramway::Event::ApplicationController
3
3
 
4
4
  def show
5
5
  @event = ::Tramway::Event::EventDecorator.decorate ::Tramway::Event::Event.find params[:id]
6
- form_class = ::Tramway::Core::ExtendableForm.new "ParticipantExtendedForm#{request.uuid.gsub('-', '')}", *@event.participant_form_fields.map(&:title).map(&:to_sym)
6
+ class_name = "ParticipantExtendedFormEventId#{@event.id}"
7
+ form_class = ::Tramway::Core::ExtendableForm.new(class_name, *@event.participant_form_fields.inputs_list.map(&:title).map(&:to_sym))
7
8
  @participant_form = form_class.new ::Tramway::Event::Participant.new
8
9
  end
9
10
  end
@@ -0,0 +1,13 @@
1
+ class Tramway::Event::ParticipantsController < Tramway::Event::ApplicationController
2
+ def create
3
+ event = ::Tramway::Event::Event.find params[:tramway_event_participant][:event_id]
4
+ class_name = "ParticipantExtendedFormEventId#{event.id}"
5
+ form_class = ::Tramway::Core::ExtendableForm.new(class_name, *(event.participant_form_fields.inputs_list.map(&:title)).map(&:to_sym))
6
+ @participant_form = form_class.new ::Tramway::Event::Participant.new event_id: event.id
7
+ if @participant_form.submit params[:tramway_event_participant].except :event_id
8
+ redirect_to event_path event, flash: :success
9
+ else
10
+ redirect_to event_path event, flash: :error
11
+ end
12
+ end
13
+ end
@@ -1,12 +1,14 @@
1
1
  class Tramway::Event::ParticipantFormFieldForm < ::Tramway::Core::ApplicationForm
2
- properties :title, :description, :field_type, :event
2
+ properties :title, :description, :field_type, :event, :options, :position
3
3
 
4
4
  def initialize(object)
5
5
  form_object = super object
6
6
  form_properties event: :association,
7
7
  title: :string,
8
8
  description: :string,
9
- field_type: :default
9
+ field_type: :default,
10
+ options: :text,
11
+ position: :numeric
10
12
  form_object
11
13
  end
12
14
 
@@ -1,6 +1,16 @@
1
+ require "tramway/collection"
2
+
1
3
  module Tramway
2
4
  module Event
3
5
  module ApplicationHelper
6
+ def collection_list_by(name:)
7
+ require name # needed to load class name with collection
8
+ unless ::Tramway::Collection.descendants.map(&:to_s).include?(name.camelize)
9
+ raise "There no such collection named #{name.camelize}. Please create class with self method `list` and extended of `Tramway::Collection`"
10
+ end
11
+
12
+ name.camelize.constantize.list
13
+ end
4
14
  end
5
15
  end
6
16
  end
@@ -1,5 +1,7 @@
1
1
  class Tramway::Event::ParticipantFormField < ::Tramway::Event::ApplicationRecord
2
2
  belongs_to :event, class_name: 'Tramway::Event::Event'
3
3
 
4
- enumerize :field_type, in: [ :text, :numeric ], default: :text
4
+ enumerize :field_type, in: [ :text, :string, :numeric, :date_picker, :select ], default: :text
5
+
6
+ scope :inputs_list, -> { active.order(position: :asc) }
5
7
  end
@@ -2,6 +2,32 @@
2
2
  = @event.title
3
3
  - content_for :body_content do
4
4
  = stylesheet_link_tag 'tramway/event/events/show'
5
+
6
+
7
+ - if params[:flash] == 'success'
8
+ .alert.alert-success{role: "alert"}
9
+ %button.close{"aria-label" => "Close", "data-dismiss" => "alert", type: "button"}
10
+ %span{"aria-hidden" => "true"} ×
11
+ %h4.alert-heading Заявка успешно отправлена!
12
+ %p Орг.комитет мероприятия свяжется с вами по одному из указанных вами каналов связи: телефон, email, страница ВКонтакте
13
+ %hr/
14
+ %p.mb-0
15
+ По всем вопросам обращайтесь по телефону
16
+ = tel_tag '+79603727276'
17
+ или пишите на email
18
+ = mail_to 'kalashnikov@ulmic.ru'
19
+ - if params[:flash] == 'error'
20
+ .alert.alert-danger{role: "alert"}
21
+ %button.close{"aria-label" => "Close", "data-dismiss" => "alert", type: "button"}
22
+ %span{"aria-hidden" => "true"} ×
23
+ %h4.alert-heading Ошибка при отправлении заявки!
24
+ %p Подробности ошибки описаны ниже в форме приёма заявок
25
+ %hr/
26
+ %p.mb-0
27
+ Если ошибка повторяется или не отображается, обращайтесь по телефону
28
+ = tel_tag '+79603727276'
29
+ или пишите на email
30
+ = mail_to 'kalashnikov@ulmic.ru'
5
31
  = render 'tramway/landing/blocks/templates/full_page', block: @event, buttons: []
6
32
  .container
7
33
  = render 'tramway/event/participants/form'
@@ -1,5 +1,19 @@
1
- .row
2
- .col-lg-12
3
- = simple_form_for @participant_form, url: { controller: 'tramway/event/participants', action: :create } do |f|
4
- - @event.participant_form_fields.each do |field|
5
- = f.input field.title.to_sym
1
+ - if @event.participant_form_fields.any?
2
+ .row
3
+ .col-lg-12
4
+ %h1
5
+ = t('.registration')
6
+ - class_name = 'tramway_event_participant'
7
+ = simple_form_for @participant_form, url: { controller: 'tramway/event/participants', action: :create }, html: { class: class_name, id: class_name } do |f|
8
+ = f.input :event_id, as: :hidden, input_html: { value: @event.id, class: class_name, id: "#{class_name}_event_id", name: "#{class_name}[event_id]" }
9
+ - @event.participant_form_fields.inputs_list.each do |field|
10
+ - case field.field_type
11
+ - when 'text', 'string', 'numeric', 'date_picker'
12
+ = f.input field.title.to_sym, as: field.field_type, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
13
+ - when 'select'
14
+ - parsed_json = JSON.parse(field.options) unless field.options == ''
15
+ - if parsed_json && parsed_json['collection']['name']
16
+ = f.input field.title.to_sym, as: :select, collection: collection_list_by(name: parsed_json['collection']['name']), input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
17
+ - else
18
+ = f.input field.title.to_sym, as: :select, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
19
+ = f.button :submit, t('.submit_form')
@@ -0,0 +1,7 @@
1
+ ru:
2
+ tramway:
3
+ event:
4
+ participants:
5
+ form:
6
+ registration: Регистрация на мероприятие
7
+ submit_form: Отправить заявку
@@ -19,6 +19,8 @@ module Tramway::Event::Generators
19
19
  migration_template 'add_photo_to_tramway_event_events.rb', 'db/migrate/add_photo_to_tramway_event_events.rb'
20
20
  migration_template 'create_tramway_event_participant_form_fields.rb', 'db/migrate/create_tramway_event_participant_form_fields.rb'
21
21
  migration_template 'create_tramway_event_participants.rb', 'db/migrate/create_tramway_event_participants.rb'
22
+ migration_template 'add_options_to_tramway_event_participant_form_fields.rb', 'db/migrate/add_options_to_tramway_event_participant_form_fields.rb'
23
+ migration_template 'add_position_to_tramway_event_participant_form_fields.rb', 'db/migrate/add_position_to_tramway_event_participant_form_fields.rb'
22
24
  end
23
25
  end
24
26
  end
@@ -0,0 +1,5 @@
1
+ class AddOptionsToTramwayEventParticipantFormFields < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :tramway_event_participant_form_fields, :options, :jsonb
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddPositionToTramwayEventParticipantFormFields < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :tramway_event_participant_form_fields, :position, :integer
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Event
3
- VERSION = '0.5'
3
+ VERSION = '0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-event
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2018-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails engine for events
14
14
  email:
@@ -26,6 +26,7 @@ files:
26
26
  - app/assets/stylesheets/tramway/event/events/show.css.sass
27
27
  - app/controllers/tramway/event/application_controller.rb
28
28
  - app/controllers/tramway/event/events_controller.rb
29
+ - app/controllers/tramway/event/participants_controller.rb
29
30
  - app/decorators/tramway/event/event_decorator.rb
30
31
  - app/decorators/tramway/event/event_link_decorator.rb
31
32
  - app/decorators/tramway/event/participant_decorator.rb
@@ -45,12 +46,15 @@ files:
45
46
  - config/initializers/assets.rb
46
47
  - config/initializers/tramway.rb
47
48
  - config/locales/models.yml
49
+ - config/locales/ru.yml
48
50
  - config/routes.rb
49
51
  - lib/tasks/tramway/event_tasks.rake
50
52
  - lib/tramway/event.rb
51
53
  - lib/tramway/event/engine.rb
52
54
  - lib/tramway/event/generators/install_generator.rb
55
+ - lib/tramway/event/generators/templates/add_options_to_tramway_event_participant_form_fields.rb
53
56
  - lib/tramway/event/generators/templates/add_photo_to_tramway_event_events.rb
57
+ - lib/tramway/event/generators/templates/add_position_to_tramway_event_participant_form_fields.rb
54
58
  - lib/tramway/event/generators/templates/create_tramway_event_events.rb
55
59
  - lib/tramway/event/generators/templates/create_tramway_event_participant_form_fields.rb
56
60
  - lib/tramway/event/generators/templates/create_tramway_event_participants.rb