@hmcts/ccd-case-ui-toolkit 6.14.5-activity-tracker → 6.14.5-activity-tracker-2
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
|
@@ -8846,223 +8846,13 @@
|
|
|
8846
8846
|
}], null, null);
|
|
8847
8847
|
})();
|
|
8848
8848
|
|
|
8849
|
-
var MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
8850
|
-
var WorkAllocationService = /** @class */ (function () {
|
|
8851
|
-
function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
8852
|
-
this.http = http;
|
|
8853
|
-
this.appConfig = appConfig;
|
|
8854
|
-
this.errorService = errorService;
|
|
8855
|
-
this.alertService = alertService;
|
|
8856
|
-
this.sessionStorageService = sessionStorageService;
|
|
8857
|
-
// Check to see if work allocation is enabled
|
|
8858
|
-
}
|
|
8859
|
-
/**
|
|
8860
|
-
* Call the API to get tasks matching the search criteria.
|
|
8861
|
-
* @param searchRequest The search parameters that specify which tasks to match.
|
|
8862
|
-
*/
|
|
8863
|
-
WorkAllocationService.prototype.searchTasks = function (searchRequest) {
|
|
8864
|
-
var _this = this;
|
|
8865
|
-
// Do not need to check if WA enabled as parent method will do that
|
|
8866
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
|
|
8867
|
-
return this.http
|
|
8868
|
-
.post(url, { searchRequest: searchRequest }, null, false)
|
|
8869
|
-
.pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
|
|
8870
|
-
_this.errorService.setError(error);
|
|
8871
|
-
// explicitly eat away 401 error and 400 error
|
|
8872
|
-
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
8873
|
-
// do nothing
|
|
8874
|
-
console.log('error status 401 or 400', error);
|
|
8875
|
-
}
|
|
8876
|
-
else {
|
|
8877
|
-
return rxjs.throwError(error);
|
|
8878
|
-
}
|
|
8879
|
-
}));
|
|
8880
|
-
};
|
|
8881
|
-
WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
|
|
8882
|
-
this.features = this.appConfig.getWAServiceConfig();
|
|
8883
|
-
var enabled = false;
|
|
8884
|
-
if (!jurisdiction || !caseType) {
|
|
8885
|
-
var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
8886
|
-
jurisdiction = caseInfo.jurisdiction;
|
|
8887
|
-
caseType = caseInfo.caseType;
|
|
8888
|
-
}
|
|
8889
|
-
if (!this.features || !this.features.configurations) {
|
|
8890
|
-
return false;
|
|
8891
|
-
}
|
|
8892
|
-
this.features.configurations.forEach(function (serviceConfig) {
|
|
8893
|
-
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
8894
|
-
enabled = true;
|
|
8895
|
-
}
|
|
8896
|
-
});
|
|
8897
|
-
return enabled;
|
|
8898
|
-
};
|
|
8899
|
-
/**
|
|
8900
|
-
* Call the API to assign a task.
|
|
8901
|
-
* @param taskId specifies which task should be assigned.
|
|
8902
|
-
* @param userId specifies the user the task should be assigned to.
|
|
8903
|
-
*/
|
|
8904
|
-
WorkAllocationService.prototype.assignTask = function (taskId, userId) {
|
|
8905
|
-
var _this = this;
|
|
8906
|
-
if (!this.isWAEnabled()) {
|
|
8907
|
-
return rxjs.of(null);
|
|
8908
|
-
}
|
|
8909
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
|
|
8910
|
-
return this.http
|
|
8911
|
-
.post(url, { userId: userId })
|
|
8912
|
-
.pipe(operators.catchError(function (error) {
|
|
8913
|
-
_this.errorService.setError(error);
|
|
8914
|
-
return rxjs.throwError(error);
|
|
8915
|
-
}));
|
|
8916
|
-
};
|
|
8917
|
-
/**
|
|
8918
|
-
* Call the API to complete a task.
|
|
8919
|
-
* @param taskId specifies which task should be completed.
|
|
8920
|
-
*/
|
|
8921
|
-
WorkAllocationService.prototype.completeTask = function (taskId) {
|
|
8922
|
-
var _this = this;
|
|
8923
|
-
if (!this.isWAEnabled()) {
|
|
8924
|
-
return rxjs.of(null);
|
|
8925
|
-
}
|
|
8926
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
8927
|
-
return this.http
|
|
8928
|
-
.post(url, {})
|
|
8929
|
-
.pipe(operators.catchError(function (error) {
|
|
8930
|
-
_this.errorService.setError(error);
|
|
8931
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
8932
|
-
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
8933
|
-
_this.handleTaskCompletionError(response);
|
|
8934
|
-
});
|
|
8935
|
-
return rxjs.throwError(error);
|
|
8936
|
-
}));
|
|
8937
|
-
};
|
|
8938
|
-
/**
|
|
8939
|
-
* Call the API to assign and complete a task.
|
|
8940
|
-
* @param taskId specifies which task should be completed.
|
|
8941
|
-
*/
|
|
8942
|
-
WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
|
|
8943
|
-
var _this = this;
|
|
8944
|
-
if (!this.isWAEnabled()) {
|
|
8945
|
-
return rxjs.of(null);
|
|
8946
|
-
}
|
|
8947
|
-
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
8948
|
-
return this.http
|
|
8949
|
-
.post(url, {
|
|
8950
|
-
completion_options: {
|
|
8951
|
-
assign_and_complete: true
|
|
8952
|
-
}
|
|
8953
|
-
})
|
|
8954
|
-
.pipe(operators.catchError(function (error) {
|
|
8955
|
-
_this.errorService.setError(error);
|
|
8956
|
-
// this will subscribe to get the user details and decide whether to display an error message
|
|
8957
|
-
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
8958
|
-
_this.handleTaskCompletionError(response);
|
|
8959
|
-
});
|
|
8960
|
-
return rxjs.throwError(error);
|
|
8961
|
-
}));
|
|
8962
|
-
};
|
|
8963
|
-
/**
|
|
8964
|
-
* Handles the response from the observable to get the user details when task is completed.
|
|
8965
|
-
* @param response is the response given from the observable which contains the user detaild.
|
|
8966
|
-
*/
|
|
8967
|
-
WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
|
|
8968
|
-
var userDetails = response;
|
|
8969
|
-
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
8970
|
-
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
8971
|
-
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
8972
|
-
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
8973
|
-
}
|
|
8974
|
-
};
|
|
8975
|
-
/**
|
|
8976
|
-
* Returns true if the user's role is equivalent to a caseworker.
|
|
8977
|
-
* @param roles is the list of roles found from the current user.
|
|
8978
|
-
*/
|
|
8979
|
-
WorkAllocationService.prototype.userIsCaseworker = function (roles) {
|
|
8980
|
-
var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
|
|
8981
|
-
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
8982
|
-
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
8983
|
-
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
8984
|
-
};
|
|
8985
|
-
/**
|
|
8986
|
-
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
8987
|
-
* 1. No tasks found => Success.
|
|
8988
|
-
* 2. One task found => Mark as done => Success.
|
|
8989
|
-
* 3. One task found => Mark as done throws error => Failure.
|
|
8990
|
-
* 4. More than one task found => Failure.
|
|
8991
|
-
* 5. Search call throws an error => Failure.
|
|
8992
|
-
* @param ccdId The ID of the case to find tasks for.
|
|
8993
|
-
* @param eventId The ID of the event to find tasks for.
|
|
8994
|
-
*/
|
|
8995
|
-
WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
|
|
8996
|
-
var _this = this;
|
|
8997
|
-
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
8998
|
-
return rxjs.of(null);
|
|
8999
|
-
}
|
|
9000
|
-
var taskSearchParameter = {
|
|
9001
|
-
ccdId: ccdId,
|
|
9002
|
-
eventId: eventId,
|
|
9003
|
-
jurisdiction: jurisdiction,
|
|
9004
|
-
caseTypeId: caseTypeId
|
|
9005
|
-
};
|
|
9006
|
-
return this.searchTasks(taskSearchParameter)
|
|
9007
|
-
.pipe(operators.map(function (response) {
|
|
9008
|
-
var tasks = response.tasks;
|
|
9009
|
-
if (tasks && tasks.length > 0) {
|
|
9010
|
-
if (tasks.length === 1) {
|
|
9011
|
-
_this.completeTask(tasks[0].id).subscribe();
|
|
9012
|
-
}
|
|
9013
|
-
else {
|
|
9014
|
-
// This is a problem. Throw an appropriate error.
|
|
9015
|
-
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
9016
|
-
}
|
|
9017
|
-
}
|
|
9018
|
-
return true; // All good. Nothing to see here.
|
|
9019
|
-
}), operators.catchError(function (error) {
|
|
9020
|
-
// Simply rethrow it.
|
|
9021
|
-
return rxjs.throwError(error);
|
|
9022
|
-
}));
|
|
9023
|
-
};
|
|
9024
|
-
/**
|
|
9025
|
-
* Return tasks for case and event.
|
|
9026
|
-
*/
|
|
9027
|
-
WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
|
|
9028
|
-
var defaultPayload = {
|
|
9029
|
-
task_required_for_event: false,
|
|
9030
|
-
tasks: []
|
|
9031
|
-
};
|
|
9032
|
-
if (!this.isWAEnabled()) {
|
|
9033
|
-
return rxjs.of(defaultPayload);
|
|
9034
|
-
}
|
|
9035
|
-
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
|
|
9036
|
-
};
|
|
9037
|
-
/**
|
|
9038
|
-
* Call the API to get a task
|
|
9039
|
-
*/
|
|
9040
|
-
WorkAllocationService.prototype.getTask = function (taskId) {
|
|
9041
|
-
if (!this.isWAEnabled()) {
|
|
9042
|
-
return rxjs.of({ task: null });
|
|
9043
|
-
}
|
|
9044
|
-
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
|
|
9045
|
-
};
|
|
9046
|
-
return WorkAllocationService;
|
|
9047
|
-
}());
|
|
9048
|
-
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
9049
|
-
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
9050
|
-
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)); };
|
|
9051
|
-
WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
9052
|
-
(function () {
|
|
9053
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
|
|
9054
|
-
type: i0.Injectable
|
|
9055
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
|
|
9056
|
-
})();
|
|
9057
|
-
|
|
9058
8849
|
var CasesService = /** @class */ (function () {
|
|
9059
|
-
function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper,
|
|
8850
|
+
function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
|
|
9060
8851
|
this.http = http;
|
|
9061
8852
|
this.appConfig = appConfig;
|
|
9062
8853
|
this.orderService = orderService;
|
|
9063
8854
|
this.errorService = errorService;
|
|
9064
8855
|
this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
|
|
9065
|
-
this.workAllocationService = workAllocationService;
|
|
9066
8856
|
this.loadingService = loadingService;
|
|
9067
8857
|
this.sessionStorageService = sessionStorageService;
|
|
9068
8858
|
this.get = this.getCaseView;
|
|
@@ -9289,12 +9079,12 @@
|
|
|
9289
9079
|
CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
|
|
9290
9080
|
CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
|
|
9291
9081
|
CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
|
|
9292
|
-
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(
|
|
9082
|
+
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)); };
|
|
9293
9083
|
CasesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
|
|
9294
9084
|
(function () {
|
|
9295
9085
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CasesService, [{
|
|
9296
9086
|
type: i0.Injectable
|
|
9297
|
-
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type:
|
|
9087
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
|
|
9298
9088
|
})();
|
|
9299
9089
|
|
|
9300
9090
|
var EventTriggerService = /** @class */ (function () {
|
|
@@ -9948,6 +9738,215 @@
|
|
|
9948
9738
|
}], function () { return [{ type: CaseFieldService }]; }, null);
|
|
9949
9739
|
})();
|
|
9950
9740
|
|
|
9741
|
+
var MULTIPLE_TASKS_FOUND = 'More than one task found!';
|
|
9742
|
+
var WorkAllocationService = /** @class */ (function () {
|
|
9743
|
+
function WorkAllocationService(http, appConfig, errorService, alertService, sessionStorageService) {
|
|
9744
|
+
this.http = http;
|
|
9745
|
+
this.appConfig = appConfig;
|
|
9746
|
+
this.errorService = errorService;
|
|
9747
|
+
this.alertService = alertService;
|
|
9748
|
+
this.sessionStorageService = sessionStorageService;
|
|
9749
|
+
// Check to see if work allocation is enabled
|
|
9750
|
+
}
|
|
9751
|
+
/**
|
|
9752
|
+
* Call the API to get tasks matching the search criteria.
|
|
9753
|
+
* @param searchRequest The search parameters that specify which tasks to match.
|
|
9754
|
+
*/
|
|
9755
|
+
WorkAllocationService.prototype.searchTasks = function (searchRequest) {
|
|
9756
|
+
var _this = this;
|
|
9757
|
+
// Do not need to check if WA enabled as parent method will do that
|
|
9758
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/searchForCompletable";
|
|
9759
|
+
return this.http
|
|
9760
|
+
.post(url, { searchRequest: searchRequest }, null, false)
|
|
9761
|
+
.pipe(operators.map(function (response) { return response; }), operators.catchError(function (error) {
|
|
9762
|
+
_this.errorService.setError(error);
|
|
9763
|
+
// explicitly eat away 401 error and 400 error
|
|
9764
|
+
if (error && error.status && (error.status === 401 || error.status === 400)) {
|
|
9765
|
+
// do nothing
|
|
9766
|
+
console.log('error status 401 or 400', error);
|
|
9767
|
+
}
|
|
9768
|
+
else {
|
|
9769
|
+
return rxjs.throwError(error);
|
|
9770
|
+
}
|
|
9771
|
+
}));
|
|
9772
|
+
};
|
|
9773
|
+
WorkAllocationService.prototype.isWAEnabled = function (jurisdiction, caseType) {
|
|
9774
|
+
this.features = this.appConfig.getWAServiceConfig();
|
|
9775
|
+
var enabled = false;
|
|
9776
|
+
if (!jurisdiction || !caseType) {
|
|
9777
|
+
var caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo'));
|
|
9778
|
+
jurisdiction = caseInfo.jurisdiction;
|
|
9779
|
+
caseType = caseInfo.caseType;
|
|
9780
|
+
}
|
|
9781
|
+
if (!this.features || !this.features.configurations) {
|
|
9782
|
+
return false;
|
|
9783
|
+
}
|
|
9784
|
+
this.features.configurations.forEach(function (serviceConfig) {
|
|
9785
|
+
if (serviceConfig.serviceName === jurisdiction && (serviceConfig.caseTypes.indexOf(caseType) !== -1)) {
|
|
9786
|
+
enabled = true;
|
|
9787
|
+
}
|
|
9788
|
+
});
|
|
9789
|
+
return enabled;
|
|
9790
|
+
};
|
|
9791
|
+
/**
|
|
9792
|
+
* Call the API to assign a task.
|
|
9793
|
+
* @param taskId specifies which task should be assigned.
|
|
9794
|
+
* @param userId specifies the user the task should be assigned to.
|
|
9795
|
+
*/
|
|
9796
|
+
WorkAllocationService.prototype.assignTask = function (taskId, userId) {
|
|
9797
|
+
var _this = this;
|
|
9798
|
+
if (!this.isWAEnabled()) {
|
|
9799
|
+
return rxjs.of(null);
|
|
9800
|
+
}
|
|
9801
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/assign";
|
|
9802
|
+
return this.http
|
|
9803
|
+
.post(url, { userId: userId })
|
|
9804
|
+
.pipe(operators.catchError(function (error) {
|
|
9805
|
+
_this.errorService.setError(error);
|
|
9806
|
+
return rxjs.throwError(error);
|
|
9807
|
+
}));
|
|
9808
|
+
};
|
|
9809
|
+
/**
|
|
9810
|
+
* Call the API to complete a task.
|
|
9811
|
+
* @param taskId specifies which task should be completed.
|
|
9812
|
+
*/
|
|
9813
|
+
WorkAllocationService.prototype.completeTask = function (taskId) {
|
|
9814
|
+
var _this = this;
|
|
9815
|
+
if (!this.isWAEnabled()) {
|
|
9816
|
+
return rxjs.of(null);
|
|
9817
|
+
}
|
|
9818
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
9819
|
+
return this.http
|
|
9820
|
+
.post(url, {})
|
|
9821
|
+
.pipe(operators.catchError(function (error) {
|
|
9822
|
+
_this.errorService.setError(error);
|
|
9823
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
9824
|
+
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
9825
|
+
_this.handleTaskCompletionError(response);
|
|
9826
|
+
});
|
|
9827
|
+
return rxjs.throwError(error);
|
|
9828
|
+
}));
|
|
9829
|
+
};
|
|
9830
|
+
/**
|
|
9831
|
+
* Call the API to assign and complete a task.
|
|
9832
|
+
* @param taskId specifies which task should be completed.
|
|
9833
|
+
*/
|
|
9834
|
+
WorkAllocationService.prototype.assignAndCompleteTask = function (taskId) {
|
|
9835
|
+
var _this = this;
|
|
9836
|
+
if (!this.isWAEnabled()) {
|
|
9837
|
+
return rxjs.of(null);
|
|
9838
|
+
}
|
|
9839
|
+
var url = this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId + "/complete";
|
|
9840
|
+
return this.http
|
|
9841
|
+
.post(url, {
|
|
9842
|
+
completion_options: {
|
|
9843
|
+
assign_and_complete: true
|
|
9844
|
+
}
|
|
9845
|
+
})
|
|
9846
|
+
.pipe(operators.catchError(function (error) {
|
|
9847
|
+
_this.errorService.setError(error);
|
|
9848
|
+
// this will subscribe to get the user details and decide whether to display an error message
|
|
9849
|
+
_this.http.get(_this.appConfig.getUserInfoApiUrl()).pipe(operators.map(function (response) { return response; })).subscribe(function (response) {
|
|
9850
|
+
_this.handleTaskCompletionError(response);
|
|
9851
|
+
});
|
|
9852
|
+
return rxjs.throwError(error);
|
|
9853
|
+
}));
|
|
9854
|
+
};
|
|
9855
|
+
/**
|
|
9856
|
+
* Handles the response from the observable to get the user details when task is completed.
|
|
9857
|
+
* @param response is the response given from the observable which contains the user detaild.
|
|
9858
|
+
*/
|
|
9859
|
+
WorkAllocationService.prototype.handleTaskCompletionError = function (response) {
|
|
9860
|
+
var userDetails = response;
|
|
9861
|
+
if (this.userIsCaseworker(userDetails.userInfo.roles)) {
|
|
9862
|
+
// when submitting the completion of task if not yet rendered cases/case confirm then preserve the alert for re-rendering
|
|
9863
|
+
this.alertService.setPreserveAlerts(true, ['cases/case', 'submit']);
|
|
9864
|
+
this.alertService.warning('A task could not be completed successfully. Please complete the task associated with the case manually.');
|
|
9865
|
+
}
|
|
9866
|
+
};
|
|
9867
|
+
/**
|
|
9868
|
+
* Returns true if the user's role is equivalent to a caseworker.
|
|
9869
|
+
* @param roles is the list of roles found from the current user.
|
|
9870
|
+
*/
|
|
9871
|
+
WorkAllocationService.prototype.userIsCaseworker = function (roles) {
|
|
9872
|
+
var lowerCaseRoles = roles.map(function (role) { return role.toLowerCase(); });
|
|
9873
|
+
// When/if lib & target permanently change to es2016, replace indexOf with includes
|
|
9874
|
+
return (lowerCaseRoles.indexOf(WorkAllocationService.iACCaseOfficer) !== -1)
|
|
9875
|
+
|| (lowerCaseRoles.indexOf(WorkAllocationService.iACAdmOfficer) !== -1);
|
|
9876
|
+
};
|
|
9877
|
+
/**
|
|
9878
|
+
* Look for open tasks for a case and event combination. There are 5 possible scenarios:
|
|
9879
|
+
* 1. No tasks found => Success.
|
|
9880
|
+
* 2. One task found => Mark as done => Success.
|
|
9881
|
+
* 3. One task found => Mark as done throws error => Failure.
|
|
9882
|
+
* 4. More than one task found => Failure.
|
|
9883
|
+
* 5. Search call throws an error => Failure.
|
|
9884
|
+
* @param ccdId The ID of the case to find tasks for.
|
|
9885
|
+
* @param eventId The ID of the event to find tasks for.
|
|
9886
|
+
*/
|
|
9887
|
+
WorkAllocationService.prototype.completeAppropriateTask = function (ccdId, eventId, jurisdiction, caseTypeId) {
|
|
9888
|
+
var _this = this;
|
|
9889
|
+
if (!this.isWAEnabled(jurisdiction, caseTypeId)) {
|
|
9890
|
+
return rxjs.of(null);
|
|
9891
|
+
}
|
|
9892
|
+
var taskSearchParameter = {
|
|
9893
|
+
ccdId: ccdId,
|
|
9894
|
+
eventId: eventId,
|
|
9895
|
+
jurisdiction: jurisdiction,
|
|
9896
|
+
caseTypeId: caseTypeId
|
|
9897
|
+
};
|
|
9898
|
+
return this.searchTasks(taskSearchParameter)
|
|
9899
|
+
.pipe(operators.map(function (response) {
|
|
9900
|
+
var tasks = response.tasks;
|
|
9901
|
+
if (tasks && tasks.length > 0) {
|
|
9902
|
+
if (tasks.length === 1) {
|
|
9903
|
+
_this.completeTask(tasks[0].id).subscribe();
|
|
9904
|
+
}
|
|
9905
|
+
else {
|
|
9906
|
+
// This is a problem. Throw an appropriate error.
|
|
9907
|
+
throw new Error(MULTIPLE_TASKS_FOUND);
|
|
9908
|
+
}
|
|
9909
|
+
}
|
|
9910
|
+
return true; // All good. Nothing to see here.
|
|
9911
|
+
}), operators.catchError(function (error) {
|
|
9912
|
+
// Simply rethrow it.
|
|
9913
|
+
return rxjs.throwError(error);
|
|
9914
|
+
}));
|
|
9915
|
+
};
|
|
9916
|
+
/**
|
|
9917
|
+
* Return tasks for case and event.
|
|
9918
|
+
*/
|
|
9919
|
+
WorkAllocationService.prototype.getTasksByCaseIdAndEventId = function (eventId, caseId, caseType, jurisdiction) {
|
|
9920
|
+
var defaultPayload = {
|
|
9921
|
+
task_required_for_event: false,
|
|
9922
|
+
tasks: []
|
|
9923
|
+
};
|
|
9924
|
+
if (!this.isWAEnabled()) {
|
|
9925
|
+
return rxjs.of(defaultPayload);
|
|
9926
|
+
}
|
|
9927
|
+
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/case/tasks/" + caseId + "/event/" + eventId + "/caseType/" + caseType + "/jurisdiction/" + jurisdiction);
|
|
9928
|
+
};
|
|
9929
|
+
/**
|
|
9930
|
+
* Call the API to get a task
|
|
9931
|
+
*/
|
|
9932
|
+
WorkAllocationService.prototype.getTask = function (taskId) {
|
|
9933
|
+
if (!this.isWAEnabled()) {
|
|
9934
|
+
return rxjs.of({ task: null });
|
|
9935
|
+
}
|
|
9936
|
+
return this.http.get(this.appConfig.getWorkAllocationApiUrl() + "/task/" + taskId);
|
|
9937
|
+
};
|
|
9938
|
+
return WorkAllocationService;
|
|
9939
|
+
}());
|
|
9940
|
+
WorkAllocationService.iACCaseOfficer = 'caseworker-ia-caseofficer';
|
|
9941
|
+
WorkAllocationService.iACAdmOfficer = 'caseworker-ia-admofficer';
|
|
9942
|
+
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)); };
|
|
9943
|
+
WorkAllocationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: WorkAllocationService, factory: WorkAllocationService.ɵfac });
|
|
9944
|
+
(function () {
|
|
9945
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WorkAllocationService, [{
|
|
9946
|
+
type: i0.Injectable
|
|
9947
|
+
}], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }, { type: AlertService }, { type: SessionStorageService }]; }, null);
|
|
9948
|
+
})();
|
|
9949
|
+
|
|
9951
9950
|
var CaseEditComponent = /** @class */ (function () {
|
|
9952
9951
|
function CaseEditComponent(fb, router, route, fieldsUtils, fieldsPurger, registrarService, wizardFactory, sessionStorageService, windowsService) {
|
|
9953
9952
|
this.fb = fb;
|