@hmcts/ccd-case-ui-toolkit 7.0.3-error-message-fix → 7.0.3-event-before-task
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/esm2020/lib/shared/components/case-editor/case-edit/case-edit.component.mjs +46 -19
- package/esm2020/lib/shared/components/case-editor/case-event-completion/components/case-event-completion-task-reassigned/case-event-completion-task-reassigned.component.mjs +4 -14
- package/esm2020/lib/shared/components/case-editor/services/event-completion-state-machine.service.mjs +6 -25
- package/esm2020/lib/shared/components/case-editor/services/wizard-page-field-to-case-field.mapper.mjs +4 -3
- package/esm2020/lib/shared/components/palette/document/write-document-field.component.mjs +2 -14
- package/esm2020/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.mjs +4 -2
- package/esm2020/lib/shared/pipes/complex/fields-filter.pipe.mjs +4 -2
- package/esm2020/lib/shared/services/fields/fields.utils.mjs +6 -1
- package/esm2020/lib/shared/services/form/form-value.service.mjs +2 -2
- package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs +66 -69
- package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
- package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs +66 -69
- package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
- package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts +4 -2
- package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts.map +1 -1
- package/lib/shared/components/case-editor/case-event-completion/components/case-event-completion-task-reassigned/case-event-completion-task-reassigned.component.d.ts.map +1 -1
- package/lib/shared/components/case-editor/services/event-completion-state-machine.service.d.ts.map +1 -1
- package/lib/shared/components/case-editor/services/wizard-page-field-to-case-field.mapper.d.ts.map +1 -1
- package/lib/shared/components/palette/document/write-document-field.component.d.ts.map +1 -1
- package/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.d.ts.map +1 -1
- package/lib/shared/pipes/complex/fields-filter.pipe.d.ts.map +1 -1
- package/lib/shared/services/fields/fields.utils.d.ts +1 -0
- package/lib/shared/services/fields/fields.utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3239,6 +3239,11 @@ class WorkbasketInput {
|
|
|
3239
3239
|
|
|
3240
3240
|
// @dynamic
|
|
3241
3241
|
class FieldsUtils {
|
|
3242
|
+
static isValidDisplayContext(ctx) {
|
|
3243
|
+
return (ctx === 'MANDATORY' || ctx === 'READONLY'
|
|
3244
|
+
|| ctx === 'OPTIONAL' || ctx === 'HIDDEN'
|
|
3245
|
+
|| ctx === 'COMPLEX');
|
|
3246
|
+
}
|
|
3242
3247
|
static convertToCaseField(obj) {
|
|
3243
3248
|
if (!(obj instanceof CaseField)) {
|
|
3244
3249
|
return plainToClassFromExist(new CaseField(), obj);
|
|
@@ -5435,7 +5440,7 @@ class FormValueService {
|
|
|
5435
5440
|
// Retain anything that is readonly and not a label.
|
|
5436
5441
|
continue;
|
|
5437
5442
|
}
|
|
5438
|
-
if (field.hidden === true && field.display_context !== 'HIDDEN' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
|
|
5443
|
+
if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
|
|
5439
5444
|
// Delete anything that is hidden (that is NOT readonly), and that
|
|
5440
5445
|
// hasn't had its display_context overridden to make it hidden.
|
|
5441
5446
|
delete data[field.id];
|
|
@@ -7269,7 +7274,8 @@ class WizardPageFieldToCaseFieldMapper {
|
|
|
7269
7274
|
childrenCaseFields.forEach(e => this.hideParentIfAllChildrenHidden(e));
|
|
7270
7275
|
if (childrenCaseFields.length > 0 && this.allCaseFieldsHidden(childrenCaseFields)) {
|
|
7271
7276
|
caseField.hidden = true;
|
|
7272
|
-
|
|
7277
|
+
// marking display_context as special hidden so field not being deleted in event submission
|
|
7278
|
+
caseField.display_context = 'HIDDEN_TEMP';
|
|
7273
7279
|
}
|
|
7274
7280
|
}
|
|
7275
7281
|
getCaseFieldChildren(caseField) {
|
|
@@ -7283,7 +7289,7 @@ class WizardPageFieldToCaseFieldMapper {
|
|
|
7283
7289
|
return childrenCaseFields;
|
|
7284
7290
|
}
|
|
7285
7291
|
allCaseFieldsHidden(children) {
|
|
7286
|
-
return
|
|
7292
|
+
return children.every(e => e.display_context === 'HIDDEN' || e.display_context === 'HIDDEN_TEMP');
|
|
7287
7293
|
}
|
|
7288
7294
|
}
|
|
7289
7295
|
WizardPageFieldToCaseFieldMapper.ɵfac = function WizardPageFieldToCaseFieldMapper_Factory(t) { return new (t || WizardPageFieldToCaseFieldMapper)(); };
|
|
@@ -8043,18 +8049,9 @@ class EventCompletionStateMachineService {
|
|
|
8043
8049
|
state.trigger(EventCompletionStates.Final);
|
|
8044
8050
|
const taskStr = context.sessionStorageService.getItem('taskToComplete');
|
|
8045
8051
|
if (taskStr) {
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
context.workAllocationService.completeTask(task.id).subscribe(response => {
|
|
8050
|
-
// Emit event can be completed event
|
|
8051
|
-
context.component.eventCanBeCompleted.emit(true);
|
|
8052
|
-
}, error => {
|
|
8053
|
-
// Emit event cannot be completed event
|
|
8054
|
-
context.component.eventCanBeCompleted.emit(false);
|
|
8055
|
-
context.alertService.error(error.message);
|
|
8056
|
-
return throwError(error);
|
|
8057
|
-
});
|
|
8052
|
+
context.sessionStorageService.setItem('assignNeeded', 'false');
|
|
8053
|
+
// just set event can be completed
|
|
8054
|
+
context.component.eventCanBeCompleted.emit(true);
|
|
8058
8055
|
}
|
|
8059
8056
|
else {
|
|
8060
8057
|
// Emit event cannot be completed event
|
|
@@ -8073,18 +8070,8 @@ class EventCompletionStateMachineService {
|
|
|
8073
8070
|
// Get task details
|
|
8074
8071
|
const taskStr = context.sessionStorageService.getItem('taskToComplete');
|
|
8075
8072
|
if (taskStr) {
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
// Assign and complete task
|
|
8079
|
-
context.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
|
|
8080
|
-
// Emit event can be completed event
|
|
8081
|
-
context.component.eventCanBeCompleted.emit(true);
|
|
8082
|
-
}, error => {
|
|
8083
|
-
// Emit event cannot be completed event
|
|
8084
|
-
context.component.eventCanBeCompleted.emit(false);
|
|
8085
|
-
context.alertService.error(error.message);
|
|
8086
|
-
return throwError(error);
|
|
8087
|
-
});
|
|
8073
|
+
context.sessionStorageService.setItem('assignNeeded', 'true');
|
|
8074
|
+
context.component.eventCanBeCompleted.emit(true);
|
|
8088
8075
|
}
|
|
8089
8076
|
else {
|
|
8090
8077
|
// Emit event cannot be completed event
|
|
@@ -8430,7 +8417,7 @@ ValidPageListCaseFieldsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({
|
|
|
8430
8417
|
}], function () { return [{ type: FieldsUtils }]; }, null); })();
|
|
8431
8418
|
|
|
8432
8419
|
class CaseEditComponent {
|
|
8433
|
-
constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService) {
|
|
8420
|
+
constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService, workAllocationService) {
|
|
8434
8421
|
this.fb = fb;
|
|
8435
8422
|
this.caseNotifier = caseNotifier;
|
|
8436
8423
|
this.router = router;
|
|
@@ -8445,6 +8432,7 @@ class CaseEditComponent {
|
|
|
8445
8432
|
this.formErrorService = formErrorService;
|
|
8446
8433
|
this.loadingService = loadingService;
|
|
8447
8434
|
this.validPageListCaseFieldsService = validPageListCaseFieldsService;
|
|
8435
|
+
this.workAllocationService = workAllocationService;
|
|
8448
8436
|
this.cancelled = new EventEmitter();
|
|
8449
8437
|
this.submitted = new EventEmitter();
|
|
8450
8438
|
this.isEventCompletionChecksRequired = false;
|
|
@@ -8731,31 +8719,57 @@ class CaseEditComponent {
|
|
|
8731
8719
|
}
|
|
8732
8720
|
caseSubmit({ form, caseEventData, submit }) {
|
|
8733
8721
|
const loadingSpinnerToken = this.loadingService.register();
|
|
8734
|
-
|
|
8735
|
-
|
|
8722
|
+
// keep the initial event response to finalise process after task completion
|
|
8723
|
+
let eventResponse;
|
|
8724
|
+
submit(caseEventData).pipe(switchMap((response) => {
|
|
8725
|
+
eventResponse = response;
|
|
8726
|
+
return this.postCompleteTaskIfRequired();
|
|
8727
|
+
}), finalize(() => {
|
|
8736
8728
|
this.loadingService.unregister(loadingSpinnerToken);
|
|
8737
8729
|
}))
|
|
8738
|
-
.subscribe(
|
|
8730
|
+
.subscribe(() => {
|
|
8739
8731
|
this.caseNotifier.cachedCaseView = null;
|
|
8740
8732
|
this.sessionStorageService.removeItem('eventUrl');
|
|
8741
|
-
const confirmation = this.buildConfirmation(
|
|
8733
|
+
const confirmation = this.buildConfirmation(eventResponse);
|
|
8742
8734
|
if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
|
|
8743
8735
|
this.confirm(confirmation);
|
|
8744
8736
|
}
|
|
8745
8737
|
else {
|
|
8746
|
-
this.emitSubmitted(
|
|
8738
|
+
this.emitSubmitted(eventResponse);
|
|
8747
8739
|
}
|
|
8748
8740
|
}, error => {
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8741
|
+
if (!eventResponse) {
|
|
8742
|
+
// event submission error
|
|
8743
|
+
this.error = error;
|
|
8744
|
+
this.callbackErrorsSubject.next(error);
|
|
8745
|
+
/* istanbul ignore else */
|
|
8746
|
+
if (this.error.details) {
|
|
8747
|
+
this.formErrorService
|
|
8748
|
+
.mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
|
|
8749
|
+
}
|
|
8750
|
+
this.isSubmitting = false;
|
|
8751
|
+
}
|
|
8752
|
+
else {
|
|
8753
|
+
// task assignment/completion error - handled within workallocation service
|
|
8754
|
+
// could set task to be deleted (or completed later)?
|
|
8755
|
+
// note: think error messages only shown if user is caseworker - might reqauire changing
|
|
8756
|
+
this.router.navigate([`/cases/case-details/${this.getCaseId(this.caseDetails)}/tasks`], { relativeTo: this.route });
|
|
8755
8757
|
}
|
|
8756
|
-
this.isSubmitting = false;
|
|
8757
8758
|
});
|
|
8758
8759
|
}
|
|
8760
|
+
postCompleteTaskIfRequired() {
|
|
8761
|
+
const taskStr = this.sessionStorageService.getItem('taskToComplete');
|
|
8762
|
+
const assignNeeded = this.sessionStorageService.getItem('assignNeeded') === 'true';
|
|
8763
|
+
if (taskStr && assignNeeded) {
|
|
8764
|
+
const task = JSON.parse(taskStr);
|
|
8765
|
+
return this.workAllocationService.assignAndCompleteTask(task.id);
|
|
8766
|
+
}
|
|
8767
|
+
else if (taskStr) {
|
|
8768
|
+
const task = JSON.parse(taskStr);
|
|
8769
|
+
return this.workAllocationService.completeTask(task.id);
|
|
8770
|
+
}
|
|
8771
|
+
return of(true);
|
|
8772
|
+
}
|
|
8759
8773
|
buildConfirmation(response) {
|
|
8760
8774
|
if (response['after_submit_callback_response']) {
|
|
8761
8775
|
return new Confirmation(response['id'], response['callback_response_status'], response['after_submit_callback_response']['confirmation_header'], response['after_submit_callback_response']['confirmation_body']);
|
|
@@ -8784,14 +8798,14 @@ class CaseEditComponent {
|
|
|
8784
8798
|
}
|
|
8785
8799
|
CaseEditComponent.ORIGIN_QUERY_PARAM = 'origin';
|
|
8786
8800
|
CaseEditComponent.ALERT_MESSAGE = 'Page is being refreshed so you will be redirected to the first page of this event.';
|
|
8787
|
-
CaseEditComponent.ɵfac = function CaseEditComponent_Factory(t) { return new (t || CaseEditComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(FieldsUtils), i0.ɵɵdirectiveInject(FieldsPurger), i0.ɵɵdirectiveInject(ConditionalShowRegistrarService), i0.ɵɵdirectiveInject(WizardFactoryService), i0.ɵɵdirectiveInject(SessionStorageService), i0.ɵɵdirectiveInject(WindowService), i0.ɵɵdirectiveInject(FormValueService), i0.ɵɵdirectiveInject(FormErrorService), i0.ɵɵdirectiveInject(LoadingService), i0.ɵɵdirectiveInject(ValidPageListCaseFieldsService)); };
|
|
8801
|
+
CaseEditComponent.ɵfac = function CaseEditComponent_Factory(t) { return new (t || CaseEditComponent)(i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(FieldsUtils), i0.ɵɵdirectiveInject(FieldsPurger), i0.ɵɵdirectiveInject(ConditionalShowRegistrarService), i0.ɵɵdirectiveInject(WizardFactoryService), i0.ɵɵdirectiveInject(SessionStorageService), i0.ɵɵdirectiveInject(WindowService), i0.ɵɵdirectiveInject(FormValueService), i0.ɵɵdirectiveInject(FormErrorService), i0.ɵɵdirectiveInject(LoadingService), i0.ɵɵdirectiveInject(ValidPageListCaseFieldsService), i0.ɵɵdirectiveInject(WorkAllocationService)); };
|
|
8788
8802
|
CaseEditComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEditComponent, selectors: [["ccd-case-edit"]], inputs: { eventTrigger: "eventTrigger", submit: "submit", validate: "validate", saveDraft: "saveDraft", caseDetails: "caseDetails" }, outputs: { cancelled: "cancelled", submitted: "submitted" }, features: [i0.ɵɵProvidersFeature([GreyBarService])], decls: 1, vars: 0, template: function CaseEditComponent_Template(rf, ctx) { if (rf & 1) {
|
|
8789
8803
|
i0.ɵɵelement(0, "router-outlet");
|
|
8790
8804
|
} }, dependencies: [i1$2.RouterOutlet], styles: ["#fieldset-case-data[_ngcontent-%COMP%]{margin-bottom:30px}#fieldset-case-data[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{width:1%;white-space:nowrap;vertical-align:top}.compound-field[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:0}#confirmation-header[_ngcontent-%COMP%]{width:630px;background-color:#17958b;border:solid 1px #979797;color:#fff;text-align:center}#confirmation-body[_ngcontent-%COMP%]{width:630px;background-color:#fff}.valign-top[_ngcontent-%COMP%]{vertical-align:top}.summary-fields[_ngcontent-%COMP%]{margin-bottom:30px}.summary-fields[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .summary-fields[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border-bottom:0px}a.disabled[_ngcontent-%COMP%]{pointer-events:none;cursor:default}.case-field-label[_ngcontent-%COMP%]{width:45%}.case-field-content[_ngcontent-%COMP%]{width:50%}.case-field-change[_ngcontent-%COMP%]{width:5%}"] });
|
|
8791
8805
|
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditComponent, [{
|
|
8792
8806
|
type: Component,
|
|
8793
8807
|
args: [{ selector: 'ccd-case-edit', providers: [GreyBarService], template: "<router-outlet></router-outlet>\n", styles: ["#fieldset-case-data{margin-bottom:30px}#fieldset-case-data th{width:1%;white-space:nowrap;vertical-align:top}.compound-field td{padding:0}#confirmation-header{width:630px;background-color:#17958b;border:solid 1px #979797;color:#fff;text-align:center}#confirmation-body{width:630px;background-color:#fff}.valign-top{vertical-align:top}.summary-fields{margin-bottom:30px}.summary-fields tbody tr th,.summary-fields tbody tr td{border-bottom:0px}a.disabled{pointer-events:none;cursor:default}.case-field-label{width:45%}.case-field-content{width:50%}.case-field-change{width:5%}\n"] }]
|
|
8794
|
-
}], function () { return [{ type: i3.FormBuilder }, { type: CaseNotifier }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: FieldsUtils }, { type: FieldsPurger }, { type: ConditionalShowRegistrarService }, { type: WizardFactoryService }, { type: SessionStorageService }, { type: WindowService }, { type: FormValueService }, { type: FormErrorService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }]; }, { eventTrigger: [{
|
|
8808
|
+
}], function () { return [{ type: i3.FormBuilder }, { type: CaseNotifier }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: FieldsUtils }, { type: FieldsPurger }, { type: ConditionalShowRegistrarService }, { type: WizardFactoryService }, { type: SessionStorageService }, { type: WindowService }, { type: FormValueService }, { type: FormErrorService }, { type: LoadingService }, { type: ValidPageListCaseFieldsService }, { type: WorkAllocationService }]; }, { eventTrigger: [{
|
|
8795
8809
|
type: Input
|
|
8796
8810
|
}], submit: [{
|
|
8797
8811
|
type: Input
|
|
@@ -10146,7 +10160,9 @@ class FieldsFilterPipe {
|
|
|
10146
10160
|
.filter(f => keepEmpty || FieldsFilterPipe.keepField(f))
|
|
10147
10161
|
.map(f => {
|
|
10148
10162
|
if (!f.display_context) {
|
|
10149
|
-
|
|
10163
|
+
if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
|
|
10164
|
+
f.display_context = complexField.display_context;
|
|
10165
|
+
}
|
|
10150
10166
|
}
|
|
10151
10167
|
return f;
|
|
10152
10168
|
});
|
|
@@ -12689,19 +12705,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
|
|
|
12689
12705
|
if (0 === error.status || 502 === error.status) {
|
|
12690
12706
|
return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
|
|
12691
12707
|
}
|
|
12692
|
-
|
|
12693
|
-
if (error && error?.error) {
|
|
12694
|
-
const fullError = error.error;
|
|
12695
|
-
const start = fullError.indexOf('{');
|
|
12696
|
-
if (start >= 0) {
|
|
12697
|
-
const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
|
|
12698
|
-
const obj = JSON.parse(json);
|
|
12699
|
-
if (obj && obj?.error) {
|
|
12700
|
-
errorMsg = obj.error;
|
|
12701
|
-
}
|
|
12702
|
-
}
|
|
12703
|
-
}
|
|
12704
|
-
return errorMsg;
|
|
12708
|
+
return error.error;
|
|
12705
12709
|
}
|
|
12706
12710
|
buildDocumentUploadData(selectedFile) {
|
|
12707
12711
|
const documentUpload = new FormData();
|
|
@@ -22005,7 +22009,9 @@ class ReadFieldsFilterPipe {
|
|
|
22005
22009
|
})
|
|
22006
22010
|
.map(f => {
|
|
22007
22011
|
if (!f.display_context) {
|
|
22008
|
-
|
|
22012
|
+
if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
|
|
22013
|
+
f.display_context = complexField.display_context;
|
|
22014
|
+
}
|
|
22009
22015
|
}
|
|
22010
22016
|
if (setupHidden) {
|
|
22011
22017
|
ReadFieldsFilterPipe.evaluateConditionalShow(f, checkConditionalShowAgainst, path, formGroupAvailable, complexField.id);
|
|
@@ -23700,18 +23706,9 @@ class CaseEventCompletionTaskReassignedComponent {
|
|
|
23700
23706
|
// Get task details
|
|
23701
23707
|
const taskStr = this.sessionStorageService.getItem('taskToComplete');
|
|
23702
23708
|
if (taskStr) {
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
23706
|
-
this.subscription = this.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
|
|
23707
|
-
// Emit event can be completed event
|
|
23708
|
-
this.parentComponent.eventCanBeCompleted.emit(true);
|
|
23709
|
-
}, error => {
|
|
23710
|
-
// Emit event cannot be completed event
|
|
23711
|
-
this.parentComponent.eventCanBeCompleted.emit(false);
|
|
23712
|
-
this.alertService.error(error.message);
|
|
23713
|
-
return throwError(error);
|
|
23714
|
-
});
|
|
23709
|
+
this.sessionStorageService.setItem('assignNeeded', 'true');
|
|
23710
|
+
// set event can be completed to true
|
|
23711
|
+
this.parentComponent.eventCanBeCompleted.emit(true);
|
|
23715
23712
|
}
|
|
23716
23713
|
else {
|
|
23717
23714
|
// Emit event cannot be completed event
|