class Decidim::Meetings::Admin::MeetingForm

This class holds a Form to create/update translatable meetings from Decidim’s admin panel.

def category

def category
  return unless current_component
  @category ||= categories.find_by(id: decidim_category_id)
end

def clean_type_of_meeting

def clean_type_of_meeting
  type_of_meeting.presence
end

def decidim_scope_id

Returns the scope identifier related to the meeting

Scope identifier
def decidim_scope_id
  super || scope&.id
end

def embeddable_meeting_url

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

def iframe_access_level_select

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

def iframe_embed_type_select

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

def map_model(model)

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
end

def number_of_services

def number_of_services
  services.size
end

def on_different_platform?

def on_different_platform?
  registration_type == "on_different_platform"
end

def on_this_platform?

def on_this_platform?
  registration_type == "on_this_platform"
end

def registration_type_select

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

def scope

Returns a Decidim::Scope

Finds the Scope from the given decidim_scope_id, uses component scope if missing.
def scope
  @scope ||= @attributes["decidim_scope_id"].value ? current_component.scopes.find_by(id: @attributes["decidim_scope_id"].value) : current_component.scope
end

def services_to_persist

def services_to_persist
  services.reject(&:deleted)
end

def type_of_meeting_select

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