@hmcts/ccd-case-ui-toolkit 7.3.68-user-by-idam-rework → 7.3.69-inconsistent-validation-error-message

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,33 +8651,31 @@ class CaseAccessUtils {
8651
8651
  static CTSC_ROLE = 'ctsc';
8652
8652
  static CTSC_ROLE_CATEGORY = 'CTSC';
8653
8653
  static CTSC_ROLE_NAME = 'ctsc';
8654
- // fallback purely if roleCategories is not available in
8655
- getMappedRoleCategories(roles = []) {
8654
+ getMappedRoleCategory(roles = [], roleCategories = []) {
8656
8655
  const roleKeywords = roles.join().split('-').join().split(',');
8657
- const roleCategoryList = [];
8658
- if (this.roleOrCategoryExists(CaseAccessUtils.JUDGE_ROLE, roleKeywords)) {
8659
- roleCategoryList.push(CaseAccessUtils.JUDGE_ROLE_CATEGORY);
8656
+ if (this.roleOrCategoryExists(CaseAccessUtils.JUDGE_ROLE, CaseAccessUtils.JUDGE_ROLE_CATEGORY, roleKeywords, roleCategories)) {
8657
+ return CaseAccessUtils.JUDGE_ROLE_CATEGORY;
8660
8658
  }
8661
- if (this.roleOrCategoryExists(CaseAccessUtils.PROFESSIONAL_ROLE, roleKeywords)) {
8662
- roleCategoryList.push(CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY);
8659
+ else if (this.roleOrCategoryExists(CaseAccessUtils.PROFESSIONAL_ROLE, CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY, roleKeywords, roleCategories)) {
8660
+ return CaseAccessUtils.PROFESSIONAL_ROLE_CATEGORY;
8663
8661
  }
8664
- if (this.roleOrCategoryExists(CaseAccessUtils.CITIZEN_ROLE, roleKeywords)) {
8665
- roleCategoryList.push(CaseAccessUtils.CITIZEN_ROLE_CATEGORY);
8662
+ else if (this.roleOrCategoryExists(CaseAccessUtils.CITIZEN_ROLE, CaseAccessUtils.CITIZEN_ROLE_CATEGORY, roleKeywords, roleCategories)) {
8663
+ return CaseAccessUtils.CITIZEN_ROLE_CATEGORY;
8666
8664
  }
8667
- if (this.roleOrCategoryExists(CaseAccessUtils.ADMIN_ROLE, roleKeywords)) {
8668
- roleCategoryList.push(CaseAccessUtils.ADMIN_ROLE_CATEGORY);
8665
+ else if (this.roleOrCategoryExists(CaseAccessUtils.ADMIN_ROLE, CaseAccessUtils.ADMIN_ROLE_CATEGORY, roleKeywords, roleCategories)) {
8666
+ return CaseAccessUtils.ADMIN_ROLE_CATEGORY;
8669
8667
  }
8670
- if (this.roleOrCategoryExists(CaseAccessUtils.CTSC_ROLE, roleKeywords)) {
8671
- roleCategoryList.push(CaseAccessUtils.CTSC_ROLE_CATEGORY);
8668
+ else if (this.roleOrCategoryExists(CaseAccessUtils.CTSC_ROLE, CaseAccessUtils.CTSC_ROLE_CATEGORY, roleKeywords, roleCategories)) {
8669
+ return CaseAccessUtils.CTSC_ROLE_CATEGORY;
8672
8670
  }
8673
- if (this.roleOrCategoryExists(CaseAccessUtils.LEGAL_OPERATIONS_ROLE, roleKeywords)) {
8674
- roleCategoryList.push(CaseAccessUtils.LEGAL_OPERATIONS_ROLE_CATEGORY);
8671
+ else {
8672
+ return CaseAccessUtils.LEGAL_OPERATIONS_ROLE_CATEGORY;
8675
8673
  }
8676
- return roleCategoryList;
8677
8674
  }
8678
- roleOrCategoryExists(roleKeyword, roleKeywords) {
8675
+ roleOrCategoryExists(roleKeyword, roleCategory, roleKeywords, roleCategories) {
8676
+ const categoryExists = roleCategories.indexOf(roleCategory) > -1;
8679
8677
  const keywordExists = roleKeywords.indexOf(roleKeyword) > -1;
8680
- return keywordExists;
8678
+ return categoryExists ? categoryExists : keywordExists;
8681
8679
  }
8682
8680
  getAMRoleName(accessType, aMRole) {
8683
8681
  let roleName = '';
@@ -9107,10 +9105,10 @@ class CaseworkerService {
9107
9105
  this.appConfig = appConfig;
9108
9106
  this.errorService = errorService;
9109
9107
  }
9110
- getUserByIdamId(idamId) {
9111
- const url = `${this.appConfig.getWorkAllocationApiUrl()}/caseworker/getUserByIdamId`;
9108
+ getCaseworkers(serviceId) {
9109
+ const url = `${this.appConfig.getWorkAllocationApiUrl()}/caseworker/getUsersByServiceName`;
9112
9110
  return this.http
9113
- .post(url, idamId)
9111
+ .post(url, { services: [serviceId] })
9114
9112
  .pipe(catchError(error => {
9115
9113
  this.errorService.setError(error);
9116
9114
  return throwError(error);
@@ -10565,21 +10563,16 @@ class CasesService {
10565
10563
  const userInfoStr = this.sessionStorageService.getItem('userDetails');
10566
10564
  const camUtils = new CaseAccessUtils();
10567
10565
  let userInfo;
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]);
10566
+ if (userInfoStr) {
10567
+ userInfo = JSON.parse(userInfoStr);
10568
+ }
10569
+ const roleCategory = userInfo.roleCategory || camUtils.getMappedRoleCategory(userInfo.roles, userInfo.roleCategories);
10570
+ const roleName = camUtils.getAMRoleName('challenged', roleCategory);
10576
10571
  const beginTime = new Date();
10577
10572
  const endTime = new Date(new Date().setUTCHours(23, 59, 59, 999));
10578
10573
  const id = userInfo.id ? userInfo.id : userInfo.uid;
10579
10574
  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);
10575
+ const payload = camUtils.getAMPayload(id, id, roleName, roleCategory, 'CHALLENGED', caseId, request, beginTime, endTime, isNew);
10583
10576
  return this.http.post(`/api/challenged-access-request`, payload);
10584
10577
  }
10585
10578
  createSpecificAccessRequest(caseId, sar) {
@@ -10587,14 +10580,10 @@ class CasesService {
10587
10580
  const userInfoStr = this.sessionStorageService.getItem('userDetails');
10588
10581
  const camUtils = new CaseAccessUtils();
10589
10582
  let userInfo;
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];
10583
+ if (userInfoStr) {
10584
+ userInfo = JSON.parse(userInfoStr);
10585
+ }
10586
+ const roleCategory = userInfo.roleCategory || camUtils.getMappedRoleCategory(userInfo.roles, userInfo.roleCategories);
10598
10587
  const roleName = camUtils.getAMRoleName('specific', roleCategory);
10599
10588
  const id = userInfo.id ? userInfo.id : userInfo.uid;
10600
10589
  const payload = camUtils.getAMPayload(null, id, roleName, roleCategory, 'SPECIFIC', caseId, sar, null, null, true);
@@ -11743,6 +11732,11 @@ class CaseEditPageComponent {
11743
11732
  this.caseEditDataService.addFormValidationError({ id, message: `%FIELDLABEL% exceeds the maximum length`, label });
11744
11733
  fieldElement.markAsDirty();
11745
11734
  }
11735
+ else if (fieldElement.hasError('markDownPattern')) {
11736
+ this.caseEditDataService.addFormValidationError({
11737
+ id, message: `The data entered is not valid for %FIELDLABEL%. Link mark up characters are not allowed in this field.`, label
11738
+ });
11739
+ }
11746
11740
  else if (fieldElement.invalid) {
11747
11741
  if (casefield.isComplex()) {
11748
11742
  errorPresent = this.generateErrorMessage(casefield.field_type.complex_fields, fieldElement, id, true);
@@ -12668,9 +12662,12 @@ class CaseEventCompletionTaskReassignedComponent {
12668
12662
  this.jurisdiction = task.jurisdiction;
12669
12663
  this.caseType = task.case_type_id;
12670
12664
  // Current user is a caseworker?
12671
- this.caseworkerSubscription = this.caseworkerService.getUserByIdamId(task.assignee).subscribe(caseworker => {
12672
- if (caseworker) {
12673
- this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
12665
+ this.caseworkerSubscription = this.caseworkerService.getCaseworkers(task.jurisdiction).subscribe(result => {
12666
+ if (result && result[0].service === task.jurisdiction && result[0].caseworkers) {
12667
+ const caseworker = result[0].caseworkers.find(x => x.idamId === task.assignee);
12668
+ if (caseworker) {
12669
+ this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
12670
+ }
12674
12671
  }
12675
12672
  if (!this.assignedUserName) {
12676
12673
  // Current user is a judicial user?
@@ -37792,9 +37789,12 @@ class TaskAssignedComponent {
37792
37789
  // Current user is a caseworker?
37793
37790
  this.jurisdiction = this.task.jurisdiction;
37794
37791
  this.caseType = this.task.case_type_id;
37795
- this.caseworkerSubscription = this.caseworkerService.getUserByIdamId(this.task.assignee).subscribe(caseworker => {
37796
- if (caseworker) {
37797
- this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
37792
+ this.caseworkerSubscription = this.caseworkerService.getCaseworkers(this.task.jurisdiction).subscribe(result => {
37793
+ if (result && result[0].service === this.task.jurisdiction && result[0].caseworkers) {
37794
+ const caseworker = result[0].caseworkers.find(x => x.idamId === this.task.assignee);
37795
+ if (caseworker) {
37796
+ this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
37797
+ }
37798
37798
  }
37799
37799
  if (!this.assignedUserName) {
37800
37800
  // Current user is a judicial user?