mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
[OP-19415] Primer patterns in FilterFormComponent
Uses `ConditionalWrapper` to eliminate template duplication in the `wrap_with_controller` branch, and `merge_data` from `Primer::AttributesHelper` for Stimulus data attributes. https://community.openproject.org/wp/OP-19415
This commit is contained in:
@@ -98,9 +98,10 @@ The host server receives the canonical string in
|
||||
|
||||
### Combining with non-filter inputs
|
||||
|
||||
`FilterFormComponent` composes with other forms via
|
||||
`Primer::Forms::FormList`. All children share the same builder and
|
||||
therefore submit through the same `<form>`.
|
||||
`FilterFormComponent` is rendered next to normal Primer form objects, not
|
||||
inside `Primer::Forms::FormList`. Render any regular form objects through
|
||||
a `FormList`, then render `FilterFormComponent` with the same builder. All
|
||||
fields still submit through the same surrounding `<form>`.
|
||||
|
||||
<%= embed OpenProject::Filter::FilterFormPreview, :combined_with_other_inputs, panels: %i[preview source] %>
|
||||
|
||||
|
||||
+7
-10
@@ -1,6 +1,7 @@
|
||||
<%# `Filters::FilterFormComponent` is a component — combine it with %>
|
||||
<%# other forms in a single `Primer::Forms::FormList` to share one builder %>
|
||||
<%# (and therefore one submission) with non-filter inputs. %>
|
||||
<%# `Filters::FilterFormComponent` is a ViewComponent that shares the %>
|
||||
<%# surrounding Primer form builder with other form objects. Render normal %>
|
||||
<%# Primer form objects through FormList, then render the filter component %>
|
||||
<%# next to that list with the same builder. %>
|
||||
<%
|
||||
note_form = Class.new(ApplicationForm) do
|
||||
form do |f|
|
||||
@@ -9,17 +10,13 @@
|
||||
end
|
||||
%>
|
||||
<%= primer_form_with(url: "/foo", method: :post) do |f| %>
|
||||
<%=
|
||||
render(
|
||||
Primer::Forms::FormList.new(
|
||||
note_form.new(f),
|
||||
<%= render(Primer::Forms::FormList.new(note_form.new(f))) %>
|
||||
<%= render(
|
||||
Filters::FilterFormComponent.new(
|
||||
builder: f,
|
||||
query: query,
|
||||
wrap_with_controller: true,
|
||||
hidden_input_name: "filters"
|
||||
)
|
||||
)
|
||||
)
|
||||
%>
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user