widget-form-relations
App: Backend
Source: web/projects/backend/src/widgets/widget-form-relations
Purpose
Maps forms to module objects (Parts, Documents, NCRs, etc.) so dashboards know which forms to require. Also defines whether a form is required and how validation scope works (per user vs. per object/global).
Data Flow
- Loads all active forms (status=2) via
FormControllerService.findwithfields: { id, name }to populate dropdowns. - Reads
ModuleState.moduleand the dashboardstateto determinemodule_idandobject_id. - Fetches existing relations with
FormRelationControllerService.find({ include: ['form'], where: { module_id, object_id } })and binds them to a table.
Dialog Behaviour
FormRelationDialogComponent handles both create and edit modes:
- Fields:
form_id,required,validation_scope(per_user,per_object,global). - Persisted through
create,updateById, ordeleteByIdin the SDK. - After dialog close, the widget refreshes and notifies the user via
NOTYFtoast.
Extension Tips
- To show additional filters (e.g., by form category), extend the
formsquery to includecategoryand render grouped dropdown sections. - Validation scope strings should stay in sync with the Front widget; add custom scopes there before exposing them here.