@hmcts/rpx-xui-common-lib 1.7.18-caa-case-share-ui-changes-3 → 1.7.18-caa-case-share-ui-changes-6

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.
@@ -2943,6 +2943,7 @@
2943
2943
  /** @enum {string} */
2944
2944
  var SharedCaseErrorMessages = {
2945
2945
  OneCaseMustBeSelected: "At least one case must be selected",
2946
+ NoChangesRequested: "You have not requested any changes to case sharing",
2946
2947
  };
2947
2948
 
2948
2949
  /**
@@ -3066,21 +3067,22 @@
3066
3067
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3067
3068
  */
3068
3069
  var ShareCaseComponent = /** @class */ (function () {
3069
- function ShareCaseComponent(stateService) {
3070
+ function ShareCaseComponent(stateService, router) {
3070
3071
  this.stateService = stateService;
3072
+ this.router = router;
3071
3073
  this.shareCases = []; // cases selected for sharing
3072
- // cases selected for sharing
3074
+ this.continueAllowed = false;
3073
3075
  this.removeUserFromCaseToggleOn = false;
3074
3076
  this.users = []; // users of this organisation the cases can be shared with
3075
3077
  // users of this organisation the cases can be shared with
3076
3078
  this.confirmLink = '';
3079
+ this.cancelLink = '';
3077
3080
  this.showRemoveUsers = false;
3078
3081
  this.fnTitle = '';
3079
3082
  this.title = '';
3080
3083
  this.unselect = new i0.EventEmitter();
3081
3084
  this.synchronizeStore = new i0.EventEmitter();
3082
3085
  this.validationErrors = [];
3083
- this.shareCaseErrorMessage = '';
3084
3086
  }
3085
3087
  /**
3086
3088
  * @return {?}
@@ -3096,8 +3098,16 @@
3096
3098
  */function (shareCases) {
3097
3099
  _this.shareCases = shareCases;
3098
3100
  _this.stateService.setCases(shareCases);
3101
+ // Set the config to be used by the xuilib-gov-uk-error-message component, in particular the element ID to
3102
+ // which the error message is associated
3103
+ if (shareCases) {
3104
+ _this.selectedCasesErrorMessageConfig = {
3105
+ id: shareCases.length > 0 ? 'cases' : 'noCaseDisplay'
3106
+ };
3107
+ }
3099
3108
  }));
3100
3109
  this.shareCases$ = this.stateService.state;
3110
+ this.shareCaseErrorMessage = { isInvalid: false, messages: [] };
3101
3111
  };
3102
3112
  /**
3103
3113
  * @param {?} c
@@ -3111,7 +3121,7 @@
3111
3121
  this.validationErrors = [];
3112
3122
  if (this.stateService.getCases().length === 1) {
3113
3123
  this.validationErrors.push({ id: 'cases', message: SharedCaseErrorMessages.OneCaseMustBeSelected });
3114
- this.shareCaseErrorMessage = SharedCaseErrorMessages.OneCaseMustBeSelected;
3124
+ this.shareCaseErrorMessage = { isInvalid: true, messages: [SharedCaseErrorMessages.OneCaseMustBeSelected] };
3115
3125
  window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
3116
3126
  }
3117
3127
  else {
@@ -3165,6 +3175,59 @@
3165
3175
  function () {
3166
3176
  return this.selectedUser === null || this.shareCases.length === 0;
3167
3177
  };
3178
+ /**
3179
+ * Function originally used to set disabled state of "Continue" button, now called by the button click handler to
3180
+ * control whether navigation to the confirmation page is allowed. It is prevented if no changes have been made
3181
+ */
3182
+ /**
3183
+ * Function originally used to set disabled state of "Continue" button, now called by the button click handler to
3184
+ * control whether navigation to the confirmation page is allowed. It is prevented if no changes have been made
3185
+ * @return {?}
3186
+ */
3187
+ ShareCaseComponent.prototype.setContinueAllowed = /**
3188
+ * Function originally used to set disabled state of "Continue" button, now called by the button click handler to
3189
+ * control whether navigation to the confirmation page is allowed. It is prevented if no changes have been made
3190
+ * @return {?}
3191
+ */
3192
+ function () {
3193
+ var _this = this;
3194
+ // Always start with continueAllowed = false. This covers the scenario where a user might add someone for sharing
3195
+ // a case (so, continueAllowed = true), then removes the same user before trying to continue. This would
3196
+ // erroneously leave continueAllowed as true
3197
+ this.continueAllowed = false;
3198
+ this.shareCases$.subscribe(( /**
3199
+ * @param {?} shareCases
3200
+ * @return {?}
3201
+ */function (shareCases) {
3202
+ var e_1, _a;
3203
+ try {
3204
+ for (var shareCases_1 = __values(shareCases), shareCases_1_1 = shareCases_1.next(); !shareCases_1_1.done; shareCases_1_1 = shareCases_1.next()) {
3205
+ var caseState = shareCases_1_1.value;
3206
+ if (caseState.pendingShares && caseState.pendingShares.length > 0) {
3207
+ _this.continueAllowed = true;
3208
+ break;
3209
+ }
3210
+ if (caseState.pendingUnshares && caseState.pendingUnshares.length > 0) {
3211
+ _this.continueAllowed = true;
3212
+ break;
3213
+ }
3214
+ }
3215
+ }
3216
+ catch (e_1_1) {
3217
+ e_1 = { error: e_1_1 };
3218
+ }
3219
+ finally {
3220
+ try {
3221
+ if (shareCases_1_1 && !shareCases_1_1.done && (_a = shareCases_1.return))
3222
+ _a.call(shareCases_1);
3223
+ }
3224
+ finally {
3225
+ if (e_1)
3226
+ throw e_1.error;
3227
+ }
3228
+ }
3229
+ }));
3230
+ };
3168
3231
  /**
3169
3232
  * @param {?} sharedCase
3170
3233
  * @return {?}
@@ -3174,7 +3237,7 @@
3174
3237
  * @return {?}
3175
3238
  */
