@hmcts/rpx-xui-common-lib 1.7.21 → 1.7.22-selected-cases-status-column-header

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.
Files changed (33) hide show
  1. package/bundles/hmcts-rpx-xui-common-lib.umd.js +212 -44
  2. package/bundles/hmcts-rpx-xui-common-lib.umd.js.map +1 -1
  3. package/bundles/hmcts-rpx-xui-common-lib.umd.min.js +1 -1
  4. package/bundles/hmcts-rpx-xui-common-lib.umd.min.js.map +1 -1
  5. package/esm2015/hmcts-rpx-xui-common-lib.js +2 -2
  6. package/esm2015/lib/components/search-service/search-service.component.js +2 -2
  7. package/esm2015/lib/components/selected-case/selected-case.component.js +3 -9
  8. package/esm2015/lib/components/share-case/share-case.component.js +166 -15
  9. package/esm2015/lib/models/case-share.model.js +7 -1
  10. package/esm2015/lib/models/index.js +2 -2
  11. package/esm2015/lib/models/person.model.js +3 -1
  12. package/esm2015/lib/services/case-sharing-state/case-sharing-state.service.js +39 -15
  13. package/esm2015/public-api.js +2 -2
  14. package/esm5/hmcts-rpx-xui-common-lib.js +2 -2
  15. package/esm5/lib/components/search-service/search-service.component.js +2 -2
  16. package/esm5/lib/components/selected-case/selected-case.component.js +3 -12
  17. package/esm5/lib/components/share-case/share-case.component.js +187 -15
  18. package/esm5/lib/models/case-share.model.js +7 -1
  19. package/esm5/lib/models/index.js +2 -2
  20. package/esm5/lib/models/person.model.js +3 -1
  21. package/esm5/lib/services/case-sharing-state/case-sharing-state.service.js +40 -16
  22. package/esm5/public-api.js +2 -2
  23. package/fesm2015/hmcts-rpx-xui-common-lib.js +192 -46
  24. package/fesm2015/hmcts-rpx-xui-common-lib.js.map +1 -1
  25. package/fesm5/hmcts-rpx-xui-common-lib.js +214 -50
  26. package/fesm5/hmcts-rpx-xui-common-lib.js.map +1 -1
  27. package/hmcts-rpx-xui-common-lib.metadata.json +1 -1
  28. package/lib/components/selected-case/selected-case.component.d.ts +0 -1
  29. package/lib/components/share-case/share-case.component.d.ts +30 -2
  30. package/lib/models/case-share.model.d.ts +4 -0
  31. package/lib/models/person.model.d.ts +2 -0
  32. package/lib/services/case-sharing-state/case-sharing-state.service.d.ts +1 -1
  33. package/package.json +1 -1
@@ -1934,29 +1934,50 @@
1934
1934
  return newSharedCases;
1935
1935
  };
1936
1936
  /**
1937
- * @param {?} caseId
1938
1937
  * @param {?} user
1938
+ * @param {?=} caseId
1939
1939
  * @return {?}
1940
1940
  */
1941
1941
  CaseSharingStateService.prototype.requestUnshare = /**
1942
- * @param {?} caseId
1943
1942
  * @param {?} user
1943
+ * @param {?=} caseId
1944
1944
  * @return {?}
1945
1945
  */
