mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Add some documentation for advanced filters. wp/74380
This commit is contained in:
@@ -55,6 +55,30 @@ module OpenProject
|
||||
def check_box_group_with_include_hidden
|
||||
render_with_template
|
||||
end
|
||||
|
||||
# **SegmentedControlInput**
|
||||
#
|
||||
# A Primer `SegmentedControl` backed by a plain `<input type="hidden">`.
|
||||
# The hidden field is the source of truth for form submission: when the
|
||||
# user selects a segment, the `filter--segmented-control` Stimulus
|
||||
# controller reacts to Primer's `itemActivated` event, writes the chosen
|
||||
# `data-value` into the hidden field, and dispatches a `change` event so
|
||||
# that any ancestor change listener (e.g. `filter--filters-form`) can
|
||||
# react without knowing about the segmented control at all.
|
||||
#
|
||||
# The first item is selected by default when `value:` is nil or absent.
|
||||
def segmented_control_input_multi
|
||||
render_with_template
|
||||
end
|
||||
|
||||
# **SegmentedControlInput — boolean toggle**
|
||||
#
|
||||
# A special case of `SegmentedControlInput` with exactly two items
|
||||
# mimicking a toggle switch. Used for boolean filters where the backing
|
||||
# values are `"t"` (yes) and `"f"` (no).
|
||||
def segmented_control_input_boolean
|
||||
render_with_template
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<%
|
||||
the_form = Class.new(ApplicationForm) do
|
||||
form do |f|
|
||||
f.segmented_control(
|
||||
name: :recurring,
|
||||
label: "Part of a meeting series",
|
||||
value: "f",
|
||||
items: [
|
||||
{ value: "f", label: I18n.t("general_text_No") },
|
||||
{ value: "t", label: I18n.t("general_text_Yes") }
|
||||
]
|
||||
)
|
||||
|
||||
f.submit(name: "submit", label: "Save")
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
||||
<%= primer_form_with(url: "/abc", method: :post) do |f|
|
||||
render(the_form.new(f))
|
||||
end %>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<%
|
||||
the_form = Class.new(ApplicationForm) do
|
||||
form do |f|
|
||||
f.segmented_control(
|
||||
name: :priority,
|
||||
label: "Priority",
|
||||
value: "normal",
|
||||
items: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "normal", label: "Normal" },
|
||||
{ value: "high", label: "High" }
|
||||
]
|
||||
)
|
||||
|
||||
f.submit(name: "submit", label: "Save")
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
||||
<%= primer_form_with(url: "/abc", method: :post) do |f|
|
||||
render(the_form.new(f))
|
||||
end %>
|
||||
Reference in New Issue
Block a user