Sha256: 58f201fccfd7821a53b1b0052f53cedbb372c82ac88022e7e24ba35bd25ca6c0

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module EnhancedTextwork
    module Admin
      # This class contains helpers needed to show the Paragraphs picker.
      #
      module EnhancedTextworkPickerHelper
        def paragraphs_picker(form, field, url)
          picker_options = {
            id: sanitize_to_id(field),
            class: "picker-multiple",
            name: "#{form.object_name}[#{field.to_s.sub(/s$/, "_ids")}]",
            multiple: true,
            autosort: true
          }

          prompt_params = {
            url: url,
            text: t("paragraphs_picker.choose_paragraphs", scope: "decidim.enhanced_textwork")
          }

          form.data_picker(field, picker_options, prompt_params) do |item|
            { url: url, text: present(item).id_and_title }
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-enhanced_textwork-1.0.1 app/helpers/decidim/enhanced_textwork/admin/paragraphs_picker_helper.rb
decidim-enhanced_textwork-1.0.0 app/helpers/decidim/enhanced_textwork/admin/paragraphs_picker_helper.rb