Sha256: 5064a3dd3b952313e1c84e1d757380c83ca5c8666758bc7eafea013d3123c59b

Contents?: true

Size: 1.56 KB

Versions: 42

Compression:

Stored size: 1.56 KB

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Component
          class TagField < Page::Component
            passboolean :single_select, :use_defaults
            passthrough :tag_tree_id, :button_text

            def to_s(delimiter: "\n")
              root.tags.to_s(delimiter: delimiter)
            end

            # Quick config helper
            # @param conf [Symbol, Array<Symbol>]
            #   - `:multiple` to allow multiple selection
            #   - `:single` to set to singular selection
            #   - `:default_tag` to prepopulate using users's `default_tag`
            #   - `:button_text` to define the button description
            def configure(*conf)
              conf.each_with_object([]) do |cnf, unused|
                case cnf
                when :single
                  self.single_select = true
                when :multiple
                  self.single_select = false
                when :default_tag
                  self.use_defaults = true
                when Hash
                  supported = [:button_text]
                  unless (rest = hash_except(cnf.dup, *supported)).empty?
                    unused.push(rest)
                  end
                  if cnf.key?(:button_text) then self.button_text = cnf[:button_text] end
                else
                  unused.push(cnf)
                end
              end.yield_self do |unused|
                super(*unused)
              end
            end

          end
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.12 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.11 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.10 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.9 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.8 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.7 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.6 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.5 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.4 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.3 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.2 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.1 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-2.0.0 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.8 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.7 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.6 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.5 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.4 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.3 lib/ecoportal/api/v2/page/component/tag_field.rb
ecoportal-api-v2-1.1.2 lib/ecoportal/api/v2/page/component/tag_field.rb