@hmcts/ccd-case-ui-toolkit 7.3.73 → 7.3.74-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.
|
@@ -8671,31 +8671,33 @@ class CaseAccessUtils {
|
|
|
8671
8671
|
static CTSC_ROLE = 'ctsc';
|
|
8672
8672
|
static CTSC_ROLE_CATEGORY = 'CTSC';
|
|
8673
8673
|
static CTSC_ROLE_NAME = 'ctsc';
|
|
8674
|
-
|
|
8674
|
+
// fallback purely if roleCategories is not available in
|
|
8675
|
+
getMappedRoleCategories(roles = []) {
|
|
8675
8676
|
const roleKeywords = roles.join().split('-').join().split(',');
|
|
8676
|
-
|
|
8677
|
-
|
|
8677
|
+
const roleCategoryList = [];
|
|
8678
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.JUDGE_ROLE, roleKeywords)) {
|
|
8679
|
+
roleCategoryList.push(CaseAccessUtils.JUDGE_ROLE_CATEGORY);
|
|
8678
8680
|
}
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.PROFESSIONAL_ROLE, roleKeywords)) {
|
|
8682
|
+
roleCategoryList.push(CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY);
|
|
8681
8683
|
}
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.CITIZEN_ROLE, roleKeywords)) {
|
|
8685
|
+
roleCategoryList.push(CaseAccessUtils.CITIZEN_ROLE_CATEGORY);
|
|
8684
8686
|
}
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.ADMIN_ROLE, roleKeywords)) {
|
|
8688
|
+
roleCategoryList.push(CaseAccessUtils.ADMIN_ROLE_CATEGORY);
|
|
8687
8689
|
}
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.CTSC_ROLE, roleKeywords)) {
|
|
8691
|
+
roleCategoryList.push(CaseAccessUtils.CTSC_ROLE_CATEGORY);
|
|
8690
8692
|
}
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
+
if (this.roleOrCategoryExists(CaseAccessUtils.LEGAL_OPERATIONS_ROLE, roleKeywords)) {
|
|
8694
|
+
roleCategoryList.push(CaseAccessUtils.LEGAL_OPERATIONS_ROLE_CATEGORY);
|
|
8693
8695
|
}
|
|
8696
|
+
return roleCategoryList;
|
|
8694
8697
|
}
|
|
8695
|
-
roleOrCategoryExists(roleKeyword,
|
|
8696
|
-
const categoryExists = roleCategories.indexOf(roleCategory) > -1;
|
|
8698
|
+
roleOrCategoryExists(roleKeyword, roleKeywords) {
|
|
8697
8699
|
const keywordExists = roleKeywords.indexOf(roleKeyword) > -1;
|
|
8698
|
-
return
|
|
8700
|
+
return keywordExists;
|
|
8699
8701
|
}
|
|
8700
8702
|
getAMRoleName(accessType, aMRole) {
|
|
8701
8703
|
let roleName = '';
|
|
@@ -10583,16 +10585,21 @@ class CasesService {
|
|
|
10583
10585
|
const userInfoStr = this.sessionStorageService.getItem('userDetails');
|
|
10584
10586
|
const camUtils = new CaseAccessUtils();
|
|
10585
10587
|
let userInfo;
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10588
|
+
userInfo = userInfoStr ? JSON.parse(userInfoStr) : null;
|
|
10589
|
+
if (!userInfo) {
|
|
10590
|
+
return throwError(() => new Error('User info not found in session storage'));
|
|
10591
|
+
}
|
|
10592
|
+
// EXUI-4758 - getMappedRoleCategories no longer returns a single string, checks all roles to get the most likely roleCategory
|
|
10593
|
+
// Unsure whether we should be using mapped role categories any more - should trust the roleCategories from userInfo if they exist
|
|
10594
|
+
const roleCategories = userInfo.roleCategories || camUtils.getMappedRoleCategories(userInfo.roles);
|
|
10595
|
+
const roleName = camUtils.getAMRoleName('challenged', roleCategories[0]);
|
|
10591
10596
|
const beginTime = new Date();
|
|
10592
10597
|
const endTime = new Date(new Date().setUTCHours(23, 59, 59, 999));
|
|
10593
10598
|
const id = userInfo.id ? userInfo.id : userInfo.uid;
|
|
10594
10599
|
const isNew = true;
|
|
10595
|
-
const payload = camUtils.getAMPayload(id, id, roleName,
|
|
10600
|
+
const payload = camUtils.getAMPayload(id, id, roleName,
|
|
10601
|
+
// EXUI-4758 - Return first roleCategory as the roleCategory
|
|
10602
|
+
roleCategories[0], 'CHALLENGED', caseId, request, beginTime, endTime, isNew);
|
|
10596
10603
|
return this.http.post(`/api/challenged-access-request`, payload);
|
|
10597
10604
|
}
|
|
10598
10605
|
createSpecificAccessRequest(caseId, sar) {
|
|
@@ -10600,10 +10607,14 @@ class CasesService {
|
|
|
10600
10607
|
const userInfoStr = this.sessionStorageService.getItem('userDetails');
|
|
10601
10608
|
const camUtils = new CaseAccessUtils();
|
|
10602
10609
|
let userInfo;
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10610
|
+
userInfo = userInfoStr ? JSON.parse(userInfoStr) : null;
|
|
10611
|
+
if (!userInfo) {
|
|
10612
|
+
return throwError(() => new Error('User info not found in session storage'));
|
|
10613
|
+
}
|
|
10614
|
+
// EXUI-4758 - See above comment
|
|
10615
|
+
const roleCategories = userInfo.roleCategories || camUtils.getMappedRoleCategories(userInfo.roles);
|
|
10616
|
+
// EXUI-4758 - Return first roleCategory as the roleCategory for now
|
|
10617
|
+
const roleCategory = roleCategories[0];
|
|
10607
10618
|
const roleName = camUtils.getAMRoleName('specific', roleCategory);
|
|
10608
10619
|
const id = userInfo.id ? userInfo.id : userInfo.uid;
|
|
10609
10620
|
const payload = camUtils.getAMPayload(null, id, roleName, roleCategory, 'SPECIFIC', caseId, sar, null, null, true);
|