@hmcts/ccd-case-ui-toolkit 7.0.3-error-message-fix → 7.0.3-event-before-task-with-logic
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 +55 -25
- 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 +75 -75
- package/fesm2015/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
- package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs +75 -75
- package/fesm2020/hmcts-ccd-case-ui-toolkit.mjs.map +1 -1
- package/lib/shared/components/case-editor/case-edit/case-edit.component.d.ts +5 -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
|
@@ -3237,6 +3237,11 @@ class WorkbasketInput {
|
|
|
3237
3237
|
|
|
3238
3238
|
// @dynamic
|
|
3239
3239
|
class FieldsUtils {
|
|
3240
|
+
static isValidDisplayContext(ctx) {
|
|
3241
|
+
return (ctx === 'MANDATORY' || ctx === 'READONLY'
|
|
3242
|
+
|| ctx === 'OPTIONAL' || ctx === 'HIDDEN'
|
|
3243
|
+
|| ctx === 'COMPLEX');
|
|
3244
|
+
}
|
|
3240
3245
|
static convertToCaseField(obj) {
|
|
3241
3246
|
if (!(obj instanceof CaseField)) {
|
|
3242
3247
|
return plainToClassFromExist(new CaseField(), obj);
|
|
@@ -5446,7 +5451,7 @@ class FormValueService {
|
|
|
5446
5451
|
// Retain anything that is readonly and not a label.
|
|
5447
5452
|
continue;
|
|
5448
5453
|
}
|
|
5449
|
-
if (field.hidden === true && field.display_context !== 'HIDDEN' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
|
|
5454
|
+
if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
|
|
5450
5455
|
// Delete anything that is hidden (that is NOT readonly), and that
|
|
5451
5456
|
// hasn't had its display_context overridden to make it hidden.
|
|
5452
5457
|
delete data[field.id];
|
|
@@ -7554,7 +7559,8 @@ class WizardPageFieldToCaseFieldMapper {
|
|
|
7554
7559
|
childrenCaseFields.forEach(e => this.hideParentIfAllChildrenHidden(e));
|
|
7555
7560
|
if (childrenCaseFields.length > 0 && this.allCaseFieldsHidden(childrenCaseFields)) {
|
|
7556
7561
|
caseField.hidden = true;
|
|
7557
|
-
|
|
7562
|
+
// marking display_context as special hidden so field not being deleted in event submission
|
|
7563
|
+
caseField.display_context = 'HIDDEN_TEMP';
|
|
7558
7564
|
}
|
|
7559
7565
|
}
|
|
7560
7566
|
getCaseFieldChildren(caseField) {
|
|
@@ -7568,7 +7574,7 @@ class WizardPageFieldToCaseFieldMapper {
|
|
|
7568
7574
|
return childrenCaseFields;
|
|
7569
7575
|
}
|
|
7570
7576
|
allCaseFieldsHidden(children) {
|
|
7571
|
-
return
|
|
7577
|
+
return children.every(e => e.display_context === 'HIDDEN' || e.display_context === 'HIDDEN_TEMP');
|
|
7572
7578
|
}
|
|
7573
7579
|
}
|
|
7574
7580
|
WizardPageFieldToCaseFieldMapper.ɵfac = function WizardPageFieldToCaseFieldMapper_Factory(t) { return new (t || WizardPageFieldToCaseFieldMapper)(); };
|
|
@@ -8331,18 +8337,9 @@ class EventCompletionStateMachineService {
|
|
|
8331
8337
|
state.trigger(EventCompletionStates.Final);
|
|
8332
8338
|
const taskStr = context.sessionStorageService.getItem('taskToComplete');
|
|
8333
8339
|
if (taskStr) {
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
context.workAllocationService.completeTask(task.id).subscribe(response => {
|
|
8338
|
-
// Emit event can be completed event
|
|
8339
|
-
context.component.eventCanBeCompleted.emit(true);
|
|
8340
|
-
}, error => {
|
|
8341
|
-
// Emit event cannot be completed event
|
|
8342
|
-
context.component.eventCanBeCompleted.emit(false);
|
|
8343
|
-
context.alertService.error(error.message);
|
|
8344
|
-
return throwError(error);
|
|
8345
|
-
});
|
|
8340
|
+
context.sessionStorageService.setItem('assignNeeded', 'false');
|
|
8341
|
+
// just set event can be completed
|
|
8342
|
+
context.component.eventCanBeCompleted.emit(true);
|
|
8346
8343
|
}
|
|
8347
8344
|
else {
|
|
8348
8345
|
// Emit event cannot be completed event
|
|
@@ -8361,18 +8358,8 @@ class EventCompletionStateMachineService {
|
|
|
8361
8358
|
// Get task details
|
|
8362
8359
|
const taskStr = context.sessionStorageService.getItem('taskToComplete');
|
|
8363
8360
|
if (taskStr) {
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
// Assign and complete task
|
|
8367
|
-
context.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
|
|
8368
|
-
// Emit event can be completed event
|
|
8369
|
-
context.component.eventCanBeCompleted.emit(true);
|
|
8370
|
-
}, error => {
|
|
8371
|
-
// Emit event cannot be completed event
|
|
8372
|
-
context.component.eventCanBeCompleted.emit(false);
|
|
8373
|
-
context.alertService.error(error.message);
|
|
8374
|
-
return throwError(error);
|
|
8375
|
-
});
|
|
8361
|
+
context.sessionStorageService.setItem('assignNeeded', 'true');
|
|
8362
|
+
context.component.eventCanBeCompleted.emit(true);
|
|
8376
8363
|
}
|
|
8377
8364
|
else {
|
|
8378
8365
|
// Emit event cannot be completed event
|
|
@@ -8728,7 +8715,7 @@ ValidPageListCaseFieldsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({
|
|
|
8728
8715
|
})();
|
|
8729
8716
|
|
|
8730
8717
|
class CaseEditComponent {
|
|
8731
|
-
constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService) {
|
|
8718
|
+
constructor(fb, caseNotifier, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService, formValueService, formErrorService, loadingService, validPageListCaseFieldsService, workAllocationService) {
|
|
8732
8719
|
this.fb = fb;
|
|
8733
8720
|
this.caseNotifier = caseNotifier;
|
|
8734
8721
|
this.router = router;
|
|
@@ -8743,6 +8730,7 @@ class CaseEditComponent {
|
|
|
8743
8730
|
this.formErrorService = formErrorService;
|
|
8744
8731
|
this.loadingService = loadingService;
|
|
8745
8732
|
this.validPageListCaseFieldsService = validPageListCaseFieldsService;
|
|
8733
|
+
this.workAllocationService = workAllocationService;
|
|
8746
8734
|
this.cancelled = new EventEmitter();
|
|
8747
8735
|
this.submitted = new EventEmitter();
|
|
8748
8736
|
this.isEventCompletionChecksRequired = false;
|
|
@@ -9029,31 +9017,60 @@ class CaseEditComponent {
|
|
|
9029
9017
|
}
|
|
9030
9018
|
caseSubmit({ form, caseEventData, submit }) {
|
|
9031
9019
|
const loadingSpinnerToken = this.loadingService.register();
|
|
9032
|
-
|
|
9033
|
-
|
|
9020
|
+
// keep the initial event response to finalise process after task completion
|
|
9021
|
+
let eventResponse;
|
|
9022
|
+
submit(caseEventData).pipe(switchMap((response) => {
|
|
9023
|
+
eventResponse = response;
|
|
9024
|
+
return this.postCompleteTaskIfRequired();
|
|
9025
|
+
}), finalize(() => {
|
|
9034
9026
|
this.loadingService.unregister(loadingSpinnerToken);
|
|
9035
9027
|
}))
|
|
9036
|
-
.subscribe(
|
|
9037
|
-
this.
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
this.
|
|
9028
|
+
.subscribe(() => {
|
|
9029
|
+
this.finishEventCompletionLogic(eventResponse);
|
|
9030
|
+
}, error => {
|
|
9031
|
+
if (!eventResponse) {
|
|
9032
|
+
// event submission error
|
|
9033
|
+
this.error = error;
|
|
9034
|
+
this.callbackErrorsSubject.next(error);
|
|
9035
|
+
/* istanbul ignore else */
|
|
9036
|
+
if (this.error.details) {
|
|
9037
|
+
this.formErrorService
|
|
9038
|
+
.mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
|
|
9039
|
+
}
|
|
9040
|
+
this.isSubmitting = false;
|
|
9042
9041
|
}
|
|
9043
9042
|
else {
|
|
9044
|
-
|
|
9043
|
+
// task assignment/completion error - handled within workallocation service
|
|
9044
|
+
// could set task to be deleted (or completed later)?
|
|
9045
|
+
// note: think error messages only shown if user is caseworker - might reqauire changing
|
|
9046
|
+
this.finishEventCompletionLogic(eventResponse);
|
|
9045
9047
|
}
|
|
9046
|
-
}, error => {
|
|
9047
|
-
this.error = error;
|
|
9048
|
-
this.callbackErrorsSubject.next(error);
|
|
9049
|
-
/* istanbul ignore else */
|
|
9050
|
-
if (this.error.details) {
|
|
9051
|
-
this.formErrorService
|
|
9052
|
-
.mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
|
|
9053
|
-
}
|
|
9054
|
-
this.isSubmitting = false;
|
|
9055
9048
|
});
|
|
9056
9049
|
}
|
|
9050
|
+
postCompleteTaskIfRequired() {
|
|
9051
|
+
const taskStr = this.sessionStorageService.getItem('taskToComplete');
|
|
9052
|
+
const assignNeeded = this.sessionStorageService.getItem('assignNeeded') === 'true';
|
|
9053
|
+
if (taskStr && assignNeeded) {
|
|
9054
|
+
const task = JSON.parse(taskStr);
|
|
9055
|
+
return this.workAllocationService.assignAndCompleteTask(task.id);
|
|
9056
|
+
}
|
|
9057
|
+
else if (taskStr) {
|
|
9058
|
+
const task = JSON.parse(taskStr);
|
|
9059
|
+
return this.workAllocationService.completeTask(task.id);
|
|
9060
|
+
}
|
|
9061
|
+
return of(true);
|
|
9062
|
+
}
|
|
9063
|
+
finishEventCompletionLogic(eventResponse) {
|
|
9064
|
+
this.caseNotifier.cachedCaseView = null;
|
|
9065
|
+
this.sessionStorageService.removeItem('eventUrl');
|
|
9066
|
+
const confirmation = this.buildConfirmation(eventResponse);
|
|
9067
|
+
if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
|
|
9068
|
+
this.confirm(confirmation);
|
|
9069
|
+
}
|
|
9070
|
+
else {
|
|
9071
|
+
this.emitSubmitted(eventResponse);
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
9057
9074
|
buildConfirmation(response) {
|
|
9058
9075
|
if (response['after_submit_callback_response']) {
|
|
9059
9076
|
return new Confirmation(response['id'], response['callback_response_status'], response['after_submit_callback_response']['confirmation_header'], response['after_submit_callback_response']['confirmation_body']);
|
|
@@ -9082,7 +9099,7 @@ class CaseEditComponent {
|
|
|
9082
9099
|
}
|
|
9083
9100
|
CaseEditComponent.ORIGIN_QUERY_PARAM = 'origin';
|
|
9084
9101
|
CaseEditComponent.ALERT_MESSAGE = 'Page is being refreshed so you will be redirected to the first page of this event.';
|
|
9085
|
-
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)); };
|
|
9102
|
+
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)); };
|
|
9086
9103
|
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) {
|
|
9087
9104
|
if (rf & 1) {
|
|
9088
9105
|
i0.ɵɵelement(0, "router-outlet");
|
|
@@ -9092,7 +9109,7 @@ CaseEditComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEditC
|
|
|
9092
9109
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditComponent, [{
|
|
9093
9110
|
type: Component,
|
|
9094
9111
|
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"] }]
|
|
9095
|
-
}], 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: [{
|
|
9112
|
+
}], 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: [{
|
|
9096
9113
|
type: Input
|
|
9097
9114
|
}], submit: [{
|
|
9098
9115
|
type: Input
|
|
@@ -12686,7 +12703,9 @@ class FieldsFilterPipe {
|
|
|
12686
12703
|
.filter(f => keepEmpty || FieldsFilterPipe.keepField(f))
|
|
12687
12704
|
.map(f => {
|
|
12688
12705
|
if (!f.display_context) {
|
|
12689
|
-
|
|
12706
|
+
if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
|
|
12707
|
+
f.display_context = complexField.display_context;
|
|
12708
|
+
}
|
|
12690
12709
|
}
|
|
12691
12710
|
return f;
|
|
12692
12711
|
});
|
|
@@ -13347,19 +13366,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
|
|
|
13347
13366
|
if (0 === error.status || 502 === error.status) {
|
|
13348
13367
|
return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
|
|
13349
13368
|
}
|
|
13350
|
-
|
|
13351
|
-
if (error && (error === null || error === void 0 ? void 0 : error.error)) {
|
|
13352
|
-
const fullError = error.error;
|
|
13353
|
-
const start = fullError.indexOf('{');
|
|
13354
|
-
if (start >= 0) {
|
|
13355
|
-
const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
|
|
13356
|
-
const obj = JSON.parse(json);
|
|
13357
|
-
if (obj && (obj === null || obj === void 0 ? void 0 : obj.error)) {
|
|
13358
|
-
errorMsg = obj.error;
|
|
13359
|
-
}
|
|
13360
|
-
}
|
|
13361
|
-
}
|
|
13362
|
-
return errorMsg;
|
|
13369
|
+
return error.error;
|
|
13363
13370
|
}
|
|
13364
13371
|
buildDocumentUploadData(selectedFile) {
|
|
13365
13372
|
const documentUpload = new FormData();
|
|
@@ -23735,7 +23742,9 @@ class ReadFieldsFilterPipe {
|
|
|
23735
23742
|
})
|
|
23736
23743
|
.map(f => {
|
|
23737
23744
|
if (!f.display_context) {
|
|
23738
|
-
|
|
23745
|
+
if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
|
|
23746
|
+
f.display_context = complexField.display_context;
|
|
23747
|
+
}
|
|
23739
23748
|
}
|
|
23740
23749
|
if (setupHidden) {
|
|
23741
23750
|
ReadFieldsFilterPipe.evaluateConditionalShow(f, checkConditionalShowAgainst, path, formGroupAvailable, complexField.id);
|
|
@@ -25591,18 +25600,9 @@ class CaseEventCompletionTaskReassignedComponent {
|
|
|
25591
25600
|
// Get task details
|
|
25592
25601
|
const taskStr = this.sessionStorageService.getItem('taskToComplete');
|
|
25593
25602
|
if (taskStr) {
|
|
25594
|
-
|
|
25595
|
-
|
|
25596
|
-
|
|
25597
|
-
this.subscription = this.workAllocationService.assignAndCompleteTask(task.id).subscribe(response => {
|
|
25598
|
-
// Emit event can be completed event
|
|
25599
|
-
this.parentComponent.eventCanBeCompleted.emit(true);
|
|
25600
|
-
}, error => {
|
|
25601
|
-
// Emit event cannot be completed event
|
|
25602
|
-
this.parentComponent.eventCanBeCompleted.emit(false);
|
|
25603
|
-
this.alertService.error(error.message);
|
|
25604
|
-
return throwError(error);
|
|
25605
|
-
});
|
|
25603
|
+
this.sessionStorageService.setItem('assignNeeded', 'true');
|
|
25604
|
+
// set event can be completed to true
|
|
25605
|
+
this.parentComponent.eventCanBeCompleted.emit(true);
|
|
25606
25606
|
}
|
|
25607
25607
|
else {
|
|
25608
25608
|
// Emit event cannot be completed event
|