widget-form-front
App: Front
Source: web/projects/front/src/widgets/widget-form-front
Purpose
Operators use this widget on shop-floor dashboards to complete forms tied to a part/document. It resolves required/optional forms via FormRelation, tracks progress for each user/object, and opens the shared FormFillDialogComponent for capturing answers.
Session Binding
- Subscribes to
SessionState.currentSessionto derivepart_id,document_id, anddocument_so_line_id. - Stores the session locally so it can reload forms whenever the user switches parts or new relations are created.
Loading Process
- Fetch
FormRelationrecords for the currentobject_idusingFormRelationControllerService. - Build a list of form IDs and request each form with its
active_revision(status=2) viaFormControllerService. - Load existing
FormResultrecords scoped bydocument_so_line_id(and optionally user ID when validation scope isper_user). - Compose
FormWithResultobjects with flags indicating whether a result is completed, in progress, or pending.
Dialog Workflow
Opening a card runs openForm(formWithResult) which constructs FormFillDialogConfig:
definition:form.active_revision.definition.initialData: existingresultsif the form is in progress.validationScope: inherited fromFormRelation.validation_scope.onSave: creates or updatesFormResultusingFormResultControllerService. Copies contextual fields (module/object/part/document) frombuildRelationFields()so audit records stay linked.onComplete: finalizes the record, setsprogress = 100, optionally calls/form-results/{id}/signwhen a signature is provided, and then/form-results/{id}/complete.fetchUserNames: when scope isper_objectorglobal, fetches user display names so the renderer can show who answered each question.
After the dialog closes with data, the widget calls loadForms() again to refresh progress bars and icons.
UI Details
- Displays status icons (
radio_button_unchecked,pending,check_circle) based on result state. - Shows optional description text and an inline progress bar for in-progress results.
- Includes a refresh button that re-runs
loadForms()if the operator suspects relations changed mid-session.
Extension Tips
- Support additional contexts by extending
buildRelationFields()to include custom IDs (e.g., job_id) and mirroring those columns on theFormResultmodel. - Inject permissions to hide completed forms or restrict deletion options based on user role.