@hmcts/ccd-case-ui-toolkit 6.13.10-case-file-view-sort-by-document-upload-date → 6.13.10-case-file-view-sort-by-document-upload-date-v2
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 +212 -213
- 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/fesm2015/hmcts-ccd-case-ui-toolkit.js +204 -205
- 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/package.json +1 -1
|
@@ -8620,223 +8620,13 @@
|
|
|
8620
8620
|
}], null, null);
|
|
8621
8621
|
})();
|
|
8622
8622
|
|
|
8623
|
-
var MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
8624
|
-
var WorkAllocationService = /** @class */ (function () {
|
|
8625
|
-
function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
8626
|
-
this.http = http;
|
|
8627
|
-
this.appConfig = appConfig;
|
|
8628
|
-
this.errorService = errorService;
|
|
8629
|
-
this.alertService = alertService;
|
|
8630
|
-
this.sessionStorageService = sessionStorageService;
|
|
8631
|
-
// Check to see if work allocation is enabled
|
|
8632
|
-
}
|
|
8633
|
-
/**
|
|
8634
|
-
* Call the API to get tasks matching the search criteria.
|
|
8635
|
-
* @param searchRequest The search parameters that specify which tasks to match.
|
|
8636
|
-
*/
|
|
8637
|
-
WorkAllocationService.prototype.searchTasks = function (searchRequest) {
|
|
8638
|
-
var _this = this;
|
|
8639
|
-
// Do not need to check if WA enabled as parent method will do that
|
|
8640
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
|
|
8641
|
-
return this.http
|
|
8642
|
-
.post(url, { searchRequest: searchRequest }, null, false)
|
|
8643
|
-
.pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
|
|
8644
|
-
_this.errorService.setError(error);
|
|
8645
|
-
// explicitly eat away 401 error and 400 error
|
|
8646
|
-
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
8647
|
-
// do nothing
|
|
8648
|
-
console.log('error status 401 or 400', error);
|
|
8649
|
-
}
|
|
8650
|
-
else {
|
|
8651
|
-
return rxjs.throwError(error);
|
|
8652
|
-
}
|
|
8653
|
-
}));
|
|
8654
|
-
};
|
|
8655
|
-
WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
|
|
8656
|
-
this.features = this.appConfig.getWAServiceConfig();
|
|
8657
|
-
var enabled = false;
|
|
8658
|
-
if (!jurisdiction || !caseType) {
|
|
8659
|
-
var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
8660
|
-
jurisdiction = caseInfo.jurisdiction;
|
|
8661
|
-
caseType = caseInfo.caseType;
|
|
8662
|
-
}
|
|
8663
|
-
if (!this.features || !this.features.configurations) {
|
|
8664
|
-
return false;
|
|
8665
|
-
}
|
|
8666
|
-
this.features.configurations.forEach(function (serviceConfig) {
|
|
8667
|
-
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
8668
|
-
enabled = true;
|
|
8669
|
-
}
|
|
8670
|
-
});
|
|
8671
|
-
return enabled;
|
|
8672
|
-
};
|
|
8673
|
-
/**
|
|
8674
|
-
* Call the API to assign a task.
|
|
8675
|
-
* @param taskId specifies which task should be assigned.
|
|
8676
|
-
* @param userId specifies the user the task should be assigned to.
|
|
8677
|
-
*/
|
|
8678
|
-
WorkAllocationService.prototype.assignTask = function (taskId, userId) {
|
|
8679
|
-
var _this = this;
|
|
8680
|
-
if (!this.isWAEnabled()) {
|
|
8681
|
-
return rxjs.of(null);
|
|
8682
|
-
}
|
|
8683
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
|
|
8684
|
-
return this.http
|
|
8685
|
-
.post(url, { userId: userId })
|
|
8686
|
-
.pipe(operators.catchError(function (error) {
|
|
8687
|
-
_this.errorService.setError(error);
|
|
8688
|
-
return rxjs.throwError(error);
|
|
8689
|
-
}));
|
|
8690
|
-
};
|
|
8691
|
-
/**
|
|
8692
|
-
* Call the API to complete a task.
|
|
8693
|
-
* @param taskId specifies which task should be completed.
|
|
8694
|
-
*/
|
|
8695
|
-
WorkAllocationService.prototype.completeTask = function (taskId) {
|
|
8696
|
-
var _this = this;
|
|
8697
|
-
if (!this.isWAEnabled()) {
|
|
8698
|
-
return rxjs.of(null);
|
|
8699
|
-
}
|
|
8700
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
8701
|
-
return this.http
|
|
8702
|
-
.post(url, {})
|
|
8703
|
-
.pipe(operators.catchError(function (error) {
|
|
8704
|
-
_this.errorService.setError(error);
|
|
8705
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
8706
|
-
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
8707
|
-
_this.handleTaskCompletionError(response);
|
|
8708
|
-
});
|
|
8709
|
-
return rxjs.throwError(error);
|
|
8710
|
-
}));
|
|
8711
|
-
};
|
|
8712
|
-
/**
|
|
8713
|
-
* Call the API to assign and complete a task.
|
|
8714
|
-
* @param taskId specifies which task should be completed.
|
|
8715
|
-
*/
|
|
8716
|
-
WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
|
|
8717
|
-
var _this = this;
|
|
8718
|
-
if (!this.isWAEnabled()) {
|
|
8719
|
-
return rxjs.of(null);
|
|
8720
|
-
}
|
|
8721
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
8722
|
-
return this.http
|
|
8723
|
-
.post(url, {
|
|
8724
|
-
completion_options: {
|
|
8725
|
-
assign_and_complete: true
|
|
8726
|
-
}
|
|
8727
|
-
})
|
|
8728
|
-
.pipe(operators.catchError(function (error) {
|
|
8729
|
-
_this.errorService.setError(error);
|
|
8730
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
8731
|
-
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
8732
|
-
_this.handleTaskCompletionError(response);
|
|
8733
|
-
});
|
|
8734
|
-
return rxjs.throwError(error);
|
|
8735
|
-
}));
|
|
8736
|
-
};
|
|
8737
|
-
/**
|
|
8738
|
-
* Handles the response from the observable to get the user details when task is completed.
|
|
8739
|
-
* @param response is the response given from the observable which contains the user detaild.
|
|
8740
|
-
*/
|
|
8741
|
-
WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
|
|
8742
|
-
var userDetails = response;
|
|
8743
|
-
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
8744
|
-
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
8745
|
-
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
8746
|
-
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
8747
|
-
}
|
|
8748
|
-
};
|
|
8749
|
-
/**
|
|
8750
|
-
* Returns true if the user's role is equivalent to a caseworker.
|
|
8751
|
-
* @param roles is the list of roles found from the current user.
|
|
8752
|
-
*/
|
|
8753
|
-
WorkAllocationService.prototype.userIsCaseworker = function (roles) {
|
|
8754
|
-
var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
|
|
8755
|
-
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
8756
|
-
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
8757
|
-
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
8758
|
-
};
|
|
8759
|
-
/**
|
|
8760
|
-
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
8761
|
-
* 1. No tasks found => Success.
|
|
8762
|
-
* 2. One task found => Mark as done => Success.
|
|
8763
|
-
* 3. One task found => Mark as done throws error => Failure.
|
|
8764
|
-
* 4. More than one task found => Failure.
|
|
8765
|
-
* 5. Search call throws an error => Failure.
|
|
8766
|
-
* @param ccdId The ID of the case to find tasks for.
|
|
8767
|
-
* @param eventId The ID of the event to find tasks for.
|
|
8768
|
-
*/
|
|
8769
|
-
WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
|
|
8770
|
-
var _this = this;
|
|
8771
|
-
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
8772
|
-
return rxjs.of(null);
|
|
8773
|
-
}
|
|
8774
|
-
var taskSearchParameter = {
|
|
8775
|
-
ccdId: ccdId,
|
|
8776
|
-
eventId: eventId,
|
|
8777
|
-
jurisdiction: jurisdiction,
|
|
8778
|
-
caseTypeId: caseTypeId
|
|
8779
|
-
};
|
|
8780
|
-
return this.searchTasks(taskSearchParameter)
|
|
8781
|
-
.pipe(operators.map(function (response) {
|
|
8782
|
-
var tasks = response.tasks;
|
|
8783
|
-
if (tasks && tasks.length > 0) {
|
|
8784
|
-
if (tasks.length === 1) {
|
|
8785
|
-
_this.completeTask(tasks[0].id).subscribe();
|
|
8786
|
-
}
|
|
8787
|
-
else {
|
|
8788
|
-
// This is a problem. Throw an appropriate error.
|
|
8789
|
-
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
8790
|
-
}
|
|
8791
|
-
}
|
|
8792
|
-
return true; // All good. Nothing to see here.
|
|
8793
|
-
}), operators.catchError(function (error) {
|
|
8794
|
-
// Simply rethrow it.
|
|
8795
|
-
return rxjs.throwError(error);
|
|
8796
|
-
}));
|
|
8797
|
-
};
|
|
8798
|
-
/**
|
|
8799
|
-
* Return tasks for case and event.
|
|
8800
|
-
*/
|
|
8801
|
-
WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
|
|
8802
|
-
var defaultPayload = {
|
|
8803
|
-
task_required_for_event: false,
|
|
8804
|
-
tasks: []
|
|
8805
|
-
};
|
|
8806
|
-
if (!this.isWAEnabled()) {
|
|
8807
|
-
return rxjs.of(defaultPayload);
|
|
8808
|
-
}
|
|
8809
|
-
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
|
|
8810
|
-
};
|
|
8811
|
-
/**
|
|
8812
|
-
* Call the API to get a task
|
|
8813
|
-
*/
|
|
8814
|
-
WorkAllocationService.prototype.getTask = function (taskId) {
|
|
8815
|
-
if (!this.isWAEnabled()) {
|
|
8816
|
-
return rxjs.of({ task: null });
|
|
8817
|
-
}
|
|
8818
|
-
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
|
|
8819
|
-
};
|
|
8820
|
-
return WorkAllocationService;
|
|
8821
|
-
}());
|
|
8822
|
-
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
8823
|
-
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
8824
|
-
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)); };
|
|
8825
|
-
WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
8826
|
-
(function () {
|
|
8827
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
|
|
8828
|
-
type: i0.Injectable
|
|
8829
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
|
|
8830
|
-
})();
|
|
8831
|
-
|
|
8832
8623
|
var CasesService = /** @class */ (function () {
|
|
8833
|
-
function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper,
|
|
8624
|
+
function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
|
|
8834
8625
|
this.http = http;
|
|
8835
8626
|
this.appConfig = appConfig;
|
|
8836
8627
|
this.orderService = orderService;
|
|
8837
8628
|
this.errorService = errorService;
|
|
8838
8629
|
this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
|
|
8839
|
-
this.workAllocationService = workAllocationService;
|
|
8840
8630
|
this.loadingService = loadingService;
|
|
8841
8631
|
this.sessionStorageService = sessionStorageService;
|
|
8842
8632
|
this.get = this.getCaseView;
|
|
@@ -9063,12 +8853,12 @@
|
|
|
9063
8853
|
CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
|
|
9064
8854
|
CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
|
|
9065
8855
|
CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
|
|
9066
|
-
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(
|
|
8856
|
+
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)); };
|
|
9067
8857
|
CasesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
|
|
9068
8858
|
(function () {
|
|
9069
8859
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CasesService, [{
|
|
9070
8860
|
type: i0.Injectable
|
|
9071
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type:
|
|
8861
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
|
|
9072
8862
|
})();
|
|
9073
8863
|
|
|
9074
8864
|
var EventTriggerService = /** @class */ (function () {
|
|
@@ -9722,6 +9512,215 @@
|
|
|
9722
9512
|
}], function () { return [{ type: CaseFieldService }]; }, null);
|
|
9723
9513
|
})();
|
|
9724
9514
|
|
|
9515
|
+
var MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
9516
|
+
var WorkAllocationService = /** @class */ (function () {
|
|
9517
|
+
function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
9518
|
+
this.http = http;
|
|
9519
|
+
this.appConfig = appConfig;
|
|
9520
|
+
this.errorService = errorService;
|
|
9521
|
+
this.alertService = alertService;
|
|
9522
|
+
this.sessionStorageService = sessionStorageService;
|
|
9523
|
+
// Check to see if work allocation is enabled
|
|
9524
|
+
}
|
|
9525
|
+
/**
|
|
9526
|
+
* Call the API to get tasks matching the search criteria.
|
|
9527
|
+
* @param searchRequest The search parameters that specify which tasks to match.
|
|
9528
|
+
*/
|
|
9529
|
+
WorkAllocationService.prototype.searchTasks = function (searchRequest) {
|
|
9530
|
+
var _this = this;
|
|
9531
|
+
// Do not need to check if WA enabled as parent method will do that
|
|
9532
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
|
|
9533
|
+
return this.http
|
|
9534
|
+
.post(url, { searchRequest: searchRequest }, null, false)
|
|
9535
|
+
.pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
|
|
9536
|
+
_this.errorService.setError(error);
|
|
9537
|
+
// explicitly eat away 401 error and 400 error
|
|
9538
|
+
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
9539
|
+
// do nothing
|
|
9540
|
+
console.log('error status 401 or 400', error);
|
|
9541
|
+
}
|
|
9542
|
+
else {
|
|
9543
|
+
return rxjs.throwError(error);
|
|
9544
|
+
}
|
|
9545
|
+
}));
|
|
9546
|
+
};
|
|
9547
|
+
WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
|
|
9548
|
+
this.features = this.appConfig.getWAServiceConfig();
|
|
9549
|
+
var enabled = false;
|
|
9550
|
+
if (!jurisdiction || !caseType) {
|
|
9551
|
+
var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
9552
|
+
jurisdiction = caseInfo.jurisdiction;
|
|
9553
|
+
caseType = caseInfo.caseType;
|
|
9554
|
+
}
|
|
9555
|
+
if (!this.features || !this.features.configurations) {
|
|
9556
|
+
return false;
|
|
9557
|
+
}
|
|
9558
|
+
this.features.configurations.forEach(function (serviceConfig) {
|
|
9559
|
+
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
9560
|
+
enabled = true;
|
|
9561
|
+
}
|
|
9562
|
+
});
|
|
9563
|
+
return enabled;
|
|
9564
|
+
};
|
|
9565
|
+
/**
|
|
9566
|
+
* Call the API to assign a task.
|
|
9567
|
+
* @param taskId specifies which task should be assigned.
|
|
9568
|
+
* @param userId specifies the user the task should be assigned to.
|
|
9569
|
+
*/
|
|
9570
|
+
WorkAllocationService.prototype.assignTask = function (taskId, userId) {
|
|
9571
|
+
var _this = this;
|
|
9572
|
+
if (!this.isWAEnabled()) {
|
|
9573
|
+
return rxjs.of(null);
|
|
9574
|
+
}
|
|
9575
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
|
|
9576
|
+
return this.http
|
|
9577
|
+
.post(url, { userId: userId })
|
|
9578
|
+
.pipe(operators.catchError(function (error) {
|
|
9579
|
+
_this.errorService.setError(error);
|
|
9580
|
+
return rxjs.throwError(error);
|
|
9581
|
+
}));
|
|
9582
|
+
};
|
|
9583
|
+
/**
|
|
9584
|
+
* Call the API to complete a task.
|
|
9585
|
+
* @param taskId specifies which task should be completed.
|
|
9586
|
+
*/
|
|
9587
|
+
WorkAllocationService.prototype.completeTask = function (taskId) {
|
|
9588
|
+
var _this = this;
|
|
9589
|
+
if (!this.isWAEnabled()) {
|
|
9590
|
+
return rxjs.of(null);
|
|
9591
|
+
}
|
|
9592
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
9593
|
+
return this.http
|
|
9594
|
+
.post(url, {})
|
|
9595
|
+
.pipe(operators.catchError(function (error) {
|
|
9596
|
+
_this.errorService.setError(error);
|
|
9597
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
9598
|
+
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
9599
|
+
_this.handleTaskCompletionError(response);
|
|
9600
|
+
});
|
|
9601
|
+
return rxjs.throwError(error);
|
|
9602
|
+
}));
|
|
9603
|
+
};
|
|
9604
|
+
/**
|
|
9605
|
+
* Call the API to assign and complete a task.
|
|
9606
|
+
* @param taskId specifies which task should be completed.
|
|
9607
|
+
*/
|
|
9608
|
+
WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
|
|
9609
|
+
var _this = this;
|
|
9610
|
+
if (!this.isWAEnabled()) {
|
|
9611
|
+
return rxjs.of(null);
|
|
9612
|
+
}
|
|
9613
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
9614
|
+
return this.http
|
|
9615
|
+
.post(url, {
|
|
9616
|
+
completion_options: {
|
|
9617
|
+
assign_and_complete: true
|
|
9618
|
+
}
|
|
9619
|
+
})
|
|
9620
|
+
.pipe(operators.catchError(function (error) {
|
|
9621
|
+
_this.errorService.setError(error);
|
|
9622
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
9623
|
+
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
9624
|
+
_this.handleTaskCompletionError(response);
|
|
9625
|
+
});
|
|
9626
|
+
return rxjs.throwError(error);
|
|
9627
|
+
}));
|
|
9628
|
+
};
|
|
9629
|
+
/**
|
|
9630
|
+
* Handles the response from the observable to get the user details when task is completed.
|
|
9631
|
+
* @param response is the response given from the observable which contains the user detaild.
|
|
9632
|
+
*/
|
|
9633
|
+
WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
|
|
9634
|
+
var userDetails = response;
|
|
9635
|
+
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
9636
|
+
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
9637
|
+
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
9638
|
+
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
9639
|
+
}
|
|
9640
|
+
};
|
|
9641
|
+
/**
|
|
9642
|
+
* Returns true if the user's role is equivalent to a caseworker.
|
|
9643
|
+
* @param roles is the list of roles found from the current user.
|
|
9644
|
+
*/
|
|
9645
|
+
WorkAllocationService.prototype.userIsCaseworker = function (roles) {
|
|
9646
|
+
var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
|
|
9647
|
+
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
9648
|
+
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
9649
|
+
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
9650
|
+
};
|
|
9651
|
+
/**
|
|
9652
|
+
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
9653
|
+
* 1. No tasks found => Success.
|
|
9654
|
+
* 2. One task found => Mark as done => Success.
|
|
9655
|
+
* 3. One task found => Mark as done throws error => Failure.
|
|
9656
|
+
* 4. More than one task found => Failure.
|
|
9657
|
+
* 5. Search call throws an error => Failure.
|
|
9658
|
+
* @param ccdId The ID of the case to find tasks for.
|
|
9659
|
+
* @param eventId The ID of the event to find tasks for.
|
|
9660
|
+
*/
|
|
9661
|
+
WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
|
|
9662
|
+
var _this = this;
|
|
9663
|
+
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
9664
|
+
return rxjs.of(null);
|
|
9665
|
+
}
|
|
9666
|
+
var taskSearchParameter = {
|
|
9667
|
+
ccdId: ccdId,
|
|
9668
|
+
eventId: eventId,
|
|
9669
|
+
jurisdiction: jurisdiction,
|
|
9670
|
+
caseTypeId: caseTypeId
|
|
9671
|
+
};
|
|
9672
|
+
return this.searchTasks(taskSearchParameter)
|
|
9673
|
+
.pipe(operators.map(function (response) {
|
|
9674
|
+
var tasks = response.tasks;
|
|
9675
|
+
if (tasks && tasks.length > 0) {
|
|
9676
|
+
if (tasks.length === 1) {
|
|
9677
|
+
_this.completeTask(tasks[0].id).subscribe();
|
|
9678
|
+
}
|
|
9679
|
+
else {
|
|
9680
|
+
// This is a problem. Throw an appropriate error.
|
|
9681
|
+
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
9682
|
+
}
|
|
9683
|
+
}
|
|
9684
|
+
return true; // All good. Nothing to see here.
|
|
9685
|
+
}), operators.catchError(function (error) {
|
|
9686
|
+
// Simply rethrow it.
|
|
9687
|
+
return rxjs.throwError(error);
|
|
9688
|
+
}));
|
|
9689
|
+
};
|
|
9690
|
+
/**
|
|
9691
|
+
* Return tasks for case and event.
|
|
9692
|
+
*/
|
|
9693
|
+
WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
|
|
9694
|
+
var defaultPayload = {
|
|
9695
|
+
task_required_for_event: false,
|
|
9696
|
+
tasks: []
|
|
9697
|
+
};
|
|
9698
|
+
if (!this.isWAEnabled()) {
|
|
9699
|
+
return rxjs.of(defaultPayload);
|
|
9700
|
+
}
|
|
9701
|
+
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
|
|
9702
|
+
};
|
|
9703
|
+
/**
|
|
9704
|
+
* Call the API to get a task
|
|
9705
|
+
*/
|
|
9706
|
+
WorkAllocationService.prototype.getTask = function (taskId) {
|
|
9707
|
+
if (!this.isWAEnabled()) {
|
|
9708
|
+
return rxjs.of({ task: null });
|
|
9709
|
+
}
|
|
9710
|
+
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
|
|
9711
|
+
};
|
|
9712
|
+
return WorkAllocationService;
|
|
9713
|
+
}());
|
|
9714
|
+
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
9715
|
+
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
9716
|
+
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)); };
|
|
9717
|
+
WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
9718
|
+
(function () {
|
|
9719
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
|
|
9720
|
+
type: i0.Injectable
|
|
9721
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
|
|
9722
|
+
})();
|
|
9723
|
+
|
|
9725
9724
|
var CaseEditComponent = /** @class */ (function () {
|
|
9726
9725
|
function CaseEditComponent(fb, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService) {
|
|
9727
9726
|
this.fb = fb;
|