Sha256: 16b5f2975fef852c9d6cdccc6bc78ac8607230e338812fb7da205c45b4a98243

Contents?: true

Size: 614 Bytes

Versions: 7

Compression:

Stored size: 614 Bytes

Contents

require 'push_type/tag_list_query'

module PushType
  class TagListField < ArrayField

    def template
      @opts[:template] || 'tag_list'
    end

    def html_options
      { multiple: true, placeholder: 'Tags...' }.merge(super).merge(class: 'tagsinput')
    end

    def to_json(val)
      super.reject(&:blank?)
    end

    def from_json(val)
      super.reject(&:blank?)
    end

    initialized_on_node do |object, field|
      object.define_singleton_method "all_#{ field.name }".to_sym do |*args|
        TagListQuery.new(field.name, object.name.underscore.to_sym).all *args
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
push_type_core-0.4.0 app/fields/push_type/tag_list_field.rb
push_type_core-0.4.0.beta.3 app/fields/push_type/tag_list_field.rb
push_type_core-0.3.3 app/fields/push_type/tag_list_field.rb
push_type_core-0.3.1 app/fields/push_type/tag_list_field.rb
push_type_core-0.2.1 app/fields/push_type/tag_list_field.rb
push_type_core-0.2.0 app/fields/push_type/tag_list_field.rb
push_type_core-0.2.0.beta2 app/fields/push_type/tag_list_field.rb