@hmcts/ccd-case-ui-toolkit 4.8.3-rc.5 → 4.8.3-rc.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.
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @hmcts/ccd-case-ui-toolkit - Case UI Toolkit
3
- * @version v4.8.3-rc.5
3
+ * @version v4.8.3-rc.6
4
4
  * @link undefined
5
5
  * @license MIT
6
6
  */
@@ -19074,6 +19074,7 @@ var router_helper_service_1 = __webpack_require__(61957);
19074
19074
  var wizard_factory_service_1 = __webpack_require__(13125);
19075
19075
  var conditional_show_model_1 = __webpack_require__(5369);
19076
19076
  var event_trigger_service_1 = __webpack_require__(17051);
19077
+ var fields_1 = __webpack_require__(64906);
19077
19078
  var CaseEditWizardGuard = /** @class */ (function () {
19078
19079
  function CaseEditWizardGuard(router, routerHelper, wizardFactory, alertService, eventTriggerService) {
19079
19080
  this.router = router;
@@ -19129,6 +19130,15 @@ var CaseEditWizardGuard = /** @class */ (function () {
19129
19130
  };
19130
19131
  CaseEditWizardGuard.prototype.buildState = function (caseFields) {
19131
19132
  var state = {};
19133
+ /**
19134
+ *
19135
+ * EUI-4873 SSCS - Dynamic lists in a collection within a complex type
19136
+ *
19137
+ * Catering for mid event callbacks, hence the call to re-evaluate
19138
+ * for DynamicList's
19139
+ *
19140
+ */
19141
+ fields_1.FieldsUtils.handleNestedDynamicLists({ case_fields: caseFields });
19132
19142
  caseFields.forEach(function (field) {
19133
19143
  state[field.id] = field.value;
19134
19144
  });
@@ -19190,17 +19200,6 @@ exports.CaseNotifier = CaseNotifier;
19190
19200
 
19191
19201
  "use strict";
19192
19202
 
19193
- var __assign = (this && this.__assign) || function () {
19194
- __assign = Object.assign || function(t) {
19195
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19196
- s = arguments[i];
19197
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19198
- t[p] = s[p];
19199
- }
19200
- return t;
19201
- };
19202
- return __assign.apply(this, arguments);
19203
- };
19204
19203
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19205
19204
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19206
19205
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -19271,73 +19270,6 @@ var CasesService = /** @class */ (function () {
19271
19270
  return rxjs_1.throwError(error);
19272
19271
  }), operators_1.finalize(function () { return _this.loadingService.unregister(loadingToken); }));
19273
19272
  };
19274
- /**
19275
- * handleNestedDynamicLists()
19276
- * Reassigns list_item and value data to DynamicList children
19277
- * down the tree. Server response returns data only in
19278
- * the `value` object of parent complex type
19279
- *
19280
- * EUI-2530 Dynamic Lists for Elements in a Complex Type
19281
- *
19282
- * @param jsonBody - { case_fields: [ CaseField, CaseField ] }
19283
- */
19284
- CasesService.prototype.handleNestedDynamicLists = function (jsonBody) {
19285
- var _this = this;
19286
- if (jsonBody.case_fields) {
19287
- jsonBody.case_fields.forEach(function (caseField) {
19288
- if (caseField.field_type) {
19289
- _this.setDynamicListDefinition(caseField, caseField.field_type, caseField);
19290
- }
19291
- });
19292
- }
19293
- return jsonBody;
19294
- };
19295
- CasesService.prototype.setDynamicListDefinition = function (caseField, caseFieldType, rootCaseField) {
19296
- var _this = this;
19297
- if (caseFieldType.type === CasesService_1.SERVER_RESPONSE_FIELD_TYPE_COMPLEX) {
19298
- caseFieldType.complex_fields.forEach(function (field) {
19299
- try {
19300
- var isDynamicField = CasesService_1.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
19301
- if (isDynamicField) {
19302
- var dynamicListValue = _this.getDynamicListValue(rootCaseField.value, field.id);
19303
- if (dynamicListValue) {
19304
- var list_items = dynamicListValue.list_items;
19305
- var value = dynamicListValue.value;
19306
- field.value = {
19307
- list_items: list_items,
19308
- value: value ? value : undefined
19309
- };
19310
- field.formatted_value = __assign({}, field.formatted_value, field.value);
19311
- }
19312
- }
19313
- else {
19314
- _this.setDynamicListDefinition(field, field.field_type, rootCaseField);
19315
- }
19316
- }
19317
- catch (error) {
19318
- console.log(error);
19319
- }
19320
- });
19321
- }
19322
- else if (caseFieldType.type === CasesService_1.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
19323
- if (caseFieldType.collection_field_type) {
19324
- this.setDynamicListDefinition(caseField, caseFieldType.collection_field_type, rootCaseField);
19325
- }
19326
- }
19327
- };
19328
- CasesService.prototype.getDynamicListValue = function (jsonBlock, key) {
19329
- if (jsonBlock[key]) {
19330
- return jsonBlock[key];
19331
- }
19332
- else {
19333
- for (var elementKey in jsonBlock) {
19334
- if (typeof jsonBlock === 'object' && jsonBlock.hasOwnProperty(elementKey)) {
19335
- return this.getDynamicListValue(jsonBlock[elementKey], key);
19336
- }
19337
- }
19338
- }
19339
- return null;
19340
- };
19341
19273
  CasesService.prototype.getEventTrigger = function (caseTypeId, eventTriggerId, caseId, ignoreWarning) {
19342
19274
  var _this = this;
19343
19275
  ignoreWarning = undefined !== ignoreWarning ? ignoreWarning : 'false';
@@ -19357,7 +19289,7 @@ var CasesService = /** @class */ (function () {
19357
19289
  return this.http
19358
19290
  .get(url, { headers: headers, observe: 'body' })
19359
19291
  .pipe(operators_1.map(function (body) {
19360
- return _this.handleNestedDynamicLists(body);
19292
+ return services_1.FieldsUtils.handleNestedDynamicLists(body);
19361
19293
  }), operators_1.catchError(function (error) {
19362
19294
  _this.errorService.setError(error);
19363
19295
  return rxjs_1.throwError(error);
@@ -19528,10 +19460,6 @@ var CasesService = /** @class */ (function () {
19528
19460
  CasesService.V2_MEDIATYPE_CASE_DATA_VALIDATE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.case-data-validate.v2+json;charset=UTF-8';
19529
19461
  CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
19530
19462
  CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
19531
- // Handling of Dynamic Lists in Complex Types
19532
- CasesService.SERVER_RESPONSE_FIELD_TYPE_COLLECTION = 'Collection';
19533
- CasesService.SERVER_RESPONSE_FIELD_TYPE_COMPLEX = 'Complex';
19534
- CasesService.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE = ['DynamicList', 'DynamicRadioList'];
19535
19463
  CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
19536
19464
  CasesService = CasesService_1 = __decorate([
19537
19465
  core_1.Injectable(),
@@ -39165,6 +39093,17 @@ exports.FieldsPurger = FieldsPurger;
39165
39093
 
39166
39094
  "use strict";
39167
39095
 
39096
+ var __assign = (this && this.__assign) || function () {
39097
+ __assign = Object.assign || function(t) {
39098
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
39099
+ s = arguments[i];
39100
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
39101
+ t[p] = s[p];
39102
+ }
39103
+ return t;
39104
+ };
39105
+ return __assign.apply(this, arguments);
39106
+ };
39168
39107
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
39169
39108
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
39170
39109
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -39308,6 +39247,74 @@ var FieldsUtils = /** @class */ (function () {
39308
39247
  : typeof x === 'number' || x.length > 0)); });
39309
39248
  return !hasNonNullPrimitive ? objectRefs.some(function (y) { return _this.containsNonEmptyValues(y); }) : hasNonNullPrimitive;
39310
39249
  };
39250
+ /**
39251
+ * handleNestedDynamicLists()
39252
+ * Reassigns list_item and value data to DynamicList children
39253
+ * down the tree. Server response returns data only in
39254
+ * the `value` object of parent complex type
39255
+ *
39256
+ * EUI-2530 Dynamic Lists for Elements in a Complex Type
39257
+ *
39258
+ * @param jsonBody - { case_fields: [ CaseField, CaseField ] }
39259
+ */
39260
+ FieldsUtils.handleNestedDynamicLists = function (jsonBody) {
39261
+ var _this = this;
39262
+ if (jsonBody.case_fields) {
39263
+ jsonBody.case_fields.forEach(function (caseField) {
39264
+ if (caseField.field_type) {
39265
+ _this.setDynamicListDefinition(caseField, caseField.field_type, caseField);
39266
+ }
39267
+ });
39268
+ }
39269
+ return jsonBody;
39270
+ };
39271
+ FieldsUtils.setDynamicListDefinition = function (caseField, caseFieldType, rootCaseField) {
39272
+ var _this = this;
39273
+ if (caseFieldType.type === FieldsUtils_1.SERVER_RESPONSE_FIELD_TYPE_COMPLEX) {
39274
+ caseFieldType.complex_fields.forEach(function (field) {
39275
+ try {
39276
+ var isDynamicField = FieldsUtils_1.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
39277
+ if (isDynamicField) {
39278
+ var dynamicListValue = _this.getDynamicListValue(rootCaseField.value, field.id);
39279
+ if (dynamicListValue) {
39280
+ var list_items = dynamicListValue.list_items;
39281
+ var complexValue = dynamicListValue.value;
39282
+ var value = {
39283
+ list_items: list_items,
39284
+ value: complexValue ? complexValue : undefined
39285
+ };
39286
+ field.value = __assign({}, value);
39287
+ field.formatted_value = __assign({}, field.formatted_value, value);
39288
+ }
39289
+ }
39290
+ else {
39291
+ _this.setDynamicListDefinition(field, field.field_type, rootCaseField);
39292
+ }
39293
+ }
39294
+ catch (error) {
39295
+ console.log(error);
39296
+ }
39297
+ });
39298
+ }
39299
+ else if (caseFieldType.type === FieldsUtils_1.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
39300
+ if (caseFieldType.collection_field_type) {
39301
+ this.setDynamicListDefinition(caseField, caseFieldType.collection_field_type, rootCaseField);
39302
+ }
39303
+ }
39304
+ };
39305
+ FieldsUtils.getDynamicListValue = function (jsonBlock, key) {
39306
+ if (jsonBlock[key]) {
39307
+ return jsonBlock[key];
39308
+ }
39309
+ else {
39310
+ for (var elementKey in jsonBlock) {
39311
+ if (typeof jsonBlock === 'object' && jsonBlock.hasOwnProperty(elementKey)) {
39312
+ return this.getDynamicListValue(jsonBlock[elementKey], key);
39313
+ }
39314
+ }
39315
+ }
39316
+ return null;
39317
+ };
39311
39318
  FieldsUtils.prototype.buildCanShowPredicate = function (eventTrigger, form) {
39312
39319
  var currentState = this.getCurrentEventState(eventTrigger, form);
39313
39320
  return function (page) {
@@ -39353,6 +39360,10 @@ var FieldsUtils = /** @class */ (function () {
39353
39360
  FieldsUtils.datePipe = new utils_1.DatePipe(new format_translator_service_1.FormatTranslatorService());
39354
39361
  // EUI-4244. 3 dashes instead of 1 to make this less likely to clash with a real field.
39355
39362
  FieldsUtils.LABEL_SUFFIX = '---LABEL';
39363
+ // Handling of Dynamic Lists in Complex Types
39364
+ FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COLLECTION = 'Collection';
39365
+ FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COMPLEX = 'Complex';
39366
+ FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE = ['DynamicList', 'DynamicRadioList'];
39356
39367
  FieldsUtils.DEFAULT_MERGE_FUNCTION = function mergeFunction(field, result) {
39357
39368
  if (!result.hasOwnProperty(field.id)) {
39358
39369
  result[field.id] = field.value;