Sha256: 53374b26e87d1c45038b20c6b8fca7b25e574dc85e7db80fe9c484209c7d0656

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ReportingProposals
    module CloseMeetingFormOverride
      extend ActiveSupport::Concern

      included do
        alias_method :map_model_original, :map_model

        def map_model(model)
          map_model_original(model)
          self.proposal_ids += model.linked_resources(:reporting_proposals, "proposals_from_meeting").pluck(:id)
        end

        def proposals
          @proposals ||= begin
            proposals_query = Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component)
            reporting_proposals_query = Decidim.find_resource_manifest(:reporting_proposals).try(:resource_scope, current_component)
            (reporting_proposals_query ? proposals_query.or(reporting_proposals_query) : proposals_query)
              &.where(id: proposal_ids)
              &.order(title: :asc)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-reporting_proposals-0.6.0 app/forms/concerns/decidim/reporting_proposals/close_meeting_form_override.rb
decidim-reporting_proposals-0.5.2 app/forms/concerns/decidim/reporting_proposals/close_meeting_form_override.rb
decidim-reporting_proposals-0.5.1 app/forms/concerns/decidim/reporting_proposals/close_meeting_form_override.rb
decidim-reporting_proposals-0.5.0 app/forms/concerns/decidim/reporting_proposals/close_meeting_form_override.rb
decidim-reporting_proposals-0.4.2 app/forms/concerns/decidim/reporting_proposals/close_meeting_form_override.rb