Sha256: 2488e4f130ccee8814af1120d50cb5e7cdad5dd5020d197f136c744084684b59

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 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
        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

6 entries across 6 versions & 1 rubygems

Version Path
katalyst-content-2.2.0 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.1.4 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.1.3 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.1.2 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.1.1 app/components/katalyst/content/editor/item_editor_component.rb
katalyst-content-2.1.0 app/components/katalyst/content/editor/item_editor_component.rb