Class: Clowk::Phlex::Charts::TypePicker
- Inherits:
-
Clowk::Phlex::Component
- Object
- Phlex::HTML
- Clowk::Phlex::Component
- Clowk::Phlex::Charts::TypePicker
- Defined in:
- lib/clowk/phlex/charts/type_picker.rb
Overview
Components::Metrics::ChartTypePicker — dropdown that switches how the metric is drawn: Area (time-series line+fill), Radial (semicircle gauge), or Linear (capacity bar gauge). Same DS dropdown chrome as IntervalPicker/MetricPicker so the modal toolbar reads as a consistent row of pickers.
Why it exists: chart_type used to stick to whatever the panel opened as, with no way to change it in the modal — open a gauge, switch metric/pod, and it stayed a gauge. This gives the operator explicit control.
URL contract: the active type lives in the chart_type query param. area
is the default and is OMITTED (clean URLs), so the param only appears once
the operator picks a gauge. Gauges silently fall back to area for metrics
without a percentage/capacity ceiling (same as ChartCard), so all three are
always offerable.
Constant Summary collapse
- DEFAULT =
"area"- OPTIONS =
The type list + labels + glyphs are Clowk::Phlex::Charts::ChartShape's — one source of truth shared with the dashboard builder's shape chips.
Clowk::Phlex::Charts::ChartShape::METRIC_TYPES
- LABELS =
Clowk::Phlex::Charts::ChartShape::LABELS
Instance Method Summary collapse
-
#initialize(current:, base_path:, extra_params: {}, turbo_stream: false) ⇒ TypePicker
constructor
current: active chart_type (e.g. "area", "gauge_radial") base_path: URL each row hits (metrics_path or metrics_chart_path) extra_params: merged into every URL EXCEPT
chart_type(the picker owns it per row). - #view_template ⇒ Object
Constructor Details
#initialize(current:, base_path:, extra_params: {}, turbo_stream: false) ⇒ TypePicker
current: active chart_type (e.g. "area", "gauge_radial")
base_path: URL each row hits (metrics_path or metrics_chart_path)
extra_params: merged into every URL EXCEPT chart_type (the picker owns
it per row). Pass the request query minus chart_type.
turbo_stream: emit data-turbo-stream so the swap stays modal-local.
30 31 32 33 34 35 |
# File 'lib/clowk/phlex/charts/type_picker.rb', line 30 def initialize(current:, base_path:, extra_params: {}, turbo_stream: false) @current = current.to_s.presence || DEFAULT @base_path = base_path @extra_params = extra_params || {} @turbo_stream = turbo_stream end |
Instance Method Details
#view_template ⇒ Object
37 38 39 40 41 42 |
# File 'lib/clowk/phlex/charts/type_picker.rb', line 37 def view_template div(class: "relative", data: {controller: "dropdown"}) do trigger end end |