Sha256: e92416bdd4e5e055cb6a15fccfc8010254a081d9195502844bb5c24fbe0e6a0d

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Content
    module Editor
      class Base
        CONTAINER_CONTROLLER  = "content--editor--container"
        LIST_CONTROLLER       = "content--editor--list"
        ITEM_CONTROLLER       = "content--editor--item"
        STATUS_BAR_CONTROLLER = "content--editor--status-bar"
        NEW_ITEM_CONTROLLER   = "content--editor--new-item"

        TURBO_FRAME = "content--editor--item-frame"

        attr_accessor :template, :container

        delegate_missing_to :template

        def initialize(template, container)
          self.template  = template
          self.container = container
        end

        def container_form_id
          dom_id(container, :items)
        end

        def attributes_scope
          "#{container.model_name.param_key}[items_attributes][]"
        end

        private

        def add_option(options, key, *path)
          if path.length > 1
            add_option(options[key] ||= {}, *path)
          else
            options[key] = [options[key], *path].compact.join(" ")
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katalyst-content-0.1.2 app/helpers/katalyst/content/editor/base.rb
katalyst-content-0.1.1 app/helpers/katalyst/content/editor/base.rb
katalyst-content-0.1.0 app/helpers/katalyst/content/editor/base.rb