Extract alt style's "go to next" field into a support form helper
I want to reuse this for unlabeled pet styles is why! (That's been the immediate motivation for this refactor, but also I do just like that it'll make support forms easier to build.)
This commit is contained in:
parent
06a301e6d7
commit
aeb00f73cf
3 changed files with 18 additions and 10 deletions
|
@ -89,9 +89,9 @@
|
|||
align-items: center
|
||||
gap: 1em
|
||||
|
||||
label
|
||||
display: flex
|
||||
align-items: center
|
||||
gap: .25em
|
||||
font-size: .85em
|
||||
font-style: italic
|
||||
.go-to-next
|
||||
display: flex
|
||||
align-items: center
|
||||
gap: .25em
|
||||
font-size: .85em
|
||||
font-style: italic
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
module SupportFormHelper
|
||||
class SupportFormBuilder < ActionView::Helpers::FormBuilder
|
||||
attr_reader :template
|
||||
delegate :capture, :content_tag, :render, to: :template, private: true
|
||||
delegate :capture, :check_box_tag, :content_tag, :params, :render,
|
||||
to: :template, private: true
|
||||
|
||||
def errors
|
||||
render partial: "application/support_form/errors", locals: {form: self}
|
||||
|
@ -38,6 +39,14 @@ module SupportFormHelper
|
|||
def actions(&block)
|
||||
content_tag(:section, class: "actions", &block)
|
||||
end
|
||||
|
||||
def go_to_next_field(**options, &block)
|
||||
content_tag(:label, class: "go-to-next", **options, &block)
|
||||
end
|
||||
|
||||
def go_to_next_check_box(value)
|
||||
check_box_tag "next", value, checked: params[:next] == value
|
||||
end
|
||||
end
|
||||
|
||||
def support_form_with(**options, &block)
|
||||
|
|
|
@ -28,9 +28,8 @@
|
|||
|
||||
= f.actions do
|
||||
= f.submit "Save changes"
|
||||
%label{title: "If checked, takes you to the next unlabeled pet style, if any. Useful for labeling in bulk!"}
|
||||
= check_box_tag "next", "unlabeled-style",
|
||||
checked: params[:next] == "unlabeled-style"
|
||||
= f.go_to_next_field title: "If checked, takes you to the next unlabeled pet style, if any. Useful for labeling in bulk!" do
|
||||
= f.go_to_next_check_box "unlabeled-style"
|
||||
Then: Go to unlabeled style
|
||||
|
||||
- content_for :stylesheets do
|
||||
|
|
Loading…
Reference in a new issue