@masterteam/work-center 0.0.88 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/i18n/ar.json +215 -214
- package/assets/i18n/en.json +215 -214
- package/assets/work-center.css +1 -1
- package/fesm2022/masterteam-work-center.mjs +115 -7
- package/fesm2022/masterteam-work-center.mjs.map +1 -1
- package/package.json +4 -4
- package/types/masterteam-work-center.d.ts +19 -2
|
@@ -19,7 +19,7 @@ import { ClientForm, ClientFormWarningsDialog } from '@masterteam/forms/client-f
|
|
|
19
19
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
20
20
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
21
21
|
import { Drawer } from '@masterteam/components/drawer';
|
|
22
|
-
import { RuntimeActionContextStore, RuntimeActionRunner, RUNTIME_ACTION_CONFIRM_DIALOG, hasActionFormFields, buildActionPayload, resolveActionLabel } from '@masterteam/components/runtime-action';
|
|
22
|
+
import { RuntimeActionContextStore, RuntimeActionRunner, RUNTIME_ACTION_CONFIRM_DIALOG, hasActionFormFields, buildActionPayload, resolveActionLabel, hasActionInputFields } from '@masterteam/components/runtime-action';
|
|
23
23
|
import { Action, Selector, State, Store, select } from '@ngxs/store';
|
|
24
24
|
import { handleApiRequest } from '@masterteam/components';
|
|
25
25
|
import { ClientInstancePreview } from '@masterteam/client-components/client-instance-preview';
|
|
@@ -38,11 +38,33 @@ class WorkCenterClientFormModal {
|
|
|
38
38
|
operationKey = input('Create', ...(ngDevMode ? [{ debugName: "operationKey" }] : /* istanbul ignore next */ []));
|
|
39
39
|
closeOnPendingApproval = input(false, ...(ngDevMode ? [{ debugName: "closeOnPendingApproval" }] : /* istanbul ignore next */ []));
|
|
40
40
|
lookups = input([], ...(ngDevMode ? [{ debugName: "lookups" }] : /* istanbul ignore next */ []));
|
|
41
|
+
/**
|
|
42
|
+
* The runtime action's `payloadTemplate`. Supplies the non-field keys the
|
|
43
|
+
* ClientForm request builder omits for action-style operations (`recordId`,
|
|
44
|
+
* `moduleId`), so an operation opened from a footer action submits against
|
|
45
|
+
* the same record the action was resolved for.
|
|
46
|
+
*/
|
|
47
|
+
submitPayloadTemplate = input(null, ...(ngDevMode ? [{ debugName: "submitPayloadTemplate" }] : /* istanbul ignore next */ []));
|
|
41
48
|
moduleKey = computed(() => this.data().moduleKey, ...(ngDevMode ? [{ debugName: "moduleKey" }] : /* istanbul ignore next */ []));
|
|
42
49
|
moduleId = computed(() => this.toNumber(this.data().moduleId), ...(ngDevMode ? [{ debugName: "moduleId" }] : /* istanbul ignore next */ []));
|
|
43
50
|
levelId = computed(() => this.toNumber(this.data().levelId), ...(ngDevMode ? [{ debugName: "levelId" }] : /* istanbul ignore next */ []));
|
|
44
51
|
levelDataId = computed(() => this.toNumber(this.data().levelDataId), ...(ngDevMode ? [{ debugName: "levelDataId" }] : /* istanbul ignore next */ []));
|
|
45
52
|
moduleDataId = computed(() => this.toNumber(this.data().moduleDataId), ...(ngDevMode ? [{ debugName: "moduleDataId" }] : /* istanbul ignore next */ []));
|
|
53
|
+
recordId = computed(() => this.toNumber(this.data().recordId), ...(ngDevMode ? [{ debugName: "recordId" }] : /* istanbul ignore next */ []));
|
|
54
|
+
submitRequestMapper = (request) => {
|
|
55
|
+
const template = this.submitPayloadTemplate();
|
|
56
|
+
if (!template) {
|
|
57
|
+
return request;
|
|
58
|
+
}
|
|
59
|
+
const next = { ...request };
|
|
60
|
+
if (next.recordId == null && template['recordId'] != null) {
|
|
61
|
+
next.recordId = template['recordId'];
|
|
62
|
+
}
|
|
63
|
+
if (next.moduleId == null && template['moduleId'] != null) {
|
|
64
|
+
next.moduleId = template['moduleId'];
|
|
65
|
+
}
|
|
66
|
+
return next;
|
|
67
|
+
};
|
|
46
68
|
formMode = computed(() => this.moduleDataId() != null ||
|
|
47
69
|
this.operationKey().trim().toLowerCase() === 'update'
|
|
48
70
|
? 'edit'
|
|
@@ -92,12 +114,12 @@ class WorkCenterClientFormModal {
|
|
|
92
114
|
return undefined;
|
|
93
115
|
}
|
|
94
116
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: WorkCenterClientFormModal, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
95
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: WorkCenterClientFormModal, isStandalone: true, selector: "mt-work-center-client-form-modal", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, operationKey: { classPropertyName: "operationKey", publicName: "operationKey", isSignal: true, isRequired: false, transformFunction: null }, closeOnPendingApproval: { classPropertyName: "closeOnPendingApproval", publicName: "closeOnPendingApproval", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "processForm", first: true, predicate: ClientForm, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'workCenter'\">\
|
|
117
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: WorkCenterClientFormModal, isStandalone: true, selector: "mt-work-center-client-form-modal", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, operationKey: { classPropertyName: "operationKey", publicName: "operationKey", isSignal: true, isRequired: false, transformFunction: null }, closeOnPendingApproval: { classPropertyName: "closeOnPendingApproval", publicName: "closeOnPendingApproval", isSignal: true, isRequired: false, transformFunction: null }, lookups: { classPropertyName: "lookups", publicName: "lookups", isSignal: true, isRequired: false, transformFunction: null }, submitPayloadTemplate: { classPropertyName: "submitPayloadTemplate", publicName: "submitPayloadTemplate", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "processForm", first: true, predicate: ClientForm, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'workCenter'\">\n <div [class]=\"modal.contentClass + ' p-5 flex flex-col gap-4'\">\n <mt-client-form\n [moduleKey]=\"moduleKey()\"\n [moduleId]=\"moduleId()\"\n [operationKey]=\"operationKey()\"\n [levelId]=\"levelId()\"\n [levelDataId]=\"levelDataId()\"\n [moduleDataId]=\"moduleDataId()\"\n [recordId]=\"recordId()\"\n [formMode]=\"formMode()\"\n [autoLoad]=\"true\"\n [renderMode]=\"'sections'\"\n [lookups]=\"lookups()\"\n [submitRequestMapper]=\"submitRequestMapper\"\n (submitted)=\"onSubmitted($event)\"\n (errored)=\"onErrored($event)\"\n />\n\n @if (isSubmitting()) {\n <div class=\"text-sm text-muted-color\">{{ t(\"modal.submitting\") }}</div>\n }\n\n @if (validationMessage()) {\n <div\n class=\"mt-2 rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-700\"\n role=\"alert\"\n >\n {{ validationMessage() }}\n </div>\n }\n\n @if (submitError()) {\n <div\n class=\"mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\n role=\"alert\"\n >\n {{ submitError() }}\n </div>\n }\n\n @if (submitStatus(); as status) {\n <div\n class=\"mt-2 rounded-lg border p-3 text-sm\"\n [class]=\"\n status === 'pending'\n ? 'border-amber-200 bg-amber-50 text-amber-700'\n : 'border-emerald-200 bg-emerald-50 text-emerald-700'\n \"\n >\n @if (status === \"pending\") {\n {{ t(\"modal.requestSubmitted\") }}\n } @else {\n {{ t(\"modal.operationExecuted\") }}\n }\n </div>\n }\n </div>\n\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('modal.cancel')\"\n variant=\"outlined\"\n [disabled]=\"isSubmitting()\"\n (onClick)=\"ref.close(false)\"\n />\n <mt-button\n [label]=\"t('modal.submit')\"\n icon=\"general.check\"\n [disabled]=\"\n isSubmitting() || processForm().hasBlockingGovernanceFailure()\n \"\n (onClick)=\"onSubmit()\"\n />\n </div>\n</ng-container>\n", dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: ClientForm, selector: "mt-client-form", inputs: ["moduleKey", "operationKey", "moduleId", "levelId", "levelDataId", "moduleDataId", "recordId", "requestSchemaId", "draftProcessId", "templateId", "returnRecord", "preview", "forceOriginalForm", "returnUrl", "defaultValues", "submitRequestMapper", "submitTransport", "readonly", "autoLoad", "formMode", "renderMode", "showInternalStepActions", "confirmWarningsOnSubmit", "confirmWarningsOnStepChange", "silentMessages", "hostMessages", "readonlyFieldDisplayMode", "lookups", "statuses", "ignoredFieldKeys", "disabledFieldKeys", "allowedFieldKeys"], outputs: ["loaded", "submitted", "errored", "modeDetected", "formSourceDetected", "footerStateChanged"] }] });
|
|
96
118
|
}
|
|
97
119
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: WorkCenterClientFormModal, decorators: [{
|
|
98
120
|
type: Component,
|
|
99
|
-
args: [{ selector: 'mt-work-center-client-form-modal', standalone: true, imports: [Button, TranslocoDirective, ClientForm], template: "<ng-container *transloco=\"let t; prefix: 'workCenter'\">\
|
|
100
|
-
}], propDecorators: { processForm: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ClientForm), { isSignal: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], operationKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "operationKey", required: false }] }], closeOnPendingApproval: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnPendingApproval", required: false }] }], lookups: [{ type: i0.Input, args: [{ isSignal: true, alias: "lookups", required: false }] }] } });
|
|
121
|
+
args: [{ selector: 'mt-work-center-client-form-modal', standalone: true, imports: [Button, TranslocoDirective, ClientForm], template: "<ng-container *transloco=\"let t; prefix: 'workCenter'\">\n <div [class]=\"modal.contentClass + ' p-5 flex flex-col gap-4'\">\n <mt-client-form\n [moduleKey]=\"moduleKey()\"\n [moduleId]=\"moduleId()\"\n [operationKey]=\"operationKey()\"\n [levelId]=\"levelId()\"\n [levelDataId]=\"levelDataId()\"\n [moduleDataId]=\"moduleDataId()\"\n [recordId]=\"recordId()\"\n [formMode]=\"formMode()\"\n [autoLoad]=\"true\"\n [renderMode]=\"'sections'\"\n [lookups]=\"lookups()\"\n [submitRequestMapper]=\"submitRequestMapper\"\n (submitted)=\"onSubmitted($event)\"\n (errored)=\"onErrored($event)\"\n />\n\n @if (isSubmitting()) {\n <div class=\"text-sm text-muted-color\">{{ t(\"modal.submitting\") }}</div>\n }\n\n @if (validationMessage()) {\n <div\n class=\"mt-2 rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-700\"\n role=\"alert\"\n >\n {{ validationMessage() }}\n </div>\n }\n\n @if (submitError()) {\n <div\n class=\"mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700\"\n role=\"alert\"\n >\n {{ submitError() }}\n </div>\n }\n\n @if (submitStatus(); as status) {\n <div\n class=\"mt-2 rounded-lg border p-3 text-sm\"\n [class]=\"\n status === 'pending'\n ? 'border-amber-200 bg-amber-50 text-amber-700'\n : 'border-emerald-200 bg-emerald-50 text-emerald-700'\n \"\n >\n @if (status === \"pending\") {\n {{ t(\"modal.requestSubmitted\") }}\n } @else {\n {{ t(\"modal.operationExecuted\") }}\n }\n </div>\n }\n </div>\n\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('modal.cancel')\"\n variant=\"outlined\"\n [disabled]=\"isSubmitting()\"\n (onClick)=\"ref.close(false)\"\n />\n <mt-button\n [label]=\"t('modal.submit')\"\n icon=\"general.check\"\n [disabled]=\"\n isSubmitting() || processForm().hasBlockingGovernanceFailure()\n \"\n (onClick)=\"onSubmit()\"\n />\n </div>\n</ng-container>\n" }]
|
|
122
|
+
}], propDecorators: { processForm: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ClientForm), { isSignal: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], operationKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "operationKey", required: false }] }], closeOnPendingApproval: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnPendingApproval", required: false }] }], lookups: [{ type: i0.Input, args: [{ isSignal: true, alias: "lookups", required: false }] }], submitPayloadTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "submitPayloadTemplate", required: false }] }] } });
|
|
101
123
|
|
|
102
124
|
class EnterArea {
|
|
103
125
|
area;
|
|
@@ -3144,6 +3166,12 @@ function withWarningsToken(payload, warningsToken) {
|
|
|
3144
3166
|
}
|
|
3145
3167
|
|
|
3146
3168
|
const DEFAULT_GENERAL_TASK_MODAL_STYLE_CLASS = '!w-[70vw] !h-[90vh]';
|
|
3169
|
+
/**
|
|
3170
|
+
* An operation-input action renders only the operation's own fields (Update
|
|
3171
|
+
* Progress is a single percentage), so it gets a dialog sized to a short form
|
|
3172
|
+
* rather than the full-height module editor.
|
|
3173
|
+
*/
|
|
3174
|
+
const DEFAULT_OPERATION_MODAL_STYLE_CLASS = '!w-[45vw] max-w-[96vw]';
|
|
3147
3175
|
class WorkCenterItemModalFooterActions {
|
|
3148
3176
|
http = inject(HttpClient);
|
|
3149
3177
|
facade = inject(WorkCenterFacade);
|
|
@@ -3241,6 +3269,19 @@ class WorkCenterItemModalFooterActions {
|
|
|
3241
3269
|
this.executeGeneralTaskUpdateAction(action);
|
|
3242
3270
|
return;
|
|
3243
3271
|
}
|
|
3272
|
+
// The action declares operation inputs the user still has to supply — its
|
|
3273
|
+
// `payloadTemplate.fields` is a list of `{ propertyKey, value: null }`
|
|
3274
|
+
// placeholders (`Task.UpdateProgress` and friends). Firing it from the
|
|
3275
|
+
// template alone submits those nulls, and the runner would only raise a
|
|
3276
|
+
// plain "are you sure?" confirmation over a payload it then rejects as
|
|
3277
|
+
// incomplete. Such an operation runs through its own form instead:
|
|
3278
|
+
// `process-form-load` → `process-submit/validate` → `process-submit`,
|
|
3279
|
+
// which is exactly what `mt-client-form` does. Mirrors the client-list
|
|
3280
|
+
// record-action path.
|
|
3281
|
+
if (hasActionInputFields(action)) {
|
|
3282
|
+
this.executeOperationInputAction(action);
|
|
3283
|
+
return;
|
|
3284
|
+
}
|
|
3244
3285
|
this.formStore.setErrors([]);
|
|
3245
3286
|
this.pendingActionKey.set(action.actionKey);
|
|
3246
3287
|
const execution = { actionKey: action.actionKey, cancelled: false };
|
|
@@ -3317,19 +3358,58 @@ class WorkCenterItemModalFooterActions {
|
|
|
3317
3358
|
]);
|
|
3318
3359
|
return;
|
|
3319
3360
|
}
|
|
3361
|
+
this.openClientFormModal(action, {
|
|
3362
|
+
data: modalData,
|
|
3363
|
+
operationKey: resolvePayloadString(action, 'operationKey') ?? 'Update',
|
|
3364
|
+
styleClass: DEFAULT_GENERAL_TASK_MODAL_STYLE_CLASS,
|
|
3365
|
+
});
|
|
3366
|
+
}
|
|
3367
|
+
/**
|
|
3368
|
+
* Runs an action whose operation declares its own input fields through the
|
|
3369
|
+
* operation's real form. The `payloadTemplate` rides along so the submit
|
|
3370
|
+
* carries the record identity the action was resolved for, the same way the
|
|
3371
|
+
* client-list record actions do.
|
|
3372
|
+
*/
|
|
3373
|
+
executeOperationInputAction(action) {
|
|
3374
|
+
this.formStore.setErrors([]);
|
|
3375
|
+
const modalData = buildOperationInputModalData(action, this.actionData()?.context);
|
|
3376
|
+
if (modalData.recordId == null && modalData.moduleDataId == null) {
|
|
3377
|
+
this.formStore.setErrors([
|
|
3378
|
+
this.transloco.translate('workCenter.error.missingRecordId'),
|
|
3379
|
+
]);
|
|
3380
|
+
return;
|
|
3381
|
+
}
|
|
3382
|
+
this.openClientFormModal(action, {
|
|
3383
|
+
data: modalData,
|
|
3384
|
+
operationKey: resolvePayloadString(action, 'operationKey') ?? action.actionKey,
|
|
3385
|
+
styleClass: DEFAULT_OPERATION_MODAL_STYLE_CLASS,
|
|
3386
|
+
// No `allowedFieldKeys`: the effective form is rendered exactly as the
|
|
3387
|
+
// backend returned it. A contract-only operation already comes back with
|
|
3388
|
+
// nothing but its own inputs, and one composed with the configured form
|
|
3389
|
+
// was deliberately composed that way — filtering would hide fields the
|
|
3390
|
+
// backend meant to show.
|
|
3391
|
+
submitPayloadTemplate: action.payloadTemplate ?? null,
|
|
3392
|
+
});
|
|
3393
|
+
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Opens the operation's form and, on a real write, refreshes the footer and
|
|
3396
|
+
* tells the host. A dismissed dialog wrote nothing and refreshes nothing.
|
|
3397
|
+
*/
|
|
3398
|
+
openClientFormModal(action, options) {
|
|
3320
3399
|
this.pendingActionKey.set(action.actionKey);
|
|
3321
3400
|
const execution = { actionKey: action.actionKey, cancelled: false };
|
|
3322
3401
|
this.currentExecution = execution;
|
|
3323
3402
|
const ref = this.modal.openModal(WorkCenterClientFormModal, 'dialog', {
|
|
3324
3403
|
header: resolveActionLabel(action),
|
|
3325
|
-
styleClass:
|
|
3404
|
+
styleClass: options.styleClass,
|
|
3326
3405
|
position: 'end',
|
|
3327
3406
|
dismissableMask: true,
|
|
3328
3407
|
inputValues: {
|
|
3329
|
-
data:
|
|
3330
|
-
operationKey:
|
|
3408
|
+
data: options.data,
|
|
3409
|
+
operationKey: options.operationKey,
|
|
3331
3410
|
closeOnPendingApproval: true,
|
|
3332
3411
|
lookups: this.facade.lookups(),
|
|
3412
|
+
submitPayloadTemplate: options.submitPayloadTemplate ?? null,
|
|
3333
3413
|
},
|
|
3334
3414
|
});
|
|
3335
3415
|
ref.onClose.pipe(take(1)).subscribe((result) => {
|
|
@@ -3392,6 +3472,34 @@ const NEGATIVE_OUTCOME_ACTION_KEYS = new Set([
|
|
|
3392
3472
|
'close',
|
|
3393
3473
|
'delete',
|
|
3394
3474
|
]);
|
|
3475
|
+
/**
|
|
3476
|
+
* The `mt-client-form` context for an operation-input action, read from the
|
|
3477
|
+
* action's own `payloadTemplate` first and the item's action context second.
|
|
3478
|
+
*
|
|
3479
|
+
* Exported for the spec: this mapping is the whole contract between the footer
|
|
3480
|
+
* button and `process-form-load`, and getting `recordId` wrong opens the
|
|
3481
|
+
* operation's form with none of the record's current values.
|
|
3482
|
+
*/
|
|
3483
|
+
function buildOperationInputModalData(action, context) {
|
|
3484
|
+
return {
|
|
3485
|
+
// The action's own module identity, not the item's generic source type: an
|
|
3486
|
+
// operation is registered against the business module (`Task`, `Risk`, …)
|
|
3487
|
+
// and `process-form-load` resolves the operation contract from it.
|
|
3488
|
+
moduleKey: resolvePayloadString(action, 'moduleKey') ??
|
|
3489
|
+
readRecordString(context, 'moduleKey') ??
|
|
3490
|
+
'ModuleData',
|
|
3491
|
+
moduleId: resolvePayloadId(action, 'moduleId') ?? readRecordId(context, 'moduleId'),
|
|
3492
|
+
levelId: resolvePayloadId(action, 'levelId') ?? readRecordId(context, 'levelId'),
|
|
3493
|
+
levelDataId: resolvePayloadId(action, 'levelDataId') ??
|
|
3494
|
+
readRecordId(context, 'levelDataId'),
|
|
3495
|
+
// `recordId`, not `moduleDataId`: a schedule item carries no module-data
|
|
3496
|
+
// row, and this is the identity `process-form-load` needs to return the
|
|
3497
|
+
// current values the form opens on.
|
|
3498
|
+
recordId: resolvePayloadId(action, 'recordId') ??
|
|
3499
|
+
readRecordId(context, 'recordId') ??
|
|
3500
|
+
readRecordId(context, 'instanceId'),
|
|
3501
|
+
};
|
|
3502
|
+
}
|
|
3395
3503
|
function commitsFormValues(action) {
|
|
3396
3504
|
if (NEGATIVE_OUTCOME_ACTION_KEYS.has(normalizeKey(action.actionKey))) {
|
|
3397
3505
|
return false;
|