@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
|
@@ -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,57 @@ 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(
|
|
9028
|
+
.subscribe(() => {
|
|
9037
9029
|
this.caseNotifier.cachedCaseView = null;
|
|
9038
9030
|
this.sessionStorageService.removeItem('eventUrl');
|
|
9039
|
-
const confirmation = this.buildConfirmation(
|
|
9031
|
+
const confirmation = this.buildConfirmation(eventResponse);
|
|
9040
9032
|
if (confirmation && (confirmation.getHeader() || confirmation.getBody())) {
|
|
9041
9033
|
this.confirm(confirmation);
|
|
9042
9034
|
}
|
|
9043
9035
|
else {
|
|
9044
|
-
this.emitSubmitted(
|
|
9036
|
+
this.emitSubmitted(eventResponse);
|
|
9045
9037
|
}
|
|
9046
9038
|
}, error => {
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9039
|
+
if (!eventResponse) {
|
|
9040
|
+
// event submission error
|
|
9041
|
+
this.error = error;
|
|
9042
|
+
this.callbackErrorsSubject.next(error);
|
|
9043
|
+
/* istanbul ignore else */
|
|
9044
|
+
if (this.error.details) {
|
|
9045
|
+
this.formErrorService
|
|
9046
|
+
.mapFieldErrors(this.error.details.field_errors, form.controls['data'], 'validation');
|
|
9047
|
+
}
|
|
9048
|
+
this.isSubmitting = false;
|
|
9049
|
+
}
|
|
9050
|
+
else {
|
|
9051
|
+
// task assignment/completion error - handled within workallocation service
|
|
9052
|
+
// could set task to be deleted (or completed later)?
|
|
9053
|
+
// note: think error messages only shown if user is caseworker - might reqauire changing
|
|
9054
|
+
this.router.navigate([`/cases/case-details/${this.getCaseId(this.caseDetails)}/tasks`], { relativeTo: this.route });
|
|
9053
9055
|
}
|
|
9054
|
-
this.isSubmitting = false;
|
|
9055
9056
|
});
|
|
9056
9057
|
}
|
|
9058
|
+
postCompleteTaskIfRequired() {
|
|
9059
|
+
const taskStr = this.sessionStorageService.getItem('taskToComplete');
|
|
9060
|
+
const assignNeeded = this.sessionStorageService.getItem('assignNeeded') === 'true';
|
|
9061
|
+
if (taskStr && assignNeeded) {
|
|
9062
|
+
const task = JSON.parse(taskStr);
|
|
9063
|
+
return this.workAllocationService.assignAndCompleteTask(task.id);
|
|
9064
|
+
}
|
|
9065
|
+
else if (taskStr) {
|
|
9066
|
+
const task = JSON.parse(taskStr);
|
|
9067
|
+
return this.workAllocationService.completeTask(task.id);
|
|
9068
|
+
}
|
|
9069
|
+
return of(true);
|
|
9070
|
+
}
|
|
9057
9071
|
buildConfirmation(response) {
|
|
9058
9072
|
if (response['after_submit_callback_response']) {
|
|
9059
9073
|
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 +9096,7 @@ class CaseEditComponent {
|
|
|
9082
9096
|
}
|
|
9083
9097
|
CaseEditComponent.ORIGIN_QUERY_PARAM = 'origin';
|
|
9084
9098
|
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)); };
|
|
9099
|
+
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
9100
|
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
9101
|
if (rf & 1) {
|
|
9088
9102
|
i0.ɵɵelement(0, "router-outlet");
|
|
@@ -9092,7 +9106,7 @@ CaseEditComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseEditC
|
|
|
9092
9106
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseEditComponent, [{
|
|
9093
9107
|
type: Component,
|
|
9094
9108
|
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: [{
|
|
9109
|
+
}], 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
9110
|
type: Input
|
|
9097
9111
|
}], submit: [{
|
|
9098
9112
|
type: Input
|
|
@@ -12686,7 +12700,9 @@ class FieldsFilterPipe {
|
|
|
12686
12700
|
.filter(f => keepEmpty || FieldsFilterPipe.keepField(f))
|
|
12687
12701
|
.map(f => {
|
|
12688
12702
|
if (!f.display_context) {
|
|
12689
|
-
|
|
12703
|
+
if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
|
|
12704
|
+
f.display_context = complexField.display_context;
|
|
12705
|
+
}
|
|
12690
12706
|
}
|
|
12691
12707
|
return f;
|
|
12692
12708
|
});
|
|
@@ -13347,19 +13363,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
|
|
|
13347
13363
|
if (0 === error.status || 502 === error.status) {
|
|
13348
13364
|
return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
|
|
13349
13365
|
}
|
|
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;
|
|
13366
|
+
return error.error;
|
|
13363
13367
|
}
|
|
13364
13368
|
buildDocumentUploadData(selectedFile) {
|
|
13365
13369
|
const documentUpload = new FormData();
|
|
@@ -23735,7 +23739,9 @@ class ReadFieldsFilterPipe {
|
|
|
23735
23739
|
})
|
|
23736
23740
|
.map(f => {
|
|
23737
23741
|
if (!f.display_context) {
|
|
23738
|
-
|
|
23742
|
+
if (FieldsUtils.isValidDisplayContext(complexField.display_context)) {
|
|
23743
|
+
f.display_context = complexField.display_context;
|
|
23744
|
+
}
|
|
23739
23745
|
}
|
|
23740
23746
|
if (setupHidden) {
|
|
23741
23747
|
ReadFieldsFilterPipe.evaluateConditionalShow(f, checkConditionalShowAgainst, path, formGroupAvailable, complexField.id);
|
|
@@ -25591,18 +25597,9 @@ class CaseEventCompletionTaskReassignedComponent {
|
|
|
25591
25597
|
// Get task details
|
|
25592
25598
|
const taskStr = this.sessionStorageService.getItem('taskToComplete');
|
|
25593
25599
|
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
|
-
});
|
|
25600
|
+
this.sessionStorageService.setItem('assignNeeded', 'true');
|
|
25601
|
+
// set event can be completed to true
|
|
25602
|
+
this.parentComponent.eventCanBeCompleted.emit(true);
|
|
25606
25603
|
}
|
|
25607
25604
|
else {
|
|
25608
25605
|
// Emit event cannot be completed event
|