@hmcts/ccd-case-ui-toolkit 6.13.10-g-eui-4157-c → 6.13.10-linked-cases-continue-button-validation-v4
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/RELEASE-NOTES.md +3 -0
- package/dist/ccd-case-ui-toolkit/bundles/hmcts-ccd-case-ui-toolkit.umd.js +279 -312
- package/dist/ccd-case-ui-toolkit/bundles/hmcts-ccd-case-ui-toolkit.umd.js.map +1 -1
- package/dist/ccd-case-ui-toolkit/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js +1 -1
- package/dist/ccd-case-ui-toolkit/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js.map +1 -1
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/commons/case-edit-data/case-edit-data.service.js +5 -8
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.js +21 -3
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/components/case-editor/services/cases.service.js +7 -4
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/components/palette/linked-cases/domain/linked-cases-state.model.js +1 -1
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.js +36 -86
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/components/palette/palette.module.js +2 -2
- package/dist/ccd-case-ui-toolkit/esm2015/lib/shared/services/fields/fields.utils.js +8 -1
- package/dist/ccd-case-ui-toolkit/fesm2015/hmcts-ccd-case-ui-toolkit.js +271 -298
- package/dist/ccd-case-ui-toolkit/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/commons/case-edit-data/case-edit-data.service.d.ts +3 -5
- package/dist/ccd-case-ui-toolkit/lib/shared/commons/case-edit-data/case-edit-data.service.d.ts.map +1 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts +2 -0
- package/dist/ccd-case-ui-toolkit/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/components/case-editor/services/cases.service.d.ts +3 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/components/case-editor/services/cases.service.d.ts.map +1 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/components/palette/linked-cases/domain/linked-cases-state.model.d.ts +0 -4
- package/dist/ccd-case-ui-toolkit/lib/shared/components/palette/linked-cases/domain/linked-cases-state.model.d.ts.map +1 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.d.ts +0 -4
- package/dist/ccd-case-ui-toolkit/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.d.ts.map +1 -1
- package/dist/ccd-case-ui-toolkit/lib/shared/services/fields/fields.utils.d.ts +2 -0
- package/dist/ccd-case-ui-toolkit/lib/shared/services/fields/fields.utils.d.ts.map +1 -1
- package/dist/ccd-case-ui-toolkit/package.json +1 -1
- package/package.json +1 -1
- package/projects/ccd-case-ui-toolkit/package.json +1 -1
- package/projects/ccd-case-ui-toolkit/src/lib/shared/commons/case-edit-data/case-edit-data.service.ts +4 -9
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts +21 -2
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/cases.service.spec.ts +1 -1
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/cases.service.ts +1 -0
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/domain/linked-cases-state.model.ts +0 -5
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.html +0 -13
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.spec.ts +4 -19
- package/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.ts +8 -31
- package/projects/ccd-case-ui-toolkit/src/lib/shared/services/fields/fields.utils.spec.ts +44 -0
- package/projects/ccd-case-ui-toolkit/src/lib/shared/services/fields/fields.utils.ts +10 -1
|
@@ -3474,6 +3474,13 @@ class FieldsUtils {
|
|
|
3474
3474
|
}
|
|
3475
3475
|
return caseField.field_type.type === 'ComponentLauncher';
|
|
3476
3476
|
}
|
|
3477
|
+
static isLinkedCasesCaseField(caseField) {
|
|
3478
|
+
return FieldsUtils.isComponentLauncherCaseField(caseField) &&
|
|
3479
|
+
caseField.id === 'LinkedCasesComponentLauncher';
|
|
3480
|
+
}
|
|
3481
|
+
static containsLinkedCasesCaseField(caseFields) {
|
|
3482
|
+
return caseFields === null || caseFields === void 0 ? void 0 : caseFields.some(caseField => FieldsUtils.isLinkedCasesCaseField(caseField));
|
|
3483
|
+
}
|
|
3477
3484
|
static isFlagsFieldType(fieldType) {
|
|
3478
3485
|
if (!fieldType) {
|
|
3479
3486
|
return false;
|
|
@@ -7210,13 +7217,215 @@ WizardPageFieldToCaseFieldMapper.ɵprov = i0.ɵɵdefineInjectable({ token: Wizar
|
|
|
7210
7217
|
}]
|
|
7211
7218
|
}], null, null); })();
|
|
7212
7219
|
|
|
7220
|
+
const MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
7221
|
+
class WorkAllocationService {
|
|
7222
|
+
constructor(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
7223
|
+
this.http = http;
|
|
7224
|
+
this.appConfig = appConfig;
|
|
7225
|
+
this.errorService = errorService;
|
|
7226
|
+
this.alertService = alertService;
|
|
7227
|
+
this.sessionStorageService = sessionStorageService;
|
|
7228
|
+
// Check to see if work allocation is enabled
|
|
7229
|
+
}
|
|
7230
|
+
/**
|
|
7231
|
+
* Call the API to get tasks matching the search criteria.
|
|
7232
|
+
* @param searchRequest The search parameters that specify which tasks to match.
|
|
7233
|
+
*/
|
|
7234
|
+
searchTasks(searchRequest) {
|
|
7235
|
+
// Do not need to check if WA enabled as parent method will do that
|
|
7236
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/searchForCompletable`;
|
|
7237
|
+
return this.http
|
|
7238
|
+
.post(url, { searchRequest }, null, false)
|
|
7239
|
+
.pipe(map(response => response), catchError(error => {
|
|
7240
|
+
this.errorService.setError(error);
|
|
7241
|
+
// explicitly eat away 401 error and 400 error
|
|
7242
|
+
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
7243
|
+
// do nothing
|
|
7244
|
+
console.log('error status 401 or 400', error);
|
|
7245
|
+
}
|
|
7246
|
+
else {
|
|
7247
|
+
return throwError(error);
|
|
7248
|
+
}
|
|
7249
|
+
}));
|
|
7250
|
+
}
|
|
7251
|
+
isWAEnabled(jurisdiction, caseType) {
|
|
7252
|
+
this.features = this.appConfig.getWAServiceConfig();
|
|
7253
|
+
let enabled = false;
|
|
7254
|
+
if (!jurisdiction || !caseType) {
|
|
7255
|
+
const caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
7256
|
+
jurisdiction = caseInfo.jurisdiction;
|
|
7257
|
+
caseType = caseInfo.caseType;
|
|
7258
|
+
}
|
|
7259
|
+
if (!this.features || !this.features.configurations) {
|
|
7260
|
+
return false;
|
|
7261
|
+
}
|
|
7262
|
+
this.features.configurations.forEach(serviceConfig => {
|
|
7263
|
+
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
7264
|
+
enabled = true;
|
|
7265
|
+
}
|
|
7266
|
+
});
|
|
7267
|
+
return enabled;
|
|
7268
|
+
}
|
|
7269
|
+
/**
|
|
7270
|
+
* Call the API to assign a task.
|
|
7271
|
+
* @param taskId specifies which task should be assigned.
|
|
7272
|
+
* @param userId specifies the user the task should be assigned to.
|
|
7273
|
+
*/
|
|
7274
|
+
assignTask(taskId, userId) {
|
|
7275
|
+
if (!this.isWAEnabled()) {
|
|
7276
|
+
return of(null);
|
|
7277
|
+
}
|
|
7278
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/assign`;
|
|
7279
|
+
return this.http
|
|
7280
|
+
.post(url, { userId })
|
|
7281
|
+
.pipe(catchError(error => {
|
|
7282
|
+
this.errorService.setError(error);
|
|
7283
|
+
return throwError(error);
|
|
7284
|
+
}));
|
|
7285
|
+
}
|
|
7286
|
+
/**
|
|
7287
|
+
* Call the API to complete a task.
|
|
7288
|
+
* @param taskId specifies which task should be completed.
|
|
7289
|
+
*/
|
|
7290
|
+
completeTask(taskId) {
|
|
7291
|
+
if (!this.isWAEnabled()) {
|
|
7292
|
+
return of(null);
|
|
7293
|
+
}
|
|
7294
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
7295
|
+
return this.http
|
|
7296
|
+
.post(url, {})
|
|
7297
|
+
.pipe(catchError(error => {
|
|
7298
|
+
this.errorService.setError(error);
|
|
7299
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
7300
|
+
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
7301
|
+
this.handleTaskCompletionError(response);
|
|
7302
|
+
});
|
|
7303
|
+
return throwError(error);
|
|
7304
|
+
}));
|
|
7305
|
+
}
|
|
7306
|
+
/**
|
|
7307
|
+
* Call the API to assign and complete a task.
|
|
7308
|
+
* @param taskId specifies which task should be completed.
|
|
7309
|
+
*/
|
|
7310
|
+
assignAndCompleteTask(taskId) {
|
|
7311
|
+
if (!this.isWAEnabled()) {
|
|
7312
|
+
return of(null);
|
|
7313
|
+
}
|
|
7314
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
7315
|
+
return this.http
|
|
7316
|
+
.post(url, {
|
|
7317
|
+
completion_options: {
|
|
7318
|
+
assign_and_complete: true
|
|
7319
|
+
}
|
|
7320
|
+
})
|
|
7321
|
+
.pipe(catchError(error => {
|
|
7322
|
+
this.errorService.setError(error);
|
|
7323
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
7324
|
+
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
7325
|
+
this.handleTaskCompletionError(response);
|
|
7326
|
+
});
|
|
7327
|
+
return throwError(error);
|
|
7328
|
+
}));
|
|
7329
|
+
}
|
|
7330
|
+
/**
|
|
7331
|
+
* Handles the response from the observable to get the user details when task is completed.
|
|
7332
|
+
* @param response is the response given from the observable which contains the user detaild.
|
|
7333
|
+
*/
|
|
7334
|
+
handleTaskCompletionError(response) {
|
|
7335
|
+
const userDetails = response;
|
|
7336
|
+
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
7337
|
+
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
7338
|
+
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
7339
|
+
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
7340
|
+
}
|
|
7341
|
+
}
|
|
7342
|
+
/**
|
|
7343
|
+
* Returns true if the user's role is equivalent to a caseworker.
|
|
7344
|
+
* @param roles is the list of roles found from the current user.
|
|
7345
|
+
*/
|
|
7346
|
+
userIsCaseworker(roles) {
|
|
7347
|
+
const lowerCaseRoles = roles.map(role => role.toLowerCase());
|
|
7348
|
+
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
7349
|
+
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
7350
|
+
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
7351
|
+
}
|
|
7352
|
+
/**
|
|
7353
|
+
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
7354
|
+
* 1. No tasks found => Success.
|
|
7355
|
+
* 2. One task found => Mark as done => Success.
|
|
7356
|
+
* 3. One task found => Mark as done throws error => Failure.
|
|
7357
|
+
* 4. More than one task found => Failure.
|
|
7358
|
+
* 5. Search call throws an error => Failure.
|
|
7359
|
+
* @param ccdId The ID of the case to find tasks for.
|
|
7360
|
+
* @param eventId The ID of the event to find tasks for.
|
|
7361
|
+
*/
|
|
7362
|
+
completeAppropriateTask(ccdId, eventId, jurisdiction, caseTypeId) {
|
|
7363
|
+
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
7364
|
+
return of(null);
|
|
7365
|
+
}
|
|
7366
|
+
const taskSearchParameter = {
|
|
7367
|
+
ccdId,
|
|
7368
|
+
eventId,
|
|
7369
|
+
jurisdiction,
|
|
7370
|
+
caseTypeId
|
|
7371
|
+
};
|
|
7372
|
+
return this.searchTasks(taskSearchParameter)
|
|
7373
|
+
.pipe(map((response) => {
|
|
7374
|
+
const tasks = response.tasks;
|
|
7375
|
+
if (tasks && tasks.length > 0) {
|
|
7376
|
+
if (tasks.length === 1) {
|
|
7377
|
+
this.completeTask(tasks[0].id).subscribe();
|
|
7378
|
+
}
|
|
7379
|
+
else {
|
|
7380
|
+
// This is a problem. Throw an appropriate error.
|
|
7381
|
+
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
7382
|
+
}
|
|
7383
|
+
}
|
|
7384
|
+
return true; // All good. Nothing to see here.
|
|
7385
|
+
}), catchError(error => {
|
|
7386
|
+
// Simply rethrow it.
|
|
7387
|
+
return throwError(error);
|
|
7388
|
+
}));
|
|
7389
|
+
}
|
|
7390
|
+
/**
|
|
7391
|
+
* Return tasks for case and event.
|
|
7392
|
+
*/
|
|
7393
|
+
getTasksByCaseIdAndEventId(eventId, caseId, caseType, jurisdiction) {
|
|
7394
|
+
const defaultPayload = {
|
|
7395
|
+
task_required_for_event: false,
|
|
7396
|
+
tasks: []
|
|
7397
|
+
};
|
|
7398
|
+
if (!this.isWAEnabled()) {
|
|
7399
|
+
return of(defaultPayload);
|
|
7400
|
+
}
|
|
7401
|
+
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/case/tasks/${caseId}/event/${eventId}/caseType/${caseType}/jurisdiction/${jurisdiction}`);
|
|
7402
|
+
}
|
|
7403
|
+
/**
|
|
7404
|
+
* Call the API to get a task
|
|
7405
|
+
*/
|
|
7406
|
+
getTask(taskId) {
|
|
7407
|
+
if (!this.isWAEnabled()) {
|
|
7408
|
+
return of({ task: null });
|
|
7409
|
+
}
|
|
7410
|
+
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}`);
|
|
7411
|
+
}
|
|
7412
|
+
}
|
|
7413
|
+
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
7414
|
+
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
7415
|
+
WorkAllocationService.ɵfac = function WorkAllocationService_Factory(t) { return new (t || WorkAllocationService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig), i0.ɵɵinject(HttpErrorService), i0.ɵɵinject(AlertService), i0.ɵɵinject(SessionStorageService)); };
|
|
7416
|
+
WorkAllocationService.ɵprov = i0.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
7417
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WorkAllocationService, [{
|
|
7418
|
+
type: Injectable
|
|
7419
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null); })();
|
|
7420
|
+
|
|
7213
7421
|
class CasesService {
|
|
7214
|
-
constructor(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
|
|
7422
|
+
constructor(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, workAllocationService, loadingService, sessionStorageService) {
|
|
7215
7423
|
this.http = http;
|
|
7216
7424
|
this.appConfig = appConfig;
|
|
7217
7425
|
this.orderService = orderService;
|
|
7218
7426
|
this.errorService = errorService;
|
|
7219
7427
|
this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
|
|
7428
|
+
this.workAllocationService = workAllocationService;
|
|
7220
7429
|
this.loadingService = loadingService;
|
|
7221
7430
|
this.sessionStorageService = sessionStorageService;
|
|
7222
7431
|
this.get = this.getCaseView;
|
|
@@ -7442,11 +7651,11 @@ CasesService.V2_MEDIATYPE_CASE_DATA_VALIDATE = 'application/vnd.uk.gov.hmcts.ccd
|
|
|
7442
7651
|
CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
|
|
7443
7652
|
CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
|
|
7444
7653
|
CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
|
|
7445
|
-
CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig), i0.ɵɵinject(OrderService), i0.ɵɵinject(HttpErrorService), i0.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0.ɵɵinject(LoadingService), i0.ɵɵinject(SessionStorageService)); };
|
|
7654
|
+
CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig), i0.ɵɵinject(OrderService), i0.ɵɵinject(HttpErrorService), i0.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0.ɵɵinject(WorkAllocationService), i0.ɵɵinject(LoadingService), i0.ɵɵinject(SessionStorageService)); };
|
|
7446
7655
|
CasesService.ɵprov = i0.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
|
|
7447
7656
|
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CasesService, [{
|
|
7448
7657
|
type: Injectable
|
|
7449
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null); })();
|
|
7658
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: WorkAllocationService }, { type: LoadingService }, { type: SessionStorageService }]; }, null); })();
|
|
7450
7659
|
|
|
7451
7660
|
class EventTriggerService {
|
|
7452
7661
|
constructor() {
|
|
@@ -8049,207 +8258,6 @@ PageValidationService.ɵprov = i0.ɵɵdefineInjectable({ token: PageValidationSe
|
|
|
8049
8258
|
type: Injectable
|
|
8050
8259
|
}], function () { return [{ type: CaseFieldService }]; }, null); })();
|
|
8051
8260
|
|
|
8052
|
-
const MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
8053
|
-
class WorkAllocationService {
|
|
8054
|
-
constructor(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
8055
|
-
this.http = http;
|
|
8056
|
-
this.appConfig = appConfig;
|
|
8057
|
-
this.errorService = errorService;
|
|
8058
|
-
this.alertService = alertService;
|
|
8059
|
-
this.sessionStorageService = sessionStorageService;
|
|
8060
|
-
// Check to see if work allocation is enabled
|
|
8061
|
-
}
|
|
8062
|
-
/**
|
|
8063
|
-
* Call the API to get tasks matching the search criteria.
|
|
8064
|
-
* @param searchRequest The search parameters that specify which tasks to match.
|
|
8065
|
-
*/
|
|
8066
|
-
searchTasks(searchRequest) {
|
|
8067
|
-
// Do not need to check if WA enabled as parent method will do that
|
|
8068
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/searchForCompletable`;
|
|
8069
|
-
return this.http
|
|
8070
|
-
.post(url, { searchRequest }, null, false)
|
|
8071
|
-
.pipe(map(response => response), catchError(error => {
|
|
8072
|
-
this.errorService.setError(error);
|
|
8073
|
-
// explicitly eat away 401 error and 400 error
|
|
8074
|
-
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
8075
|
-
// do nothing
|
|
8076
|
-
console.log('error status 401 or 400', error);
|
|
8077
|
-
}
|
|
8078
|
-
else {
|
|
8079
|
-
return throwError(error);
|
|
8080
|
-
}
|
|
8081
|
-
}));
|
|
8082
|
-
}
|
|
8083
|
-
isWAEnabled(jurisdiction, caseType) {
|
|
8084
|
-
this.features = this.appConfig.getWAServiceConfig();
|
|
8085
|
-
let enabled = false;
|
|
8086
|
-
if (!jurisdiction || !caseType) {
|
|
8087
|
-
const caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
8088
|
-
jurisdiction = caseInfo.jurisdiction;
|
|
8089
|
-
caseType = caseInfo.caseType;
|
|
8090
|
-
}
|
|
8091
|
-
if (!this.features || !this.features.configurations) {
|
|
8092
|
-
return false;
|
|
8093
|
-
}
|
|
8094
|
-
this.features.configurations.forEach(serviceConfig => {
|
|
8095
|
-
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
8096
|
-
enabled = true;
|
|
8097
|
-
}
|
|
8098
|
-
});
|
|
8099
|
-
return enabled;
|
|
8100
|
-
}
|
|
8101
|
-
/**
|
|
8102
|
-
* Call the API to assign a task.
|
|
8103
|
-
* @param taskId specifies which task should be assigned.
|
|
8104
|
-
* @param userId specifies the user the task should be assigned to.
|
|
8105
|
-
*/
|
|
8106
|
-
assignTask(taskId, userId) {
|
|
8107
|
-
if (!this.isWAEnabled()) {
|
|
8108
|
-
return of(null);
|
|
8109
|
-
}
|
|
8110
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/assign`;
|
|
8111
|
-
return this.http
|
|
8112
|
-
.post(url, { userId })
|
|
8113
|
-
.pipe(catchError(error => {
|
|
8114
|
-
this.errorService.setError(error);
|
|
8115
|
-
return throwError(error);
|
|
8116
|
-
}));
|
|
8117
|
-
}
|
|
8118
|
-
/**
|
|
8119
|
-
* Call the API to complete a task.
|
|
8120
|
-
* @param taskId specifies which task should be completed.
|
|
8121
|
-
*/
|
|
8122
|
-
completeTask(taskId) {
|
|
8123
|
-
if (!this.isWAEnabled()) {
|
|
8124
|
-
return of(null);
|
|
8125
|
-
}
|
|
8126
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
8127
|
-
return this.http
|
|
8128
|
-
.post(url, {})
|
|
8129
|
-
.pipe(catchError(error => {
|
|
8130
|
-
this.errorService.setError(error);
|
|
8131
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
8132
|
-
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
8133
|
-
this.handleTaskCompletionError(response);
|
|
8134
|
-
});
|
|
8135
|
-
return throwError(error);
|
|
8136
|
-
}));
|
|
8137
|
-
}
|
|
8138
|
-
/**
|
|
8139
|
-
* Call the API to assign and complete a task.
|
|
8140
|
-
* @param taskId specifies which task should be completed.
|
|
8141
|
-
*/
|
|
8142
|
-
assignAndCompleteTask(taskId) {
|
|
8143
|
-
if (!this.isWAEnabled()) {
|
|
8144
|
-
return of(null);
|
|
8145
|
-
}
|
|
8146
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
8147
|
-
return this.http
|
|
8148
|
-
.post(url, {
|
|
8149
|
-
completion_options: {
|
|
8150
|
-
assign_and_complete: true
|
|
8151
|
-
}
|
|
8152
|
-
})
|
|
8153
|
-
.pipe(catchError(error => {
|
|
8154
|
-
this.errorService.setError(error);
|
|
8155
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
8156
|
-
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
8157
|
-
this.handleTaskCompletionError(response);
|
|
8158
|
-
});
|
|
8159
|
-
return throwError(error);
|
|
8160
|
-
}));
|
|
8161
|
-
}
|
|
8162
|
-
/**
|
|
8163
|
-
* Handles the response from the observable to get the user details when task is completed.
|
|
8164
|
-
* @param response is the response given from the observable which contains the user detaild.
|
|
8165
|
-
*/
|
|
8166
|
-
handleTaskCompletionError(response) {
|
|
8167
|
-
const userDetails = response;
|
|
8168
|
-
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
8169
|
-
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
8170
|
-
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
8171
|
-
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
8172
|
-
}
|
|
8173
|
-
}
|
|
8174
|
-
/**
|
|
8175
|
-
* Returns true if the user's role is equivalent to a caseworker.
|
|
8176
|
-
* @param roles is the list of roles found from the current user.
|
|
8177
|
-
*/
|
|
8178
|
-
userIsCaseworker(roles) {
|
|
8179
|
-
const lowerCaseRoles = roles.map(role => role.toLowerCase());
|
|
8180
|
-
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
8181
|
-
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
8182
|
-
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
8183
|
-
}
|
|
8184
|
-
/**
|
|
8185
|
-
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
8186
|
-
* 1. No tasks found => Success.
|
|
8187
|
-
* 2. One task found => Mark as done => Success.
|
|
8188
|
-
* 3. One task found => Mark as done throws error => Failure.
|
|
8189
|
-
* 4. More than one task found => Failure.
|
|
8190
|
-
* 5. Search call throws an error => Failure.
|
|
8191
|
-
* @param ccdId The ID of the case to find tasks for.
|
|
8192
|
-
* @param eventId The ID of the event to find tasks for.
|
|
8193
|
-
*/
|
|
8194
|
-
completeAppropriateTask(ccdId, eventId, jurisdiction, caseTypeId) {
|
|
8195
|
-
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
8196
|
-
return of(null);
|
|
8197
|
-
}
|
|
8198
|
-
const taskSearchParameter = {
|
|
8199
|
-
ccdId,
|
|
8200
|
-
eventId,
|
|
8201
|
-
jurisdiction,
|
|
8202
|
-
caseTypeId
|
|
8203
|
-
};
|
|
8204
|
-
return this.searchTasks(taskSearchParameter)
|
|
8205
|
-
.pipe(map((response) => {
|
|
8206
|
-
const tasks = response.tasks;
|
|
8207
|
-
if (tasks && tasks.length > 0) {
|
|
8208
|
-
if (tasks.length === 1) {
|
|
8209
|
-
this.completeTask(tasks[0].id).subscribe();
|
|
8210
|
-
}
|
|
8211
|
-
else {
|
|
8212
|
-
// This is a problem. Throw an appropriate error.
|
|
8213
|
-
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
8214
|
-
}
|
|
8215
|
-
}
|
|
8216
|
-
return true; // All good. Nothing to see here.
|
|
8217
|
-
}), catchError(error => {
|
|
8218
|
-
// Simply rethrow it.
|
|
8219
|
-
return throwError(error);
|
|
8220
|
-
}));
|
|
8221
|
-
}
|
|
8222
|
-
/**
|
|
8223
|
-
* Return tasks for case and event.
|
|
8224
|
-
*/
|
|
8225
|
-
getTasksByCaseIdAndEventId(eventId, caseId, caseType, jurisdiction) {
|
|
8226
|
-
const defaultPayload = {
|
|
8227
|
-
task_required_for_event: false,
|
|
8228
|
-
tasks: []
|
|
8229
|
-
};
|
|
8230
|
-
if (!this.isWAEnabled()) {
|
|
8231
|
-
return of(defaultPayload);
|
|
8232
|
-
}
|
|
8233
|
-
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/case/tasks/${caseId}/event/${eventId}/caseType/${caseType}/jurisdiction/${jurisdiction}`);
|
|
8234
|
-
}
|
|
8235
|
-
/**
|
|
8236
|
-
* Call the API to get a task
|
|
8237
|
-
*/
|
|
8238
|
-
getTask(taskId) {
|
|
8239
|
-
if (!this.isWAEnabled()) {
|
|
8240
|
-
return of({ task: null });
|
|
8241
|
-
}
|
|
8242
|
-
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}`);
|
|
8243
|
-
}
|
|
8244
|
-
}
|
|
8245
|
-
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
8246
|
-
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
8247
|
-
WorkAllocationService.ɵfac = function WorkAllocationService_Factory(t) { return new (t || WorkAllocationService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig), i0.ɵɵinject(HttpErrorService), i0.ɵɵinject(AlertService), i0.ɵɵinject(SessionStorageService)); };
|
|
8248
|
-
WorkAllocationService.ɵprov = i0.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
8249
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WorkAllocationService, [{
|
|
8250
|
-
type: Injectable
|
|
8251
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null); })();
|
|
8252
|
-
|
|
8253
8261
|
class CaseEditComponent {
|
|
8254
8262
|
constructor(fb, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService) {
|
|
8255
8263
|
this.fb = fb;
|
|
@@ -8623,14 +8631,14 @@ class CaseEditDataService {
|
|
|
8623
8631
|
this.title$ = new BehaviorSubject(null);
|
|
8624
8632
|
this.formValidationErrors$ = new BehaviorSubject([]);
|
|
8625
8633
|
this.editForm$ = new BehaviorSubject(null);
|
|
8626
|
-
this.
|
|
8634
|
+
this.isLinkedCasesJourneyAtFinalStep$ = new BehaviorSubject(null);
|
|
8627
8635
|
this.eventTriggerName$ = new BehaviorSubject(null);
|
|
8628
8636
|
this.triggerSubmitEvent$ = new BehaviorSubject(null);
|
|
8629
8637
|
this.caseDetails$ = this.details$.asObservable();
|
|
8630
8638
|
this.caseTitle$ = this.title$.asObservable();
|
|
8631
8639
|
this.caseEditForm$ = this.editForm$.asObservable();
|
|
8632
8640
|
this.caseFormValidationErrors$ = this.formValidationErrors$.asObservable();
|
|
8633
|
-
this.
|
|
8641
|
+
this.caseIsLinkedCasesJourneyAtFinalStep$ = this.isLinkedCasesJourneyAtFinalStep$.asObservable();
|
|
8634
8642
|
this.caseEventTriggerName$ = this.eventTriggerName$.asObservable();
|
|
8635
8643
|
this.caseTriggerSubmitEvent$ = this.triggerSubmitEvent$.asObservable();
|
|
8636
8644
|
}
|
|
@@ -8643,9 +8651,6 @@ class CaseEditDataService {
|
|
|
8643
8651
|
setCaseEventTriggerName(triggerName) {
|
|
8644
8652
|
this.eventTriggerName$.next(triggerName);
|
|
8645
8653
|
}
|
|
8646
|
-
setCaseLinkError(error) {
|
|
8647
|
-
this.linkError$.next(error);
|
|
8648
|
-
}
|
|
8649
8654
|
setFormValidationErrors(validationErrors) {
|
|
8650
8655
|
this.formValidationErrors$.next(validationErrors);
|
|
8651
8656
|
}
|
|
@@ -8655,8 +8660,8 @@ class CaseEditDataService {
|
|
|
8655
8660
|
clearFormValidationErrors() {
|
|
8656
8661
|
this.formValidationErrors$.next([]);
|
|
8657
8662
|
}
|
|
8658
|
-
|
|
8659
|
-
this.
|
|
8663
|
+
setLinkedCasesJourneyAtFinalStep(isAtFinalStep) {
|
|
8664
|
+
this.isLinkedCasesJourneyAtFinalStep$.next(isAtFinalStep);
|
|
8660
8665
|
}
|
|
8661
8666
|
addFormValidationError(validationError) {
|
|
8662
8667
|
this.formValidationErrors$.next(this.formValidationErrors$.getValue().concat([validationError]));
|
|
@@ -9030,6 +9035,11 @@ class CaseEditPageComponent {
|
|
|
9030
9035
|
this.caseEditDataService.caseEditForm$.subscribe({
|
|
9031
9036
|
next: editForm => this.editForm = editForm
|
|
9032
9037
|
});
|
|
9038
|
+
this.caseEditDataService.caseIsLinkedCasesJourneyAtFinalStep$.subscribe({
|
|
9039
|
+
next: isLinkedCasesJourneyAtFinalStep => {
|
|
9040
|
+
this.isLinkedCasesJourneyAtFinalStep = isLinkedCasesJourneyAtFinalStep;
|
|
9041
|
+
}
|
|
9042
|
+
});
|
|
9033
9043
|
this.caseEditDataService.caseTriggerSubmitEvent$.subscribe({
|
|
9034
9044
|
next: state => {
|
|
9035
9045
|
if (state) {
|
|
@@ -9049,7 +9059,11 @@ class CaseEditPageComponent {
|
|
|
9049
9059
|
return this.caseEdit.first();
|
|
9050
9060
|
}
|
|
9051
9061
|
currentPageIsNotValid() {
|
|
9052
|
-
return !this.pageValidationService.isPageValid(this.currentPage, this.editForm)
|
|
9062
|
+
return !this.pageValidationService.isPageValid(this.currentPage, this.editForm) ||
|
|
9063
|
+
(this.isLinkedCasesJourney() && !this.isLinkedCasesJourneyAtFinalStep);
|
|
9064
|
+
}
|
|
9065
|
+
isLinkedCasesJourney() {
|
|
9066
|
+
return FieldsUtils.containsLinkedCasesCaseField(this.currentPage.case_fields);
|
|
9053
9067
|
}
|
|
9054
9068
|
/**
|
|
9055
9069
|
* caseEventData.event_data contains all the values from the previous pages so we set caseEventData.data = caseEventData.event_data
|
|
@@ -9147,7 +9161,16 @@ class CaseEditPageComponent {
|
|
|
9147
9161
|
submit() {
|
|
9148
9162
|
this.caseEditDataService.clearFormValidationErrors();
|
|
9149
9163
|
if (this.currentPageIsNotValid()) {
|
|
9150
|
-
|
|
9164
|
+
// The generateErrorMessage method filters out the hidden fields.
|
|
9165
|
+
// The error message for LinkedCases journey will never get displayed because the
|
|
9166
|
+
// LinkedCases is configured with ComponentLauncher field as visible and caseLinks field as hidden.
|
|
9167
|
+
if (this.isLinkedCasesJourney()) {
|
|
9168
|
+
this.validationErrors.push({ id: 'next-button', message: 'Please select Next to go to the next page' });
|
|
9169
|
+
CaseEditPageComponent.scrollToTop();
|
|
9170
|
+
}
|
|
9171
|
+
else {
|
|
9172
|
+
this.generateErrorMessage(this.currentPage.case_fields);
|
|
9173
|
+
}
|
|
9151
9174
|
}
|
|
9152
9175
|
if (!this.isSubmitting && !this.currentPageIsNotValid()) {
|
|
9153
9176
|
this.isSubmitting = true;
|
|
@@ -15297,72 +15320,43 @@ ReadLinkedCasesFieldComponent.ɵcmp = i0.ɵɵdefineComponent({ type: ReadLinkedC
|
|
|
15297
15320
|
}]
|
|
15298
15321
|
}], function () { return [{ type: i1$1.ActivatedRoute }, { type: i1$1.Router }, { type: LinkedCasesService }, { type: AbstractAppConfig }, { type: CommonDataService }]; }, null); })();
|
|
15299
15322
|
|
|
15300
|
-
function
|
|
15301
|
-
const
|
|
15302
|
-
i0.ɵɵ
|
|
15303
|
-
i0.ɵɵelementStart(1, "
|
|
15304
|
-
i0.ɵɵ
|
|
15305
|
-
i0.ɵɵelementStart(3, "a", 9);
|
|
15306
|
-
i0.ɵɵlistener("click", function WriteLinkedCasesFieldComponent_div_0_div_3_Template_a_click_3_listener() { i0.ɵɵrestoreView(_r9); const errorMessage_r7 = ctx.$implicit; const ctx_r8 = i0.ɵɵnextContext(2); return ctx_r8.navigateToErrorElement(errorMessage_r7.fieldId); });
|
|
15307
|
-
i0.ɵɵtext(4);
|
|
15308
|
-
i0.ɵɵelementEnd();
|
|
15309
|
-
i0.ɵɵelementEnd();
|
|
15310
|
-
i0.ɵɵelementEnd();
|
|
15311
|
-
i0.ɵɵelementEnd();
|
|
15312
|
-
} if (rf & 2) {
|
|
15313
|
-
const errorMessage_r7 = ctx.$implicit;
|
|
15314
|
-
i0.ɵɵadvance(4);
|
|
15315
|
-
i0.ɵɵtextInterpolate(errorMessage_r7.description);
|
|
15316
|
-
} }
|
|
15317
|
-
function WriteLinkedCasesFieldComponent_div_0_Template(rf, ctx) { if (rf & 1) {
|
|
15318
|
-
i0.ɵɵelementStart(0, "div", 4);
|
|
15319
|
-
i0.ɵɵelementStart(1, "h2", 5);
|
|
15320
|
-
i0.ɵɵtext(2, " There is a problem ");
|
|
15321
|
-
i0.ɵɵelementEnd();
|
|
15322
|
-
i0.ɵɵtemplate(3, WriteLinkedCasesFieldComponent_div_0_div_3_Template, 5, 1, "div", 6);
|
|
15323
|
+
function WriteLinkedCasesFieldComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
|
|
15324
|
+
const _r6 = i0.ɵɵgetCurrentView();
|
|
15325
|
+
i0.ɵɵelementContainerStart(0);
|
|
15326
|
+
i0.ɵɵelementStart(1, "ccd-linked-cases-before-you-start", 3);
|
|
15327
|
+
i0.ɵɵlistener("linkedCasesStateEmitter", function WriteLinkedCasesFieldComponent_ng_container_2_Template_ccd_linked_cases_before_you_start_linkedCasesStateEmitter_1_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r5 = i0.ɵɵnextContext(); return ctx_r5.onLinkedCasesStateEmitted($event); });
|
|
15323
15328
|
i0.ɵɵelementEnd();
|
|
15324
|
-
|
|
15325
|
-
const ctx_r0 = i0.ɵɵnextContext();
|
|
15326
|
-
i0.ɵɵadvance(3);
|
|
15327
|
-
i0.ɵɵproperty("ngForOf", ctx_r0.errorMessages);
|
|
15329
|
+
i0.ɵɵelementContainerEnd();
|
|
15328
15330
|
} }
|
|
15329
15331
|
function WriteLinkedCasesFieldComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
|
|
15330
|
-
const
|
|
15332
|
+
const _r8 = i0.ɵɵgetCurrentView();
|
|
15331
15333
|
i0.ɵɵelementContainerStart(0);
|
|
15332
|
-
i0.ɵɵelementStart(1, "ccd-linked-cases
|
|
15333
|
-
i0.ɵɵlistener("linkedCasesStateEmitter", function
|
|
15334
|
+
i0.ɵɵelementStart(1, "ccd-no-linked-cases", 3);
|
|
15335
|
+
i0.ɵɵlistener("linkedCasesStateEmitter", function WriteLinkedCasesFieldComponent_ng_container_3_Template_ccd_no_linked_cases_linkedCasesStateEmitter_1_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r7 = i0.ɵɵnextContext(); return ctx_r7.onLinkedCasesStateEmitted($event); });
|
|
15334
15336
|
i0.ɵɵelementEnd();
|
|
15335
15337
|
i0.ɵɵelementContainerEnd();
|
|
15336
15338
|
} }
|
|
15337
15339
|
function WriteLinkedCasesFieldComponent_ng_container_4_Template(rf, ctx) { if (rf & 1) {
|
|
15338
|
-
const
|
|
15340
|
+
const _r10 = i0.ɵɵgetCurrentView();
|
|
15339
15341
|
i0.ɵɵelementContainerStart(0);
|
|
15340
|
-
i0.ɵɵelementStart(1, "ccd-
|
|
15341
|
-
i0.ɵɵlistener("linkedCasesStateEmitter", function
|
|
15342
|
+
i0.ɵɵelementStart(1, "ccd-link-cases", 3);
|
|
15343
|
+
i0.ɵɵlistener("linkedCasesStateEmitter", function WriteLinkedCasesFieldComponent_ng_container_4_Template_ccd_link_cases_linkedCasesStateEmitter_1_listener($event) { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(); return ctx_r9.onLinkedCasesStateEmitted($event); });
|
|
15342
15344
|
i0.ɵɵelementEnd();
|
|
15343
15345
|
i0.ɵɵelementContainerEnd();
|
|
15344
15346
|
} }
|
|
15345
15347
|
function WriteLinkedCasesFieldComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
|
|
15346
|
-
const
|
|
15348
|
+
const _r12 = i0.ɵɵgetCurrentView();
|
|
15347
15349
|
i0.ɵɵelementContainerStart(0);
|
|
15348
|
-
i0.ɵɵelementStart(1, "ccd-
|
|
15349
|
-
i0.ɵɵlistener("linkedCasesStateEmitter", function
|
|
15350
|
+
i0.ɵɵelementStart(1, "ccd-unlink-cases", 3);
|
|
15351
|
+
i0.ɵɵlistener("linkedCasesStateEmitter", function WriteLinkedCasesFieldComponent_ng_container_5_Template_ccd_unlink_cases_linkedCasesStateEmitter_1_listener($event) { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(); return ctx_r11.onLinkedCasesStateEmitted($event); });
|
|
15350
15352
|
i0.ɵɵelementEnd();
|
|
15351
15353
|
i0.ɵɵelementContainerEnd();
|
|
15352
15354
|
} }
|
|
15353
15355
|
function WriteLinkedCasesFieldComponent_ng_container_6_Template(rf, ctx) { if (rf & 1) {
|
|
15354
|
-
const
|
|
15355
|
-
i0.ɵɵelementContainerStart(0);
|
|
15356
|
-
i0.ɵɵelementStart(1, "ccd-unlink-cases", 10);
|
|
15357
|
-
i0.ɵɵlistener("linkedCasesStateEmitter", function WriteLinkedCasesFieldComponent_ng_container_6_Template_ccd_unlink_cases_linkedCasesStateEmitter_1_listener($event) { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(); return ctx_r16.onLinkedCasesStateEmitted($event); });
|
|
15358
|
-
i0.ɵɵelementEnd();
|
|
15359
|
-
i0.ɵɵelementContainerEnd();
|
|
15360
|
-
} }
|
|
15361
|
-
function WriteLinkedCasesFieldComponent_ng_container_7_Template(rf, ctx) { if (rf & 1) {
|
|
15362
|
-
const _r19 = i0.ɵɵgetCurrentView();
|
|
15356
|
+
const _r14 = i0.ɵɵgetCurrentView();
|
|
15363
15357
|
i0.ɵɵelementContainerStart(0);
|
|
15364
|
-
i0.ɵɵelementStart(1, "ccd-linked-cases-check-your-answers",
|
|
15365
|
-
i0.ɵɵlistener("linkedCasesStateEmitter", function
|
|
15358
|
+
i0.ɵɵelementStart(1, "ccd-linked-cases-check-your-answers", 3);
|
|
15359
|
+
i0.ɵɵlistener("linkedCasesStateEmitter", function WriteLinkedCasesFieldComponent_ng_container_6_Template_ccd_linked_cases_check_your_answers_linkedCasesStateEmitter_1_listener($event) { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(); return ctx_r13.onLinkedCasesStateEmitted($event); });
|
|
15366
15360
|
i0.ɵɵelementEnd();
|
|
15367
15361
|
i0.ɵɵelementContainerEnd();
|
|
15368
15362
|
} }
|
|
@@ -15377,9 +15371,11 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
|
|
|
15377
15371
|
this.linkedCasesPages = LinkedCasesPages;
|
|
15378
15372
|
this.linkedCasesEventTriggers = LinkedCasesEventTriggers;
|
|
15379
15373
|
this.linkedCases = [];
|
|
15380
|
-
this.errorMessages = [];
|
|
15381
15374
|
}
|
|
15382
15375
|
ngOnInit() {
|
|
15376
|
+
// This is required to enable Continue button validation
|
|
15377
|
+
// Continue button should be enabled only at check your answers page
|
|
15378
|
+
this.caseEditDataService.setLinkedCasesJourneyAtFinalStep(false);
|
|
15383
15379
|
// Clear validation errors
|
|
15384
15380
|
this.caseEditDataService.clearFormValidationErrors();
|
|
15385
15381
|
// Get linked case reasons from ref data
|
|
@@ -15415,11 +15411,10 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
|
|
|
15415
15411
|
}
|
|
15416
15412
|
}
|
|
15417
15413
|
onLinkedCasesStateEmitted(linkedCasesState) {
|
|
15418
|
-
|
|
15414
|
+
// Clear validation errors
|
|
15419
15415
|
this.caseEditDataService.clearFormValidationErrors();
|
|
15420
15416
|
if (linkedCasesState.navigateToNextPage) {
|
|
15421
15417
|
this.linkedCasesPage = this.getNextPage(linkedCasesState);
|
|
15422
|
-
this.setContinueButtonValidationErrorMessage();
|
|
15423
15418
|
this.proceedToNextPage();
|
|
15424
15419
|
}
|
|
15425
15420
|
else {
|
|
@@ -15442,27 +15437,19 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
|
|
|
15442
15437
|
}
|
|
15443
15438
|
});
|
|
15444
15439
|
}
|
|
15445
|
-
setContinueButtonValidationErrorMessage() {
|
|
15446
|
-
const errorMessage = this.linkedCasesService.isLinkedCasesEventTrigger
|
|
15447
|
-
? LinkedCasesErrorMessages.LinkCasesNavigationError
|
|
15448
|
-
: LinkedCasesErrorMessages.UnlinkCasesNavigationError;
|
|
15449
|
-
const buttonId = this.linkedCasesService.linkedCases.length === 0
|
|
15450
|
-
? 'back-button'
|
|
15451
|
-
: 'next-button';
|
|
15452
|
-
this.caseEditDataService.setCaseLinkError({
|
|
15453
|
-
componentId: buttonId,
|
|
15454
|
-
errorMessage
|
|
15455
|
-
});
|
|
15456
|
-
}
|
|
15457
15440
|
proceedToNextPage() {
|
|
15458
15441
|
if (this.isAtFinalPage()) {
|
|
15459
15442
|
// Continue button event must be allowed in final page
|
|
15460
|
-
this.caseEditDataService.
|
|
15443
|
+
this.caseEditDataService.setLinkedCasesJourneyAtFinalStep(true);
|
|
15461
15444
|
// Trigger validation to clear the "notAtFinalPage" error if now at the final state
|
|
15462
15445
|
this.formGroup.updateValueAndValidity();
|
|
15463
15446
|
// update form value
|
|
15464
15447
|
this.submitLinkedCases();
|
|
15465
15448
|
}
|
|
15449
|
+
else {
|
|
15450
|
+
// Continue button event must not be allowed if not in final page
|
|
15451
|
+
this.caseEditDataService.setLinkedCasesJourneyAtFinalStep(false);
|
|
15452
|
+
}
|
|
15466
15453
|
}
|
|
15467
15454
|
submitLinkedCases() {
|
|
15468
15455
|
if (!this.linkedCasesService.isLinkedCasesEventTrigger) {
|
|
@@ -15503,35 +15490,21 @@ class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent {
|
|
|
15503
15490
|
&& !this.linkedCasesService.serverLinkedApiError)
|
|
15504
15491
|
? LinkedCasesPages.BEFORE_YOU_START
|
|
15505
15492
|
: LinkedCasesPages.NO_LINKED_CASES;
|
|
15506
|
-
// Initialise the error to be displayed when clicked on Continue button
|
|
15507
|
-
this.setContinueButtonValidationErrorMessage();
|
|
15508
15493
|
});
|
|
15509
15494
|
}
|
|
15510
|
-
navigateToErrorElement(elementId) {
|
|
15511
|
-
if (elementId) {
|
|
15512
|
-
const htmlElement = document.getElementById(elementId);
|
|
15513
|
-
if (htmlElement) {
|
|
15514
|
-
htmlElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
15515
|
-
htmlElement.focus();
|
|
15516
|
-
}
|
|
15517
|
-
}
|
|
15518
|
-
}
|
|
15519
15495
|
}
|
|
15520
15496
|
WriteLinkedCasesFieldComponent.ɵfac = function WriteLinkedCasesFieldComponent_Factory(t) { return new (t || WriteLinkedCasesFieldComponent)(i0.ɵɵdirectiveInject(AbstractAppConfig), i0.ɵɵdirectiveInject(CommonDataService), i0.ɵɵdirectiveInject(CasesService), i0.ɵɵdirectiveInject(LinkedCasesService), i0.ɵɵdirectiveInject(CaseEditDataService)); };
|
|
15521
|
-
WriteLinkedCasesFieldComponent.ɵcmp = i0.ɵɵdefineComponent({ type: WriteLinkedCasesFieldComponent, selectors: [["ccd-write-linked-cases-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls:
|
|
15522
|
-
i0.ɵɵ
|
|
15497
|
+
WriteLinkedCasesFieldComponent.ɵcmp = i0.ɵɵdefineComponent({ type: WriteLinkedCasesFieldComponent, selectors: [["ccd-write-linked-cases-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 7, vars: 7, consts: [[1, "form-group", "govuk-!-margin-bottom-2", 3, "formGroup"], [1, "govuk-form-group", 3, "ngSwitch"], [4, "ngSwitchCase"], [3, "linkedCasesStateEmitter"]], template: function WriteLinkedCasesFieldComponent_Template(rf, ctx) { if (rf & 1) {
|
|
15498
|
+
i0.ɵɵelementStart(0, "div", 0);
|
|
15523
15499
|
i0.ɵɵelementStart(1, "div", 1);
|
|
15524
|
-
i0.ɵɵ
|
|
15525
|
-
i0.ɵɵtemplate(3, WriteLinkedCasesFieldComponent_ng_container_3_Template, 2, 0, "ng-container",
|
|
15526
|
-
i0.ɵɵtemplate(4, WriteLinkedCasesFieldComponent_ng_container_4_Template, 2, 0, "ng-container",
|
|
15527
|
-
i0.ɵɵtemplate(5, WriteLinkedCasesFieldComponent_ng_container_5_Template, 2, 0, "ng-container",
|
|
15528
|
-
i0.ɵɵtemplate(6, WriteLinkedCasesFieldComponent_ng_container_6_Template, 2, 0, "ng-container",
|
|
15529
|
-
i0.ɵɵtemplate(7, WriteLinkedCasesFieldComponent_ng_container_7_Template, 2, 0, "ng-container", 3);
|
|
15500
|
+
i0.ɵɵtemplate(2, WriteLinkedCasesFieldComponent_ng_container_2_Template, 2, 0, "ng-container", 2);
|
|
15501
|
+
i0.ɵɵtemplate(3, WriteLinkedCasesFieldComponent_ng_container_3_Template, 2, 0, "ng-container", 2);
|
|
15502
|
+
i0.ɵɵtemplate(4, WriteLinkedCasesFieldComponent_ng_container_4_Template, 2, 0, "ng-container", 2);
|
|
15503
|
+
i0.ɵɵtemplate(5, WriteLinkedCasesFieldComponent_ng_container_5_Template, 2, 0, "ng-container", 2);
|
|
15504
|
+
i0.ɵɵtemplate(6, WriteLinkedCasesFieldComponent_ng_container_6_Template, 2, 0, "ng-container", 2);
|
|
15530
15505
|
i0.ɵɵelementEnd();
|
|
15531
15506
|
i0.ɵɵelementEnd();
|
|
15532
15507
|
} if (rf & 2) {
|
|
15533
|
-
i0.ɵɵproperty("ngIf", ctx.errorMessages.length > 0);
|
|
15534
|
-
i0.ɵɵadvance(1);
|
|
15535
15508
|
i0.ɵɵproperty("formGroup", ctx.formGroup);
|
|
15536
15509
|
i0.ɵɵadvance(1);
|
|
15537
15510
|
i0.ɵɵproperty("ngSwitch", ctx.linkedCasesPage);
|
|
@@ -22674,7 +22647,7 @@ i0.ɵɵsetComponentScope(WriteCaseFlagFieldComponent, [i1.NgIf, i1.NgForOf, i2.N
|
|
|
22674
22647
|
AddCommentsComponent,
|
|
22675
22648
|
ManageCaseFlagsComponent,
|
|
22676
22649
|
UpdateFlagComponent], []);
|
|
22677
|
-
i0.ɵɵsetComponentScope(WriteLinkedCasesFieldComponent, [
|
|
22650
|
+
i0.ɵɵsetComponentScope(WriteLinkedCasesFieldComponent, [i2.NgControlStatusGroup, i2.FormGroupDirective, i1.NgSwitch, i1.NgSwitchCase, BeforeYouStartComponent,
|
|
22678
22651
|
NoLinkedCasesComponent,
|
|
22679
22652
|
LinkCasesComponent,
|
|
22680
22653
|
UnLinkCasesComponent,
|