Class: Decidim::Meetings::MeetingForm

Inherits:
Form
  • Object
show all
Defined in:
decidim-meetings/app/forms/decidim/meetings/meeting_form.rb

Overview

This class holds a Form to create/update meetings for Participants and UserGroups.

Instance Method Summary collapse

Instance Method Details

#categoryObject


77
78
79
80
81
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 77

def category
  return unless current_component

  @category ||= categories.find_by(id: decidim_category_id)
end

#clean_type_of_meetingObject


111
112
113
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 111

def clean_type_of_meeting
  type_of_meeting.presence
end

#decidim_scope_idObject

Scope identifier

Returns the scope identifier related to the meeting


73
74
75
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 73

def decidim_scope_id
  @decidim_scope_id || scope&.id
end

#geocoded?Boolean

Returns:

  • (Boolean)

95
96
97
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 95

def geocoded?
  latitude.present? && longitude.present?
end

#geocoding_enabled?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 83

def geocoding_enabled?
  Decidim::Map.available?(:geocoding)
end

#has_address?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 87

def has_address?
  geocoding_enabled? && address.present?
end

#hybrid_meeting?Boolean

Returns:

  • (Boolean)

107
108
109
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 107

def hybrid_meeting?
  type_of_meeting == "hybrid"
end

#in_person_meeting?Boolean

Returns:

  • (Boolean)

103
104
105
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 103

def in_person_meeting?
  type_of_meeting == "in_person"
end

#map_model(model) ⇒ Object


50
51
52
53
54
55
56
57
58
59
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 50

def map_model(model)
  self.decidim_category_id = model.categorization.decidim_category_id if model.categorization
  presenter = MeetingPresenter.new(model)
  self.title = presenter.title(all_locales: false)
  self.description = presenter.description(all_locales: false)
  self.location = presenter.location(all_locales: false)
  self.location_hints = presenter.location_hints(all_locales: false)
  self.registration_terms = presenter.registration_terms(all_locales: false)
  self.type_of_meeting = model.type_of_meeting
end

#needs_address?Boolean

Returns:

  • (Boolean)

91
92
93
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 91

def needs_address?
  in_person_meeting? || hybrid_meeting?
end

#on_different_platform?Boolean

Returns:

  • (Boolean)

128
129
130
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 128

def on_different_platform?
  registration_type == "on_different_platform"
end

#on_this_platform?Boolean

Returns:

  • (Boolean)

124
125
126
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 124

def on_this_platform?
  registration_type == "on_this_platform"
end

#online_meeting?Boolean

Returns:

  • (Boolean)

99
100
101
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 99

def online_meeting?
  type_of_meeting == "online"
end

#registration_type_selectObject


132
133
134
135
136
137
138
139
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 132

def registration_type_select
  Decidim::Meetings::Meeting::REGISTRATION_TYPE.map do |type|
    [
      I18n.t("registration_type.#{type}", scope: "decidim.meetings"),
      type
    ]
  end
end

#registrations_enabledObject


141
142
143
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 141

def registrations_enabled
  on_this_platform?
end

#scopeObject

Finds the Scope from the given decidim_scope_id, uses the compoenent scope if missing.

Returns a Decidim::Scope


66
67
68
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 66

def scope
  @scope ||= @decidim_scope_id ? current_component.scopes.find_by(id: @decidim_scope_id) : current_component.scope
end

#type_of_meeting_selectObject


115
116
117
118
119
120
121
122
# File 'decidim-meetings/app/forms/decidim/meetings/meeting_form.rb', line 115

def type_of_meeting_select
  Decidim::Meetings::Meeting::TYPE_OF_MEETING.map do |type|
    [
      I18n.t("type_of_meeting.#{type}", scope: "decidim.meetings"),
      type
    ]
  end
end