Module: Koi::Form::Builder
- Extended by:
- ActiveSupport::Concern
- Included in:
- Koi::FormBuilder
- Defined in:
- lib/koi/form/builder.rb
Instance Method Summary collapse
-
#admin_archive(text = "Archive") ⇒ Object
deprecated
Deprecated.
will be removed in Koi 6.0
-
#admin_delete(text = "Delete", url: nil, confirm: "Are you sure?", data: {}) ⇒ Object
deprecated
Deprecated.
will be removed in Koi 6.0
-
#admin_discard(text = "Discard", url: :back) ⇒ Object
deprecated
Deprecated.
will be removed in Koi 6.0
-
#admin_save(text = "Save", name: :commit, value: :save, class: "button") ⇒ Object
deprecated
Deprecated.
will be removed in Koi 6.0
- #govuk_document_field(attribute_name, hint: {}) ⇒ Object
- #govuk_image_field(attribute_name, hint: {}) ⇒ Object
-
#lexxy_rich_textarea(attribute_name, **attributes) ⇒ Object
Use Koi's admin direct uploads URL.
-
#trix_rich_textarea(attribute_name, **attributes) ⇒ Object
Use Koi's admin direct uploads URL.
Instance Method Details
#admin_archive(text = "Archive") ⇒ Object
Deprecated.
will be removed in Koi 6.0
Generates an archive link formatted as a button that will perform a turbo delete with a confirmation.
29 30 31 |
# File 'lib/koi/form/builder.rb', line 29 def admin_archive(text = "Archive", **) admin_delete(text, **) end |
#admin_delete(text = "Delete", url: nil, confirm: "Are you sure?", data: {}) ⇒ Object
Deprecated.
will be removed in Koi 6.0
Generates a delete link formatted as a button that will perform a turbo delete with a confirmation.
17 18 19 20 21 22 23 24 |
# File 'lib/koi/form/builder.rb', line 17 def admin_delete(text = "Delete", url: nil, confirm: "Are you sure?", data: {}, **) return unless object.persisted? link_to(text, url || @template.url_for(action: :destroy), class: "button", data: data.reverse_merge(turbo_method: :delete, turbo_confirm: confirm, ghost_button: ""), **) end |
#admin_discard(text = "Discard", url: :back) ⇒ Object
Deprecated.
will be removed in Koi 6.0
Generates a discard changes link formatted as a text button that navigates the user back to the previous page.
36 37 38 |
# File 'lib/koi/form/builder.rb', line 36 def admin_discard(text = "Discard", url: :back, **) link_to(text, url, class: "button", data: { text_button: "" }, **) end |
#admin_save(text = "Save", name: :commit, value: :save, class: "button") ⇒ Object
Deprecated.
will be removed in Koi 6.0
Generates a submit button for saving admin resources.
10 11 12 |
# File 'lib/koi/form/builder.rb', line 10 def admin_save(text = "Save", name: :commit, value: :save, class: "button", **) (text, name:, value:, class:, **) end |
#govuk_document_field(attribute_name, hint: {}) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/koi/form/builder.rb', line 42 def govuk_document_field(attribute_name, hint: {}, **, &) if hint.is_a?(Hash) max_size = hint.fetch(:max_size, Koi.config.document_size_limit) hint[:text] ||= @template.t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size)) end super end |
#govuk_image_field(attribute_name, hint: {}) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/koi/form/builder.rb', line 54 def govuk_image_field(attribute_name, hint: {}, **, &) if hint.is_a?(Hash) max_size = hint.fetch(:max_size, Koi.config.image_size_limit) hint[:text] ||= @template.t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size)) end super end |
#lexxy_rich_textarea(attribute_name, **attributes) ⇒ Object
Use Koi's admin direct uploads URL.
70 71 72 73 74 75 76 77 |
# File 'lib/koi/form/builder.rb', line 70 def lexxy_rich_textarea(attribute_name, **attributes, &) attributes = { class: "lexxy-content", data: { direct_upload_url: @template.main_app.admin_direct_uploads_url }, }.merge_html(**attributes) super end |
#trix_rich_textarea(attribute_name, **attributes) ⇒ Object
Use Koi's admin direct uploads URL.
83 84 85 86 87 88 89 90 |
# File 'lib/koi/form/builder.rb', line 83 def trix_rich_textarea(attribute_name, **attributes, &) attributes = { class: "trix-content", data: { direct_upload_url: @template.main_app.admin_direct_uploads_url }, }.merge_html(**attributes) super end |