Skip to content

widget-form-revisions

App: Backend
Source: web/projects/backend/src/widgets/widget-form-revisions

Purpose

Full revision history manager for a form. Lets authors create new revisions, preview definitions, publish, and switch the active revision used by production widgets.

Data Flow

  • Fetches revisions via FormRevisionControllerService.find({ where: { form_id }, order: 'rev_number DESC' }) and binds them to a MatTableDataSource with pagination.
  • Uses the NgXS store to access the parent FormWithRelations so it can update form_revision_id when a revision becomes active.

Actions

  • Set Active: Calls FormControllerService.updateById to write form_revision_id with the selected revision ID, then dispatches FindOneForm to refresh related widgets.
  • Publish / Revert: Updates status via FormRevisionControllerService.updateById (status=2 for publish, status=1 for draft) and stamps user_published_id + date_published automatically.
  • Create New Revision: Clones the latest definition, increments rev_number and human-friendly rev string (e.g., 3.0), and persists through create().
  • Edit Definition: Opens FormBuilderDialogComponent; once saved, patches the revision definition payload.
  • View Definition: Lazy-loads FormFillDialogComponent in read-only mode to simulate the renderer with the stored JSON definition.
  • Delete: Allowed only when the revision is not active; uses ConfirmationDialogService before calling deleteById.

Extension Tips

  • Add filters (draft/published) by adjusting the LoopBack filter before binding data.
  • Surface diffing by comparing the selected revision definition against the active one before previewing.

Syneo/Barcoding Documentation