tramway-event 1.2.6 → 1.3
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/event/participants_controller.rb +1 -3
- data/app/decorators/tramway/event/participant_decorator.rb +7 -5
- data/app/forms/tramway/event/participant_extended_form_creator.rb +5 -2
- data/app/forms/tramway/event/participant_form.rb +11 -5
- data/app/views/tramway/event/participants/_form.html.haml +1 -9
- data/lib/tramway/event/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 561ce6e60c09b2065aa0054c1203e7f8faafb38308dbb1ec01e55bfebf606a18
|
4
|
+
data.tar.gz: b2d52e2dac5e50dde7ed0099ad907c369d2ecc50ff6c087f1147cc6b587df220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7237e9582084934e3f564719199efa0f9587a0f999623e2bcdb1158f23e5f3e614094025f007d5c41bd7f5b7551c40eb790c0ba33598cacf72a6ea07b8c63e45
|
7
|
+
data.tar.gz: '09b550168725e0d6ee8e67a8e49fac7a5abedc621a605bc8a47a5b746c300cc53428d91491d1718f84666e163569d271731a23b00a86c234d4e6438ee841e1b6'
|
@@ -1,9 +1,7 @@
|
|
1
1
|
class Tramway::Event::ParticipantsController < Tramway::Event::ApplicationController
|
2
2
|
def create
|
3
3
|
event = ::Tramway::Event::Event.find params[:tramway_event_participant][:event_id]
|
4
|
-
|
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
|
4
|
+
@participant_form = ::Tramway::Event::ParticipantExtendedFormCreator.create_form_class(request.uuid, event).new ::Tramway::Event::Participant.new event_id: event.id
|
7
5
|
if @participant_form.submit params[:tramway_event_participant].except :event_id
|
8
6
|
redirect_to event_path event, flash: :success
|
9
7
|
else
|
@@ -6,15 +6,17 @@ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorat
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def title
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if object.values.present?
|
10
|
+
first_name = object.values['Фамилия']
|
11
|
+
last_name = object.values['Имя']
|
12
|
+
patronymic = object.values['Отчество']
|
13
|
+
"#{first_name} #{last_name} #{patronymic}"
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
def values
|
16
18
|
content_tag :table, class: :table do
|
17
|
-
object.values
|
19
|
+
object.values&.each do |key, value|
|
18
20
|
concat(content_tag(:tr) do
|
19
21
|
concat(content_tag(:td) do
|
20
22
|
key
|
@@ -1,6 +1,9 @@
|
|
1
|
-
class Tramway::Event::ParticipantExtendedFormCreator
|
1
|
+
class Tramway::Event::ParticipantExtendedFormCreator < Tramway::Core::FormCreator
|
2
2
|
def self.create_form_class(uuid, event)
|
3
3
|
class_name = "ParticipantExtendedForm#{uuid.gsub('-', '')}"
|
4
|
-
|
4
|
+
properties = event.participant_form_fields.inputs_list.reduce({}) do |hash, field|
|
5
|
+
hash.merge! field.title.to_sym => field
|
6
|
+
end
|
7
|
+
::Tramway::Core::ExtendableForm.new(class_name, **properties)
|
5
8
|
end
|
6
9
|
end
|
@@ -1,9 +1,15 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
class Tramway::Event::ParticipantForm < ::Tramway::Core::ApplicationForm
|
2
|
-
|
4
|
+
association :event
|
3
5
|
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def self.new(object)
|
7
|
+
if object.event_id.present?
|
8
|
+
::Tramway::Event::ParticipantExtendedFormCreator.create_form_class(SecureRandom.hex, object.event).new object
|
9
|
+
else
|
10
|
+
super(object).tap do |obj|
|
11
|
+
obj.form_properties event: :association
|
12
|
+
end
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
@@ -7,13 +7,5 @@
|
|
7
7
|
= simple_form_for @participant_form, url: ::Tramway::Event::Engine.routes.url_helpers.participants_path, method: :post, html: { class: class_name, id: class_name } do |f|
|
8
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
9
|
- event.participant_form_fields.inputs_list.each do |field|
|
10
|
-
|
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}]" }
|
10
|
+
= render 'tramway/core/shared/input_extended', field: field, class_name: class_name, f: f
|
19
11
|
= f.button :submit, t('.submit_form')
|