Class: Plutonium::UI::Kanban::Card

Inherits:
Component::Base show all
Defined in:
lib/plutonium/ui/kanban/card.rb

Overview

Thin wrapper around Grid::Card that makes the card draggable.

Emits a draggable container div carrying:

data-kanban-record-id — the record's id, consumed by the Stimulus
                      drag controller (Task 11) to identify the card
data-kanban-column-key — the source column key, used by the move
                       handler (Task 7) to determine which column
                       the card came from

All actual card rendering (image, header, meta, actions dropdown) is delegated to Plutonium::UI::Grid::Card which already handles slots, policy-gated actions, and the row-click controller.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Component::Behaviour

#around_template

Methods included from Component::Tokens

#classes, #tokens

Methods included from Component::Kit

#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?

Constructor Details

#initialize(record, column_key:, resource_definition:, resource_fields:, card_fields: nil, show_turbo_frame: "_top") ⇒ Card

Returns a new instance of Card.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/plutonium/ui/kanban/card.rb', line 21

def initialize(record, column_key:, resource_definition:, resource_fields:, card_fields: nil, show_turbo_frame: "_top")
  @record = record
  @column_key = column_key
  @resource_definition = resource_definition
  @resource_fields = resource_fields
  # Optional slot-layout override from the board's card_fields declaration.
  # Threaded through to Grid::Card so it takes precedence over the
  # resource definition's grid_fields.  nil means use the definition.
  @card_fields = card_fields
  # The turbo-frame the card's show link targets — the remote-modal frame
  # (board show_in :modal) or "_top" (show_in :page). Either escapes the
  # column's lazy frame. Defaults to "_top".
  @show_turbo_frame = show_turbo_frame
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit

Instance Attribute Details

#card_fieldsObject (readonly)

Returns the value of attribute card_fields.



19
20
21
# File 'lib/plutonium/ui/kanban/card.rb', line 19

def card_fields
  @card_fields
end

#column_keyObject (readonly)

Returns the value of attribute column_key.



19
20
21
# File 'lib/plutonium/ui/kanban/card.rb', line 19

def column_key
  @column_key
end

#recordObject (readonly)

Returns the value of attribute record.



19
20
21
# File 'lib/plutonium/ui/kanban/card.rb', line 19

def record
  @record
end

#resource_definitionObject (readonly)

Returns the value of attribute resource_definition.



19
20
21
# File 'lib/plutonium/ui/kanban/card.rb', line 19

def resource_definition
  @resource_definition
end

#resource_fieldsObject (readonly)

Returns the value of attribute resource_fields.



19
20
21
# File 'lib/plutonium/ui/kanban/card.rb', line 19

def resource_fields
  @resource_fields
end

Instance Method Details

#view_templateObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/plutonium/ui/kanban/card.rb', line 36

def view_template
  div(
    draggable: "true",
    data: {
      kanban_record_id: record.id,
      kanban_column_key: column_key.to_s
    }
  ) do
    render_grid_card
  end
end