@hmcts/ccd-case-ui-toolkit 6.10.7-rollback-case-link → 6.13.0-rc1

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 (34) hide show
  1. package/bundles/hmcts-ccd-case-ui-toolkit.umd.js +381 -234
  2. package/bundles/hmcts-ccd-case-ui-toolkit.umd.js.map +1 -1
  3. package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js +1 -1
  4. package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js.map +1 -1
  5. package/esm2015/lib/shared/components/case-viewer/case-full-access-view/case-full-access-view.component.js +15 -1
  6. package/esm2015/lib/shared/components/palette/case-file-view/components/case-file-view-folder-selector/case-file-view-folder-selector.component.js +1 -1
  7. package/esm2015/lib/shared/components/palette/case-flag/components/select-flag-type/select-flag-type.component.js +13 -15
  8. package/esm2015/lib/shared/components/palette/case-flag/write-case-flag-field.component.js +11 -8
  9. package/esm2015/lib/shared/components/palette/datetime-picker/datetime-picker.component.js +10 -3
  10. package/esm2015/lib/shared/components/search-result/search-result.component.js +10 -14
  11. package/esm2015/lib/shared/directives/conditional-show/domain/conditional-show.model.js +103 -200
  12. package/esm2015/lib/shared/directives/conditional-show/services/condition-parser.service.js +201 -0
  13. package/esm2015/lib/shared/directives/conditional-show/services/condition.peg.js +90 -0
  14. package/esm2015/lib/shared/domain/case-flag/hmcts-service-detail.model.js +1 -1
  15. package/esm2015/lib/shared/services/case-flag/case-flag-refdata.service.js +25 -4
  16. package/fesm2015/hmcts-ccd-case-ui-toolkit.js +443 -215
  17. package/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
  18. package/lib/shared/components/case-viewer/case-full-access-view/case-full-access-view.component.d.ts +1 -0
  19. package/lib/shared/components/case-viewer/case-full-access-view/case-full-access-view.component.d.ts.map +1 -1
  20. package/lib/shared/components/palette/case-flag/components/select-flag-type/select-flag-type.component.d.ts +2 -1
  21. package/lib/shared/components/palette/case-flag/components/select-flag-type/select-flag-type.component.d.ts.map +1 -1
  22. package/lib/shared/components/palette/case-flag/write-case-flag-field.component.d.ts +1 -0
  23. package/lib/shared/components/palette/case-flag/write-case-flag-field.component.d.ts.map +1 -1
  24. package/lib/shared/components/palette/datetime-picker/datetime-picker.component.d.ts.map +1 -1
  25. package/lib/shared/directives/conditional-show/domain/conditional-show.model.d.ts +13 -30
  26. package/lib/shared/directives/conditional-show/domain/conditional-show.model.d.ts.map +1 -1
  27. package/lib/shared/directives/conditional-show/services/condition-parser.service.d.ts +30 -0
  28. package/lib/shared/directives/conditional-show/services/condition-parser.service.d.ts.map +1 -0
  29. package/lib/shared/directives/conditional-show/services/condition.peg.d.ts +3 -0
  30. package/lib/shared/directives/conditional-show/services/condition.peg.d.ts.map +1 -0
  31. package/lib/shared/domain/case-flag/hmcts-service-detail.model.d.ts.map +1 -1
  32. package/lib/shared/services/case-flag/case-flag-refdata.service.d.ts +14 -3
  33. package/lib/shared/services/case-flag/case-flag-refdata.service.d.ts.map +1 -1
  34. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@angular/forms'), require('rx-polling'), require('rxjs'), require('@angular/common/http'), require('rxjs/operators'), require('class-transformer'), require('underscore'), require('moment'), require('util'), require('@edium/fsm'), require('@angular/material/dialog'), require('@angular-material-components/datetime-picker'), require('@angular/cdk/overlay'), require('@angular/cdk/tree'), require('@angular/material/autocomplete'), require('@angular/material/core'), require('@angular/material/datepicker'), require('@angular/material/form-field'), require('@angular/material/input'), require('@hmcts/ccpay-web-component'), require('@hmcts/media-viewer'), require('@nicky-lenaers/ngx-scroll-to'), require('ngx-md'), require('@angular-material-components/moment-adapter'), require('@angular/cdk/portal'), require('ngx-pagination'), require('@angular/material/tabs')) :
3
- typeof define === 'function' && define.amd ? define('@hmcts/ccd-case-ui-toolkit', ['exports', '@angular/core', '@angular/common', '@angular/router', '@angular/forms', 'rx-polling', 'rxjs', '@angular/common/http', 'rxjs/operators', 'class-transformer', 'underscore', 'moment', 'util', '@edium/fsm', '@angular/material/dialog', '@angular-material-components/datetime-picker', '@angular/cdk/overlay', '@angular/cdk/tree', '@angular/material/autocomplete', '@angular/material/core', '@angular/material/datepicker', '@angular/material/form-field', '@angular/material/input', '@hmcts/ccpay-web-component', '@hmcts/media-viewer', '@nicky-lenaers/ngx-scroll-to', 'ngx-md', '@angular-material-components/moment-adapter', '@angular/cdk/portal', 'ngx-pagination', '@angular/material/tabs'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hmcts = global.hmcts || {}, global.hmcts["ccd-case-ui-toolkit"] = {}), global.ng.core, global.ng.common, global.ng.router, global.ng.forms, global["rx-polling"], global.rxjs, global.ng.common.http, global.rxjs.operators, global["class-transformer"], global.underscore, global.moment, global.util, global["@edium/fsm"], global.ng.material.dialog, global["@angular-material-components/datetime-picker"], global.ng.cdk.overlay, global.ng.cdk.tree, global.ng.material.autocomplete, global.ng.material.core, global.ng.material.datepicker, global.ng.material.formField, global.ng.material.input, global["@hmcts/ccpay-web-component"], global.i11, global["@nicky-lenaers/ngx-scroll-to"], global["ngx-md"], global["@angular-material-components/moment-adapter"], global.ng.cdk.portal, global["ngx-pagination"], global.ng.material.tabs));
5
- })(this, (function (exports, i0, i1, i1$1, i2, polling, rxjs, i1$2, operators, classTransformer, _, moment, util, fsm, i1$3, i4, i1$4, i7, i5, i6, i5$1, i6$1, i3$1, i3, i11, i2$1, i1$5, momentAdapter, i6$2, i1$6, i9) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@angular/forms'), require('rx-polling'), require('rxjs'), require('@angular/common/http'), require('rxjs/operators'), require('class-transformer'), require('moment'), require('underscore'), require('pegjs'), require('util'), require('@edium/fsm'), require('@angular/material/dialog'), require('@angular-material-components/datetime-picker'), require('@angular/cdk/overlay'), require('@angular/cdk/tree'), require('@angular/material/autocomplete'), require('@angular/material/core'), require('@angular/material/datepicker'), require('@angular/material/form-field'), require('@angular/material/input'), require('@hmcts/ccpay-web-component'), require('@hmcts/media-viewer'), require('@nicky-lenaers/ngx-scroll-to'), require('ngx-md'), require('@angular-material-components/moment-adapter'), require('@angular/cdk/portal'), require('ngx-pagination'), require('@angular/material/tabs')) :
3
+ typeof define === 'function' && define.amd ? define('@hmcts/ccd-case-ui-toolkit', ['exports', '@angular/core', '@angular/common', '@angular/router', '@angular/forms', 'rx-polling', 'rxjs', '@angular/common/http', 'rxjs/operators', 'class-transformer', 'moment', 'underscore', 'pegjs', 'util', '@edium/fsm', '@angular/material/dialog', '@angular-material-components/datetime-picker', '@angular/cdk/overlay', '@angular/cdk/tree', '@angular/material/autocomplete', '@angular/material/core', '@angular/material/datepicker', '@angular/material/form-field', '@angular/material/input', '@hmcts/ccpay-web-component', '@hmcts/media-viewer', '@nicky-lenaers/ngx-scroll-to', 'ngx-md', '@angular-material-components/moment-adapter', '@angular/cdk/portal', 'ngx-pagination', '@angular/material/tabs'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hmcts = global.hmcts || {}, global.hmcts["ccd-case-ui-toolkit"] = {}), global.ng.core, global.ng.common, global.ng.router, global.ng.forms, global["rx-polling"], global.rxjs, global.ng.common.http, global.rxjs.operators, global["class-transformer"], global.moment, global.underscore, global.pegjs, global.util, global["@edium/fsm"], global.ng.material.dialog, global["@angular-material-components/datetime-picker"], global.ng.cdk.overlay, global.ng.cdk.tree, global.ng.material.autocomplete, global.ng.material.core, global.ng.material.datepicker, global.ng.material.formField, global.ng.material.input, global["@hmcts/ccpay-web-component"], global.i11, global["@nicky-lenaers/ngx-scroll-to"], global["ngx-md"], global["@angular-material-components/moment-adapter"], global.ng.cdk.portal, global["ngx-pagination"], global.ng.material.tabs));
5
+ })(this, (function (exports, i0, i1, i1$1, i2, polling, rxjs, i1$2, operators, classTransformer, moment, _, pegjs, util, fsm, i1$3, i4, i1$4, i7, i5, i6, i5$1, i6$1, i3$1, i3, i11, i2$1, i1$5, momentAdapter, i6$2, i1$6, i9) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -30,8 +30,8 @@
30
30
  var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
31
31
  var polling__default = /*#__PURE__*/_interopDefaultLegacy(polling);
32
32
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
33
- var ___namespace = /*#__PURE__*/_interopNamespace(_);
34
33
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
34
+ var ___namespace = /*#__PURE__*/_interopNamespace(_);
35
35
  var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$3);
36
36
  var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
37
37
  var i1__namespace$4 = /*#__PURE__*/_interopNamespace(i1$4);
@@ -4419,183 +4419,69 @@
4419
4419
  }], null, null);
