@hmcts/ccd-case-ui-toolkit 7.3.68-user-by-idam-rework → 7.3.69-case-search
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.
|
@@ -8123,6 +8123,9 @@ class RequestOptionsBuilder {
|
|
|
8123
8123
|
* @param value The value to be assessed.
|
|
8124
8124
|
*/
|
|
8125
8125
|
static includeParam(value) {
|
|
8126
|
+
if (Array.isArray(value)) {
|
|
8127
|
+
return value.some(item => RequestOptionsBuilder.includeParam(item));
|
|
8128
|
+
}
|
|
8126
8129
|
/* istanbul ignore else */
|
|
8127
8130
|
if (value) {
|
|
8128
8131
|
/* istanbul ignore else */
|
|
@@ -8133,6 +8136,36 @@ class RequestOptionsBuilder {
|
|
|
8133
8136
|
}
|
|
8134
8137
|
return false;
|
|
8135
8138
|
}
|
|
8139
|
+
static sanitiseValue(value) {
|
|
8140
|
+
const trimmedValue = value.trim ? value.trim() : value;
|
|
8141
|
+
return trimmedValue.replace ? trimmedValue.replace(/’/i, `'`) : trimmedValue;
|
|
8142
|
+
}
|
|
8143
|
+
static getValueByPath(value, path) {
|
|
8144
|
+
return path.split('.').reduce((currentValue, pathPart) => {
|
|
8145
|
+
if (currentValue === undefined || currentValue === null) {
|
|
8146
|
+
return undefined;
|
|
8147
|
+
}
|
|
8148
|
+
return currentValue[pathPart];
|
|
8149
|
+
}, value);
|
|
8150
|
+
}
|
|
8151
|
+
static getCollectionValues(value, criterion) {
|
|
8152
|
+
if (!Array.isArray(value) ||
|
|
8153
|
+
criterion.indexOf('.value.') < 0 ||
|
|
8154
|
+
value.some(item => item === null || typeof item !== 'object' || !Object.prototype.hasOwnProperty.call(item, 'value'))) {
|
|
8155
|
+
return value;
|
|
8156
|
+
}
|
|
8157
|
+
const valuePath = criterion.substring(criterion.indexOf('.value.') + 1);
|
|
8158
|
+
return value.map(item => RequestOptionsBuilder.getValueByPath(item, valuePath));
|
|
8159
|
+
}
|
|
8160
|
+
static appendParam(params, key, value) {
|
|
8161
|
+
if (Array.isArray(value)) {
|
|
8162
|
+
const values = value
|
|
8163
|
+
.filter(item => RequestOptionsBuilder.includeParam(item))
|
|
8164
|
+
.map(item => RequestOptionsBuilder.sanitiseValue(item));
|
|
8165
|
+
return params.set(key, `[${values.join(', ')}]`);
|
|
8166
|
+
}
|
|
8167
|
+
return params.set(key, RequestOptionsBuilder.sanitiseValue(value));
|
|
8168
|
+
}
|
|
8136
8169
|
buildOptions(metaCriteria, caseCriteria, view) {
|
|
8137
8170
|
// TODO: This should probably be the now built-in URLSearchParams but it
|
|
8138
8171
|
// requires a bigger refactor and there are bigger fish to fry right now.
|
|
@@ -8157,8 +8190,7 @@ class RequestOptionsBuilder {
|
|
|
8157
8190
|
/* istanbul ignore else */
|
|
8158
8191
|
if (RequestOptionsBuilder.includeParam(caseCriteria[criterion])) {
|
|
8159
8192
|
const key = RequestOptionsBuilder.FIELD_PREFIX + criterion;
|
|
8160
|
-
|
|
8161
|
-
params = params.set(key, value.replace(/’/i, `'`));
|
|
8193
|
+
params = RequestOptionsBuilder.appendParam(params, key, RequestOptionsBuilder.getCollectionValues(caseCriteria[criterion], criterion));
|
|
8162
8194
|
}
|
|
8163
8195
|
}
|
|
8164
8196
|
}
|
|
@@ -8651,33 +8683,31 @@ class CaseAccessUtils {
|
|
|
8651
8683
|
static CTSC_ROLE = 'ctsc';
|
|
8652
8684
|
static CTSC_ROLE_CATEGORY = 'CTSC';
|
|
8653
8685
|
static CTSC_ROLE_NAME = 'ctsc';
|
|
8654
|
-
|
|
8655
|
-
getMappedRoleCategories(roles = []) {
|
|
8686
|
+
getMappedRoleCategory(roles = [], roleCategories = []) {
|
|
8656
8687
|
const roleKeywords = roles.join().split('-').join().split(',');
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
roleCategoryList.push(CaseAccessUtils.JUDGE_ROLE_CATEGORY);
|
|
8688
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.JUDGE_ROLE, CaseAccessUtils.JUDGE_ROLE_CATEGORY, roleKeywords, roleCategories)) {
|
|
8689
|
+
return CaseAccessUtils.JUDGE_ROLE_CATEGORY;
|
|
8660
8690
|
}
|
|
8661
|
-
if (this.roleOrCategoryExists(CaseAccessUtils.PROFESSIONAL_ROLE, roleKeywords)) {
|
|
8662
|
-
|
|
8691
|
+
else if (this.roleOrCategoryExists(CaseAccessUtils.PROFESSIONAL_ROLE, CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY, roleKeywords, roleCategories)) {
|
|
8692
|
+
return CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY;
|
|
8663
8693
|
}
|
|
8664
|
-
if (this.roleOrCategoryExists(CaseAccessUtils.CITIZEN_ROLE, roleKeywords)) {
|
|
8665
|
-
|
|
8694
|
+
else if (this.roleOrCategoryExists(CaseAccessUtils.CITIZEN_ROLE, CaseAccessUtils.CITIZEN_ROLE_CATEGORY, roleKeywords, roleCategories)) {
|
|
8695
|
+
return CaseAccessUtils.CITIZEN_ROLE_CATEGORY;
|
|
8666
8696
|
}
|
|
8667
|
-
if (this.roleOrCategoryExists(CaseAccessUtils.ADMIN_ROLE, roleKeywords)) {
|
|
8668
|
-
|
|
8697
|
+
else if (this.roleOrCategoryExists(CaseAccessUtils.ADMIN_ROLE, CaseAccessUtils.ADMIN_ROLE_CATEGORY, roleKeywords, roleCategories)) {
|
|
8698
|
+
return CaseAccessUtils.ADMIN_ROLE_CATEGORY;
|
|
8669
8699
|
}
|
|
8670
|
-
if (this.roleOrCategoryExists(CaseAccessUtils.CTSC_ROLE, roleKeywords)) {
|
|
8671
|
-
|
|
8700
|
+
else if (this.roleOrCategoryExists(CaseAccessUtils.CTSC_ROLE, CaseAccessUtils.CTSC_ROLE_CATEGORY, roleKeywords, roleCategories)) {
|
|
8701
|
+
return CaseAccessUtils.CTSC_ROLE_CATEGORY;
|
|
8672
8702
|
}
|
|
8673
|
-
|
|
8674
|
-
|
|
8703
|
+
else {
|
|
8704
|
+
return CaseAccessUtils.LEGAL_OPERATIONS_ROLE_CATEGORY;
|
|
8675
8705
|
}
|
|
8676
|
-
return roleCategoryList;
|
|
8677
8706
|
}
|
|
8678
|
-
roleOrCategoryExists(roleKeyword, roleKeywords) {
|
|
8707
|
+
roleOrCategoryExists(roleKeyword, roleCategory, roleKeywords, roleCategories) {
|
|
8708
|
+
const categoryExists = roleCategories.indexOf(roleCategory) > -1;
|
|
8679
8709
|
const keywordExists = roleKeywords.indexOf(roleKeyword) > -1;
|
|
8680
|
-
return keywordExists;
|
|
8710
|
+
return categoryExists ? categoryExists : keywordExists;
|
|
8681
8711
|
}
|
|
8682
8712
|
getAMRoleName(accessType, aMRole) {
|
|
8683
8713
|
let roleName = '';
|
|
@@ -9107,10 +9137,10 @@ class CaseworkerService {
|
|
|
9107
9137
|
this.appConfig = appConfig;
|
|
9108
9138
|
this.errorService = errorService;
|
|
9109
9139
|
}
|
|
9110
|
-
|
|
9111
|
-
const url = `${this.appConfig.getWorkAllocationApiUrl()}/caseworker/
|
|
9140
|
+
getCaseworkers(serviceId) {
|
|
9141
|
+
const url = `${this.appConfig.getWorkAllocationApiUrl()}/caseworker/getUsersByServiceName`;
|
|
9112
9142
|
return this.http
|
|
9113
|
-
.post(url,
|
|
9143
|
+
.post(url, { services: [serviceId] })
|
|
9114
9144
|
.pipe(catchError(error => {
|
|
9115
9145
|
this.errorService.setError(error);
|
|
9116
9146
|
return throwError(error);
|
|
@@ -10565,21 +10595,16 @@ class CasesService {
|
|
|
10565
10595
|
const userInfoStr = this.sessionStorageService.getItem('userDetails');
|
|
10566
10596
|
const camUtils = new CaseAccessUtils();
|
|
10567
10597
|
let userInfo;
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
// Unsure whether we should be using mapped role categories any more - should trust the roleCategories from userInfo if they exist
|
|
10574
|
-
const roleCategories = userInfo.roleCategories || camUtils.getMappedRoleCategories(userInfo.roles);
|
|
10575
|
-
const roleName = camUtils.getAMRoleName('challenged', roleCategories[0]);
|
|
10598
|
+
if (userInfoStr) {
|
|
10599
|
+
userInfo = JSON.parse(userInfoStr);
|
|
10600
|
+
}
|
|
10601
|
+
const roleCategory = userInfo.roleCategory || camUtils.getMappedRoleCategory(userInfo.roles, userInfo.roleCategories);
|
|
10602
|
+
const roleName = camUtils.getAMRoleName('challenged', roleCategory);
|
|
10576
10603
|
const beginTime = new Date();
|
|
10577
10604
|
const endTime = new Date(new Date().setUTCHours(23, 59, 59, 999));
|
|
10578
10605
|
const id = userInfo.id ? userInfo.id : userInfo.uid;
|
|
10579
10606
|
const isNew = true;
|
|
10580
|
-
const payload = camUtils.getAMPayload(id, id, roleName,
|
|
10581
|
-
// EXUI-4758 - Return first roleCategory as the roleCategory
|
|
10582
|
-
roleCategories[0], 'CHALLENGED', caseId, request, beginTime, endTime, isNew);
|
|
10607
|
+
const payload = camUtils.getAMPayload(id, id, roleName, roleCategory, 'CHALLENGED', caseId, request, beginTime, endTime, isNew);
|
|
10583
10608
|
return this.http.post(`/api/challenged-access-request`, payload);
|
|
10584
10609
|
}
|
|
10585
10610
|
createSpecificAccessRequest(caseId, sar) {
|
|
@@ -10587,14 +10612,10 @@ class CasesService {
|
|
|
10587
10612
|
const userInfoStr = this.sessionStorageService.getItem('userDetails');
|
|
10588
10613
|
const camUtils = new CaseAccessUtils();
|
|
10589
10614
|
let userInfo;
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
// EXUI-4758 - See above comment
|
|
10595
|
-
const roleCategories = userInfo.roleCategories || camUtils.getMappedRoleCategories(userInfo.roles);
|
|
10596
|
-
// EXUI-4758 - Return first roleCategory as the roleCategory for now
|
|
10597
|
-
const roleCategory = roleCategories[0];
|
|
10615
|
+
if (userInfoStr) {
|
|
10616
|
+
userInfo = JSON.parse(userInfoStr);
|
|
10617
|
+
}
|
|
10618
|
+
const roleCategory = userInfo.roleCategory || camUtils.getMappedRoleCategory(userInfo.roles, userInfo.roleCategories);
|
|
10598
10619
|
const roleName = camUtils.getAMRoleName('specific', roleCategory);
|
|
10599
10620
|
const id = userInfo.id ? userInfo.id : userInfo.uid;
|
|
10600
10621
|
const payload = camUtils.getAMPayload(null, id, roleName, roleCategory, 'SPECIFIC', caseId, sar, null, null, true);
|
|
@@ -12668,9 +12689,12 @@ class CaseEventCompletionTaskReassignedComponent {
|
|
|
12668
12689
|
this.jurisdiction = task.jurisdiction;
|
|
12669
12690
|
this.caseType = task.case_type_id;
|
|
12670
12691
|
// Current user is a caseworker?
|
|
12671
|
-
this.caseworkerSubscription = this.caseworkerService.
|
|
12672
|
-
if (
|
|
12673
|
-
|
|
12692
|
+
this.caseworkerSubscription = this.caseworkerService.getCaseworkers(task.jurisdiction).subscribe(result => {
|
|
12693
|
+
if (result && result[0].service === task.jurisdiction && result[0].caseworkers) {
|
|
12694
|
+
const caseworker = result[0].caseworkers.find(x => x.idamId === task.assignee);
|
|
12695
|
+
if (caseworker) {
|
|
12696
|
+
this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
|
|
12697
|
+
}
|
|
12674
12698
|
}
|
|
12675
12699
|
if (!this.assignedUserName) {
|
|
12676
12700
|
// Current user is a judicial user?
|
|
@@ -37792,9 +37816,12 @@ class TaskAssignedComponent {
|
|
|
37792
37816
|
// Current user is a caseworker?
|
|
37793
37817
|
this.jurisdiction = this.task.jurisdiction;
|
|
37794
37818
|
this.caseType = this.task.case_type_id;
|
|
37795
|
-
this.caseworkerSubscription = this.caseworkerService.
|
|
37796
|
-
if (
|
|
37797
|
-
|
|
37819
|
+
this.caseworkerSubscription = this.caseworkerService.getCaseworkers(this.task.jurisdiction).subscribe(result => {
|
|
37820
|
+
if (result && result[0].service === this.task.jurisdiction && result[0].caseworkers) {
|
|
37821
|
+
const caseworker = result[0].caseworkers.find(x => x.idamId === this.task.assignee);
|
|
37822
|
+
if (caseworker) {
|
|
37823
|
+
this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
|
|
37824
|
+
}
|
|
37798
37825
|
}
|
|
37799
37826
|
if (!this.assignedUserName) {
|
|
37800
37827
|
// Current user is a judicial user?
|