Class: Decidim::Meetings::Admin::MeetingForm
- Inherits:
-
BaseMeetingForm
show all
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/meetings/admin/meeting_form.rb
Overview
This class holds a Form to create/update translatable meetings from Decidim’s admin panel.
Instance Method Summary
collapse
#geocoded?, #geocoding_enabled?, #has_address?, #hybrid_meeting?, #in_person_meeting?, #needs_address?, #online_meeting?, #type_of_meeting_select
Instance Method Details
#category ⇒ Object
90
91
92
93
94
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 90
def category
return unless current_component
@category ||= categories.find_by(id: decidim_category_id)
end
|
#clean_type_of_meeting ⇒ Object
96
97
98
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 96
def clean_type_of_meeting
type_of_meeting.presence
end
|
#decidim_scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the meeting
86
87
88
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 86
def decidim_scope_id
super || scope&.id
end
|
#embeddable_meeting_url ⇒ Object
144
145
146
147
148
149
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 144
def embeddable_meeting_url
if online_meeting_url.present? && %w(embed_in_meeting_page open_in_live_event_page).include?(iframe_embed_type)
embedder_service = Decidim::Meetings::MeetingIframeEmbedder.new(online_meeting_url)
errors.add(:iframe_embed_type, :not_embeddable) unless embedder_service.embeddable?
end
end
|
#iframe_access_level_select ⇒ Object
100
101
102
103
104
105
106
107
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 100
def iframe_access_level_select
Decidim::Meetings::Meeting.iframe_access_levels.map do |level, _value|
[
I18n.t("iframe_access_level.#{level}", scope: "decidim.meetings"),
level
]
end
end
|
#iframe_embed_type_select ⇒ Object
109
110
111
112
113
114
115
116
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 109
def iframe_embed_type_select
Decidim::Meetings::Meeting.iframe_embed_types.map do |type, _value|
[
I18n.t("iframe_embed_type.#{type}", scope: "decidim.meetings"),
type
]
end
end
|
#map_model(model) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 53
def map_model(model)
self.services = model.services.map do |service|
MeetingServiceForm.from_model(service)
end
self.decidim_category_id = model.categorization.decidim_category_id if model.categorization
self.type_of_meeting = model.type_of_meeting
presenter = MeetingEditionPresenter.new(model)
self.title = presenter.title(all_locales: true)
self.description = presenter.editor_description(all_locales: true)
end
|
#number_of_services ⇒ Object
70
71
72
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 70
def number_of_services
services.size
end
|
127
128
129
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 127
def on_different_platform?
registration_type == "on_different_platform"
end
|
123
124
125
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 123
def on_this_platform?
registration_type == "on_this_platform"
end
|
#questionnaire ⇒ Object
119
120
121
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 119
def questionnaire
Decidim::Forms::Questionnaire.new
end
|
#registration_type_select ⇒ Object
131
132
133
134
135
136
137
138
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 131
def registration_type_select
Decidim::Meetings::Meeting::REGISTRATION_TYPES.keys.map do |type|
[
I18n.t("registration_type.#{type}", scope: "decidim.meetings"),
type
]
end
end
|
#registrations_enabled ⇒ Object
140
141
142
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 140
def registrations_enabled
on_this_platform?
end
|
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses component scope if missing.
Returns a Decidim::Scope
79
80
81
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 79
def scope
@scope ||= @attributes["decidim_scope_id"].value ? current_component.scopes.find_by(id: @attributes["decidim_scope_id"].value) : current_component.scope
end
|
#services_to_persist ⇒ Object
66
67
68
|
# File 'app/forms/decidim/meetings/admin/meeting_form.rb', line 66
def services_to_persist
services.reject(&:deleted)
end
|