@hmcts/ccd-case-ui-toolkit 6.14.4-eui-4157 → 6.14.4-publish-fix
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 +213 -212
- 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 +7 -4
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js +205 -204
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
- package/lib/shared/components/case-editor/services/cases.service.d.ts +3 -1
- package/lib/shared/components/case-editor/services/cases.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -8421,13 +8421,223 @@
|
|
|
8421
8421
|
}], null, null);
|
|
8422
8422
|
})();
|
|
8423
8423
|
|
|
8424
|
+
var MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
8425
|
+
var WorkAllocationService = /** @class */ (function () {
|
|
8426
|
+
function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
8427
|
+
this.http = http;
|
|
8428
|
+
this.appConfig = appConfig;
|
|
8429
|
+
this.errorService = errorService;
|
|
8430
|
+
this.alertService = alertService;
|
|
8431
|
+
this.sessionStorageService = sessionStorageService;
|
|
8432
|
+
// Check to see if work allocation is enabled
|
|
8433
|
+
}
|
|
8434
|
+
/**
|
|
8435
|
+
* Call the API to get tasks matching the search criteria.
|
|
8436
|
+
* @param searchRequest The search parameters that specify which tasks to match.
|
|
8437
|
+
*/
|
|
8438
|
+
WorkAllocationService.prototype.searchTasks = function (searchRequest) {
|
|
8439
|
+
var _this = this;
|
|
8440
|
+
// Do not need to check if WA enabled as parent method will do that
|
|
8441
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
|
|
8442
|
+
return this.http
|
|
8443
|
+
.post(url, { searchRequest: searchRequest }, null, false)
|
|
8444
|
+
.pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
|
|
8445
|
+
_this.errorService.setError(error);
|
|
8446
|
+
// explicitly eat away 401 error and 400 error
|
|
8447
|
+
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
8448
|
+
// do nothing
|
|
8449
|
+
console.log('error status 401 or 400', error);
|
|
8450
|
+
}
|
|
8451
|
+
else {
|
|
8452
|
+
return rxjs.throwError(error);
|
|
8453
|
+
}
|
|
8454
|
+
}));
|
|
8455
|
+
};
|
|
8456
|
+
WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
|
|
8457
|
+
this.features = this.appConfig.getWAServiceConfig();
|
|
8458
|
+
var enabled = false;
|
|
8459
|
+
if (!jurisdiction || !caseType) {
|
|
8460
|
+
var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
8461
|
+
jurisdiction = caseInfo.jurisdiction;
|
|
8462
|
+
caseType = caseInfo.caseType;
|
|
8463
|
+
}
|
|
8464
|
+
if (!this.features || !this.features.configurations) {
|
|
8465
|
+
return false;
|
|
8466
|
+
}
|
|
8467
|
+
this.features.configurations.forEach(function (serviceConfig) {
|
|
8468
|
+
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
8469
|
+
enabled = true;
|
|
8470
|
+
}
|
|
8471
|
+
});
|
|
8472
|
+
return enabled;
|
|
8473
|
+
};
|
|
8474
|
+
/**
|
|
8475
|
+
* Call the API to assign a task.
|
|
8476
|
+
* @param taskId specifies which task should be assigned.
|
|
8477
|
+
* @param userId specifies the user the task should be assigned to.
|
|
8478
|
+
*/
|
|
8479
|
+
WorkAllocationService.prototype.assignTask = function (taskId, userId) {
|
|
8480
|
+
var _this = this;
|
|
8481
|
+
if (!this.isWAEnabled()) {
|
|
8482
|
+
return rxjs.of(null);
|
|
8483
|
+
}
|
|
8484
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
|
|
8485
|
+
return this.http
|
|
8486
|
+
.post(url, { userId: userId })
|
|
8487
|
+
.pipe(operators.catchError(function (error) {
|
|
8488
|
+
_this.errorService.setError(error);
|
|
8489
|
+
return rxjs.throwError(error);
|
|
8490
|
+
}));
|
|
8491
|
+
};
|
|
8492
|
+
/**
|
|
8493
|
+
* Call the API to complete a task.
|
|
8494
|
+
* @param taskId specifies which task should be completed.
|
|
8495
|
+
*/
|
|
8496
|
+
WorkAllocationService.prototype.completeTask = function (taskId) {
|
|
8497
|
+
var _this = this;
|
|
8498
|
+
if (!this.isWAEnabled()) {
|
|
8499
|
+
return rxjs.of(null);
|
|
8500
|
+
}
|
|
8501
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
8502
|
+
return this.http
|
|
8503
|
+
.post(url, {})
|
|
8504
|
+
.pipe(operators.catchError(function (error) {
|
|
8505
|
+
_this.errorService.setError(error);
|
|
8506
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
8507
|
+
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
8508
|
+
_this.handleTaskCompletionError(response);
|
|
8509
|
+
});
|
|
8510
|
+
return rxjs.throwError(error);
|
|
8511
|
+
}));
|
|
8512
|
+
};
|
|
8513
|
+
/**
|
|
8514
|
+
* Call the API to assign and complete a task.
|
|
8515
|
+
* @param taskId specifies which task should be completed.
|
|
8516
|
+
*/
|
|
8517
|
+
WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
|
|
8518
|
+
var _this = this;
|
|
8519
|
+
if (!this.isWAEnabled()) {
|
|
8520
|
+
return rxjs.of(null);
|
|
8521
|
+
}
|
|
8522
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
8523
|
+
return this.http
|
|
8524
|
+
.post(url, {
|
|
8525
|
+
completion_options: {
|
|
8526
|
+
assign_and_complete: true
|
|
8527
|
+
}
|
|
8528
|
+
})
|
|
8529
|
+
.pipe(operators.catchError(function (error) {
|
|
8530
|
+
_this.errorService.setError(error);
|
|
8531
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
8532
|
+
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
8533
|
+
_this.handleTaskCompletionError(response);
|
|
8534
|
+
});
|
|
8535
|
+
return rxjs.throwError(error);
|
|
8536
|
+
}));
|
|
8537
|
+
};
|
|
8538
|
+
/**
|
|
8539
|
+
* Handles the response from the observable to get the user details when task is completed.
|
|
8540
|
+
* @param response is the response given from the observable which contains the user detaild.
|
|
8541
|
+
*/
|
|
8542
|
+
WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
|
|
8543
|
+
var userDetails = response;
|
|
8544
|
+
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
8545
|
+
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
8546
|
+
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
8547
|
+
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
8548
|
+
}
|
|
8549
|
+
};
|
|
8550
|
+
/**
|
|
8551
|
+
* Returns true if the user's role is equivalent to a caseworker.
|
|
8552
|
+
* @param roles is the list of roles found from the current user.
|
|
8553
|
+
*/
|
|
8554
|
+
WorkAllocationService.prototype.userIsCaseworker = function (roles) {
|
|
8555
|
+
var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
|
|
8556
|
+
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
8557
|
+
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
8558
|
+
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
8559
|
+
};
|
|
8560
|
+
/**
|
|
8561
|
+
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
8562
|
+
* 1. No tasks found => Success.
|
|
8563
|
+
* 2. One task found => Mark as done => Success.
|
|
8564
|
+
* 3. One task found => Mark as done throws error => Failure.
|
|
8565
|
+
* 4. More than one task found => Failure.
|
|
8566
|
+
* 5. Search call throws an error => Failure.
|
|
8567
|
+
* @param ccdId The ID of the case to find tasks for.
|
|
8568
|
+
* @param eventId The ID of the event to find tasks for.
|
|
8569
|
+
*/
|
|
8570
|
+
WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
|
|
8571
|
+
var _this = this;
|
|
8572
|
+
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
8573
|
+
return rxjs.of(null);
|
|
8574
|
+
}
|
|
8575
|
+
var taskSearchParameter = {
|
|
8576
|
+
ccdId: ccdId,
|
|
8577
|
+
eventId: eventId,
|
|
8578
|
+
jurisdiction: jurisdiction,
|
|
8579
|
+
caseTypeId: caseTypeId
|
|
8580
|
+
};
|
|
8581
|
+
return this.searchTasks(taskSearchParameter)
|
|
8582
|
+
.pipe(operators.map(function (response) {
|
|
8583
|
+
var tasks = response.tasks;
|
|
8584
|
+
if (tasks && tasks.length > 0) {
|
|
8585
|
+
if (tasks.length === 1) {
|
|
8586
|
+
_this.completeTask(tasks[0].id).subscribe();
|
|
8587
|
+
}
|
|
8588
|
+
else {
|
|
8589
|
+
// This is a problem. Throw an appropriate error.
|
|
8590
|
+
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
8591
|
+
}
|
|
8592
|
+
}
|
|
8593
|
+
return true; // All good. Nothing to see here.
|
|
8594
|
+
}), operators.catchError(function (error) {
|
|
8595
|
+
// Simply rethrow it.
|
|
8596
|
+
return rxjs.throwError(error);
|
|
8597
|
+
}));
|
|
8598
|
+
};
|
|
8599
|
+
/**
|
|
8600
|
+
* Return tasks for case and event.
|
|
8601
|
+
*/
|
|
8602
|
+
WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
|
|
8603
|
+
var defaultPayload = {
|
|
8604
|
+
task_required_for_event: false,
|
|
8605
|
+
tasks: []
|
|
8606
|
+
};
|
|
8607
|
+
if (!this.isWAEnabled()) {
|
|
8608
|
+
return rxjs.of(defaultPayload);
|
|
8609
|
+
}
|
|
8610
|
+
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
|
|
8611
|
+
};
|
|
8612
|
+
/**
|
|
8613
|
+
* Call the API to get a task
|
|
8614
|
+
*/
|
|
8615
|
+
WorkAllocationService.prototype.getTask = function (taskId) {
|
|
8616
|
+
if (!this.isWAEnabled()) {
|
|
8617
|
+
return rxjs.of({ task: null });
|
|
8618
|
+
}
|
|
8619
|
+
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
|
|
8620
|
+
};
|
|
8621
|
+
return WorkAllocationService;
|
|
8622
|
+
}());
|
|
8623
|
+
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
8624
|
+
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
8625
|
+
WorkAllocationService.ɵfac = function WorkAllocationService_Factory(t) { return new (t || WorkAllocationService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(AlertService), i0__namespace.ɵɵinject(SessionStorageService)); };
|
|
8626
|
+
WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
8627
|
+
(function () {
|
|
8628
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
|
|
8629
|
+
type: i0.Injectable
|
|
8630
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
|
|
8631
|
+
})();
|
|
8632
|
+
|
|
8424
8633
|
var CasesService = /** @class */ (function () {
|
|
8425
|
-
function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
|
|
8634
|
+
function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, workAllocationService, loadingService, sessionStorageService) {
|
|
8426
8635
|
this.http = http;
|
|
8427
8636
|
this.appConfig = appConfig;
|
|
8428
8637
|
this.orderService = orderService;
|
|
8429
8638
|
this.errorService = errorService;
|
|
8430
8639
|
this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
|
|
8640
|
+
this.workAllocationService = workAllocationService;
|
|
8431
8641
|
this.loadingService = loadingService;
|
|
8432
8642
|
this.sessionStorageService = sessionStorageService;
|
|
8433
8643
|
this.get = this.getCaseView;
|
|
@@ -8662,12 +8872,12 @@
|
|
|
8662
8872
|
CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
|
|
8663
8873
|
CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
|
|
8664
8874
|
CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
|
|
8665
|
-
CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(OrderService), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0__namespace.ɵɵinject(LoadingService), i0__namespace.ɵɵinject(SessionStorageService)); };
|
|
8875
|
+
CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(OrderService), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0__namespace.ɵɵinject(WorkAllocationService), i0__namespace.ɵɵinject(LoadingService), i0__namespace.ɵɵinject(SessionStorageService)); };
|
|
8666
8876
|
CasesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
|
|
8667
8877
|
(function () {
|
|
8668
8878
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CasesService, [{
|
|
8669
8879
|
type: i0.Injectable
|
|
8670
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
|
|
8880
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: WorkAllocationService }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
|
|
8671
8881
|
})();
|
|
8672
8882
|
|
|
8673
8883
|
var EventTriggerService = /** @class */ (function () {
|
|
@@ -9321,215 +9531,6 @@
|
|
|
9321
9531
|
}], function () { return [{ type: CaseFieldService }]; }, null);
|
|
9322
9532
|
})();
|
|
9323
9533
|
|
|
9324
|
-
var MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
9325
|
-
var WorkAllocationService = /** @class */ (function () {
|
|
9326
|
-
function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
9327
|
-
this.http = http;
|
|
9328
|
-
this.appConfig = appConfig;
|
|
9329
|
-
this.errorService = errorService;
|
|
9330
|
-
this.alertService = alertService;
|
|
9331
|
-
this.sessionStorageService = sessionStorageService;
|
|
9332
|
-
// Check to see if work allocation is enabled
|
|
9333
|
-
}
|
|
9334
|
-
/**
|
|
9335
|
-
* Call the API to get tasks matching the search criteria.
|
|
9336
|
-
* @param searchRequest The search parameters that specify which tasks to match.
|
|
9337
|
-
*/
|
|
9338
|
-
WorkAllocationService.prototype.searchTasks = function (searchRequest) {
|
|
9339
|
-
var _this = this;
|
|
9340
|
-
// Do not need to check if WA enabled as parent method will do that
|
|
9341
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
|
|
9342
|
-
return this.http
|
|
9343
|
-
.post(url, { searchRequest: searchRequest }, null, false)
|
|
9344
|
-
.pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
|
|
9345
|
-
_this.errorService.setError(error);
|
|
9346
|
-
// explicitly eat away 401 error and 400 error
|
|
9347
|
-
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
9348
|
-
// do nothing
|
|
9349
|
-
console.log('error status 401 or 400', error);
|
|
9350
|
-
}
|
|
9351
|
-
else {
|
|
9352
|
-
return rxjs.throwError(error);
|
|
9353
|
-
}
|
|
9354
|
-
}));
|
|
9355
|
-
};
|
|
9356
|
-
WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
|
|
9357
|
-
this.features = this.appConfig.getWAServiceConfig();
|
|
9358
|
-
var enabled = false;
|
|
9359
|
-
if (!jurisdiction || !caseType) {
|
|
9360
|
-
var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
9361
|
-
jurisdiction = caseInfo.jurisdiction;
|
|
9362
|
-
caseType = caseInfo.caseType;
|
|
9363
|
-
}
|
|
9364
|
-
if (!this.features || !this.features.configurations) {
|
|
9365
|
-
return false;
|
|
9366
|
-
}
|
|
9367
|
-
this.features.configurations.forEach(function (serviceConfig) {
|
|
9368
|
-
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
9369
|
-
enabled = true;
|
|
9370
|
-
}
|
|
9371
|
-
});
|
|
9372
|
-
return enabled;
|
|
9373
|
-
};
|
|
9374
|
-
/**
|
|
9375
|
-
* Call the API to assign a task.
|
|
9376
|
-
* @param taskId specifies which task should be assigned.
|
|
9377
|
-
* @param userId specifies the user the task should be assigned to.
|
|
9378
|
-
*/
|
|
9379
|
-
WorkAllocationService.prototype.assignTask = function (taskId, userId) {
|
|
9380
|
-
var _this = this;
|
|
9381
|
-
if (!this.isWAEnabled()) {
|
|
9382
|
-
return rxjs.of(null);
|
|
9383
|
-
}
|
|
9384
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
|
|
9385
|
-
return this.http
|
|
9386
|
-
.post(url, { userId: userId })
|
|
9387
|
-
.pipe(operators.catchError(function (error) {
|
|
9388
|
-
_this.errorService.setError(error);
|
|
9389
|
-
return rxjs.throwError(error);
|
|
9390
|
-
}));
|
|
9391
|
-
};
|
|
9392
|
-
/**
|
|
9393
|
-
* Call the API to complete a task.
|
|
9394
|
-
* @param taskId specifies which task should be completed.
|
|
9395
|
-
*/
|
|
9396
|
-
WorkAllocationService.prototype.completeTask = function (taskId) {
|
|
9397
|
-
var _this = this;
|
|
9398
|
-
if (!this.isWAEnabled()) {
|
|
9399
|
-
return rxjs.of(null);
|
|
9400
|
-
}
|
|
9401
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
9402
|
-
return this.http
|
|
9403
|
-
.post(url, {})
|
|
9404
|
-
.pipe(operators.catchError(function (error) {
|
|
9405
|
-
_this.errorService.setError(error);
|
|
9406
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
9407
|
-
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
9408
|
-
_this.handleTaskCompletionError(response);
|
|
9409
|
-
});
|
|
9410
|
-
return rxjs.throwError(error);
|
|
9411
|
-
}));
|
|
9412
|
-
};
|
|
9413
|
-
/**
|
|
9414
|
-
* Call the API to assign and complete a task.
|
|
9415
|
-
* @param taskId specifies which task should be completed.
|
|
9416
|
-
*/
|
|
9417
|
-
WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
|
|
9418
|
-
var _this = this;
|
|
9419
|
-
if (!this.isWAEnabled()) {
|
|
9420
|
-
return rxjs.of(null);
|
|
9421
|
-
}
|
|
9422
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
9423
|
-
return this.http
|
|
9424
|
-
.post(url, {
|
|
9425
|
-
completion_options: {
|
|
9426
|
-
assign_and_complete: true
|
|
9427
|
-
}
|
|
9428
|
-
})
|
|
9429
|
-
.pipe(operators.catchError(function (error) {
|
|
9430
|
-
_this.errorService.setError(error);
|
|
9431
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
9432
|
-
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
9433
|
-
_this.handleTaskCompletionError(response);
|
|
9434
|
-
});
|
|
9435
|
-
return rxjs.throwError(error);
|
|
9436
|
-
}));
|
|
9437
|
-
};
|
|
9438
|
-
/**
|
|
9439
|
-
* Handles the response from the observable to get the user details when task is completed.
|
|
9440
|
-
* @param response is the response given from the observable which contains the user detaild.
|
|
9441
|
-
*/
|
|
9442
|
-
WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
|
|
9443
|
-
var userDetails = response;
|
|
9444
|
-
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
9445
|
-
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
9446
|
-
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
9447
|
-
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
9448
|
-
}
|
|
9449
|
-
};
|
|
9450
|
-
/**
|
|
9451
|
-
* Returns true if the user's role is equivalent to a caseworker.
|
|
9452
|
-
* @param roles is the list of roles found from the current user.
|
|
9453
|
-
*/
|
|
9454
|
-
WorkAllocationService.prototype.userIsCaseworker = function (roles) {
|
|
9455
|
-
var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
|
|
9456
|
-
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
9457
|
-
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
9458
|
-
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
9459
|
-
};
|
|
9460
|
-
/**
|
|
9461
|
-
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
9462
|
-
* 1. No tasks found => Success.
|
|
9463
|
-
* 2. One task found => Mark as done => Success.
|
|
9464
|
-
* 3. One task found => Mark as done throws error => Failure.
|
|
9465
|
-
* 4. More than one task found => Failure.
|
|
9466
|
-
* 5. Search call throws an error => Failure.
|
|
9467
|
-
* @param ccdId The ID of the case to find tasks for.
|
|
9468
|
-
* @param eventId The ID of the event to find tasks for.
|
|
9469
|
-
*/
|
|
9470
|
-
WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
|
|
9471
|
-
var _this = this;
|
|
9472
|
-
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
9473
|
-
return rxjs.of(null);
|
|
9474
|
-
}
|
|
9475
|
-
var taskSearchParameter = {
|
|
9476
|
-
ccdId: ccdId,
|
|
9477
|
-
eventId: eventId,
|
|
9478
|
-
jurisdiction: jurisdiction,
|
|
9479
|
-
caseTypeId: caseTypeId
|
|
9480
|
-
};
|
|
9481
|
-
return this.searchTasks(taskSearchParameter)
|
|
9482
|
-
.pipe(operators.map(function (response) {
|
|
9483
|
-
var tasks = response.tasks;
|
|
9484
|
-
if (tasks && tasks.length > 0) {
|
|
9485
|
-
if (tasks.length === 1) {
|
|
9486
|
-
_this.completeTask(tasks[0].id).subscribe();
|
|
9487
|
-
}
|
|
9488
|
-
else {
|
|
9489
|
-
// This is a problem. Throw an appropriate error.
|
|
9490
|
-
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
9491
|
-
}
|
|
9492
|
-
}
|
|
9493
|
-
return true; // All good. Nothing to see here.
|
|
9494
|
-
}), operators.catchError(function (error) {
|
|
9495
|
-
// Simply rethrow it.
|
|
9496
|
-
return rxjs.throwError(error);
|
|
9497
|
-
}));
|
|
9498
|
-
};
|
|
9499
|
-
/**
|
|
9500
|
-
* Return tasks for case and event.
|
|
9501
|
-
*/
|
|
9502
|
-
WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
|
|
9503
|
-
var defaultPayload = {
|
|
9504
|
-
task_required_for_event: false,
|
|
9505
|
-
tasks: []
|
|
9506
|
-
};
|
|
9507
|
-
if (!this.isWAEnabled()) {
|
|
9508
|
-
return rxjs.of(defaultPayload);
|
|
9509
|
-
}
|
|
9510
|
-
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
|
|
9511
|
-
};
|
|
9512
|
-
/**
|
|
9513
|
-
* Call the API to get a task
|
|
9514
|
-
*/
|
|
9515
|
-
WorkAllocationService.prototype.getTask = function (taskId) {
|
|
9516
|
-
if (!this.isWAEnabled()) {
|
|
9517
|
-
return rxjs.of({ task: null });
|
|
9518
|
-
}
|
|
9519
|
-
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
|
|
9520
|
-
};
|
|
9521
|
-
return WorkAllocationService;
|
|
9522
|
-
}());
|
|
9523
|
-
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
9524
|
-
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
9525
|
-
WorkAllocationService.ɵfac = function WorkAllocationService_Factory(t) { return new (t || WorkAllocationService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(AlertService), i0__namespace.ɵɵinject(SessionStorageService)); };
|
|
9526
|
-
WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
9527
|
-
(function () {
|
|
9528
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
|
|
9529
|
-
type: i0.Injectable
|
|
9530
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
|
|
9531
|
-
})();
|
|
9532
|
-
|
|
9533
9534
|
var CaseEditComponent = /** @class */ (function () {
|
|
9534
9535
|
function CaseEditComponent(fb, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService) {
|
|
9535
9536
|
this.fb = fb;
|