@hmcts/ccd-case-ui-toolkit 6.13.10-eui-8000 → 6.13.10-eui-4157
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/bundles/hmcts-ccd-case-ui-toolkit.umd.js +215 -218
- package/bundles/hmcts-ccd-case-ui-toolkit.umd.js.map +1 -1
- package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js +1 -1
- package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js.map +1 -1
- package/esm2015/lib/shared/components/case-editor/services/cases.service.js +4 -7
- package/esm2015/lib/shared/components/palette/case-file-view/case-file-view-field-read.component.js +4 -4
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js +207 -208
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
- package/lib/shared/components/case-editor/services/cases.service.d.ts +1 -3
- package/lib/shared/components/case-editor/services/cases.service.d.ts.map +1 -1
- package/lib/shared/components/palette/case-file-view/case-file-view-field-read.component.d.ts +2 -5
- package/lib/shared/components/palette/case-file-view/case-file-view-field-read.component.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -7192,215 +7192,13 @@ WizardPageFieldToCaseFieldMapper.ɵprov = i0.ɵɵdefineInjectable({ token: Wizar
|
|
|
7192
7192
|
}]
|
|
7193
7193
|
}], null, null); })();
|
|
7194
7194
|
|
|
7195
|
-
const MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
7196
|
-
class WorkAllocationService {
|
|
7197
|
-
constructor(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
7198
|
-
this.http = http;
|
|
7199
|
-
this.appConfig = appConfig;
|
|
7200
|
-
this.errorService = errorService;
|
|
7201
|
-
this.alertService = alertService;
|
|
7202
|
-
this.sessionStorageService = sessionStorageService;
|
|
7203
|
-
// Check to see if work allocation is enabled
|
|
7204
|
-
}
|
|
7205
|
-
/**
|
|
7206
|
-
* Call the API to get tasks matching the search criteria.
|
|
7207
|
-
* @param searchRequest The search parameters that specify which tasks to match.
|
|
7208
|
-
*/
|
|
7209
|
-
searchTasks(searchRequest) {
|
|
7210
|
-
// Do not need to check if WA enabled as parent method will do that
|
|
7211
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/searchForCompletable`;
|
|
7212
|
-
return this.http
|
|
7213
|
-
.post(url, { searchRequest }, null, false)
|
|
7214
|
-
.pipe(map(response => response), catchError(error => {
|
|
7215
|
-
this.errorService.setError(error);
|
|
7216
|
-
// explicitly eat away 401 error and 400 error
|
|
7217
|
-
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
7218
|
-
// do nothing
|
|
7219
|
-
console.log('error status 401 or 400', error);
|
|
7220
|
-
}
|
|
7221
|
-
else {
|
|
7222
|
-
return throwError(error);
|
|
7223
|
-
}
|
|
7224
|
-
}));
|
|
7225
|
-
}
|
|
7226
|
-
isWAEnabled(jurisdiction, caseType) {
|
|
7227
|
-
this.features = this.appConfig.getWAServiceConfig();
|
|
7228
|
-
let enabled = false;
|
|
7229
|
-
if (!jurisdiction || !caseType) {
|
|
7230
|
-
const caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
7231
|
-
jurisdiction = caseInfo.jurisdiction;
|
|
7232
|
-
caseType = caseInfo.caseType;
|
|
7233
|
-
}
|
|
7234
|
-
if (!this.features || !this.features.configurations) {
|
|
7235
|
-
return false;
|
|
7236
|
-
}
|
|
7237
|
-
this.features.configurations.forEach(serviceConfig => {
|
|
7238
|
-
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
7239
|
-
enabled = true;
|
|
7240
|
-
}
|
|
7241
|
-
});
|
|
7242
|
-
return enabled;
|
|
7243
|
-
}
|
|
7244
|
-
/**
|
|
7245
|
-
* Call the API to assign a task.
|
|
7246
|
-
* @param taskId specifies which task should be assigned.
|
|
7247
|
-
* @param userId specifies the user the task should be assigned to.
|
|
7248
|
-
*/
|
|
7249
|
-
assignTask(taskId, userId) {
|
|
7250
|
-
if (!this.isWAEnabled()) {
|
|
7251
|
-
return of(null);
|
|
7252
|
-
}
|
|
7253
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/assign`;
|
|
7254
|
-
return this.http
|
|
7255
|
-
.post(url, { userId })
|
|
7256
|
-
.pipe(catchError(error => {
|
|
7257
|
-
this.errorService.setError(error);
|
|
7258
|
-
return throwError(error);
|
|
7259
|
-
}));
|
|
7260
|
-
}
|
|
7261
|
-
/**
|
|
7262
|
-
* Call the API to complete a task.
|
|
7263
|
-
* @param taskId specifies which task should be completed.
|
|
7264
|
-
*/
|
|
7265
|
-
completeTask(taskId) {
|
|
7266
|
-
if (!this.isWAEnabled()) {
|
|
7267
|
-
return of(null);
|
|
7268
|
-
}
|
|
7269
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
7270
|
-
return this.http
|
|
7271
|
-
.post(url, {})
|
|
7272
|
-
.pipe(catchError(error => {
|
|
7273
|
-
this.errorService.setError(error);
|
|
7274
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
7275
|
-
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
7276
|
-
this.handleTaskCompletionError(response);
|
|
7277
|
-
});
|
|
7278
|
-
return throwError(error);
|
|
7279
|
-
}));
|
|
7280
|
-
}
|
|
7281
|
-
/**
|
|
7282
|
-
* Call the API to assign and complete a task.
|
|
7283
|
-
* @param taskId specifies which task should be completed.
|
|
7284
|
-
*/
|
|
7285
|
-
assignAndCompleteTask(taskId) {
|
|
7286
|
-
if (!this.isWAEnabled()) {
|
|
7287
|
-
return of(null);
|
|
7288
|
-
}
|
|
7289
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
7290
|
-
return this.http
|
|
7291
|
-
.post(url, {
|
|
7292
|
-
completion_options: {
|
|
7293
|
-
assign_and_complete: true
|
|
7294
|
-
}
|
|
7295
|
-
})
|
|
7296
|
-
.pipe(catchError(error => {
|
|
7297
|
-
this.errorService.setError(error);
|
|
7298
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
7299
|
-
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
7300
|
-
this.handleTaskCompletionError(response);
|
|
7301
|
-
});
|
|
7302
|
-
return throwError(error);
|
|
7303
|
-
}));
|
|
7304
|
-
}
|
|
7305
|
-
/**
|
|
7306
|
-
* Handles the response from the observable to get the user details when task is completed.
|
|
7307
|
-
* @param response is the response given from the observable which contains the user detaild.
|
|
7308
|
-
*/
|
|
7309
|
-
handleTaskCompletionError(response) {
|
|
7310
|
-
const userDetails = response;
|
|
7311
|
-
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
7312
|
-
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
7313
|
-
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
7314
|
-
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
7315
|
-
}
|
|
7316
|
-
}
|
|
7317
|
-
/**
|
|
7318
|
-
* Returns true if the user's role is equivalent to a caseworker.
|
|
7319
|
-
* @param roles is the list of roles found from the current user.
|
|
7320
|
-
*/
|
|
7321
|
-
userIsCaseworker(roles) {
|
|
7322
|
-
const lowerCaseRoles = roles.map(role => role.toLowerCase());
|
|
7323
|
-
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
7324
|
-
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
7325
|
-
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
7326
|
-
}
|
|
7327
|
-
/**
|
|
7328
|
-
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
7329
|
-
* 1. No tasks found => Success.
|
|
7330
|
-
* 2. One task found => Mark as done => Success.
|
|
7331
|
-
* 3. One task found => Mark as done throws error => Failure.
|
|
7332
|
-
* 4. More than one task found => Failure.
|
|
7333
|
-
* 5. Search call throws an error => Failure.
|
|
7334
|
-
* @param ccdId The ID of the case to find tasks for.
|
|
7335
|
-
* @param eventId The ID of the event to find tasks for.
|
|
7336
|
-
*/
|
|
7337
|
-
completeAppropriateTask(ccdId, eventId, jurisdiction, caseTypeId) {
|
|
7338
|
-
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
7339
|
-
return of(null);
|
|
7340
|
-
}
|
|
7341
|
-
const taskSearchParameter = {
|
|
7342
|
-
ccdId,
|
|
7343
|
-
eventId,
|
|
7344
|
-
jurisdiction,
|
|
7345
|
-
caseTypeId
|
|
7346
|
-
};
|
|
7347
|
-
return this.searchTasks(taskSearchParameter)
|
|
7348
|
-
.pipe(map((response) => {
|
|
7349
|
-
const tasks = response.tasks;
|
|
7350
|
-
if (tasks && tasks.length > 0) {
|
|
7351
|
-
if (tasks.length === 1) {
|
|
7352
|
-
this.completeTask(tasks[0].id).subscribe();
|
|
7353
|
-
}
|
|
7354
|
-
else {
|
|
7355
|
-
// This is a problem. Throw an appropriate error.
|
|
7356
|
-
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
7357
|
-
}
|
|
7358
|
-
}
|
|
7359
|
-
return true; // All good. Nothing to see here.
|
|
7360
|
-
}), catchError(error => {
|
|
7361
|
-
// Simply rethrow it.
|
|
7362
|
-
return throwError(error);
|
|
7363
|
-
}));
|
|
7364
|
-
}
|
|
7365
|
-
/**
|
|
7366
|
-
* Return tasks for case and event.
|
|
7367
|
-
*/
|
|
7368
|
-
getTasksByCaseIdAndEventId(eventId, caseId, caseType, jurisdiction) {
|
|
7369
|
-
const defaultPayload = {
|
|
7370
|
-
task_required_for_event: false,
|
|
7371
|
-
tasks: []
|
|
7372
|
-
};
|
|
7373
|
-
if (!this.isWAEnabled()) {
|
|
7374
|
-
return of(defaultPayload);
|
|
7375
|
-
}
|
|
7376
|
-
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/case/tasks/${caseId}/event/${eventId}/caseType/${caseType}/jurisdiction/${jurisdiction}`);
|
|
7377
|
-
}
|
|
7378
|
-
/**
|
|
7379
|
-
* Call the API to get a task
|
|
7380
|
-
*/
|
|
7381
|
-
getTask(taskId) {
|
|
7382
|
-
if (!this.isWAEnabled()) {
|
|
7383
|
-
return of({ task: null });
|
|
7384
|
-
}
|
|
7385
|
-
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}`);
|
|
7386
|
-
}
|
|
7387
|
-
}
|
|
7388
|
-
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
7389
|
-
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
7390
|
-
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)); };
|
|
7391
|
-
WorkAllocationService.ɵprov = i0.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
7392
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WorkAllocationService, [{
|
|
7393
|
-
type: Injectable
|
|
7394
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null); })();
|
|
7395
|
-
|
|
7396
7195
|
class CasesService {
|
|
7397
|
-
constructor(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper,
|
|
7196
|
+
constructor(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
|
|
7398
7197
|
this.http = http;
|
|
7399
7198
|
this.appConfig = appConfig;
|
|
7400
7199
|
this.orderService = orderService;
|
|
7401
7200
|
this.errorService = errorService;
|
|
7402
7201
|
this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
|
|
7403
|
-
this.workAllocationService = workAllocationService;
|
|
7404
7202
|
this.loadingService = loadingService;
|
|
7405
7203
|
this.sessionStorageService = sessionStorageService;
|
|
7406
7204
|
this.get = this.getCaseView;
|
|
@@ -7626,11 +7424,11 @@ CasesService.V2_MEDIATYPE_CASE_DATA_VALIDATE = 'application/vnd.uk.gov.hmcts.ccd
|
|
|
7626
7424
|
CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
|
|
7627
7425
|
CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
|
|
7628
7426
|
CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
|
|
7629
|
-
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(
|
|
7427
|
+
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)); };
|
|
7630
7428
|
CasesService.ɵprov = i0.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
|
|
7631
7429
|
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CasesService, [{
|
|
7632
7430
|
type: Injectable
|
|
7633
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type:
|
|
7431
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null); })();
|
|
7634
7432
|
|
|
7635
7433
|
class EventTriggerService {
|
|
7636
7434
|
constructor() {
|
|
@@ -8233,6 +8031,207 @@ PageValidationService.ɵprov = i0.ɵɵdefineInjectable({ token: PageValidationSe
|
|
|
8233
8031
|
type: Injectable
|
|
8234
8032
|
}], function () { return [{ type: CaseFieldService }]; }, null); })();
|
|
8235
8033
|
|
|
8034
|
+
const MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
8035
|
+
class WorkAllocationService {
|
|
8036
|
+
constructor(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
8037
|
+
this.http = http;
|
|
8038
|
+
this.appConfig = appConfig;
|
|
8039
|
+
this.errorService = errorService;
|
|
8040
|
+
this.alertService = alertService;
|
|
8041
|
+
this.sessionStorageService = sessionStorageService;
|
|
8042
|
+
// Check to see if work allocation is enabled
|
|
8043
|
+
}
|
|
8044
|
+
/**
|
|
8045
|
+
* Call the API to get tasks matching the search criteria.
|
|
8046
|
+
* @param searchRequest The search parameters that specify which tasks to match.
|
|
8047
|
+
*/
|
|
8048
|
+
searchTasks(searchRequest) {
|
|
8049
|
+
// Do not need to check if WA enabled as parent method will do that
|
|
8050
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/searchForCompletable`;
|
|
8051
|
+
return this.http
|
|
8052
|
+
.post(url, { searchRequest }, null, false)
|
|
8053
|
+
.pipe(map(response => response), catchError(error => {
|
|
8054
|
+
this.errorService.setError(error);
|
|
8055
|
+
// explicitly eat away 401 error and 400 error
|
|
8056
|
+
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
8057
|
+
// do nothing
|
|
8058
|
+
console.log('error status 401 or 400', error);
|
|
8059
|
+
}
|
|
8060
|
+
else {
|
|
8061
|
+
return throwError(error);
|
|
8062
|
+
}
|
|
8063
|
+
}));
|
|
8064
|
+
}
|
|
8065
|
+
isWAEnabled(jurisdiction, caseType) {
|
|
8066
|
+
this.features = this.appConfig.getWAServiceConfig();
|
|
8067
|
+
let enabled = false;
|
|
8068
|
+
if (!jurisdiction || !caseType) {
|
|
8069
|
+
const caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
8070
|
+
jurisdiction = caseInfo.jurisdiction;
|
|
8071
|
+
caseType = caseInfo.caseType;
|
|
8072
|
+
}
|
|
8073
|
+
if (!this.features || !this.features.configurations) {
|
|
8074
|
+
return false;
|
|
8075
|
+
}
|
|
8076
|
+
this.features.configurations.forEach(serviceConfig => {
|
|
8077
|
+
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
8078
|
+
enabled = true;
|
|
8079
|
+
}
|
|
8080
|
+
});
|
|
8081
|
+
return enabled;
|
|
8082
|
+
}
|
|
8083
|
+
/**
|
|
8084
|
+
* Call the API to assign a task.
|
|
8085
|
+
* @param taskId specifies which task should be assigned.
|
|
8086
|
+
* @param userId specifies the user the task should be assigned to.
|
|
8087
|
+
*/
|
|
8088
|
+
assignTask(taskId, userId) {
|
|
8089
|
+
if (!this.isWAEnabled()) {
|
|
8090
|
+
return of(null);
|
|
8091
|
+
}
|
|
8092
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/assign`;
|
|
8093
|
+
return this.http
|
|
8094
|
+
.post(url, { userId })
|
|
8095
|
+
.pipe(catchError(error => {
|
|
8096
|
+
this.errorService.setError(error);
|
|
8097
|
+
return throwError(error);
|
|
8098
|
+
}));
|
|
8099
|
+
}
|
|
8100
|
+
/**
|
|
8101
|
+
* Call the API to complete a task.
|
|
8102
|
+
* @param taskId specifies which task should be completed.
|
|
8103
|
+
*/
|
|
8104
|
+
completeTask(taskId) {
|
|
8105
|
+
if (!this.isWAEnabled()) {
|
|
8106
|
+
return of(null);
|
|
8107
|
+
}
|
|
8108
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
8109
|
+
return this.http
|
|
8110
|
+
.post(url, {})
|
|
8111
|
+
.pipe(catchError(error => {
|
|
8112
|
+
this.errorService.setError(error);
|
|
8113
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
8114
|
+
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
8115
|
+
this.handleTaskCompletionError(response);
|
|
8116
|
+
});
|
|
8117
|
+
return throwError(error);
|
|
8118
|
+
}));
|
|
8119
|
+
}
|
|
8120
|
+
/**
|
|
8121
|
+
* Call the API to assign and complete a task.
|
|
8122
|
+
* @param taskId specifies which task should be completed.
|
|
8123
|
+
*/
|
|
8124
|
+
assignAndCompleteTask(taskId) {
|
|
8125
|
+
if (!this.isWAEnabled()) {
|
|
8126
|
+
return of(null);
|
|
8127
|
+
}
|
|
8128
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}/complete`;
|
|
8129
|
+
return this.http
|
|
8130
|
+
.post(url, {
|
|
8131
|
+
completion_options: {
|
|
8132
|
+
assign_and_complete: true
|
|
8133
|
+
}
|
|
8134
|
+
})
|
|
8135
|
+
.pipe(catchError(error => {
|
|
8136
|
+
this.errorService.setError(error);
|
|
8137
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
8138
|
+
this.http.get(this.appConfig.getUserInfoApiUrl()).pipe(map(response => response)).subscribe((response) => {
|
|
8139
|
+
this.handleTaskCompletionError(response);
|
|
8140
|
+
});
|
|
8141
|
+
return throwError(error);
|
|
8142
|
+
}));
|
|
8143
|
+
}
|
|
8144
|
+
/**
|
|
8145
|
+
* Handles the response from the observable to get the user details when task is completed.
|
|
8146
|
+
* @param response is the response given from the observable which contains the user detaild.
|
|
8147
|
+
*/
|
|
8148
|
+
handleTaskCompletionError(response) {
|
|
8149
|
+
const userDetails = response;
|
|
8150
|
+
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
8151
|
+
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
8152
|
+
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
8153
|
+
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
8154
|
+
}
|
|
8155
|
+
}
|
|
8156
|
+
/**
|
|
8157
|
+
* Returns true if the user's role is equivalent to a caseworker.
|
|
8158
|
+
* @param roles is the list of roles found from the current user.
|
|
8159
|
+
*/
|
|
8160
|
+
userIsCaseworker(roles) {
|
|
8161
|
+
const lowerCaseRoles = roles.map(role => role.toLowerCase());
|
|
8162
|
+
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
8163
|
+
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
8164
|
+
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
8165
|
+
}
|
|
8166
|
+
/**
|
|
8167
|
+
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
8168
|
+
* 1. No tasks found => Success.
|
|
8169
|
+
* 2. One task found => Mark as done => Success.
|
|
8170
|
+
* 3. One task found => Mark as done throws error => Failure.
|
|
8171
|
+
* 4. More than one task found => Failure.
|
|
8172
|
+
* 5. Search call throws an error => Failure.
|
|
8173
|
+
* @param ccdId The ID of the case to find tasks for.
|
|
8174
|
+
* @param eventId The ID of the event to find tasks for.
|
|
8175
|
+
*/
|
|
8176
|
+
completeAppropriateTask(ccdId, eventId, jurisdiction, caseTypeId) {
|
|
8177
|
+
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
8178
|
+
return of(null);
|
|
8179
|
+
}
|
|
8180
|
+
const taskSearchParameter = {
|
|
8181
|
+
ccdId,
|
|
8182
|
+
eventId,
|
|
8183
|
+
jurisdiction,
|
|
8184
|
+
caseTypeId
|
|
8185
|
+
};
|
|
8186
|
+
return this.searchTasks(taskSearchParameter)
|
|
8187
|
+
.pipe(map((response) => {
|
|
8188
|
+
const tasks = response.tasks;
|
|
8189
|
+
if (tasks && tasks.length > 0) {
|
|
8190
|
+
if (tasks.length === 1) {
|
|
8191
|
+
this.completeTask(tasks[0].id).subscribe();
|
|
8192
|
+
}
|
|
8193
|
+
else {
|
|
8194
|
+
// This is a problem. Throw an appropriate error.
|
|
8195
|
+
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
return true; // All good. Nothing to see here.
|
|
8199
|
+
}), catchError(error => {
|
|
8200
|
+
// Simply rethrow it.
|
|
8201
|
+
return throwError(error);
|
|
8202
|
+
}));
|
|
8203
|
+
}
|
|
8204
|
+
/**
|
|
8205
|
+
* Return tasks for case and event.
|
|
8206
|
+
*/
|
|
8207
|
+
getTasksByCaseIdAndEventId(eventId, caseId, caseType, jurisdiction) {
|
|
8208
|
+
const defaultPayload = {
|
|
8209
|
+
task_required_for_event: false,
|
|
8210
|
+
tasks: []
|
|
8211
|
+
};
|
|
8212
|
+
if (!this.isWAEnabled()) {
|
|
8213
|
+
return of(defaultPayload);
|
|
8214
|
+
}
|
|
8215
|
+
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/case/tasks/${caseId}/event/${eventId}/caseType/${caseType}/jurisdiction/${jurisdiction}`);
|
|
8216
|
+
}
|
|
8217
|
+
/**
|
|
8218
|
+
* Call the API to get a task
|
|
8219
|
+
*/
|
|
8220
|
+
getTask(taskId) {
|
|
8221
|
+
if (!this.isWAEnabled()) {
|
|
8222
|
+
return of({ task: null });
|
|
8223
|
+
}
|
|
8224
|
+
return this.http.get(`${this.appConfig.getWorkAllocationApiUrl()}/task/${taskId}`);
|
|
8225
|
+
}
|
|
8226
|
+
}
|
|
8227
|
+
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
8228
|
+
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
8229
|
+
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)); };
|
|
8230
|
+
WorkAllocationService.ɵprov = i0.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
8231
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WorkAllocationService, [{
|
|
8232
|
+
type: Injectable
|
|
8233
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null); })();
|
|
8234
|
+
|
|
8236
8235
|
class CaseEditComponent {
|
|
8237
8236
|
constructor(fb, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService) {
|
|
8238
8237
|
this.fb = fb;
|
|
@@ -10275,9 +10274,9 @@ function CaseFileViewFieldReadComponent_div_1_Template(rf, ctx) { if (rf & 1) {
|
|
|
10275
10274
|
i0.ɵɵproperty("ngIf", ctx_r1.currentDocument);
|
|
10276
10275
|
} }
|
|
10277
10276
|
class CaseFileViewFieldReadComponent extends CaseFileViewFieldComponent {
|
|
10278
|
-
|
|
10279
|
-
super
|
|
10280
|
-
this.allowMoving =
|
|
10277
|
+
constructor() {
|
|
10278
|
+
super(...arguments);
|
|
10279
|
+
this.allowMoving = false;
|
|
10281
10280
|
}
|
|
10282
10281
|
}
|
|
10283
10282
|
CaseFileViewFieldReadComponent.ɵfac = function CaseFileViewFieldReadComponent_Factory(t) { return ɵCaseFileViewFieldReadComponent_BaseFactory(t || CaseFileViewFieldReadComponent); };
|