@hmcts/ccd-case-ui-toolkit 7.3.68-exui-4803-rc-2 → 7.3.68-multiple-role-categories
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.
|
@@ -8651,31 +8651,33 @@ class CaseAccessUtils {
|
|
|
8651
8651
|
static CTSC_ROLE = 'ctsc';
|
|
8652
8652
|
static CTSC_ROLE_CATEGORY = 'CTSC';
|
|
8653
8653
|
static CTSC_ROLE_NAME = 'ctsc';
|
|
8654
|
-
|
|
8654
|
+
// fallback purely if roleCategories is not available in
|
|
8655
|
+
getMappedRoleCategories(roles = []) {
|
|
8655
8656
|
const roleKeywords = roles.join().split('-').join().split(',');
|
|
8656
|
-
|
|
8657
|
-
|
|
8657
|
+
const roleCategoryList = [];
|
|
8658
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.JUDGE_ROLE, roleKeywords)) {
|
|
8659
|
+
roleCategoryList.push(CaseAccessUtils.JUDGE_ROLE_CATEGORY);
|
|
8658
8660
|
}
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.PROFESSIONAL_ROLE, roleKeywords)) {
|
|
8662
|
+
roleCategoryList.push(CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY);
|
|
8661
8663
|
}
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.CITIZEN_ROLE, roleKeywords)) {
|
|
8665
|
+
roleCategoryList.push(CaseAccessUtils.CITIZEN_ROLE_CATEGORY);
|
|
8664
8666
|
}
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.ADMIN_ROLE, roleKeywords)) {
|
|
8668
|
+
roleCategoryList.push(CaseAccessUtils.ADMIN_ROLE_CATEGORY);
|
|
8667
8669
|
}
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.CTSC_ROLE, roleKeywords)) {
|
|
8671
|
+
roleCategoryList.push(CaseAccessUtils.CTSC_ROLE_CATEGORY);
|
|
8670
8672
|
}
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.LEGAL_OPERATIONS_ROLE, roleKeywords)) {
|
|
8674
|
+
roleCategoryList.push(CaseAccessUtils.LEGAL_OPERATIONS_ROLE_CATEGORY);
|
|
8673
8675
|
}
|
|
8676
|
+
return roleCategoryList;
|
|
8674
8677
|
}
|
|
8675
|
-
roleOrCategoryExists(roleKeyword,
|
|
8676
|
-
const categoryExists = roleCategories.indexOf(roleCategory) > -1;
|
|
8678
|
+
roleOrCategoryExists(roleKeyword, roleKeywords) {
|
|
8677
8679
|
const keywordExists = roleKeywords.indexOf(roleKeyword) > -1;
|
|
8678
|
-
return
|
|
8680
|
+
return keywordExists;
|
|
8679
8681
|
}
|
|
8680
8682
|
getAMRoleName(accessType, aMRole) {
|
|
8681
8683
|
let roleName = '';
|
|
@@ -10563,16 +10565,21 @@ class CasesService {
|
|
|
10563
10565
|
const userInfoStr = this.sessionStorageService.getItem('userDetails');
|
|
10564
10566
|
const camUtils = new CaseAccessUtils();
|
|
10565
10567
|
let userInfo;
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10568
|
+
userInfo = userInfoStr ? JSON.parse(userInfoStr) : null;
|
|
10569
|
+
if (!userInfo) {
|
|
10570
|
+
return throwError(() => new Error('User info not found in session storage'));
|
|
10571
|
+
}
|
|
10572
|
+
// EXUI-4758 - getMappedRoleCategories no longer returns a single string, checks all roles to get the most likely roleCategory
|
|
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]);
|
|
10571
10576
|
const beginTime = new Date();
|
|
10572
10577
|
const endTime = new Date(new Date().setUTCHours(23, 59, 59, 999));
|
|
10573
10578
|
const id = userInfo.id ? userInfo.id : userInfo.uid;
|
|
10574
10579
|
const isNew = true;
|
|
10575
|
-
const payload = camUtils.getAMPayload(id, id, roleName,
|
|
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);
|
|
10576
10583
|
return this.http.post(`/api/challenged-access-request`, payload);
|
|
10577
10584
|
}
|
|
10578
10585
|
createSpecificAccessRequest(caseId, sar) {
|
|
@@ -10580,10 +10587,14 @@ class CasesService {
|
|
|
10580
10587
|
const userInfoStr = this.sessionStorageService.getItem('userDetails');
|
|
10581
10588
|
const camUtils = new CaseAccessUtils();
|
|
10582
10589
|
let userInfo;
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10590
|
+
userInfo = userInfoStr ? JSON.parse(userInfoStr) : null;
|
|
10591
|
+
if (!userInfo) {
|
|
10592
|
+
return throwError(() => new Error('User info not found in session storage'));
|
|
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];
|
|
10587
10598
|
const roleName = camUtils.getAMRoleName('specific', roleCategory);
|
|
10588
10599
|
const id = userInfo.id ? userInfo.id : userInfo.uid;
|
|
10589
10600
|
const payload = camUtils.getAMPayload(null, id, roleName, roleCategory, 'SPECIFIC', caseId, sar, null, null, true);
|