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