Skip to content

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.currentSession to derive part_id, document_id, and document_so_line_id.
  • Stores the session locally so it can reload forms whenever the user switches parts or new relations are created.

Loading Process

  1. Fetch FormRelation records for the current object_id using FormRelationControllerService.
  2. Build a list of form IDs and request each form with its active_revision (status=2) via FormControllerService.
  3. Load existing FormResult records scoped by document_so_line_id (and optionally user ID when validation scope is per_user).
  4. Compose FormWithResult objects 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: existing results if the form is in progress.
  • validationScope: inherited from FormRelation.validation_scope.
  • onSave: creates or updates FormResult using FormResultControllerService. Copies contextual fields (module/object/part/document) from buildRelationFields() so audit records stay linked.
  • onComplete: finalizes the record, sets progress = 100, optionally calls /form-results/{id}/sign when a signature is provided, and then /form-results/{id}/complete.
  • fetchUserNames: when scope is per_object or global, 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 the FormResult model.
  • Inject permissions to hide completed forms or restrict deletion options based on user role.

Syneo/Barcoding Documentation