Class: Clowk::Phlex::Charts::DisplaySettings

Inherits:
Clowk::Phlex::Component show all
Defined in:
lib/clowk/phlex/charts/display_settings.rb

Overview

Views::Metrics::DisplaySettings — the "Settings" drawer body for the chart grid. A flat, domain-agnostic tile per card (portable → gem): click a tile to toggle its visibility, drag the grip to reorder, pick the column count. The "Update" button commits { hidden, order, cols } to the shared display store and fires metrics-display:changed; the grid re-applies live.

items — [{ metric:, label:, color:, unit:, default_visible: }] for every manageable card on the page (those carrying a metric key).

Instance Method Summary collapse

Constructor Details

#initialize(kind:, items:) ⇒ DisplaySettings

Returns a new instance of DisplaySettings.



12
13
14
15
# File 'lib/clowk/phlex/charts/display_settings.rb', line 12

def initialize(kind:, items:)
  @kind = kind
  @items = items
end

Instance Method Details

#view_templateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/clowk/phlex/charts/display_settings.rb', line 17

def view_template
  return if @items.empty?

  div(
    class: "p-4 flex flex-col gap-4 @container",
    data: {
      controller: "metrics-display-settings",
      metrics_display_settings_kind_value: @kind
    }
  ) do
    header_row
    hint_row
    columns_picker
    cards_grid
  end
end