Sha256: 0a1452b28b9b74a09221187abe05e860f64eb80a1ad956a5f8ff4b63483e90a0
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Decidim module Plans module AttachedProposalsHelper include Decidim::ApplicationHelper def attached_proposals_picker_field(form, name) picker_options = { id: "attached_proposals", "class": "picker-multiple", name: "proposal_ids", multiple: true } prompt_params = { url: plan_search_proposals_path(current_component, format: :html), text: t("decidim.plans.attached_proposals_helper.attach_proposal") } form.data_picker(name, picker_options, prompt_params) do |item| { url: plan_search_proposals_path(current_component, format: :json), text: item.title } end end def search_proposals respond_to do |format| format.html do render partial: "decidim/plans/attached_proposals/proposals" end format.json do query = Decidim .find_resource_manifest(:proposals) .try(:resource_scope, current_component) &.order(title: :asc) &.where("title ilike ?", "%#{params[:term]}%") render json: query.all.collect { |p| [present(p).title, p.id] } end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems