Class: Tramway::Event::ParticipantDecorator
- Inherits:
-
Core::ApplicationDecorator
- Object
- Core::ApplicationDecorator
- Tramway::Event::ParticipantDecorator
- Includes:
- HTMLTagsHelpers
- Defined in:
- app/decorators/tramway/event/participant_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #created_at ⇒ Object
- #event ⇒ Object
- #list_fields ⇒ Object
- #participation_state ⇒ Object
- #participation_state_button_color(event) ⇒ Object
- #state ⇒ Object
- #title ⇒ Object
- #updated_at ⇒ Object
- #values ⇒ Object
Class Method Details
.collections ⇒ Object
6 7 8 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 6 def collections %i[all requested waiting prev_approved without_answer approved rejected reserved] end |
.list_attributes ⇒ Object
10 11 12 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 10 def list_attributes [:list_fields] end |
.show_attributes ⇒ Object
15 16 17 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 15 def show_attributes %i[id event values state created_at updated_at participation_state comment] end |
Instance Method Details
#created_at ⇒ Object
103 104 105 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 103 def created_at date_view object.created_at end |
#event ⇒ Object
33 34 35 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 33 def event object.event.title end |
#list_fields ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 37 def list_fields content_tag :table, class: :table do concat(content_tag(:tr) do concat(content_tag(:td) do object.class.human_attribute_name(:event) end) concat(content_tag(:td) do object.event.title end) end) object.event.participant_form_fields.map do |field| hash = if field..is_a?(Hash) field. else begin JSON.parse(field..present? ? field. : '{}') rescue StandardError => e I18n.t('.invalid_field_with_error', e) end end if hash.is_a? Hash if hash.dig('list_field') == 'true' concat(content_tag(:tr) do concat(content_tag(:td) do field.title end) concat(content_tag(:td) do value = object.values&.dig(field.title) if russian_phone_number?(value) tel_tag value else value end end) end) end else hash end end.compact end end |
#participation_state ⇒ Object
111 112 113 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 111 def participation_state state_machine_view object, :participation_state end |
#participation_state_button_color(event) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 117 def (event) case event when :previous_approve, :approve :success when :wait_for_decision, :not_got_answer :warning when :reject :danger when :reserve :warning when :return_to_requested :warning end end |
#state ⇒ Object
99 100 101 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 99 def state state_machine_view object, :state end |
#title ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 22 def title if object.values.present? first_name = object.values['Фамилия'] last_name = object.values['Имя'] patronymic = object.values['Отчество'] "#{first_name} #{last_name} #{patronymic}" else '(участник не ввёл ФИО)' end end |
#updated_at ⇒ Object
107 108 109 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 107 def updated_at date_view object.updated_at end |
#values ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/decorators/tramway/event/participant_decorator.rb', line 80 def values content_tag :table, class: :table do object.values&.each do |key, value| concat(content_tag(:tr) do concat(content_tag(:td) do key end) concat(content_tag(:td) do concat(if russian_phone_number?(value) tel_tag value else value end) end) end) end end end |