Sha256: 42c04b348f03c6a64a5fabe30345565a5bd1f1b170362b140cb9c31f6b91f565

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Admin
      # A form object used to copy a meeting from the admin
      # dashboard.
      #
      class MeetingCopyForm < ::Decidim::Meetings::BaseMeetingForm
        include TranslatableAttributes

        translatable_attribute :title, String
        translatable_attribute :description, String
        translatable_attribute :location, String
        translatable_attribute :location_hints, String

        attribute :show_embedded_iframe, Boolean, default: false
        attribute :private_meeting, Boolean
        attribute :transparent, Boolean
        attribute :services, Array[MeetingServiceForm]

        mimic :meeting

        validates :online_meeting_url, url: true, if: ->(form) { form.online_meeting? || form.hybrid_meeting? }
        validates :title, translatable_presence: true
        validates :description, translatable_presence: true
        validates :location, translatable_presence: true, if: ->(form) { form.in_person_meeting? || form.hybrid_meeting? }

        def map_model(model)
          self.services = model.services.map do |service|
            MeetingServiceForm.new(service.attributes)
          end
        end

        def services_to_persist
          services.reject(&:deleted)
        end

        def number_of_services
          services.size
        end

        alias component current_component

        def questionnaire
          Decidim::Forms::Questionnaire.new
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-meetings-0.27.1 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.4 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.27.0 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.3 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.27.0.rc2 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.27.0.rc1 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.2 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.1 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.0 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.0.rc2 app/forms/decidim/meetings/admin/meeting_copy_form.rb
decidim-meetings-0.26.0.rc1 app/forms/decidim/meetings/admin/meeting_copy_form.rb