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 aMatTableDataSourcewith pagination. - Uses the NgXS store to access the parent
FormWithRelationsso it can updateform_revision_idwhen a revision becomes active.
Actions
- Set Active: Calls
FormControllerService.updateByIdto writeform_revision_idwith the selected revision ID, then dispatchesFindOneFormto refresh related widgets. - Publish / Revert: Updates
statusviaFormRevisionControllerService.updateById(status=2 for publish, status=1 for draft) and stampsuser_published_id+date_publishedautomatically. - Create New Revision: Clones the latest definition, increments
rev_numberand human-friendlyrevstring (e.g.,3.0), and persists throughcreate(). - Edit Definition: Opens
FormBuilderDialogComponent; once saved, patches the revisiondefinitionpayload. - View Definition: Lazy-loads
FormFillDialogComponentin read-only mode to simulate the renderer with the stored JSON definition. - Delete: Allowed only when the revision is not active; uses
ConfirmationDialogServicebefore callingdeleteById.
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.