1946
- function (caseId, user) {
1946
+ function (user, caseId) {
1947
1947
  var e_2, _a;
1948
1948
  /** @type {?} */
1949
1949
  var newSharedCases = [];
1950
1950
  try {
1951
1951
  for (var _b = __values(this.caseState), _c = _b.next(); !_c.done; _c = _b.next()) {
1952
1952
  var sharedCase = _c.value;
1953
- if (sharedCase.caseId === caseId) {
1953
+ // If no caseId, then request unshare from all shared cases
1954
+ if (caseId === undefined || sharedCase.caseId === caseId) {
1954
1955
  if (!sharedCase.pendingUnshares) {
1955
1956
  sharedCase.pendingUnshares = [];
1956
1957
  }
1957
1958
  /** @type {?} */
1958
1959
  var newPendingUnshares = sharedCase.pendingUnshares.slice();
1959
- if (newPendingUnshares) {
1960
+ // If the user is pending shared access, just remove them from pendingShares
1961
+ /** @type {?} */
1962
+ var newPendingShares = void 0;
1963
+ /** @type {?} */
1964
+ var indexOfPreviouslyAddedUser = -1;
1965
+ if (sharedCase.pendingShares) {
1966
+ indexOfPreviouslyAddedUser = sharedCase.pendingShares.findIndex(( /**
1967
+ * @param {?} u
1968
+ * @return {?}
1969
+ */function (u) { return u.idamId === user.idamId; }));
1970
+ if (indexOfPreviouslyAddedUser > -1) {
1971
+ newPendingShares = sharedCase.pendingShares.slice();
1972
+ newPendingShares.splice(indexOfPreviouslyAddedUser, 1);
1973
+ }
1974
+ }
1975
+ // If the user does not exist in pendingShares, and already has shared access (i.e. exists in sharedWith),
1976
+ // request removal of shared access
1977
+ if (indexOfPreviouslyAddedUser === -1 && sharedCase.sharedWith && sharedCase.sharedWith.findIndex(( /**
1978
+ * @param {?} u
1979
+ * @return {?}
1980
+ */function (u) { return u.idamId === user.idamId; })) > -1) {
1960
1981
  if (!newPendingUnshares.some(( /**
1961
1982
  * @param {?} u
1962
1983
  * @return {?}
@@ -1964,11 +1985,10 @@
1964
1985
  newPendingUnshares.push(user);
1965
1986
  }
1966
1987
  }
1967
- else {
1968
- newPendingUnshares.push(user);
1969
- }
1970
1988
  /** @type {?} */
1971
- var newSharedCase = __assign({}, sharedCase, { pendingUnshares: newPendingUnshares });
1989
+ var newSharedCase = __assign({}, sharedCase, { pendingUnshares: newPendingUnshares }, (newPendingShares && {
1990
+ pendingShares: newPendingShares
1991
+ }));
1972
1992
  newSharedCases.push(newSharedCase);
1973
1993
  }
1974
1994
  else {
@@ -1990,7 +2010,7 @@
1990
2010
  }
1991
2011
  }
1992
2012
  this.subject.next(newSharedCases);
1993
- return;
2013
+ return newSharedCases;
1994
2014
  };
1995
2015
  /**
1996
2016
  * @param {?} caseId
@@ -2066,11 +2086,13 @@
2066
2086
  * @return {?}
2067
2087
  */
2068
2088
  function (caseId) {
2069
- for (var i = 0, l = this.caseState.length; i < l; i++) {
2070
- if (this.caseState[i].caseId === caseId) {
2071
- this.caseState.splice(i, 1);
2072
- this.subject.next(this.caseState);
2073
- return;
2089
+ if (this.caseState.length > 1) {
2090
+ for (var i = 0, l = this.caseState.length; i < l; i++) {
2091
+ if (this.caseState[i].caseId === caseId) {
2092
+ this.caseState.splice(i, 1);
2093
+ this.subject.next(this.caseState);
2094
+ return;
2095
+ }
2074
2096
  }
2075
2097
  }
2076
2098
  };
@@ -2301,15 +2323,6 @@
2301
2323
  this.combinedSortedShares = this.combineAndSortShares(sharedWith, pendingShares);
2302
2324
  }
2303
2325
  };
2304
- /**
2305
- * @return {?}
2306
- */
2307
- SelectedCaseComponent.prototype.onUnselect = /**
2308
- * @return {?}
2309
- */
2310
- function () {
2311
- this.unselect.emit(this.sharedCase);
2312
- };
2313
2326
  /**
2314
2327
  * @param {?} c
2315
2328
  * @return {?}
@@ -2532,7 +2545,7 @@
2532
2545
  * @return {?}
2533
2546
  */
2534
2547
  function (user, sharedCase) {
2535
- this.stateService.requestUnshare(sharedCase.caseId, user);
2548
+ this.stateService.requestUnshare(user, sharedCase.caseId);
2536
2549
  this.synchronizeStore.emit(this.shareCases);
2537
2550
  };
2538
2551
  /**
@@ -2651,7 +2664,7 @@
2651
2664
  SelectedCaseComponent.decorators = [
2652
2665
  { type: i0.Component, args: [{
2653
2666
  selector: 'xuilib-selected-case',
2654
- template: "<div id=\"{{buildElementId('govuk-accordion__section')}}\" class=\"govuk-accordion__section\">\n <div class=\"govuk-grid-row govuk-case-header\">\n <div class=\"govuk-grid-column-three-quarters\">\n <h3 id=\"{{buildElementId('case-title')}}\" class=\"govuk-case-title\">{{ sharedCase.caseTitle }}</h3>\n <h1 id=\"{{buildElementId('case-id')}}\" class=\"govuk-case-sub-title\">{{ sharedCase.caseId }}</h1>\n </div>\n <div class=\"govuk-grid-column-twenty-percent\">\n <button id=\"{{buildElementId('btn-deselect-case')}}\" class=\"govuk-button hmcts-button--secondary\" (click)=\"onDeselect(sharedCase)\" title=\"Deselect case\">Deselect case</button>\n </div>\n <div class=\"govuk-accordion__section-header govuk-grid-column-five-percent\">\n <div class=\"govuk-accordion__section-heading\">\n <button type=\"button\" id=\"{{buildElementId('accordion-with-summary-sections-heading')}}\"\n aria-controls=\"accordion-with-summary-sections-content-1\" class=\"govuk-accordion__section-button\"\n aria-describedby=\"accordion-with-summary-sections-summary-1\" aria-expanded=\"false\" title=\"Expand or Collapse\">\n <span class=\"govuk-accordion__icon\" aria-hidden=\"true\"></span></button>\n </div>\n </div>\n </div>\n <div id=\"{{buildElementId('accordion-with-summary-sections-content')}}\" class=\"govuk-accordion__section-content\"\n aria-labelledby=\"buildElementId('accordion-with-summary-sections-heading')\" >\n <div class=\"govuk-grid-row\" *ngIf=\"showNoUsersAccessInfo()\">\n <span id=\"{{buildElementId('access-info-no-user')}}\" class=\"govuk-div-align-left\">No users from your organisation currently have access to this case.</span>\n </div>\n <div class=\"govuk-grid-row\" *ngIf=\"showUserHasAccessInfo()\">\n <span id=\"{{buildElementId('access-info-has-users')}}\" class=\"govuk-div-align-left\">Users from your organisation with access to this case.</span>\n </div>\n <table class=\"govuk-table\" *ngIf=\"showUserAccessTable()\">\n <thead class=\"govuk-table__head\">\n <tr class=\"govuk-table__row\">\n <th id=\"{{buildElementId('name-heading')}}\" class=\"govuk-table__header govuk-table-column-header\" scope=\"col\">Name</th>\n <th id=\"{{buildElementId('email-heading')}}\" class=\"govuk-table__header govuk-table-column-header\" scope=\"col\">Email address</th>\n <th id=\"{{buildElementId('action-heading')}}\" class=\"govuk-table__header govuk-table-column-actions\" scope=\"col\">Actions</th>\n <th id=\"{{buildElementId('label-heading')}}\" class=\"govuk-table__header govuk-table-column-label\" scope=\"col\">&nbsp;&nbsp;</th>\n </tr>\n </thead>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\" *ngFor=\"let user of combinedSortedShares; index as idx; trackBy: trackByUserId\">\n <td id=\"user-full-name-{{ userIdSetter(canCancel(sharedCase.caseId, user) | async, idx) }}\" class=\"govuk-table__cell\">{{ user.firstName + ' ' + user.lastName }}</td>\n <td id=\"user-email-{{ userIdSetter(canCancel(sharedCase.caseId, user) | async, idx) }}\" class=\"govuk-table__cell\">{{ user.email }}</td>\n <td class=\"govuk-table__cell\">\n <a *ngIf=\"canRemove(sharedCase.caseId, user) | async\" (click)=\"onRemove(user, sharedCase)\" href=\"javascript:void(0);\">Remove <span class=\"govuk-visually-hidden\">{{ user.firstName + ' ' + user.lastName }} from case</span></a>\n <a *ngIf=\"canCancel(sharedCase.caseId, user) | async\" (click)=\"onCancel(user, sharedCase)\" href=\"javascript:void(0);\">Cancel <span class=\"govuk-visually-hidden\">adding {{ user.firstName + ' ' + user.lastName }} to case</span></a>\n </td>\n <td class=\"govuk-table__cell\">\n <span *ngIf=\"isToBeRemoved(sharedCase.caseId, user) | async\" class=\"hmcts-badge hmcts-badge--red\">To be removed</span>\n <span *ngIf=\"isToBeAdded(sharedCase.caseId, user) | async\" class=\"hmcts-badge\">To be added</span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</div>\n",
2667
+ template: "<div id=\"{{buildElementId('govuk-accordion__section')}}\" class=\"govuk-accordion__section\">\n <div class=\"govuk-grid-row govuk-case-header\">\n <div class=\"govuk-grid-column-three-quarters\">\n <h3 id=\"{{buildElementId('case-title')}}\" class=\"govuk-case-title\">{{ sharedCase.caseTitle }}</h3>\n <h1 id=\"{{buildElementId('case-id')}}\" class=\"govuk-case-sub-title\">{{ sharedCase.caseId }}</h1>\n </div>\n <div class=\"govuk-grid-column-twenty-percent\">\n <button id=\"{{buildElementId('btn-deselect-case')}}\" class=\"govuk-button hmcts-button--secondary\" (click)=\"onDeselect(sharedCase)\" title=\"Deselect case\">Deselect case</button>\n </div>\n <div class=\"govuk-accordion__section-header govuk-grid-column-five-percent\">\n <div class=\"govuk-accordion__section-heading\">\n <button type=\"button\" id=\"{{buildElementId('accordion-with-summary-sections-heading')}}\"\n aria-controls=\"accordion-with-summary-sections-content-1\" class=\"govuk-accordion__section-button\"\n aria-describedby=\"accordion-with-summary-sections-summary-1\" aria-expanded=\"false\" title=\"Expand or Collapse\">\n <span class=\"govuk-accordion__icon\" aria-hidden=\"true\"></span></button>\n </div>\n </div>\n </div>\n <div id=\"{{buildElementId('accordion-with-summary-sections-content')}}\" class=\"govuk-accordion__section-content\"\n aria-labelledby=\"buildElementId('accordion-with-summary-sections-heading')\" >\n <div class=\"govuk-grid-row\" *ngIf=\"showNoUsersAccessInfo()\">\n <span id=\"{{buildElementId('access-info-no-user')}}\" class=\"govuk-div-align-left\">No users from your organisation currently have access to this case.</span>\n </div>\n <div class=\"govuk-grid-row\" *ngIf=\"showUserHasAccessInfo()\">\n <span id=\"{{buildElementId('access-info-has-users')}}\" class=\"govuk-div-align-left\">Users from your organisation with access to this case.</span>\n </div>\n <table class=\"govuk-table\" *ngIf=\"showUserAccessTable()\">\n <thead class=\"govuk-table__head\">\n <tr class=\"govuk-table__row\">\n <th id=\"{{buildElementId('name-heading')}}\" class=\"govuk-table__header govuk-table-column-header\" scope=\"col\">Name</th>\n <th id=\"{{buildElementId('email-heading')}}\" class=\"govuk-table__header govuk-table-column-header\" scope=\"col\">Email address</th>\n <th id=\"{{buildElementId('action-heading')}}\" class=\"govuk-table__header govuk-table-column-actions\" scope=\"col\">Actions</th>\n <th id=\"{{buildElementId('label-heading')}}\" class=\"govuk-table__header govuk-table-column-label\" scope=\"col\">Status</th>\n </tr>\n </thead>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\" *ngFor=\"let user of combinedSortedShares; index as idx; trackBy: trackByUserId\">\n <td id=\"user-full-name-{{ userIdSetter(canCancel(sharedCase.caseId, user) | async, idx) }}\" class=\"govuk-table__cell\">{{ user.firstName + ' ' + user.lastName }}</td>\n <td id=\"user-email-{{ userIdSetter(canCancel(sharedCase.caseId, user) | async, idx) }}\" class=\"govuk-table__cell\">{{ user.email }}</td>\n <td class=\"govuk-table__cell\">\n <a *ngIf=\"canRemove(sharedCase.caseId, user) | async\" (click)=\"onRemove(user, sharedCase)\" href=\"javascript:void(0);\">Remove <span class=\"govuk-visually-hidden\">{{ user.firstName + ' ' + user.lastName }} from case</span></a>\n <a *ngIf=\"canCancel(sharedCase.caseId, user) | async\" (click)=\"onCancel(user, sharedCase)\" href=\"javascript:void(0);\">Cancel <span class=\"govuk-visually-hidden\">adding {{ user.firstName + ' ' + user.lastName }} to case</span></a>\n </td>\n <td class=\"govuk-table__cell\">\n <span *ngIf=\"isToBeRemoved(sharedCase.caseId, user) | async\" class=\"hmcts-badge hmcts-badge--red\">To be removed</span>\n <span *ngIf=\"isToBeAdded(sharedCase.caseId, user) | async\" class=\"hmcts-badge\">To be added</span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</div>\n",
2655
2668
  styles: [".govuk-case-header{border-top:1px solid #bfc1c3}.govuk-case-title{font-family:nta,Arial,sans-serif;font-size:24px;color:#005ea5;font-weight:700;padding-left:0}.govuk-case-sub-title{font-family:nta,Arial,sans-serif;font-size:1rem!important;color:#6f777b;font-weight:400;padding-left:0}.govuk-grid-row{margin-left:0;margin-right:0}.govuk-grid-column-three-quarters{padding-top:5px;padding-left:0}.govuk-grid-column-twenty-percent{box-sizing:border-box;padding-top:10px;width:20%;float:left}.govuk-grid-column-five-percent{box-sizing:border-box;padding-top:15px;width:5%;float:left}.govuk-table-column-header{width:40%}.govuk-table-column-actions,.govuk-table-column-label{width:10%}.govuk-div-align-left{font-family:nta,Arial,sans-serif;font-size:1.1875rem!important;line-height:1.31579!important;text-align:left;margin-bottom:20px;padding-left:0;color:#0b0c0c}.govuk-accordion__section-header{border-top:0}.govuk-accordion__section-content{padding-top:0}"]
2656
2669
  }] }
2657
2670
  ];
@@ -2942,6 +2955,17 @@
2942
2955
  return ShareCaseConfirmComponent;
2943
2956
  }());
2944
2957
 
2958
+ /**
2959
+ * @fileoverview added by tsickle
2960
+ * Generated from: lib/models/case-share.model.ts
2961
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2962
+ */
2963
+ /** @enum {string} */
2964
+ var SharedCaseErrorMessages = {
2965
+ OneCaseMustBeSelected: "At least one case must be selected",
2966
+ NoChangesRequested: "You have not requested any changes to case sharing",
2967
+ };
2968
+
2945
2969
  /**
2946
2970
  * @fileoverview added by tsickle
2947
2971
  * Generated from: lib/components/user-select/user-select.component.ts
@@ -3063,16 +3087,23 @@
3063
3087
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3064
3088
  */
3065
3089
  var ShareCaseComponent = /** @class */ (function () {
3066
- function ShareCaseComponent(stateService) {
3090
+ function ShareCaseComponent(stateService, router) {
3067
3091
  this.stateService = stateService;
3092
+ this.router = router;
3068
3093
  this.shareCases = []; // cases selected for sharing
3069
- // cases selected for sharing
3094
+ this.continueAllowed = false;
3095
+ this.selectedUserToRemove = null;
3070
3096
  this.removeUserFromCaseToggleOn = false;
3071
3097
  this.users = []; // users of this organisation the cases can be shared with
3072
3098
  // users of this organisation the cases can be shared with
3073
3099
  this.confirmLink = '';
3100
+ this.cancelLink = '';
3101
+ this.showRemoveUsers = false;
3102
+ this.fnTitle = '';
3103
+ this.title = '';
3074
3104
  this.unselect = new i0.EventEmitter();
3075
3105
  this.synchronizeStore = new i0.EventEmitter();
3106
+ this.validationErrors = [];
3076
3107
  }
3077
3108
  /**
3078
3109
  * @return {?}
@@ -3082,14 +3113,33 @@
3082
3113
  */
3083
3114
  function () {
3084
3115
  var _this = this;
3085
- this.shareCases$.subscribe(( /**
3086
- * @param {?} shareCases
3087
- * @return {?}
3088
- */function (shareCases) {
3116
+ this.shareCases$
3117
+ .pipe(operators.tap(( /**
3118
+ * @param {?} sharedCases
3119
+ * @return {?}
3120
+ */function (sharedCases) {
3121
+ // Update the list of users assigned to at least one case
3122
+ _this.getAssignedUsers(sharedCases.filter(( /**
3123
+ * @param {?} sharedCase
3124
+ * @return {?}
3125
+ */function (sharedCase) { return sharedCase.sharedWith && sharedCase.sharedWith.length > 0; })));
3126
+ })))
3127
+ .subscribe(( /**
3128
+ * @param {?} shareCases
3129
+ * @return {?}
3130
+ */function (shareCases) {
3089
3131
  _this.shareCases = shareCases;
3090
3132
  _this.stateService.setCases(shareCases);
3133
+ // Set the config to be used by the xuilib-gov-uk-error-message component, in particular the element ID to
3134
+ // which the error message is associated
3135
+ if (shareCases) {
3136
+ _this.selectedCasesErrorMessageConfig = {
3137
+ id: shareCases.length > 0 ? 'cases' : 'noCaseDisplay'
3138
+ };
3139
+ }
3091
3140
  }));
3092
3141
  this.shareCases$ = this.stateService.state;
3142
+ this.shareCaseErrorMessage = { isInvalid: false, messages: [] };
3093
3143
  };
3094
3144
  /**
3095
3145
  * @param {?} c
@@ -3100,8 +3150,16 @@
3100
3150
  * @return {?}
3101
3151
  */
3102
3152
  function (c) {
3103
- this.unselect.emit(c);
3104
- this.stateService.removeCase(c.caseId);
3153
+ this.validationErrors = [];
3154
+ if (this.stateService.getCases().length === 1) {
3155
+ this.validationErrors.push({ id: 'cases', message: SharedCaseErrorMessages.OneCaseMustBeSelected });
3156
+ this.shareCaseErrorMessage = { isInvalid: true, messages: [SharedCaseErrorMessages.OneCaseMustBeSelected] };
3157
+ window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
3158
+ }
3159
+ else {
3160
+ this.unselect.emit(c);
3161
+ this.stateService.removeCase(c.caseId);
3162
+ }
3105
3163
  };
3106
3164
  /**
3107
3165
  * @param {?} event
@@ -3139,6 +3197,21 @@
3139
3197
  this.userSelect.clear();
3140
3198
  }
3141
3199
  this.synchronizeStore.emit(newSharedCases);
3200
+ // Update the list of assigned users (which includes pending users)
3201
+ this.getAssignedUsers(newSharedCases);
3202
+ };
3203
+ /**
3204
+ * @return {?}
3205
+ */
3206
+ ShareCaseComponent.prototype.removeUser = /**
3207
+ * @return {?}
3208
+ */
3209
+ function () {
3210
+ if (this.selectedUserToRemove) {
3211
+ /** @type {?} */
3212
+ var newSharedCases = this.stateService.requestUnshare(this.selectedUserToRemove);
3213
+ this.synchronizeStore.emit(newSharedCases);
3214
+ }
3142
3215
  };
3143
3216
  /**
3144
3217
  * @return {?}
@@ -3150,14 +3223,25 @@
3150
3223
  return this.selectedUser === null || this.shareCases.length === 0;
3151
3224
  };
3152
3225
  /**
3226
+ * Function originally used to set disabled state of "Continue" button, now called by the button click handler to
3227
+ * control whether navigation to the confirmation page is allowed. It is prevented if no changes have been made
3228
+ */
3229
+ /**
3230
+ * Function originally used to set disabled state of "Continue" button, now called by the button click handler to
3231
+ * control whether navigation to the confirmation page is allowed. It is prevented if no changes have been made
3153
3232
  * @return {?}
3154
3233
  */
3155
- ShareCaseComponent.prototype.isDisabledContinue = /**
3234
+ ShareCaseComponent.prototype.setContinueAllowed = /**
3235
+ * Function originally used to set disabled state of "Continue" button, now called by the button click handler to
3236
+ * control whether navigation to the confirmation page is allowed. It is prevented if no changes have been made
3156
3237
  * @return {?}
3157
3238
  */
3158
3239
  function () {
3159
- /** @type {?} */
3160
- var isDisabled = true;
3240
+ var _this = this;
3241
+ // Always start with continueAllowed = false. This covers the scenario where a user might add someone for sharing
3242
+ // a case (so, continueAllowed = true), then removes the same user before trying to continue. This would
3243
+ // erroneously leave continueAllowed as true
3244
+ this.continueAllowed = false;
3161
3245
  this.shareCases$.subscribe(( /**
3162
3246
  * @param {?} shareCases
3163
3247
  * @return {?}
@@ -3167,11 +3251,11 @@
3167
3251
  for (var shareCases_1 = __values(shareCases), shareCases_1_1 = shareCases_1.next(); !shareCases_1_1.done; shareCases_1_1 = shareCases_1.next()) {
3168
3252
  var caseState = shareCases_1_1.value;
3169
3253
  if (caseState.pendingShares && caseState.pendingShares.length > 0) {
3170
- isDisabled = false;
3254
+ _this.continueAllowed = true;
3171
3255
  break;
3172
3256
  }
3173
3257
  if (caseState.pendingUnshares && caseState.pendingUnshares.length > 0) {
3174
- isDisabled = false;
3258
+ _this.continueAllowed = true;
3175
3259
  break;
3176
3260
  }
3177
3261
  }
@@ -3190,7 +3274,6 @@
3190
3274
  }
3191
3275
  }
3192
3276
  }));
3193
- return isDisabled;
3194
3277
  };
3195
3278
  /**
3196
3279
  * @param {?} sharedCase
@@ -3230,17 +3313,88 @@
3230
3313
  }
3231
3314
  this.stateService.setCases(this.shareCases);
3232
3315
  };
3316
+ /**
3317
+ * @return {?}
3318
+ */
3319
+ ShareCaseComponent.prototype.onContinue = /**
3320
+ * @return {?}
3321
+ */
3322
+ function () {
3323
+ this.setContinueAllowed();
3324
+ // If continuation is not allowed, set an error message
3325
+ if (!this.continueAllowed) {
3326
+ this.validationErrors = [];
3327
+ this.validationErrors.push({ id: 'cases', message: SharedCaseErrorMessages.NoChangesRequested });
3328
+ this.shareCaseErrorMessage = { isInvalid: true, messages: [SharedCaseErrorMessages.NoChangesRequested] };
3329
+ window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
3330
+ }
3331
+ // Navigate to confirmation page only if allowed to continue
3332
+ if (this.continueAllowed) {
3333
+ this.router.navigate([this.confirmLink]);
3334
+ }
3335
+ };
3336
+ /**
3337
+ * Gets a unique list of all users that have been assigned, or are pending assigment to, at least one case
3338
+ * @param sharedCases The list of shared cases from which to get users these are shared with, or are to be shared with
3339
+ */
3340
+ /**
3341
+ * Gets a unique list of all users that have been assigned, or are pending assigment to, at least one case
3342
+ * @param {?} sharedCases The list of shared cases from which to get users these are shared with, or are to be shared with
3343
+ * @return {?}
3344
+ */
3345
+ ShareCaseComponent.prototype.getAssignedUsers = /**
3346
+ * Gets a unique list of all users that have been assigned, or are pending assigment to, at least one case
3347
+ * @param {?} sharedCases The list of shared cases from which to get users these are shared with, or are to be shared with
3348
+ * @return {?}
3349
+ */
3350
+ function (sharedCases) {
3351
+ /** @type {?} */
3352
+ var users = [];
3353
+ sharedCases.forEach(( /**
3354
+ * @param {?} sharedCase
3355
+ * @return {?}
3356
+ */function (sharedCase) {
3357
+ if (sharedCase.sharedWith) {
3358
+ sharedCase.sharedWith.forEach(( /**
3359
+ * @param {?} user
3360
+ * @return {?}
3361
+ */function (user) {
3362
+ if (!users.some(( /**
3363
+ * @param {?} existingUser
3364
+ * @return {?}
3365
+ */function (existingUser) { return user.idamId === existingUser.idamId; }))) {
3366
+ users.push(user);
3367
+ }
3368
+ }));
3369
+ }
3370
+ if (sharedCase.pendingShares) {
3371
+ sharedCase.pendingShares.forEach(( /**
3372
+ * @param {?} user
3373
+ * @return {?}
3374
+ */function (user) {
3375
+ if (!users.some(( /**
3376
+ * @param {?} existingUser
3377
+ * @return {?}
3378
+ */function (existingUser) { return user.idamId === existingUser.idamId; }))) {
3379
+ users.push(user);
3380
+ }
3381
+ }));
3382
+ }
3383
+ }));
3384
+ this.assignedUsers = users;
3385
+ };
3233
3386
  ShareCaseComponent.decorators = [
3234
3387
  { type: i0.Component, args: [{
3235
3388
  selector: 'xuilib-share-case',
3236
- template: "<div id=\"add-user\">\n <label class=\"govuk-label govuk-!-font-weight-bold\" for=\"add-user-input\">Enter email address</label>\n <span id=\"add-user-hint\" class=\"govuk-hint\">\n Search by name or email address. You can only add people from your organisation individually - but you can add as many as you like.\n </span>\n <div class=\"govuk-grid-row\">\n <div class=\"govuk-grid-column-two-thirds\">\n <xuilib-user-select\n id=\"add-user-input\"\n aria-describedby=\"add-user-hint\"\n [users]=\"users\"\n (selected)=\"onSelectedUser($event)\">\n </xuilib-user-select>\n </div>\n <div class=\"govuk-grid-column-one-thirds\">\n <button id=\"btn-add-user\" (click)=\"addUser()\" class=\"govuk-button\" [disabled]=\"isDisabledAdd()\" title=\"Add user to the case\">Add</button>\n </div>\n </div>\n <details id=\"add-user-help\" class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span id=\"content-why-can-not-find-email\" class=\"govuk-details__summary-text\">\n Can\u2019t find an email address?\n </span>\n </summary>\n <div id=\"content-reason-can-not-find-email\" class=\"govuk-details__text\">\n If you can\u2019t find your colleague\u2019s email address, they will need to complete their registration. Contact your\n administrator for help.\n </div>\n </details>\n</div>\n\n<div id=\"cases\">\n <h3 id=\"title-selected-cases\" class=\"govuk-heading-m\">Selected cases</h3>\n <div *ngIf=\"shareCases && shareCases.length > 0\" class=\"govuk-accordion\" data-module=\"govuk-accordion\" id=\"accordion-with-summary-sections\">\n <xuilib-selected-case-list\n [shareCases$]=\"shareCases$\"\n [removeUserFromCaseToggleOn]=\"removeUserFromCaseToggleOn\"\n (unselect)=\"onUnselect($event)\"\n (synchronizeStore)=\"onSynchronizeStore($event)\"\n >\n </xuilib-selected-case-list>\n </div>\n\n <div id=\"noCaseDisplay\" *ngIf=\"shareCases && shareCases.length === 0\" class=\"govuk-hint\">\n No cases to display.\n </div>\n\n</div>\n\n<div id=\"share-case-nav\">\n <button class=\"govuk-button\" [disabled]=\"isDisabledContinue()\" title=\"Continue\" [routerLink]=\"confirmLink\">Continue</button>\n</div>\n",
3237
- styles: [""]
3389
+ template: "<xuilib-hmcts-error-summary\n [errorMessages]=\"validationErrors\"\n [header]=\"'There is a problem'\"\n></xuilib-hmcts-error-summary>\n<h1 *ngIf=\"title\" class=\"govuk-heading-xl govuk-!-margin-top-2\">\n <span *ngIf=\"fnTitle\" class=\"govuk-caption-xl\">{{fnTitle}}</span>\n {{title}}\n</h1>\n<div id=\"add-user\">\n <div class=\"govuk-form-group\">\n <label class=\"govuk-label govuk-!-font-weight-bold\" for=\"add-user-input\">{{addUserLabel}}</label>\n <span id=\"add-user-hint\" class=\"govuk-hint\">\n Search by name or email address. You can share access with as many people as you need.\n </span>\n <div class=\"govuk-grid-row\">\n <div class=\"govuk-grid-column-two-thirds\">\n <xuilib-user-select\n id=\"add-user-input\"\n aria-describedby=\"add-user-hint\"\n [users]=\"users\"\n (selected)=\"onSelectedUser($event)\">\n </xuilib-user-select>\n </div>\n <div class=\"govuk-grid-column-one-thirds\">\n <button id=\"btn-add-user\" (click)=\"addUser()\" class=\"govuk-button govuk-button--secondary\" [disabled]=\"isDisabledAdd()\" title=\"Add user to selected cases\">Add</button>\n </div>\n </div>\n <details id=\"add-user-help\" class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span id=\"content-why-can-not-find-email\" class=\"govuk-details__summary-text\">\n Can't find an email address?\n </span>\n </summary>\n <div id=\"content-reason-can-not-find-email\" class=\"govuk-details__text\">\n If you can't find your colleague's email address, they will need to complete their registration. Contact your\n administrator for help.\n </div>\n </details>\n </div>\n <div class=\"govuk-form-group\" *ngIf=\"showRemoveUsers\">\n <label class=\"govuk-label govuk-!-font-weight-bold\" for=\"remove-user-input\">Remove a person from all cases</label>\n <span id=\"remove-user-hint\" class=\"govuk-hint\">\n Select a person to remove them from all selected cases.\n </span>\n <div class=\"govuk-grid-row\">\n <div class=\"govuk-grid-column-two-thirds\">\n <select [(ngModel)]=\"selectedUserToRemove\" class=\"govuk-select\" id=\"remove-user-input\" aria-describedby=\"remove-user-hint\">\n <option [ngValue]=\"null\" selected>Select a person</option>\n <option *ngFor=\"let user of assignedUsers\" [ngValue]=\"user\">{{user.firstName}} {{user.lastName}} - {{user.email}}</option>\n </select>\n </div>\n <div class=\"govuk-grid-column-one-thirds\">\n <button id=\"btn-remove-user\" (click)=\"removeUser()\" class=\"govuk-button govuk-button--secondary\" title=\"Remove user from selected cases\">Remove</button>\n </div>\n </div>\n </div>\n</div>\n\n<div id=\"cases\" [ngClass]=\"{'govuk-form-group--error': shareCaseErrorMessage.messages && shareCaseErrorMessage.messages.length > 0}\">\n <h3 id=\"title-selected-cases\" class=\"govuk-heading-m\">Selected cases</h3>\n <xuilib-gov-uk-error-message [config]=\"selectedCasesErrorMessageConfig\" [errorMessage]=\"shareCaseErrorMessage\"></xuilib-gov-uk-error-message>\n <div *ngIf=\"shareCases && shareCases.length > 0\" class=\"govuk-accordion\" data-module=\"govuk-accordion\" id=\"accordion-with-summary-sections\">\n <xuilib-selected-case-list\n [shareCases$]=\"shareCases$\"\n [removeUserFromCaseToggleOn]=\"removeUserFromCaseToggleOn\"\n (unselect)=\"onUnselect($event)\"\n (synchronizeStore)=\"onSynchronizeStore($event)\"\n >\n </xuilib-selected-case-list>\n </div>\n\n <div id=\"noCaseDisplay\" *ngIf=\"shareCases && shareCases.length === 0\" class=\"govuk-hint\"\n [ngClass]=\"{'govuk-form-group--error': shareCaseErrorMessage.messages && shareCaseErrorMessage.messages.length > 0}\">\n No cases to display.\n </div>\n\n</div>\n\n<div id=\"share-case-nav\" class=\"govuk-button-group\">\n <button id=\"btn-continue\" class=\"govuk-button\" data-module=\"govuk-button\" (click)=\"onContinue()\" title=\"Continue\">Continue</button>\n <button id=\"btn-cancel\" class=\"govuk-button govuk-button--secondary\" data-module=\"govuk-button\" title=\"Cancel\" [routerLink]=\"cancelLink\">Cancel</button>\n</div>\n",
3390
+ styles: ["select{width:100%}"]
3238
3391
  }] }
3239
3392
  ];
3240
3393
  /** @nocollapse */
3241
3394
  ShareCaseComponent.ctorParameters = function () {
3242
3395
  return [
3243
- { type: CaseSharingStateService }
3396
+ { type: CaseSharingStateService },
3397
+ { type: i2$2.Router }
3244
3398
  ];
3245
3399
  };
3246
3400
  ShareCaseComponent.propDecorators = {
@@ -3248,6 +3402,11 @@
3248
3402
  shareCases$: [{ type: i0.Input }],
3249
3403
  users: [{ type: i0.Input }],
3250
3404
  confirmLink: [{ type: i0.Input }],
3405
+ cancelLink: [{ type: i0.Input }],
3406
+ addUserLabel: [{ type: i0.Input }],
3407
+ showRemoveUsers: [{ type: i0.Input }],
3408
+ fnTitle: [{ type: i0.Input }],
3409
+ title: [{ type: i0.Input }],
3251
3410
  unselect: [{ type: i0.Output }],
3252
3411
  synchronizeStore: [{ type: i0.Output }],
3253
3412
  userSelect: [{ type: i0.ViewChild, args: [UserSelectComponent,] }]
@@ -3833,6 +3992,7 @@
3833
3992
  JUDICIAL: "Judicial",
3834
3993
  CASEWORKER: "Legal Ops",
3835
3994
  ADMIN: "Admin",
3995
+ CTSC: "CTSC User",
3836
3996
  ALL: "All",
3837
3997
  };
3838
3998
  /** @enum {string} */
@@ -3840,6 +4000,7 @@
3840
4000
  JUDICIAL: "JUDICIAL",
3841
4001
  CASEWORKER: "LEGAL_OPERATIONS",
3842
4002
  ADMIN: "ADMIN",
4003
+ CTSC: "CTSC",
3843
4004
  ALL: "ALL",
3844
4005
  };
3845
4006
 
@@ -3854,6 +4015,12 @@
3854
4015
  return RadioFilterFieldConfig;
3855
4016
  }());
3856
4017
 
4018
+ /**
4019
+ * @fileoverview added by tsickle
4020
+ * Generated from: lib/models/index.ts
4021
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4022
+ */
4023
+
3857
4024
  /**
3858
4025
  * @fileoverview added by tsickle
3859
4026
  * Generated from: lib/services/locations/location.service.ts
@@ -5514,7 +5681,7 @@
5514
5681
  SearchServiceComponent.decorators = [
5515
5682
  { type: i0.Component, args: [{
5516
5683
  selector: 'exui-search-service',
5517
- template: "<div class=\"auto-complete-container\">\n <input\n id=\"inputServiceSearch\"\n (input)=\"onInput()\"\n [formControl]=\"form.controls.searchTerm\"\n [matAutocomplete]=\"autoSearchService\"\n class=\"govuk-input\"\n [attr.disabled]=\"disabled\">\n <mat-autocomplete class=\"mat-autocomplete-panel-extend\" autoActiveFirstOption #autoSearchService=\"matAutocomplete\">\n <mat-option *ngFor=\"let service of services\" (onSelectionChange)=\"onSelectionChange()\">\n {{ service.name }}\n </mat-option>\n <mat-option *ngIf=\"!services.length && showAutocomplete && term && term.length >= this.minSearchCharacters\">No results found</mat-option>\n </mat-autocomplete>\n</div>\n",
5684
+ template: "<div class=\"auto-complete-container\">\n <input\n id=\"inputServiceSearch\"\n (input)=\"onInput()\"\n [formControl]=\"form?.controls.searchTerm\"\n [matAutocomplete]=\"autoSearchService\"\n class=\"govuk-input\"\n [attr.disabled]=\"disabled\">\n <mat-autocomplete class=\"mat-autocomplete-panel-extend\" autoActiveFirstOption #autoSearchService=\"matAutocomplete\">\n <mat-option *ngFor=\"let service of services\" (onSelectionChange)=\"onSelectionChange()\">\n {{ service.name }}\n </mat-option>\n <mat-option *ngIf=\"!services?.length && showAutocomplete && term && term.length >= this.minSearchCharacters\">No results found</mat-option>\n </mat-autocomplete>\n</div>\n",
5518
5685
  styles: [".autocomplete__input--show-all-values{padding:5px 34px 5px 5px;cursor:pointer}.autocomplete__dropdown-arrow-down{z-index:-1;display:inline-block;position:absolute;right:8px;width:24px;height:24px;top:10px}.autocomplete__menu{background-color:#fff;border:2px solid #0b0c0c;border-top:0;color:#0b0c0c;margin:0;max-height:342px;overflow-x:hidden;padding:0;width:100%;width:calc(100% - 4px)}.autocomplete__menu--visible{display:block}.autocomplete__menu--hidden{display:none}.autocomplete__menu--overlay{box-shadow:rgba(0,0,0,.256863) 0 2px 6px;left:0;position:absolute;top:100%;z-index:100}.autocomplete__menu--inline{position:relative}.autocomplete__option{border-bottom:solid #b1b4b6;border-width:1px 0;cursor:pointer;display:block;position:relative}.autocomplete__option>*{pointer-events:none}.autocomplete__option:first-of-type{border-top-width:0}.autocomplete__option:last-of-type{border-bottom-width:0}.autocomplete__option--odd{background-color:#fafafa}.autocomplete__option--focused,.autocomplete__option:hover{background-color:#1d70b8;border-color:#1d70b8;color:#fff;outline:0}.autocomplete__option--no-results{background-color:#fafafa;color:#646b6f;cursor:not-allowed}.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:13px;line-height:1.25}.autocomplete__hint,.autocomplete__option{padding:5px}@media (min-width:641px){.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:13px;line-height:1.31579}}.div-action{display:inline-block}.add-location{display:inline}.remove-location-button{margin:5px}.hide-autocomplete{display:none}.auto-complete-container{min-width:250px;display:inline-block;margin-right:4px}.autocomplete__input{line-height:24px;font-size:19px}"]
5519
5686
  }] }
5520
5687
  ];
@@ -7935,6 +8102,7 @@
7935
8102
  exports.dateValidator = dateValidator;
7936
8103
  exports.radioGroupValidator = radioGroupValidator;
7937
8104
  exports.HmctsSubNavigationComponent = HmctsSubNavigationComponent;
8105
+ exports.SharedCaseErrorMessages = SharedCaseErrorMessages;
7938
8106
  exports.BadgeColour = BadgeColour;
7939
8107
  exports.DateBadgeColour = DateBadgeColour;
7940
8108
  exports.SECONDS_IN_A_DAY = SECONDS_IN_A_DAY;