3176
3239
  function (sharedCase) {
3177
- var e_1, _a;
3240
+ var e_2, _a;
3178
3241
  if (sharedCase !== null) {
3179
3242
  /** @type {?} */
3180
3243
  var updated = [];
@@ -3186,8 +3249,8 @@
3186
3249
  }
3187
3250
  }
3188
3251
  }
3189
- catch (e_1_1) {
3190
- e_1 = { error: e_1_1 };
3252
+ catch (e_2_1) {
3253
+ e_2 = { error: e_2_1 };
3191
3254
  }
3192
3255
  finally {
3193
3256
  try {
@@ -3195,25 +3258,46 @@
3195
3258
  _a.call(_b);
3196
3259
  }
3197
3260
  finally {
3198
- if (e_1)
3199
- throw e_1.error;
3261
+ if (e_2)
3262
+ throw e_2.error;
3200
3263
  }
3201
3264
  }
3202
3265
  this.shareCases = updated;
3203
3266
  }
3204
3267
  this.stateService.setCases(this.shareCases);
3205
3268
  };
3269
+ /**
3270
+ * @return {?}
3271
+ */
3272
+ ShareCaseComponent.prototype.onContinue = /**
3273
+ * @return {?}
3274
+ */
3275
+ function () {
3276
+ this.setContinueAllowed();
3277
+ // If continuation is not allowed, set an error message
3278
+ if (!this.continueAllowed) {
3279
+ this.validationErrors = [];
3280
+ this.validationErrors.push({ id: 'cases', message: SharedCaseErrorMessages.NoChangesRequested });
3281
+ this.shareCaseErrorMessage = { isInvalid: true, messages: [SharedCaseErrorMessages.NoChangesRequested] };
3282
+ window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
3283
+ }
3284
+ // Navigate to confirmation page only if allowed to continue
3285
+ if (this.continueAllowed) {
3286
+ this.router.navigate([this.confirmLink]);
3287
+ }
3288
+ };
3206
3289
  ShareCaseComponent.decorators = [
3207
3290
  { type: i0.Component, args: [{
3208
3291
  selector: 'xuilib-share-case',
3209
- 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 class=\"govuk-select\" id=\"remove-user-input\" aria-describedby=\"remove-user-hint\">\n <option value=\"{{user}}\" *ngFor=\"let user of users\">{{user.email}}</option>\n </select>\n </div>\n <div class=\"govuk-grid-column-one-thirds\">\n <button id=\"btn-remove-user\" 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.length > 0}\">\n <p class=\"govuk-error-message\" *ngIf=\"validationErrors.length > 0\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{shareCaseErrorMessage}}\n </p>\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\" class=\"govuk-button-group\">\n <button class=\"govuk-button\" data-module=\"govuk-button\" title=\"Continue\" [routerLink]=\"confirmLink\">Continue</button>\n <button class=\"govuk-button govuk-button--secondary\" data-module=\"govuk-button\" title=\"Cancel\">Cancel</button>\n</div>\n",
3292
+ 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 class=\"govuk-select\" id=\"remove-user-input\" aria-describedby=\"remove-user-hint\">\n <option value=\"{{user}}\" *ngFor=\"let user of users\">{{user.email}}</option>\n </select>\n </div>\n <div class=\"govuk-grid-column-one-thirds\">\n <button id=\"btn-remove-user\" 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",
3210
3293
  styles: ["select{width:100%}"]
3211
3294
  }] }
3212
3295
  ];
3213
3296
  /** @nocollapse */
3214
3297
  ShareCaseComponent.ctorParameters = function () {
3215
3298
  return [
3216
- { type: CaseSharingStateService }
3299
+ { type: CaseSharingStateService },
3300
+ { type: i2$2.Router }
3217
3301
  ];
3218
3302
  };
3219
3303
  ShareCaseComponent.propDecorators = {
@@ -3221,6 +3305,7 @@
3221
3305
  shareCases$: [{ type: i0.Input }],
3222
3306
  users: [{ type: i0.Input }],
3223
3307
  confirmLink: [{ type: i0.Input }],
3308
+ cancelLink: [{ type: i0.Input }],
3224
3309
  addUserLabel: [{ type: i0.Input }],
3225
3310
  showRemoveUsers: [{ type: i0.Input }],
3226
3311
  fnTitle: [{ type: i0.Input }],
@@ -3810,6 +3895,7 @@
3810
3895
  JUDICIAL: "Judicial",
3811
3896
  CASEWORKER: "Legal Ops",
3812
3897
  ADMIN: "Admin",
3898
+ CTSC: "CTSC User",
3813
3899
  ALL: "All",
3814
3900
  };
3815
3901
  /** @enum {string} */
@@ -3817,6 +3903,7 @@
3817
3903
  JUDICIAL: "JUDICIAL",
3818
3904
  CASEWORKER: "LEGAL_OPERATIONS",
3819
3905
  ADMIN: "ADMIN",
3906
+ CTSC: "CTSC",
3820
3907
  ALL: "ALL",
3821
3908
  };
3822
3909