Class: Glib::JsonUi::ViewBuilder::Fields::Sign
- Inherits:
-
AbstractField
- Object
- JsonUiElement
- View
- AbstractField
- Glib::JsonUi::ViewBuilder::Fields::Sign
- Defined in:
- app/helpers/glib/json_ui/view_builder/fields.rb
Overview
A saved signature is a signed id that cannot be redrawn from the
canvas: when a record is re-edited the field pre-populates value
with the existing attachment's signed id (the component renders a
read-only preview instead of ink). An untouched field therefore
re-submits that same signed id, so consumers should treat a
same-signed-id re-attach as "no change". Resize it via
components_set/logics_set with width/height.
Signature field that lets the user draw a signature on a canvas and upload it as an image via ActiveStorage direct upload.
The form shows a placeholder sized by width/height; tapping it opens
a dialog with the drawing canvas, and Confirm uploads the drawing as a
PNG to directUploadUrl and submits the resulting signed id under
name. The placeholder then shows the signature, and reopening the
dialog lets the user edit it. Because the canvas is not in the form,
the placeholder can be given the same height as a neighbouring input
(e.g. a typed-name alternative) without losing drawing space.
label titles the dialog; placeholder replaces the "Tap to sign"
prompt.
With typedName the dialog gains Draw/Type tabs: the user can type
their name instead of drawing, and the placeholder then shows the name
in a handwriting style (the glib-sign-typed hook carries the font).
The typed name is submitted under typedName[:name]; exactly one of the
signed id and the typed name is ever non-blank. typedName[:value]
pre-populates an existing name.
Instance Attribute Summary
Attributes inherited from JsonUiElement
Instance Method Summary collapse
-
#determine_value(context, prop) ⇒ Object
Override A stored signature is an attachment -- submit its signed id (mirrors File#determine_value) so re-editing a signed submission pre-fills the field with the existing blob's signed id instead of serializing the whole attachment proxy.
Methods inherited from AbstractField
#autoValidate, #context, #created, #default_url_options, #disableDirtyCheck, #existing_attachment_url, #hint, #hint_args, #label, #label_args, #name, #placeholder, #placeholder_args, #prop, #validation, #value
Methods inherited from View
Methods inherited from JsonUiElement
action, any, array, badgeable, bool, color, component_name, date, date_time, enum, float, hash, icon, #initialize, int, length, menu, panels_builder, #props, required, singleton_array, string, text, url, views
Constructor Details
This class inherits a constructor from Glib::JsonUi::JsonUiElement
Instance Method Details
#determine_value(context, prop) ⇒ Object
Override A stored signature is an attachment -- submit its signed id (mirrors File#determine_value) so re-editing a signed submission pre-fills the field with the existing blob's signed id instead of serializing the whole attachment proxy.
990 991 992 993 994 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 990 def determine_value(context, prop) if (value = context.field_value(prop)).attached? value.signed_id || '' end end |