Sha256: 9ce1fb5be0702e132f533e9d94f614aa9827146c7b1dc961fd2f2aa6f599ed86

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Content
    module Editor
      class ItemEditorComponent < BaseComponent
        include ::Turbo::FramesHelper

        module Helpers
          def prefix_partial_path_with_controller_namespace
            false
          end

          def content_routes
            katalyst_content
          end
        end

        def call
          tag.div(**html_attributes) do
            helpers.extend(Helpers)
            helpers.render(item, path:)
          end
        end

        def id
          "item-editor-#{item.id}"
        end

        def title
          if item.persisted?
            "Edit #{item.model_name.human.downcase}"
          else
            "New #{item.model_name.human.downcase}"
          end
        end

        def path
          if item.persisted?
            view_context.katalyst_content.item_path(item)
          else
            view_context.katalyst_content.items_path
          end
        end

        def default_html_attributes
          {
            id:,
            class: "content--item-editor",
          }
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
katalyst-content-2.7.0 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.6.2 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.6.1 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.6.0 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.5.1 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.5.0 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.4.2 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.4.1 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.3.2 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.3.1 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.3.0 app/components/katalyst/content/editor/item_editor_component.rb