Sha256: cc853bc277de6937b40f4397bb2d5fb3e6b1f2aadc91d5933899321c5a14eaa3

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Navigation
    module Editor
      class List < Base
        ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
          dragstart->#{LIST_CONTROLLER}#dragstart
          dragover->#{LIST_CONTROLLER}#dragover
          dragenter->#{LIST_CONTROLLER}#dragenter
          dragleave->#{LIST_CONTROLLER}#dragleave
          drop->#{LIST_CONTROLLER}#drop
          dragend->#{LIST_CONTROLLER}#dragend
        ACTIONS

        def build(options, &_block)
          content_tag :ol, default_options(id: menu_form_id, **options) do
            yield self
          end
        end

        def items(*items)
          render partial:    "katalyst/navigation/menus/item",
                 layout:     "katalyst/navigation/menus/list_item",
                 collection: items,
                 as:         :item
        end

        private

        def default_options(options)
          add_option(options, :data, :controller, LIST_CONTROLLER)
          add_option(options, :data, :action, ACTIONS)
          add_option(options, :data, :"#{MENU_CONTROLLER}_target", "menu")

          options
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katalyst-navigation-1.0.3 app/helpers/katalyst/navigation/editor/list.rb
katalyst-navigation-1.0.2 app/helpers/katalyst/navigation/editor/list.rb
katalyst-navigation-1.0.1 app/helpers/katalyst/navigation/editor/list.rb
katalyst-navigation-1.0.0 app/helpers/katalyst/navigation/editor/list.rb