4420
4420
  })();
4421
4421
 
4422
- var ShowCondition = /** @class */ (function () {
4423
- // Expects a show condition of the form: <fieldName>="string"
4424
- function ShowCondition(condition) {
4425
- this.condition = condition;
4426
- this.orConditions = null;
4427
- this.andConditions = null;
4428
- if (!!condition) {
4429
- if (condition.search(ShowCondition.OR_CONDITION_REGEXP) !== -1) {
4430
- this.orConditions = condition.split(ShowCondition.OR_CONDITION_REGEXP);
4431
- }
4432
- else {
4433
- this.andConditions = condition.split(ShowCondition.AND_CONDITION_REGEXP);
4434
- }
4435
- }
4422
+ var conditionSource = "{\n function flat(arr, depth = 1) {\n var flatten = function (arr, depth = 1) {\n if (depth) return arr;\n\n // Otherwise, concatenate into the parent array\n return arr.reduce(function (acc, val) {\n return acc.concat(Array.isArray(val) ? flatten(val, depth - 1) : val);\n }, []);\n\n };\n\n return flatten(arr, depth - 1);\n }\n }\n\n Start\n = Formula\n\n Formula\n = EnclosedFormula\n / OpenFormula\n\n EnclosedFormula\n = bracket formula:OpenFormula bracket join:(JoinComparator)*\n { return flat([ [formula], join[0] ], 1) }\n\n OpenFormula\n = eq:OpenEqualityCheck joins:(JoinComparator)*\n { return flat([ eq, flat(joins) ]) }\n\n JoinComparator\n = comp:Comparator eq:OpenEqualityCheck\n { return [comp, eq]; }\n / CompoundJoinComparator\n\n CompoundJoinComparator\n = comp:Comparator bracket f:OpenFormula bracket\n { return [comp, f ] }\n\n OpenEqualityCheck\n = fr:FieldReference _? op:operator _? val:Value\n { return { fieldReference: fr, comparator: op, value: val } }\n\n Comparator\n = _? c:'AND' _?\n { return c; }\n / _? c:'OR' _?\n { return c; }\n\n Word\n = l:Letter+\n { return l.join(\"\"); }\n\n Letter\n = [a-zA-Z]\n\n Value\n = v:quotedValue / v:Word\n { return v.join(\"\") }\n / v:number\n { return parseInt(v.join(\"\")) }\n\n FieldReference\n = characters:[A-Za-z0-9._]+ { return characters.join(\"\"); }\n\n number\n = [0-9]+\n\n quotedValue\n = '\"'val:[A-Za-z0-9.,* _-]*'\"'\n { return val.join(\"\"); }\n\n bracket\n = (_? \"(\"+ _? / _? \")\"+ _? )\n\n operator\n = \"=\" / \"!=\" / \"CONTAINS\"\n\n ws \"Whitespace\"\n = [ \t]\n\n _ \"One or more whitespaces\"\n = ws+\n\n nl \"New line\"\n = \"\\n\"";
4423
+ var peg = pegjs.generate(conditionSource);
4424
+
4425
+ var ConditionParser = /** @class */ (function () {
4426
+ function ConditionParser() {
4436
4427
  }
4437
- ShowCondition.addPathPrefixToCondition = function (showCondition, pathPrefix) {
4438
- if (!pathPrefix || pathPrefix === '') {
4439
- return showCondition;
4440
- }
4441
- if (showCondition.search(ShowCondition.OR_CONDITION_REGEXP) !== -1) {
4442
- var orConditions = showCondition.split(ShowCondition.OR_CONDITION_REGEXP);
4443
- orConditions = this.extractConditions(orConditions, pathPrefix);
4444
- return orConditions.join(' OR ');
4445
- }
4446
- else {
4447
- var andConditions = showCondition.split(ShowCondition.AND_CONDITION_REGEXP);
4448
- andConditions = this.extractConditions(andConditions, pathPrefix);
4449
- return andConditions.join(' AND ');
4450
- }
4451
- };
4452
- // Cache instances so that we can cache results more effectively
4453
- ShowCondition.getInstance = function (condition) {
4454
- var instance = this.instanceCache.get(condition);
4455
- if (!instance) {
4456
- instance = new ShowCondition(condition);
4457
- this.instanceCache.set(condition, instance);
4428
+ /**
4429
+ * Parse the raw formula and output structured condition data
4430
+ * that can be used in evaluating show/hide logic
4431
+ * @param condition raw formula e.g. TextField = "Hello"
4432
+ */
4433
+ ConditionParser.parse = function (condition) {
4434
+ if (!condition) {
4435
+ return null;
4458
4436
  }
4459
- return instance;
4437
+ ;
4438
+ condition = condition.replace(/CONTAINS/g, ' CONTAINS');
4439
+ return peg.parse(condition.trim(), {});
4460
4440
  };
4461
4441
  /**
4462
- * Determine whether a ShowCondition model is affected by fields that have
4463
- * a display_context of HIDDEN or READONLY, which means they aren't able to
4464
- * be changed by the user's actions.
4465
- *
4466
- * @param showCondition The ShowCondition model to evaluate.
4467
- * @param caseFields Inspected to see appropriate display_contexts.
4442
+ * Evaluate the current fields against the conditions
4443
+ * @param fields the current page fields and their value
4444
+ * @param conditions The PegJS formula output
4468
4445
  */
4469
- ShowCondition.hiddenCannotChange = function (showCondition, caseFields) {
4470
- var e_1, _a;
4471
- if (showCondition && caseFields) {
4472
- var conditions = showCondition.andConditions || showCondition.orConditions;
4473
- if (conditions && conditions.length > 0) {
4474
- var allUnchangeable = true;
4475
- var _loop_1 = function (condition) {
4476
- var _a = __read(ShowCondition.getField(condition), 1), field = _a[0];
4477
- var path = field.split('.');
4478
- var head = path.shift();
4479
- var caseField = caseFields.find(function (cf) { return cf.id === head; });
4480
- while (path.length > 0) {
4481
- head = path.shift();
4482
- if (caseField) {
4483
- // Jump out if this is HIDDEN or READONLY, regardless of whether or not it's
4484
- // complex or a collection - nested fields will "inherit" the display_context.
4485
- if (['HIDDEN', 'READONLY'].indexOf(caseField.display_context) > -1) {
4486
- break;
4487
- }
4488
- // Consider what type of field this is.
4489
- var ft = caseField.field_type;
4490
- switch (ft.type) {
4491
- case 'Collection':
4492
- if (ft.collection_field_type.type === 'Complex' && ft.collection_field_type.complex_fields) {
4493
- caseField = ft.collection_field_type.complex_fields.find(function (cf) { return cf.id === head; });
4494
- }
4495
- break;
4496
- case 'Complex':
4497
- if (ft.complex_fields) {
4498
- caseField = ft.complex_fields.find(function (cf) { return cf.id === head; });
4499
- }
4500
- break;
4501
- }
4502
- }
4503
- }
4504
- if (caseField) {
4505
- allUnchangeable = allUnchangeable && ['HIDDEN', 'READONLY'].indexOf(caseField.display_context) > -1;
4506
- }
4507
- };
4508
- try {
4509
- for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
4510
- var condition = conditions_1_1.value;
4511
- _loop_1(condition);
4512
- }
4513
- }
4514
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4515
- finally {
4516
- try {
4517
- if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
4518
- }
4519
- finally { if (e_1) throw e_1.error; }
4446
+ ConditionParser.evaluate = function (fields, conditions, path) {
4447
+ var _this = this;
4448
+ if (!conditions) {
4449
+ return true;
4450
+ }
4451
+ ;
4452
+ var validJoinComparators = ['AND', 'OR'];
4453
+ var result = conditions.reduce(function (accumulator, condition, index) {
4454
+ var isJoinComparator = function (comparator) { return (typeof comparator === 'string' && validJoinComparators.indexOf(comparator) !== -1); };
4455
+ if (isJoinComparator(condition)) {
4456
+ return accumulator;
4457
+ }
4458
+ ;
4459
+ var currentConditionResult = true;
4460
+ if (Array.isArray(condition)) {
4461
+ currentConditionResult = _this.evaluate(fields, condition);
4462
+ if (isJoinComparator(conditions[index - 1])) {
4463
+ return _this.evaluateJoin(accumulator, conditions[index - 1], currentConditionResult);
4520
4464
  }
4521
- return allUnchangeable;
4522
4465
  }
4523
- }
4524
- return false;
4525
- };
4526
- ShowCondition.extractConditions = function (conditionsArray, pathPrefix) {
4527
- var extracted = conditionsArray.map(function (condition) {
4528
- if (condition.startsWith(pathPrefix)) {
4529
- return condition;
4466
+ if (condition.comparator) {
4467
+ var formula = condition.fieldReference + condition.comparator + condition.value;
4468
+ currentConditionResult = _this.matchEqualityCondition(fields, formula, path);
4530
4469
  }
4531
- return pathPrefix + "." + condition;
4532
- });
4533
- return extracted;
4534
- };
4535
- ShowCondition.getField = function (condition) {
4536
- var separator = ShowCondition.CONTAINS;
4537
- if (condition.indexOf(ShowCondition.CONTAINS) < 0) {
4538
- separator = ShowCondition.CONDITION_EQUALS;
4539
- if (condition.indexOf(ShowCondition.CONDITION_NOT_EQUALS) > -1) {
4540
- separator = ShowCondition.CONDITION_NOT_EQUALS;
4470
+ if (isJoinComparator(conditions[index - 1])) {
4471
+ return _this.evaluateJoin(accumulator, conditions[index - 1], currentConditionResult);
4541
4472
  }
4542
- }
4543
- return [condition.split(separator)[0], separator];
4544
- };
4545
- ShowCondition.prototype.match = function (fields, path) {
4546
- if (!this.condition) {
4547
- return true;
4548
- }
4549
- return this.matchAndConditions(fields, this.updatePathName(path));
4550
- };
4551
- ShowCondition.prototype.matchByContextFields = function (contextFields) {
4552
- return this.match(FieldsUtils.toValuesMap(contextFields));
4553
- };
4554
- /**
4555
- * Determine whether this is affected by fields that have a display_context
4556
- * of HIDDEN or READONLY, which means they aren't able to be changed by the
4557
- * user's actions.
4558
- *
4559
- * @param caseFields Inspected to see appropriate display_contexts.
4560
- */
4561
- ShowCondition.prototype.hiddenCannotChange = function (caseFields) {
4562
- return ShowCondition.hiddenCannotChange(this, caseFields);
4563
- };
4564
- /**
4565
- * Path Name gets updated for complex sub fields
4566
- * @param path Path name.
4567
- */
4568
- ShowCondition.prototype.updatePathName = function (path) {
4569
- if (path && path.split(/[_]+/g).length > 0) {
4570
- var _a = __read(path.split(/[_]+/g)), pathName_1 = _a[0], pathTail = _a.slice(1);
4571
- var pathFinalIndex_1 = pathTail.pop();
4572
- var pathTailString = pathTail.toString();
4573
- var mappedPathTail = void 0;
4574
- mappedPathTail = pathTail.map(function (value) {
4575
- return Number(pathFinalIndex_1) === Number(value) ? pathName_1 : value;
4576
- });
4577
- return pathTailString !== mappedPathTail.toString()
4578
- ? pathName_1 + "_" + mappedPathTail.join('_') + "_" + pathFinalIndex_1
4579
- : path;
4580
- }
4581
- else {
4582
- return path;
4583
- }
4473
+ return currentConditionResult;
4474
+ }, true);
4475
+ return result;
4584
4476
  };
4585
- ShowCondition.prototype.matchAndConditions = function (fields, path) {
4586
- var _this = this;
4587
- if (!!this.orConditions) {
4588
- return this.orConditions.some(function (orCondition) { return _this.matchEqualityCondition(fields, orCondition, path); });
4589
- }
4590
- else if (!!this.andConditions) {
4591
- return this.andConditions.every(function (andCondition) { return _this.matchEqualityCondition(fields, andCondition, path); });
4592
- }
4593
- else {
4594
- return false;
4477
+ ConditionParser.evaluateJoin = function (leftResult, comparator, rightResult) {
4478
+ switch (comparator) {
4479
+ case 'OR': return leftResult || rightResult;
4480
+ case 'AND': return leftResult && rightResult;
4595
4481
  }
4596
4482
  };
4597
- ShowCondition.prototype.matchEqualityCondition = function (fields, condition, path) {
4598
- var _a = __read(ShowCondition.getField(condition), 2), field = _a[0], conditionSeparator = _a[1];
4483
+ ConditionParser.matchEqualityCondition = function (fields, condition, path) {
4484
+ var _a = __read(this.getField(condition), 2), field = _a[0], conditionSeparator = _a[1];
4599
4485
  var _b = __read(field.split('.')), head = _b[0], tail = _b.slice(1);
4600
4486
  var currentValue = this.findValueForComplexCondition(fields, head, tail, path);
4601
4487
  var expectedValue = this.unquoted(condition.split(conditionSeparator)[1]);
@@ -4606,7 +4492,29 @@
4606
4492
  return this.checkValueEquals(expectedValue, currentValue, conditionSeparator);
4607
4493
  }
4608
4494
  };
4609
- ShowCondition.prototype.checkValueEquals = function (expectedValue, currentValue, conditionSeparaor) {
4495
+ ConditionParser.getValue = function (fields, head) {
4496
+ if (this.isDynamicList(fields[head])) {
4497
+ return fields[head].value.code;
4498
+ }
4499
+ else {
4500
+ return fields[head];
4501
+ }
4502
+ };
4503
+ ConditionParser.isDynamicList = function (dynamiclist) {
4504
+ return !___namespace.isEmpty(dynamiclist) &&
4505
+ (___namespace.has(dynamiclist, 'value') && ___namespace.has(dynamiclist, 'list_items'));
4506
+ };
4507
+ ConditionParser.getField = function (condition) {
4508
+ var separator = ShowCondition.CONTAINS;
4509
+ if (condition.indexOf(ShowCondition.CONTAINS) < 0) {
4510
+ separator = ShowCondition.CONDITION_EQUALS;
4511
+ if (condition.indexOf(ShowCondition.CONDITION_NOT_EQUALS) > -1) {
4512
+ separator = ShowCondition.CONDITION_NOT_EQUALS;
4513
+ }
4514
+ }
4515
+ return [condition.split(separator)[0], separator];
4516
+ };
4517
+ ConditionParser.checkValueEquals = function (expectedValue, currentValue, conditionSeparaor) {
4610
4518
  if (expectedValue.search('[,]') > -1) { // for multi-select list
4611
4519
  return this.checkMultiSelectListEquals(expectedValue, currentValue, conditionSeparaor);
4612
4520
  }
@@ -4626,7 +4534,7 @@
4626
4534
  }
4627
4535
  }
4628
4536
  };
4629
- ShowCondition.prototype.checkValueNotEquals = function (expectedValue, currentValue) {
4537
+ ConditionParser.checkValueNotEquals = function (expectedValue, currentValue) {
4630
4538
  var formatCurrentValue = currentValue ? currentValue.toString().trim() : '';
4631
4539
  if ('*' === expectedValue && formatCurrentValue !== '') {
4632
4540
  return false;
@@ -4634,7 +4542,7 @@
4634
4542
  var formatExpectedValue = expectedValue ? expectedValue.toString().trim() : '';
4635
4543
  return formatCurrentValue != formatExpectedValue; // tslint:disable-line
4636
4544
  };
4637
- ShowCondition.prototype.checkMultiSelectListEquals = function (expectedValue, currentValue, conditionSeparator) {
4545
+ ConditionParser.checkMultiSelectListEquals = function (expectedValue, currentValue, conditionSeparator) {
4638
4546
  var expectedValues = expectedValue.split(',').sort().toString();
4639
4547
  var values = currentValue ? currentValue.sort().toString() : '';
4640
4548
  if (conditionSeparator === ShowCondition.CONDITION_NOT_EQUALS) {
@@ -4644,7 +4552,7 @@
4644
4552
  return expectedValues === values;
4645
4553
  }
4646
4554
  };
4647
- ShowCondition.prototype.checkValueContains = function (expectedValue, currentValue) {
4555
+ ConditionParser.checkValueContains = function (expectedValue, currentValue) {
4648
4556
  if (expectedValue.search(',') > -1) {
4649
4557
  var expectedValues = expectedValue.split(',').sort();
4650
4558
  var values_1 = currentValue ? currentValue.sort().toString() : '';
@@ -4655,7 +4563,11 @@
4655
4563
  return values.search(expectedValue) >= 0;
4656
4564
  }
4657
4565
  };
4658
- ShowCondition.prototype.findValueForComplexCondition = function (fields, head, tail, path) {
4566
+ ConditionParser.unquoted = function (str) {
4567
+ var res = str.replace(/^"|"$/g, '');
4568
+ return res;
4569
+ };
4570
+ ConditionParser.findValueForComplexCondition = function (fields, head, tail, path) {
4659
4571
  if (!fields) {
4660
4572
  return undefined;
4661
4573
  }
@@ -4671,7 +4583,7 @@
4671
4583
  }
4672
4584
  }
4673
4585
  };
4674
- ShowCondition.prototype.findValueForComplexConditionForPathIfAny = function (fields, head, tail, path) {
4586
+ ConditionParser.findValueForComplexConditionForPathIfAny = function (fields, head, tail, path) {
4675
4587
  if (path) {
4676
4588
  var _a = __read(path.split(/[_]+/g)), _ = _a[0], pathTail = _a.slice(1);
4677
4589
  return this.findValueForComplexCondition(fields[head], tail[0], tail.slice(1), pathTail.join('_'));
@@ -4680,9 +4592,9 @@
4680
4592
  return this.findValueForComplexCondition(fields[head], tail[0], tail.slice(1), path);
4681
4593
  }
4682
4594
  };
4683
- ShowCondition.prototype.findValueForComplexConditionInArray = function (fields, head, tail, path) {
4595
+ ConditionParser.findValueForComplexConditionInArray = function (fields, head, tail, path) {
4684
4596
  // use the path to resolve which array element we refer to
4685
- if (path && path.startsWith(head)) {
4597
+ if (path.startsWith(head)) {
4686
4598
  var _a = __read(path.split(/[_]+/g)), _ = _a[0], pathTail = _a.slice(1);
4687
4599
  if (pathTail.length > 0) {
4688
4600
  try {
@@ -4691,43 +4603,239 @@
4691
4603
  return (fields[head][arrayIndex] !== undefined) ? this.findValueForComplexCondition(fields[head][arrayIndex]['value'], tail[0], tail.slice(1), dropNumberPath.join('_')) : null;
4692
4604
  }
4693
4605
  catch (e) {
4694
- console.log('Error while parsing number', pathTail[0], e);
4606
+ console.error('Error while parsing number', pathTail[0], e);
4695
4607
  }
4696
4608
  }
4697
4609
  }
4698
4610
  else {
4699
- console.log('Path in formArray should start with ', head, ', full path: ', path);
4611
+ console.error('Path in formArray should start with ', head, ', full path: ', path);
4700
4612
  }
4701
4613
  };
4702
- ShowCondition.prototype.getValue = function (fields, head) {
4703
- if (this.isDynamicList(fields[head])) {
4704
- return fields[head].value.code;
4614
+ ConditionParser.removeStarChar = function (str) {
4615
+ if (str && str.indexOf('*') > -1) {
4616
+ return str.substring(0, str.indexOf('*'));
4617
+ }
4618
+ return str;
4619
+ };
4620
+ ConditionParser.okIfBothEmpty = function (right, value) {
4621
+ return value === null && (right === '');
4622
+ };
4623
+ return ConditionParser;
4624
+ }());
4625
+
4626
+ var ShowCondition = /** @class */ (function () {
4627
+ // Expects a show condition of the form: <fieldName>="string"
4628
+ function ShowCondition(condition) {
4629
+ this.condition = condition;
4630
+ this.conditions = [];
4631
+ if (!!condition) {
4632
+ this.conditions = ConditionParser.parse(condition);
4633
+ }
4634
+ }
4635
+ ShowCondition.addPathPrefixToCondition = function (showCondition, pathPrefix) {
4636
+ if (!pathPrefix || pathPrefix === '') {
4637
+ return showCondition;
4638
+ }
4639
+ if (!showCondition) {
4640
+ return '';
4641
+ }
4642
+ var formula = ConditionParser.parse(showCondition);
4643
+ if (!formula) {
4644
+ return showCondition;
4645
+ }
4646
+ this.processedList = [];
4647
+ showCondition = showCondition.replace(/CONTAINS/g, ' CONTAINS');
4648
+ var processedCondition = this.processAddPathPrefixToCondition(formula, pathPrefix, showCondition);
4649
+ return processedCondition.replace(/ CONTAINS/g, 'CONTAINS');
4650
+ };
4651
+ ShowCondition.processAddPathPrefixToCondition = function (formula, pathPrefix, originalCondition) {
4652
+ var _this = this;
4653
+ var finalCondition = originalCondition;
4654
+ if (Array.isArray(formula)) {
4655
+ formula.forEach(function (condition) {
4656
+ if (typeof condition === 'string' && _this.validJoinComparators.indexOf(condition) !== -1) {
4657
+ // do nothing
4658
+ }
4659
+ else {
4660
+ if (Array.isArray(condition)) {
4661
+ finalCondition = _this.processAddPathPrefixToCondition(condition, pathPrefix, finalCondition);
4662
+ }
4663
+ else {
4664
+ finalCondition = _this.extractConditions(condition, pathPrefix, finalCondition);
4665
+ }
4666
+ }
4667
+ });
4705
4668
  }
4706
4669
  else {
4707
- return fields[head];
4670
+ finalCondition = this.extractConditions(formula, pathPrefix, finalCondition);
4708
4671
  }
4672
+ return finalCondition;
4709
4673
  };
4710
- ShowCondition.prototype.isDynamicList = function (dynamiclist) {
4711
- return !___namespace.isEmpty(dynamiclist) &&
4712
- (___namespace.has(dynamiclist, 'value') && ___namespace.has(dynamiclist, 'list_items'));
4674
+ ShowCondition.extractConditions = function (condition, pathPrefix, originalCondition) {
4675
+ if (condition.fieldReference.startsWith(pathPrefix)) {
4676
+ return originalCondition;
4677
+ }
4678
+ else {
4679
+ if (originalCondition.indexOf(condition.fieldReference) > -1) {
4680
+ if (this.processedList && this.processedList.indexOf(condition.fieldReference) === -1) {
4681
+ this.processedList.push(condition.fieldReference);
4682
+ var regularExp = new RegExp('(\\b)' + condition.fieldReference + '(?=[^"]*(?:"[^"]*"[^"]*)*$)(\\b)', 'g');
4683
+ return originalCondition.replace(regularExp, pathPrefix + '.' + condition.fieldReference);
4684
+ }
4685
+ else {
4686
+ return originalCondition;
4687
+ }
4688
+ }
4689
+ }
4713
4690
  };
4714
- ShowCondition.prototype.unquoted = function (str) {
4715
- return str.replace(/(?:^")|(?:"$)/g, '');
4691
+ // Cache instances so that we can cache results more effectively
4692
+ ShowCondition.getInstance = function (condition) {
4693
+ var instance = this.instanceCache.get(condition);
4694
+ if (!instance) {
4695
+ instance = new ShowCondition(condition);
4696
+ this.instanceCache.set(condition, instance);
4697
+ }
4698
+ return instance;
4716
4699
  };
4717
- ShowCondition.prototype.removeStarChar = function (str) {
4718
- return str.substring(0, str.length - 1);
4700
+ ShowCondition.getField = function (condition) {
4701
+ var separator = ShowCondition.CONTAINS;
4702
+ if (condition.indexOf(ShowCondition.CONTAINS) < 0) {
4703
+ separator = ShowCondition.CONDITION_EQUALS;
4704
+ if (condition.indexOf(ShowCondition.CONDITION_NOT_EQUALS) > -1) {
4705
+ separator = ShowCondition.CONDITION_NOT_EQUALS;
4706
+ }
4707
+ }
4708
+ return [condition.split(separator)[0], separator];
4719
4709
  };
4720
- ShowCondition.prototype.okIfBothEmpty = function (right, value) {
4721
- return value === null && (right === '');
4710
+ ShowCondition.getConditions = function (formula) {
4711
+ var _this = this;
4712
+ var conditionList = [];
4713
+ if (!!formula) {
4714
+ var newFormula = typeof formula === 'string' ? JSON.parse(formula) : formula;
4715
+ if (Array.isArray(newFormula)) {
4716
+ newFormula.forEach(function (condition) {
4717
+ if (!(typeof condition === 'string' && _this.validJoinComparators.indexOf(condition) !== -1)) {
4718
+ if (Array.isArray(condition)) {
4719
+ conditionList.push(ShowCondition.getConditions(condition).toString());
4720
+ }
4721
+ else {
4722
+ conditionList.push(condition.fieldReference + condition.comparator + condition.value);
4723
+ }
4724
+ }
4725
+ });
4726
+ }
4727
+ else {
4728
+ conditionList.push(newFormula.fieldReference + newFormula.comparator + newFormula.value);
4729
+ }
4730
+ }
4731
+ return conditionList.toString();
4732
+ };
4733
+ /**
4734
+ * Determine whether a ShowCondition model is affected by fields that have
4735
+ * a display_context of HIDDEN or READONLY, which means they aren't able to
4736
+ * be changed by the user's actions.
4737
+ *
4738
+ * @param showCondition The ShowCondition model to evaluate.
4739
+ * @param caseFields Inspected to see appropriate display_contexts.
4740
+ */
4741
+ ShowCondition.hiddenCannotChange = function (showCondition, caseFields) {
4742
+ var e_1, _a;
4743
+ if (showCondition && showCondition.conditions.length && caseFields) {
4744
+ var conditions = this.getConditions(showCondition.conditions).split(',');
4745
+ if (conditions && conditions.length > 0) {
4746
+ var allUnchangeable = true;
4747
+ var _loop_1 = function (condition) {
4748
+ var _a = __read(ShowCondition.getField(condition), 1), field = _a[0];
4749
+ var path = field.split('.');
4750
+ var head = path.shift();
4751
+ var caseField = caseFields.find(function (cf) { return cf.id === head; });
4752
+ while (path.length > 0) {
4753
+ head = path.shift();
4754
+ if (caseField) {
4755
+ // Jump out if this is HIDDEN or READONLY, regardless of whether or not it's
4756
+ // complex or a collection - nested fields will "inherit" the display_context.
4757
+ if (['HIDDEN', 'READONLY'].indexOf(caseField.display_context) > -1) {
4758
+ break;
4759
+ }
4760
+ // Consider what type of field this is.
4761
+ var ft = caseField.field_type;
4762
+ switch (ft.type) {
4763
+ case 'Collection':
4764
+ if (ft.collection_field_type.type === 'Complex' && ft.collection_field_type.complex_fields) {
4765
+ caseField = ft.collection_field_type.complex_fields.find(function (cf) { return cf.id === head; });
4766
+ }
4767
+ break;
4768
+ case 'Complex':
4769
+ if (ft.complex_fields) {
4770
+ caseField = ft.complex_fields.find(function (cf) { return cf.id === head; });
4771
+ }
4772
+ break;
4773
+ }
4774
+ }
4775
+ }
4776
+ if (caseField) {
4777
+ allUnchangeable = allUnchangeable && ['HIDDEN', 'READONLY'].indexOf(caseField.display_context) > -1;
4778
+ }
4779
+ };
4780
+ try {
4781
+ for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
4782
+ var condition = conditions_1_1.value;
4783
+ _loop_1(condition);
4784
+ }
4785
+ }
4786
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4787
+ finally {
4788
+ try {
4789
+ if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
4790
+ }
4791
+ finally { if (e_1) throw e_1.error; }
4792
+ }
4793
+ return allUnchangeable;
4794
+ }
4795
+ }
4796
+ return false;
4797
+ };
4798
+ ShowCondition.prototype.match = function (fields, path) {
4799
+ return ConditionParser.evaluate(fields, this.conditions, this.updatePathName(path));
4800
+ };
4801
+ ShowCondition.prototype.updatePathName = function (path) {
4802
+ if (path && path.split(/[_]+/g).length > 0) {
4803
+ /* tslint:disable-next-line */
4804
+ var _a = __read(path.split(/[_]+/g)), pathName_1 = _a[0], pathTail = _a.slice(1);
4805
+ var pathFinalIndex_1 = pathTail.pop();
4806
+ var pathTailString = pathTail.toString();
4807
+ pathTail = pathTail.map(function (value) {
4808
+ return Number(pathFinalIndex_1) === Number(value) ? pathName_1 : value;
4809
+ });
4810
+ return pathTailString !== pathTail.toString()
4811
+ ? pathName_1 + "_" + pathTail.join('_') + "_" + pathFinalIndex_1
4812
+ : path;
4813
+ }
4814
+ else {
4815
+ return path;
4816
+ }
4817
+ };
4818
+ ShowCondition.prototype.matchByContextFields = function (contextFields) {
4819
+ return this.match(FieldsUtils.toValuesMap(contextFields));
4820
+ };
4821
+ /**
4822
+ * Determine whether this is affected by fields that have a display_context
4823
+ * of HIDDEN or READONLY, which means they aren't able to be changed by the
4824
+ * user's actions.
4825
+ *
4826
+ * @param caseFields Inspected to see appropriate display_contexts.
4827
+ */
4828
+ ShowCondition.prototype.hiddenCannotChange = function (caseFields) {
4829
+ return ShowCondition.hiddenCannotChange(this, caseFields);
4722
4830
  };
4723
4831
  return ShowCondition;
4724
4832
  }());
4725
- ShowCondition.AND_CONDITION_REGEXP = new RegExp('\\sAND\\s(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)', 'g');
4726
- ShowCondition.OR_CONDITION_REGEXP = new RegExp('\\sOR\\s(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)', 'g');
4727
4833
  ShowCondition.CONDITION_NOT_EQUALS = '!=';
4728
4834
  ShowCondition.CONDITION_EQUALS = '=';
4729
4835
  ShowCondition.CONTAINS = 'CONTAINS';
4730
4836
  ShowCondition.instanceCache = new Map();
4837
+ ShowCondition.validJoinComparators = ['AND', 'OR'];
4838
+ ShowCondition.processedList = [];
4731
4839
 
4732
4840
  var Constants = /** @class */ (function () {
4733
4841
  function Constants() {
@@ -6906,13 +7014,14 @@
6906
7014
  return rxjs.of(null);
6907
7015
  };
6908
7016
  /**
6909
- * Retrieves the HMCTS service details for a jurisdiction or service, including service code. (For example, the "SSCS"
6910
- * service has a corresponding service code of "BBA3".)
7017
+ * Retrieves the HMCTS service details for a jurisdiction or service, including service codes. More than one
7018
+ * service code may be present. For example, the Divorce jurisdiction/service has corresponding service codes of
7019
+ * "ABA1" and "ABA2".
6911
7020
  *
6912
7021
  * @param serviceNames The service name(s) to look up, comma-separated if more than one
6913
7022
  * @returns An `Observable` of an array of service details
6914
7023
  */
6915
- CaseFlagRefdataService.prototype.getHmctsServiceDetails = function (serviceNames) {
7024
+ CaseFlagRefdataService.prototype.getHmctsServiceDetailsByServiceName = function (serviceNames) {
6916
7025
  var url = this.appConfig.getLocationRefApiUrl();
6917
7026
  if (url) {
6918
7027
  url += '/orgServices';
@@ -6923,6 +7032,26 @@
6923
7032
  }
6924
7033
  return rxjs.of(null);
6925
7034
  };
7035
+ /**
7036
+ * Retrieves the HMCTS service details for a case type, including service code. For example, the
7037
+ * "FinancialRemedyContested" case type is associated with the Divorce jurisdiction/service and service code "ABA2".
7038
+ *
7039
+ * Note that a case type might not be associated with any service codes of a jurisdiction or service.
7040
+ *
7041
+ * @param caseTypeId The case type ID to look up
7042
+ * @returns An `Observable` of an array of service details
7043
+ */
7044
+ CaseFlagRefdataService.prototype.getHmctsServiceDetailsByCaseType = function (caseTypeId) {
7045
+ var url = this.appConfig.getLocationRefApiUrl();
7046
+ if (url) {
7047
+ url += '/orgServices';
7048
+ if (caseTypeId) {
7049
+ url += "?ccdCaseType=" + caseTypeId;
7050
+ }
7051
+ return this.http.get(url, { observe: 'body' });
7052
+ }
7053
+ return rxjs.of(null);
7054
+ };
6926
7055
  return CaseFlagRefdataService;
6927
7056
  }());
6928
7057
  CaseFlagRefdataService.ɵfac = function CaseFlagRefdataService_Factory(t) { return new (t || CaseFlagRefdataService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig)); };
@@ -12283,7 +12412,7 @@
12283
12412
  if (rf & 2) {
12284
12413
  var ctx_r8 = i0__namespace.ɵɵnextContext(2);
12285
12414
  i0__namespace.ɵɵadvance(1);
12286
- i0__namespace.ɵɵproperty("formGroup", ctx_r8.caseFlagParentFormGroup)("jurisdiction", ctx_r8.jurisdiction);
12415
+ i0__namespace.ɵɵproperty("formGroup", ctx_r8.caseFlagParentFormGroup)("jurisdiction", ctx_r8.jurisdiction)("caseTypeId", ctx_r8.caseTypeId);
12287
12416
  }
12288
12417
  }
12289
12418
  function WriteCaseFlagFieldComponent_div_1_ng_container_6_Template(rf, ctx) {
@@ -12325,7 +12454,7 @@
12325
12454
  i0__namespace.ɵɵtext(3);
12326
12455
  i0__namespace.ɵɵelementEnd();
12327
12456
  i0__namespace.ɵɵtemplate(4, WriteCaseFlagFieldComponent_div_1_ng_container_4_Template, 2, 2, "ng-container", 11);
12328
- i0__namespace.ɵɵtemplate(5, WriteCaseFlagFieldComponent_div_1_ng_container_5_Template, 2, 2, "ng-container", 11);
12457
+ i0__namespace.ɵɵtemplate(5, WriteCaseFlagFieldComponent_div_1_ng_container_5_Template, 2, 3, "ng-container", 11);
12329
12458
  i0__namespace.ɵɵtemplate(6, WriteCaseFlagFieldComponent_div_1_ng_container_6_Template, 2, 3, "ng-container", 11);
12330
12459
  i0__namespace.ɵɵtemplate(7, WriteCaseFlagFieldComponent_div_1_ng_container_7_Template, 2, 2, "ng-container", 11);
12331
12460
  i0__namespace.ɵɵelementEnd();
@@ -12438,11 +12567,14 @@
12438
12567
  }
12439
12568
  }), true);
12440
12569
  this.createFlagCaption = exports.CaseFlagText.CAPTION;
12441
- // Get the jurisdiction from the CaseView object in the snapshot data (required for retrieving the available flag
12570
+ // Get the case type ID from the CaseView object in the snapshot data (required for retrieving the available flag
12442
12571
  // types for a case)
12443
- if (this.route.snapshot.data.case && this.route.snapshot.data.case.case_type &&
12444
- this.route.snapshot.data.case.case_type.jurisdiction) {
12445
- this.jurisdiction = this.route.snapshot.data.case.case_type.jurisdiction.id;
12572
+ if (this.route.snapshot.data.case && this.route.snapshot.data.case.case_type) {
12573
+ this.caseTypeId = this.route.snapshot.data.case.case_type.id;
12574
+ // Get the jurisdiction (required for retrieving the available flag types if unable to determine using case type ID)
12575
+ if (this.route.snapshot.data.case.case_type.jurisdiction) {
12576
+ this.jurisdiction = this.route.snapshot.data.case.case_type.jurisdiction.id;
12577
+ }
12446
12578
  }
12447
12579
  // Extract all flags-related data from the CaseEventTrigger object in the snapshot data
12448
12580
  if (this.route.snapshot.data.eventTrigger && this.route.snapshot.data.eventTrigger.case_fields) {
@@ -12696,7 +12828,7 @@
12696
12828
  return WriteCaseFlagFieldComponent;
12697
12829
  }(AbstractFieldWriteComponent));
12698
12830
  WriteCaseFlagFieldComponent.ɵfac = function WriteCaseFlagFieldComponent_Factory(t) { return new (t || WriteCaseFlagFieldComponent)(i0__namespace.ɵɵdirectiveInject(i1__namespace$1.ActivatedRoute), i0__namespace.ɵɵdirectiveInject(CaseEditDataService)); };
12699
- WriteCaseFlagFieldComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: WriteCaseFlagFieldComponent, selectors: [["ccd-write-case-flag-field"]], features: [i0__namespace.ɵɵInheritDefinitionFeature], decls: 3, vars: 3, consts: [["class", "govuk-error-summary", "aria-labelledby", "error-summary-title", "role", "alert", "tabindex", "-1", "data-module", "govuk-error-summary", 4, "ngIf"], ["class", "form-group", 3, "formGroup", 4, "ngIf"], ["aria-labelledby", "error-summary-title", "role", "alert", "tabindex", "-1", "data-module", "govuk-error-summary", 1, "govuk-error-summary"], ["id", "error-summary-title", 1, "govuk-error-summary__title"], ["class", "govuk-error-summary__body", 4, "ngFor", "ngForOf"], [1, "govuk-error-summary__body"], [1, "govuk-list", "govuk-error-summary__list"], [1, "validation-error", 3, "click"], [1, "form-group", 3, "formGroup"], [1, "govuk-form-group", 3, "ngSwitch"], ["id", "create-flag-caption", 1, "govuk-caption-l", 3, "ngClass"], [4, "ngSwitchCase"], [3, "formGroup", "flagsData", "caseFlagStateEmitter"], [3, "formGroup", "jurisdiction", "caseFlagStateEmitter", "flagCommentsOptionalEmitter"], [3, "formGroup", "languages", "flagCode", "caseFlagStateEmitter"], [3, "formGroup", "optional", "caseFlagStateEmitter"], [3, "formGroup", "flagsData", "caseTitle", "caseFlagStateEmitter"], [3, "formGroup", "selectedFlag", "caseFlagStateEmitter"]], template: function WriteCaseFlagFieldComponent_Template(rf, ctx) {
12831
+ WriteCaseFlagFieldComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: WriteCaseFlagFieldComponent, selectors: [["ccd-write-case-flag-field"]], features: [i0__namespace.ɵɵInheritDefinitionFeature], decls: 3, vars: 3, consts: [["class", "govuk-error-summary", "aria-labelledby", "error-summary-title", "role", "alert", "tabindex", "-1", "data-module", "govuk-error-summary", 4, "ngIf"], ["class", "form-group", 3, "formGroup", 4, "ngIf"], ["aria-labelledby", "error-summary-title", "role", "alert", "tabindex", "-1", "data-module", "govuk-error-summary", 1, "govuk-error-summary"], ["id", "error-summary-title", 1, "govuk-error-summary__title"], ["class", "govuk-error-summary__body", 4, "ngFor", "ngForOf"], [1, "govuk-error-summary__body"], [1, "govuk-list", "govuk-error-summary__list"], [1, "validation-error", 3, "click"], [1, "form-group", 3, "formGroup"], [1, "govuk-form-group", 3, "ngSwitch"], ["id", "create-flag-caption", 1, "govuk-caption-l", 3, "ngClass"], [4, "ngSwitchCase"], [3, "formGroup", "flagsData", "caseFlagStateEmitter"], [3, "formGroup", "jurisdiction", "caseTypeId", "caseFlagStateEmitter", "flagCommentsOptionalEmitter"], [3, "formGroup", "languages", "flagCode", "caseFlagStateEmitter"], [3, "formGroup", "optional", "caseFlagStateEmitter"], [3, "formGroup", "flagsData", "caseTitle", "caseFlagStateEmitter"], [3, "formGroup", "selectedFlag", "caseFlagStateEmitter"]], template: function WriteCaseFlagFieldComponent_Template(rf, ctx) {
12700
12832
  if (rf & 1) {
12701
12833
  i0__namespace.ɵɵtemplate(0, WriteCaseFlagFieldComponent_div_0_Template, 4, 1, "div", 0);
12702
12834
  i0__namespace.ɵɵtemplate(1, WriteCaseFlagFieldComponent_div_1_Template, 8, 10, "div", 1);
@@ -18072,7 +18204,7 @@
18072
18204
  i0__namespace.ɵɵadvance(2);
18073
18205
  i0__namespace.ɵɵproperty("ngForOf", ctx.currentCategories);
18074
18206
  }
18075
- }, directives: [i1__namespace.NgForOf, i1__namespace.NgTemplateOutlet], styles: [":host{position:relative;display:block}.folders{margin-bottom:20px}.folder{display:none;border-top:1px solid #ccc;margin:0 0 -1px}.folder:last-child{border-bottom:1px solid #ccc}.folders>.folder,input:checked~.folder{display:block}.iconImg{position:relative;display:inline-block;height:28px}.folder>.folder{margin-left:20px}.folder label:before{top:3px}.folder label:after{top:13px}p{font-weight:700}button{margin-right:20px}.close{float:right;width:30px;height:30px;background:url(/assets/img/x.PNG) no-repeat 50%}.cancel,.close{cursor:pointer}.cdk-overlay-pane{overflow:auto}.cdk-overlay-pane::-webkit-scrollbar{width:7px}.cdk-overlay-pane::-webkit-scrollbar-thumb{border:4px solid transparent;background-clip:padding-box;border-radius:9999px;background-color:#aaa}.cdk-overlay-pane::-webkit-scrollbar-button{display:none}.cdk-overlay-pane::-webkit-scrollbar-track-piece{background:#eee}.cdk-overlay-pane::-webkit-scrollbar-thumb{background:#ccc}"], encapsulation: 2 });
18207
+ }, directives: [i1__namespace.NgForOf, i1__namespace.NgTemplateOutlet], styles: [":host{position:relative;display:block}.folders{margin-bottom:20px}.folder{display:none;border-top:1px solid #ccc;margin:0 0 -1px}.folder,.folder:last-child{border-bottom:1px solid #ccc}.folders>.folder,input:checked~.folder{display:block}.iconImg{position:relative;display:inline-block;height:28px}.folder>.folder{margin-left:20px}.folder label:before{top:3px}.folder label:after{top:13px}p{font-weight:700}button{margin-right:20px}.close{float:right;width:30px;height:30px;background:url(/assets/img/x.PNG) no-repeat 50%}.cancel,.close{cursor:pointer}.cdk-overlay-pane{overflow:auto}.cdk-overlay-pane::-webkit-scrollbar{width:7px}.cdk-overlay-pane::-webkit-scrollbar-thumb{border:4px solid transparent;background-clip:padding-box;border-radius:9999px;background-color:#aaa}.cdk-overlay-pane::-webkit-scrollbar-button{display:none}.cdk-overlay-pane::-webkit-scrollbar-track-piece{background:#eee}.cdk-overlay-pane::-webkit-scrollbar-thumb{background:#ccc}"], encapsulation: 2 });
18076
18208
  (function () {
18077
18209
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CaseFileViewFolderSelectorComponent, [{
18078
18210
  type: i0.Component,
@@ -19084,22 +19216,18 @@
19084
19216
  && this.formGroup['caseField'].id === this.caseLevelCaseFlagsFieldId
19085
19217
  ? exports.RefdataCaseFlagType.CASE
19086
19218
  : exports.RefdataCaseFlagType.PARTY;
19087
- // HMCTS service code for a given jurisdiction is required to retrieve the relevant list of flag types
19088
- this.flagRefdata$ = this.caseFlagRefdataService.getHmctsServiceDetails(this.jurisdiction)
19219
+ // HMCTS service code is required to retrieve the relevant list of flag types; attempt to obtain it by case type ID first
19220
+ this.flagRefdata$ = this.caseFlagRefdataService.getHmctsServiceDetailsByCaseType(this.caseTypeId)
19089
19221
  .pipe(
19222
+ // If an error occurs retrieving HMCTS service details by case type ID, try by service name instead
19223
+ operators.catchError(function (_) { return _this.caseFlagRefdataService.getHmctsServiceDetailsByServiceName(_this.jurisdiction); }),
19090
19224
  // Use switchMap to return an inner Observable of the flag types data, having received the service details
19091
19225
  // including service_code. This avoids having nested `subscribe`s, which is an anti-pattern!
19092
- operators.switchMap(function (serviceDetails) {
19093
- return _this.caseFlagRefdataService.getCaseFlagsRefdata(serviceDetails[0].service_code, flagType);
19094
- }))
19226
+ operators.switchMap(function (serviceDetails) { return _this.caseFlagRefdataService.getCaseFlagsRefdata(serviceDetails[0].service_code, flagType); }))
19095
19227
  .subscribe({
19096
- next: function (flagTypes) {
19097
- // First (and only) object in the returned array should be the top-level "Party" flag type
19098
- _this.flagTypes = flagTypes[0].childFlags;
19099
- },
19100
- error: function (error) {
19101
- _this.onRefdataError(error);
19102
- }
19228
+ // First (and only) object in the returned array should be the top-level "Party" flag type
19229
+ next: function (flagTypes) { return _this.flagTypes = flagTypes[0].childFlags; },
19230
+ error: function (error) { return _this.onRefdataError(error); }
19103
19231
  });
19104
19232
  };
19105
19233
  SelectFlagTypeComponent.prototype.ngOnDestroy = function () {
@@ -19172,7 +19300,7 @@
19172
19300
  return SelectFlagTypeComponent;
19173
19301
  }());
19174
19302
  SelectFlagTypeComponent.ɵfac = function SelectFlagTypeComponent_Factory(t) { return new (t || SelectFlagTypeComponent)(i0__namespace.ɵɵdirectiveInject(CaseFlagRefdataService)); };
19175
- SelectFlagTypeComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: SelectFlagTypeComponent, selectors: [["ccd-select-flag-type"]], inputs: { formGroup: "formGroup", jurisdiction: "jurisdiction" }, outputs: { caseFlagStateEmitter: "caseFlagStateEmitter", flagCommentsOptionalEmitter: "flagCommentsOptionalEmitter" }, decls: 11, vars: 9, consts: [[1, "form-group", 3, "formGroup"], [1, "govuk-form-group", 3, "ngClass"], ["aria-describedby", "flag-type-heading", 1, "govuk-fieldset"], [1, "govuk-fieldset__legend", "govuk-fieldset__legend--l"], ["id", "flag-type-heading", 1, "govuk-fieldset__heading"], ["id", "flag-type-not-selected-error-message", "class", "govuk-error-message", 4, "ngIf"], ["data-module", "govuk-radios", "id", "conditional-radios-list", 1, "govuk-radios", "govuk-radios--conditional"], ["class", "govuk-radios__item", 4, "ngFor", "ngForOf"], ["class", "govuk-radios__conditional", "id", "conditional-flagType", 4, "ngIf"], ["class", "govuk-button-group", 4, "ngIf"], ["id", "flag-type-not-selected-error-message", 1, "govuk-error-message"], [1, "govuk-visually-hidden"], [1, "govuk-radios__item"], ["type", "radio", 1, "govuk-radios__input", 3, "id", "name", "value", "formControlName", "change"], [1, "govuk-label", "govuk-radios__label", 3, "for"], ["id", "conditional-flagType", 1, "govuk-radios__conditional"], ["for", "other-flag-type-description", 1, "govuk-label"], ["id", "flag-type-error-message", "class", "govuk-error-message", 4, "ngIf"], ["id", "other-flag-type-description", "type", "text", 1, "govuk-input", "govuk-!-width-one-half", 3, "ngClass", "name", "formControlName"], ["id", "flag-type-error-message", 1, "govuk-error-message"], [1, "govuk-button-group"], ["type", "button", 1, "button", "button-primary", 3, "click"]], template: function SelectFlagTypeComponent_Template(rf, ctx) {
19303
+ SelectFlagTypeComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: SelectFlagTypeComponent, selectors: [["ccd-select-flag-type"]], inputs: { formGroup: "formGroup", jurisdiction: "jurisdiction", caseTypeId: "caseTypeId" }, outputs: { caseFlagStateEmitter: "caseFlagStateEmitter", flagCommentsOptionalEmitter: "flagCommentsOptionalEmitter" }, decls: 11, vars: 9, consts: [[1, "form-group", 3, "formGroup"], [1, "govuk-form-group", 3, "ngClass"], ["aria-describedby", "flag-type-heading", 1, "govuk-fieldset"], [1, "govuk-fieldset__legend", "govuk-fieldset__legend--l"], ["id", "flag-type-heading", 1, "govuk-fieldset__heading"], ["id", "flag-type-not-selected-error-message", "class", "govuk-error-message", 4, "ngIf"], ["data-module", "govuk-radios", "id", "conditional-radios-list", 1, "govuk-radios", "govuk-radios--conditional"], ["class", "govuk-radios__item", 4, "ngFor", "ngForOf"], ["class", "govuk-radios__conditional", "id", "conditional-flagType", 4, "ngIf"], ["class", "govuk-button-group", 4, "ngIf"], ["id", "flag-type-not-selected-error-message", 1, "govuk-error-message"], [1, "govuk-visually-hidden"], [1, "govuk-radios__item"], ["type", "radio", 1, "govuk-radios__input", 3, "id", "name", "value", "formControlName", "change"], [1, "govuk-label", "govuk-radios__label", 3, "for"], ["id", "conditional-flagType", 1, "govuk-radios__conditional"], ["for", "other-flag-type-description", 1, "govuk-label"], ["id", "flag-type-error-message", "class", "govuk-error-message", 4, "ngIf"], ["id", "other-flag-type-description", "type", "text", 1, "govuk-input", "govuk-!-width-one-half", 3, "ngClass", "name", "formControlName"], ["id", "flag-type-error-message", 1, "govuk-error-message"], [1, "govuk-button-group"], ["type", "button", 1, "button", "button-primary", 3, "click"]], template: function SelectFlagTypeComponent_Template(rf, ctx) {
19176
19304
  if (rf & 1) {
19177
19305
  i0__namespace.ɵɵelementStart(0, "div", 0);
19178
19306
  i0__namespace.ɵɵelementStart(1, "div", 1);
@@ -19220,6 +19348,8 @@
19220
19348
  type: i0.Input
19221
19349
  }], jurisdiction: [{
19222
19350
  type: i0.Input
19351
+ }], caseTypeId: [{
19352
+ type: i0.Input
19223
19353
  }], caseFlagStateEmitter: [{
19224
19354
  type: i0.Output
19225
19355
  }], flagCommentsOptionalEmitter: [{
@@ -21494,7 +21624,10 @@
21494
21624
  }
21495
21625
  }, inputs: { dateControl: "dateControl" }, features: [i0__namespace.ɵɵProvidersFeature([
21496
21626
  { provide: i4.NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS },
21497
- { provide: i4.NgxMatDateAdapter, useClass: momentAdapter.NgxMatMomentAdapter },
21627
+ { provide: i4.NgxMatDateAdapter,
21628
+ useClass: momentAdapter.NgxMatMomentAdapter,
21629
+ deps: [i6.MAT_DATE_LOCALE, momentAdapter.NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS]
21630
+ },
21498
21631
  { provide: momentAdapter.NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }
21499
21632
  ]), i0__namespace.ɵɵInheritDefinitionFeature], decls: 14, vars: 26, consts: [[1, "govuk-form-group", "bottom-30", 3, "id", "ngClass"], ["class", "form-label", 4, "ngIf"], ["class", "form-hint", 4, "ngIf"], ["class", "error-message", 4, "ngIf"], [1, "datepicker-container"], ["ng-model-options", "{timezone:'utc'}", 1, "govuk-input", 3, "min", "max", "formControl", "ngxMatDatetimePicker", "focusin", "focusout", "dateChange"], ["input", ""], ["matSuffix", "", "id", "pickerOpener", 3, "for"], [3, "color", "touchUi", "hideTime", "startView", "stepHour", "stepSecond", "stepMinute", "showSeconds", "showSpinners", "disableMinute", "enableMeridian", "yearSelected", "monthSelected", "opened"], ["picker", ""], [1, "form-label"], [1, "form-hint"], [1, "error-message"]], template: function DatetimePickerComponent_Template(rf, ctx) {
21500
21633
  if (rf & 1) {
@@ -21551,7 +21684,10 @@
21551
21684
  encapsulation: i0.ViewEncapsulation.None,
21552
21685
  providers: [
21553
21686
  { provide: i4.NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS },
21554
- { provide: i4.NgxMatDateAdapter, useClass: momentAdapter.NgxMatMomentAdapter },
21687
+ { provide: i4.NgxMatDateAdapter,
21688
+ useClass: momentAdapter.NgxMatMomentAdapter,
21689
+ deps: [i6.MAT_DATE_LOCALE, momentAdapter.NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS]
21690
+ },
21555
21691
  { provide: momentAdapter.NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }
21556
21692
  ]
21557
21693
  }]
@@ -27618,6 +27754,7 @@
27618
27754
  _this.activitySubscription = _this.postViewActivity().subscribe();
27619
27755
  });
27620
27756
  }
27757
+ this.checkRouteAndSetCaseViewTab();
27621
27758
  // Check for active Case Flags
27622
27759
  this.activeCaseFlags = this.hasActiveCaseFlags();
27623
27760
  };
@@ -27647,6 +27784,20 @@
27647
27784
  subscription.unsubscribe();
27648
27785
  }
27649
27786
  };
27787
+ CaseFullAccessViewComponent.prototype.checkRouteAndSetCaseViewTab = function () {
27788
+ var _this = this;
27789
+ this.router.events.subscribe(function (val) {
27790
+ var url = val && val.url;
27791
+ if (url) {
27792
+ var tabUrl = url ? url.split('#') : null;
27793
+ var tab_1 = tabUrl && tabUrl.length > 1 ? tabUrl[tabUrl.length - 1].replaceAll('%20', ' ') : '';
27794
+ var matTab = _this.tabGroup._tabs.find(function (x) { return x.textLabel.toLowerCase() === tab_1.toLowerCase(); });
27795
+ if (matTab && matTab.position) {
27796
+ _this.tabGroup.selectedIndex = matTab.position;
27797
+ }
27798
+ }
27799
+ });
27800
+ };
27650
27801
  CaseFullAccessViewComponent.prototype.postViewActivity = function () {
27651
27802
  return this.activityPollingService.postViewActivity(this.caseDetails.case_id);
27652
27803
  };
@@ -31404,12 +31555,12 @@
31404
31555
  i0__namespace.ɵɵproperty("checked", ctx_r6.allOnPageSelected())("disabled", !ctx_r6.canAnyBeShared());
31405
31556
  }
31406
31557
  }
31407
- function SearchResultComponent_table_0_th_10_div_6_Template(rf, ctx) {
31558
+ function SearchResultComponent_table_0_th_10_div_4_Template(rf, ctx) {
31408
31559
  if (rf & 1) {
31409
31560
  var _r19_1 = i0__namespace.ɵɵgetCurrentView();
31410
31561
  i0__namespace.ɵɵelementStart(0, "div", 27);
31411
31562
  i0__namespace.ɵɵelementStart(1, "a", 28);
31412
- i0__namespace.ɵɵlistener("click", function SearchResultComponent_table_0_th_10_div_6_Template_a_click_1_listener() { i0__namespace.ɵɵrestoreView(_r19_1); var col_r15 = i0__namespace.ɵɵnextContext().$implicit; var ctx_r17 = i0__namespace.ɵɵnextContext(2); return ctx_r17.sort(col_r15); });
31563
+ i0__namespace.ɵɵlistener("click", function SearchResultComponent_table_0_th_10_div_4_Template_a_click_1_listener() { i0__namespace.ɵɵrestoreView(_r19_1); var col_r15 = i0__namespace.ɵɵnextContext().$implicit; var ctx_r17 = i0__namespace.ɵɵnextContext(2); return ctx_r17.sort(col_r15); });
31413
31564
  i0__namespace.ɵɵelementEnd();
31414
31565
  i0__namespace.ɵɵelementEnd();
31415
31566
  }
@@ -31424,16 +31575,12 @@
31424
31575
  if (rf & 1) {
31425
31576
  var _r22_1 = i0__namespace.ɵɵgetCurrentView();
31426
31577
  i0__namespace.ɵɵelementStart(0, "th");
31427
- i0__namespace.ɵɵelementStart(1, "table", 24);
31428
- i0__namespace.ɵɵelementStart(2, "tr");
31429
- i0__namespace.ɵɵelementStart(3, "th");
31430
- i0__namespace.ɵɵelementStart(4, "div", 25);
31431
- i0__namespace.ɵɵlistener("click", function SearchResultComponent_table_0_th_10_Template_div_click_4_listener() { i0__namespace.ɵɵrestoreView(_r22_1); var col_r15 = ctx.$implicit; var ctx_r21 = i0__namespace.ɵɵnextContext(2); return ctx_r21.sort(col_r15); });
31432
- i0__namespace.ɵɵtext(5);
31433
- i0__namespace.ɵɵelementEnd();
31434
- i0__namespace.ɵɵtemplate(6, SearchResultComponent_table_0_th_10_div_6_Template, 2, 1, "div", 26);
31435
- i0__namespace.ɵɵelementEnd();
31578
+ i0__namespace.ɵɵelementStart(1, "div", 24);
31579
+ i0__namespace.ɵɵelementStart(2, "div", 25);
31580
+ i0__namespace.ɵɵlistener("click", function SearchResultComponent_table_0_th_10_Template_div_click_2_listener() { i0__namespace.ɵɵrestoreView(_r22_1); var col_r15 = ctx.$implicit; var ctx_r21 = i0__namespace.ɵɵnextContext(2); return ctx_r21.sort(col_r15); });
31581
+ i0__namespace.ɵɵtext(3);
31436
31582
  i0__namespace.ɵɵelementEnd();
31583
+ i0__namespace.ɵɵtemplate(4, SearchResultComponent_table_0_th_10_div_4_Template, 2, 1, "div", 26);
31437
31584
  i0__namespace.ɵɵelementEnd();
31438
31585
  i0__namespace.ɵɵelementEnd();
31439
31586
  }
@@ -31442,7 +31589,7 @@
31442
31589
  var ctx_r7 = i0__namespace.ɵɵnextContext(2);
31443
31590
  i0__namespace.ɵɵadvance(1);
31444
31591
  i0__namespace.ɵɵattribute("aria-label", "Sort by " + col_r15.label + " " + ctx_r7.isSortAscending(col_r15) ? "ascending" : "descending");
31445
- i0__namespace.ɵɵadvance(4);
31592
+ i0__namespace.ɵɵadvance(2);
31446
31593
  i0__namespace.ɵɵtextInterpolate(col_r15.label);
31447
31594
  i0__namespace.ɵɵadvance(1);
31448
31595
  i0__namespace.ɵɵproperty("ngIf", ctx_r7.comparator(col_r15));
@@ -31778,7 +31925,7 @@
31778
31925
  i0__namespace.ɵɵelementStart(7, "thead");
31779
31926
  i0__namespace.ɵɵelementStart(8, "tr", 7);
31780
31927
  i0__namespace.ɵɵtemplate(9, SearchResultComponent_table_0_th_9_Template, 4, 2, "th", 8);
31781
- i0__namespace.ɵɵtemplate(10, SearchResultComponent_table_0_th_10_Template, 7, 3, "th", 9);
31928
+ i0__namespace.ɵɵtemplate(10, SearchResultComponent_table_0_th_10_Template, 5, 3, "th", 9);
31782
31929
  i0__namespace.ɵɵtemplate(11, SearchResultComponent_table_0_th_11_Template, 1, 0, "th", 10);
31783
31930
  i0__namespace.ɵɵelementEnd();
31784
31931
  i0__namespace.ɵɵelementEnd();