Class: Plutonium::UI::Kanban::Column
- Inherits:
-
Component::Base
- Object
- Component::Base
- Plutonium::UI::Kanban::Column
- Includes:
- Phlex::Rails::Helpers::LinkTo, ColorDot
- Defined in:
- lib/plutonium/ui/kanban/column.rb
Overview
Renders a single column body: header with wip badge, card list, and a "+N more" footer when the total exceeds per_column.
This is the component that Task 6's lazy frame endpoint serves. The
board shell (Resource) wraps each column in a
Collapsed variant: when column.collapsed? the component renders a thin
rotated-label strip instead of the full card list. Both the strip and
the expanded body are always emitted in the HTML; CSS (controlled by
the pu-kanban-column-collapsed class on the wrapper) shows one and
hides the other. The Stimulus controller's toggleColumn action flips the
class and persists the choice to localStorage.
Action slot: column.actions are rendered as minimal placeholder buttons so the DOM seam is in place for Task 8 which wires the actual action handlers (interactive bulk actions). The buttons carry data-kanban-action and data-kanban-column attributes for Stimulus targeting.
Drop policy: the wrapper emits data-kanban-accepts and data-kanban-locked so the Stimulus drag controller can provide client-side drop hints without re-implementing server-side logic. The server remains the authority.
Instance Attribute Summary collapse
-
#cards ⇒ Object
readonly
Returns the value of attribute cards.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#per_column ⇒ Object
readonly
Returns the value of attribute per_column.
-
#resource_definition ⇒ Object
readonly
Returns the value of attribute resource_definition.
-
#resource_fields ⇒ Object
readonly
Returns the value of attribute resource_fields.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#effective_collapsed? ⇒ Boolean
Effective collapse state: the caller's resolved value, or the column default when none was passed (tests / board shell / non-cookie paths).
-
#initialize(column:, cards:, total:, per_column:, resource_definition:, resource_fields:, column_action_data: [], column_add_url: nil, board_url: nil, card_fields: nil, card_show_frame: "_top", collapsed: nil, drop_form_url_template: nil, drop_immediate: false, drop_confirm: nil) ⇒ Column
constructor
column_action_data: array of Plutonium::Kanban::Action, ids: [Integer, ...] Resolved by the controller (KanbanActions#render_kanban_column_html) and threaded here so the component can render real bulk-action links without needing to re-query the DB.
- #view_template ⇒ Object
Methods included from ColorDot
#color_css_value, #render_color_dot
Methods included from Component::Behaviour
Methods included from Component::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(column:, cards:, total:, per_column:, resource_definition:, resource_fields:, column_action_data: [], column_add_url: nil, board_url: nil, card_fields: nil, card_show_frame: "_top", collapsed: nil, drop_form_url_template: nil, drop_immediate: false, drop_confirm: nil) ⇒ Column
column_action_data: array of Plutonium::Kanban::Action, ids: [Integer, ...] Resolved by the controller (KanbanActions#render_kanban_column_html) and threaded here so the component can render real bulk-action links without needing to re-query the DB. Defaults to [] when the component is constructed outside of a controller context (e.g., tests or the board shell which renders column frames without card data).
column_add_url: URL for the "+ Add" quick-add button (or nil).
Set by the controller when column.add? is true and the policy permits
create. Carries kanban_column=
card_fields: optional slot-layout hash from the board's card_fields declaration (e.g. { header: :title, meta: [:status] }). Threaded through to each Kanban::Card (and ultimately Grid::Card) so it overrides the resource definition's grid_fields for every card in the column. nil means "use the definition's grid_fields" (default). card_show_frame: the turbo-frame each card's show link targets — the remote-modal frame (board show_in :modal) or "_top" (show_in :page). Resolved by the controller and threaded through to Kanban::Card. Defaults to "_top" so a card always escapes the column's lazy frame when the component is built outside a controller (tests, board shell). collapsed: the EFFECTIVE collapse state for this render (the user's cookie-persisted choice resolved against the column default by the controller). nil → fall back to the column's declared default. The component still emits the DEFAULT separately (data-kanban-default- collapsed) so the controller can store only deltas from it. drop_form_url_template: the kanban_move_form member URL with an ID placeholder for the dragged card's record id (mirrors the board's move-url template). Set by the controller ONLY for columns that declare an enter_interaction:; nil for plain columns. When present, the wrapper advertises data-kanban-drop-interaction + data-kanban-drop-form-url- template so Task 6's Stimulus controller opens the interaction modal on drop instead of committing the move immediately.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/plutonium/ui/kanban/column.rb', line 68 def initialize(column:, cards:, total:, per_column:, resource_definition:, resource_fields:, column_action_data: [], column_add_url: nil, board_url: nil, card_fields: nil, card_show_frame: "_top", collapsed: nil, drop_form_url_template: nil, drop_immediate: false, drop_confirm: nil) @column = column @cards = cards @total = total @per_column = per_column @resource_definition = resource_definition @resource_fields = resource_fields @column_action_data = column_action_data @column_add_url = column_add_url @board_url = board_url @card_fields = card_fields @card_show_frame = card_show_frame @collapsed = collapsed @drop_form_url_template = drop_form_url_template @drop_immediate = drop_immediate @drop_confirm = drop_confirm end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Attribute Details
#cards ⇒ Object (readonly)
Returns the value of attribute cards.
32 33 34 |
# File 'lib/plutonium/ui/kanban/column.rb', line 32 def cards @cards end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
32 33 34 |
# File 'lib/plutonium/ui/kanban/column.rb', line 32 def column @column end |
#per_column ⇒ Object (readonly)
Returns the value of attribute per_column.
32 33 34 |
# File 'lib/plutonium/ui/kanban/column.rb', line 32 def per_column @per_column end |
#resource_definition ⇒ Object (readonly)
Returns the value of attribute resource_definition.
32 33 34 |
# File 'lib/plutonium/ui/kanban/column.rb', line 32 def resource_definition @resource_definition end |
#resource_fields ⇒ Object (readonly)
Returns the value of attribute resource_fields.
32 33 34 |
# File 'lib/plutonium/ui/kanban/column.rb', line 32 def resource_fields @resource_fields end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
32 33 34 |
# File 'lib/plutonium/ui/kanban/column.rb', line 32 def total @total end |
Instance Method Details
#effective_collapsed? ⇒ Boolean
Effective collapse state: the caller's resolved value, or the column default when none was passed (tests / board shell / non-cookie paths).
88 89 90 |
# File 'lib/plutonium/ui/kanban/column.rb', line 88 def effective_collapsed? @collapsed.nil? ? column.collapsed? : @collapsed end |
#view_template ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/plutonium/ui/kanban/column.rb', line 92 def view_template # Wrapper carries the drop-policy data attributes and the initial # collapsed CSS class. The Stimulus controller reads data-kanban-col # to find wrappers unambiguously (distinct from toggle button attrs). div( class: tokens( "pu-kanban-column-wrapper", effective_collapsed? && "pu-kanban-column-collapsed" ), data: wrapper_data ) do render_collapsed_strip end end |