@icure/form 3.0.39 → 3.0.42

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 (114) hide show
  1. package/.yarn/cache/{@babel-runtime-npm-7.26.10-d01a90d446-22d2e0abb8.zip → @babel-runtime-npm-7.28.4-31bc1b0001-934b0a0460.zip} +0 -0
  2. package/.yarn/cache/{@icure-motss-app-datepicker-npm-6.0.0-rc.39-d00d21c35a-eefaed31a8.zip → @icure-motss-app-datepicker-npm-6.0.0-rc.40-ca1da7abbb-9bbe2bed34.zip} +0 -0
  3. package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.4.0-e5ef5fbeba-e267c25576.zip +0 -0
  4. package/.yarn/cache/{@lit-reactive-element-npm-2.1.0-77512b732b-fb36e9f64b.zip → @lit-reactive-element-npm-2.1.1-3875228c32-b9bbc9c089.zip} +0 -0
  5. package/.yarn/cache/{@lit-task-npm-1.0.2-01d3dd32e9-22e1265a62.zip → @lit-task-npm-1.0.3-48f265b3e9-790b6a2603.zip} +0 -0
  6. package/.yarn/cache/{lit-element-npm-4.1.1-bb20932b82-74d0f2d6fb.zip → lit-element-npm-4.2.1-b5bc114ced-5925326176.zip} +0 -0
  7. package/.yarn/cache/{lit-html-npm-3.2.1-1662fc597d-1bacd9f8b2.zip → lit-html-npm-3.3.1-e3722d4f4a-de07c66945.zip} +0 -0
  8. package/.yarn/cache/{lit-npm-3.2.1-27cb5b7782-ee22bbc53d.zip → lit-npm-3.3.1-8f683c51f1-fb88f1ff80.zip} +0 -0
  9. package/.yarn/cache/{prosemirror-commands-npm-1.7.0-212f35173c-a39225d534.zip → prosemirror-commands-npm-1.7.1-5b2afb6640-2316c40ea2.zip} +0 -0
  10. package/.yarn/cache/prosemirror-history-npm-1.5.0-e639d02880-6afb0e1d17.zip +0 -0
  11. package/.yarn/cache/prosemirror-keymap-npm-1.2.3-0e7e0c8195-0a2eed2771.zip +0 -0
  12. package/.yarn/cache/prosemirror-model-npm-1.25.4-e7ee2df3df-ab5aa609df.zip +0 -0
  13. package/.yarn/cache/prosemirror-state-npm-1.4.4-8b7e3a396c-1b5dba46c2.zip +0 -0
  14. package/.yarn/cache/prosemirror-transform-npm-1.10.5-5b3b4f5f61-6f5921e53a.zip +0 -0
  15. package/.yarn/cache/prosemirror-view-npm-1.41.4-cf361fd330-b663b8c6ce.zip +0 -0
  16. package/.yarn/install-state.gz +0 -0
  17. package/components/common/field.d.ts +0 -1
  18. package/components/common/field.js +0 -5
  19. package/components/common/field.js.map +1 -1
  20. package/components/common/metadata-buttons-bar.d.ts +1 -1
  21. package/components/common/metadata-buttons-bar.js +2 -6
  22. package/components/common/metadata-buttons-bar.js.map +1 -1
  23. package/components/icure-button/index.js +0 -4
  24. package/components/icure-button/index.js.map +1 -1
  25. package/components/icure-button-group/index.js +0 -4
  26. package/components/icure-button-group/index.js.map +1 -1
  27. package/components/icure-date-picker/index.d.ts +1 -1
  28. package/components/icure-date-picker/index.js +2 -6
  29. package/components/icure-date-picker/index.js.map +1 -1
  30. package/components/icure-dropdown-field/index.js +0 -4
  31. package/components/icure-dropdown-field/index.js.map +1 -1
  32. package/components/icure-form/fields/button-group/checkbox.d.ts +0 -1
  33. package/components/icure-form/fields/button-group/checkbox.js +2 -39
  34. package/components/icure-form/fields/button-group/checkbox.js.map +1 -1
  35. package/components/icure-form/fields/button-group/radio-button.d.ts +0 -1
  36. package/components/icure-form/fields/button-group/radio-button.js +2 -39
  37. package/components/icure-form/fields/button-group/radio-button.js.map +1 -1
  38. package/components/icure-form/fields/date-picker/date-picker.d.ts +0 -1
  39. package/components/icure-form/fields/date-picker/date-picker.js +17 -54
  40. package/components/icure-form/fields/date-picker/date-picker.js.map +1 -1
  41. package/components/icure-form/fields/date-picker/date-time-picker.d.ts +0 -1
  42. package/components/icure-form/fields/date-picker/date-time-picker.js +17 -54
  43. package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -1
  44. package/components/icure-form/fields/date-picker/time-picker.d.ts +0 -1
  45. package/components/icure-form/fields/date-picker/time-picker.js +17 -54
  46. package/components/icure-form/fields/date-picker/time-picker.js.map +1 -1
  47. package/components/icure-form/fields/dropdown/dropdown-field.d.ts +0 -1
  48. package/components/icure-form/fields/dropdown/dropdown-field.js +2 -39
  49. package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -1
  50. package/components/icure-form/fields/items-list-field/items-list-field.d.ts +0 -1
  51. package/components/icure-form/fields/items-list-field/items-list-field.js +17 -55
  52. package/components/icure-form/fields/items-list-field/items-list-field.js.map +1 -1
  53. package/components/icure-form/fields/measure-field/measure-field.d.ts +0 -1
  54. package/components/icure-form/fields/measure-field/measure-field.js +2 -39
  55. package/components/icure-form/fields/measure-field/measure-field.js.map +1 -1
  56. package/components/icure-form/fields/number-field/number-field.d.ts +0 -1
  57. package/components/icure-form/fields/number-field/number-field.js +18 -55
  58. package/components/icure-form/fields/number-field/number-field.js.map +1 -1
  59. package/components/icure-form/fields/text-field/text-field.d.ts +0 -1
  60. package/components/icure-form/fields/text-field/text-field.js +28 -65
  61. package/components/icure-form/fields/text-field/text-field.js.map +1 -1
  62. package/components/icure-form/fields/token-field/token-field.d.ts +0 -1
  63. package/components/icure-form/fields/token-field/token-field.js +17 -55
  64. package/components/icure-form/fields/token-field/token-field.js.map +1 -1
  65. package/components/icure-form/fields/utils/index.d.ts +0 -1
  66. package/components/icure-form/fields/utils/index.js +0 -2
  67. package/components/icure-form/fields/utils/index.js.map +1 -1
  68. package/components/icure-form/index.d.ts +1 -1
  69. package/components/icure-form/index.js +5 -26
  70. package/components/icure-form/index.js.map +1 -1
  71. package/components/icure-form/renderer/form/form-selection-button.js +0 -4
  72. package/components/icure-form/renderer/form/form-selection-button.js.map +1 -1
  73. package/components/icure-form/renderer/form/form.d.ts +2 -7
  74. package/components/icure-form/renderer/form/form.js +454 -618
  75. package/components/icure-form/renderer/form/form.js.map +1 -1
  76. package/components/icure-form/renderer/index.d.ts +1 -1
  77. package/components/icure-form/renderer/index.js.map +1 -1
  78. package/components/icure-label/index.js +0 -4
  79. package/components/icure-label/index.js.map +1 -1
  80. package/components/icure-text-field/index.js +11 -10
  81. package/components/icure-text-field/index.js.map +1 -1
  82. package/components/model/index.d.ts +1 -15
  83. package/components/model/index.js +2 -13
  84. package/components/model/index.js.map +1 -1
  85. package/generic/model.d.ts +6 -6
  86. package/generic/model.js.map +1 -1
  87. package/icure/form-values-container.d.ts +42 -63
  88. package/icure/form-values-container.js +151 -192
  89. package/icure/form-values-container.js.map +1 -1
  90. package/icure/icure-utils.js +12 -30
  91. package/icure/icure-utils.js.map +1 -1
  92. package/icure/model.d.ts +2 -9
  93. package/icure/model.js +1 -7
  94. package/icure/model.js.map +1 -1
  95. package/package.json +1 -2
  96. package/utils/code-utils.d.ts +2 -3
  97. package/utils/code-utils.js +6 -5
  98. package/utils/code-utils.js.map +1 -1
  99. package/.yarn/cache/@icure-cardinal-sdk-npm-1.3.0-ts-2-d77151b3e6-86e1497829.zip +0 -0
  100. package/.yarn/cache/@js-joda-core-npm-3.2.0-d2526290e9-64625c2f22.zip +0 -0
  101. package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.3.0-6bfa115c08-c2003e8bb6.zip +0 -0
  102. package/.yarn/cache/@lit-reactive-element-npm-2.0.4-4836436301-368d788d9e.zip +0 -0
  103. package/.yarn/cache/format-util-npm-1.0.5-a524ca953a-0c8622e54a.zip +0 -0
  104. package/.yarn/cache/prosemirror-history-npm-1.4.1-ad68c86bb7-90f9bf59bc.zip +0 -0
  105. package/.yarn/cache/prosemirror-keymap-npm-1.2.2-efb8276b00-85fe4fc303.zip +0 -0
  106. package/.yarn/cache/prosemirror-model-npm-1.25.0-0870b04e23-e311e1e36c.zip +0 -0
  107. package/.yarn/cache/prosemirror-state-npm-1.4.3-d6540e44ad-28857d935c.zip +0 -0
  108. package/.yarn/cache/prosemirror-transform-npm-1.10.3-fb23bef7a8-8cbe29501e.zip +0 -0
  109. package/.yarn/cache/prosemirror-view-npm-1.38.1-8cfb4ec84f-12f7f4d27f.zip +0 -0
  110. package/.yarn/cache/regenerator-runtime-npm-0.14.1-a6c97c609a-9f57c93277.zip +0 -0
  111. package/.yarn/cache/ws-npm-8.18.0-56f68bc4d6-91d4d35bc9.zip +0 -0
  112. package/utils/form-value-container.d.ts +0 -3
  113. package/utils/form-value-container.js +0 -30
  114. package/utils/form-value-container.js.map +0 -1
@@ -7,18 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { CodeStub, DecryptedContact, DecryptedService, DecryptedSubContact } from '@icure/cardinal-sdk';
10
+ import { CodeStub, DecryptedContact, DecryptedService, DecryptedSubContact, ServiceLink } from '@icure/cardinal-sdk';
11
11
  import { sortedBy } from '../utils/no-lodash';
12
- import { CodeStubWithId } from './model';
13
12
  import { areCodesEqual, codeStubToCode, contentToPrimitiveType, isContentEqual, primitiveTypeToContent } from './icure-utils';
14
13
  import { parsePrimitive } from '../utils/primitive';
15
14
  import { anyDateToDate, dateToFuzzyDate } from '../utils/dates';
15
+ import { v4 as uuidv4 } from 'uuid';
16
16
  import { normalizeCodes } from '../utils/code-utils';
17
- let bfvcIdGen = 0;
18
- let cfvcIdGen = 0;
19
- function notify(l, fvc, modifiedFields = [], context = undefined, id = undefined, recurse = false) {
20
- console.log(`${id !== null && id !== void 0 ? id : 'cc'}: Notifying listener with context [>>> ${fvc['_id']}] -> ${context} <- ${modifiedFields.length ? `and modified fields ${modifiedFields.map((f) => f.label).join(', ')}` : ''}`);
21
- l(fvc, modifiedFields, recurse);
17
+ function notify(l, fvc) {
18
+ l(fvc);
22
19
  }
23
20
  /** This class is a bridge between the ICure API and the generic FormValuesContainer interface.
24
21
  * It wraps around a ContactFormValuesContainer and provides a series of services:
@@ -43,21 +40,6 @@ export class BridgedFormValuesContainer {
43
40
  toString() {
44
41
  return `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`;
45
42
  }
46
- options() {
47
- return {
48
- responsible: this.responsible,
49
- contactFormValuesContainer: this.contactFormValuesContainer,
50
- interpreter: this.interpreter,
51
- contact: this.contact,
52
- initialValuesProvider: this.initialValuesProvider,
53
- dependentValuesProvider: this.dependentValuesProvider,
54
- validatorsProvider: this.validatorsProvider,
55
- language: this.language,
56
- changeListeners: this.changeListeners,
57
- interpreterContext: this.interpreterContext,
58
- currentComputations: this.currentComputations,
59
- };
60
- }
61
43
  /**
62
44
  * Creates an instance of BridgedFormValuesContainer.
63
45
  * @param responsible The id of the data owner responsible for the creation of the values
@@ -70,83 +52,36 @@ export class BridgedFormValuesContainer {
70
52
  * @param language The language in which the values are displayed
71
53
  * @param changeListeners The listeners that will be notified when the values change
72
54
  * @param interpreterContext A map with keys that are the names of the variables and values that are the functions that return the values of the variables
73
- * @param currentComputations A list of ongoing computations that should be observed and not recomputed when the form is created.
74
- * @param modifiedFields A list of fields that have been modified and should be considered when computing the initial values
75
- * @param stackLevel The stack level at which the BridgedFormValuesContainer is created, used to limit recursion induced by default values computations
76
- * @param context A string that describes the context in which the BridgedFormValuesContainer is created, used for debugging purposes
77
55
  */
78
- constructor({ responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider, dependentValuesProvider, validatorsProvider, language, changeListeners, interpreterContext, currentComputations, modifiedFields, stackLevel = 0, context, }) {
79
- this._id = `B-${(bfvcIdGen++).toString()}`;
80
- this.initialValuesProvider = () => [];
81
- this.dependentValuesProvider = () => [];
82
- this.validatorsProvider = () => [];
83
- this.language = 'en';
84
- this.changeListeners = [];
85
- this.interpreterContext = {};
86
- this.currentComputations = {};
87
- console.log(`${this._id}: Creating BridgedFormValuesContainer because ${context !== null && context !== void 0 ? context : 'no context provided'}`);
88
- //Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values
89
- this.contactFormValuesContainer = contactFormValuesContainer;
56
+ constructor(responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider = () => [], dependentValuesProvider = () => [], validatorsProvider = () => [], language = 'en', changeListeners = [], interpreterContext = {}) {
90
57
  this.responsible = responsible;
91
58
  this.interpreter = interpreter;
92
- this.initialValuesProvider = initialValuesProvider !== null && initialValuesProvider !== void 0 ? initialValuesProvider : (() => []);
93
- this.dependentValuesProvider = dependentValuesProvider !== null && dependentValuesProvider !== void 0 ? dependentValuesProvider : (() => []);
94
- this.validatorsProvider = validatorsProvider !== null && validatorsProvider !== void 0 ? validatorsProvider : (() => []);
95
- this.language = language !== null && language !== void 0 ? language : 'en';
96
- this.changeListeners = changeListeners !== null && changeListeners !== void 0 ? changeListeners : [];
97
- this.interpreterContext = interpreterContext !== null && interpreterContext !== void 0 ? interpreterContext : {};
98
- this.contact = contact !== null && contact !== void 0 ? contact : contactFormValuesContainer.currentContact;
99
- const isFormValueContainerObsolete = { current: false };
100
- this.mutateAndNotify = (newContactFormValuesContainer_1, modifiedFields_1, ...args_1) => __awaiter(this, [newContactFormValuesContainer_1, modifiedFields_1, ...args_1], void 0, function* (newContactFormValuesContainer, modifiedFields, recurse = false) {
59
+ this.initialValuesProvider = initialValuesProvider;
60
+ this.dependentValuesProvider = dependentValuesProvider;
61
+ this.validatorsProvider = validatorsProvider;
62
+ this.language = language;
63
+ this.changeListeners = changeListeners;
64
+ this.interpreterContext = interpreterContext;
65
+ this._id = uuidv4();
66
+ console.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`);
67
+ //Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values
68
+ this.contactFormValuesContainer = contactFormValuesContainer;
69
+ this.mutateAndNotify = (newContactFormValuesContainer) => __awaiter(this, void 0, void 0, function* () {
101
70
  newContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify);
102
- const modifiedLabels = modifiedFields.map((f) => f.label);
103
- const newBridgedFormValueContainer = new BridgedFormValuesContainer(Object.assign(Object.assign({}, this.options()), { contactFormValuesContainer: newContactFormValuesContainer, contact: this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, currentComputations: Object.entries(this.currentComputations).reduce((acc, [label, { metadata, revisionsFilter, computation, status }]) => {
104
- return modifiedLabels.includes(label)
105
- ? Object.assign(Object.assign({}, acc), { [label]: { metadata, revisionsFilter, computation, status: 'resolved' } }) : Object.assign(Object.assign({}, acc), { [label]: { metadata, revisionsFilter, computation, status } });
106
- }, {}), modifiedFields: modifiedFields, context: 'ContactFormValuesContainer change', stackLevel: recurse ? stackLevel + 1 : stackLevel }));
107
- isFormValueContainerObsolete.current = true;
108
- this.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer, modifiedFields, 'ContactFormValuesContainer change', this._id));
71
+ const newBridgedFormValueContainer = yield new BridgedFormValuesContainer(this.responsible, newContactFormValuesContainer, this.interpreter, this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, this.changeListeners, this.interpreterContext).init();
72
+ this.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer));
109
73
  return newBridgedFormValueContainer;
110
74
  });
111
75
  this.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify);
112
- this.currentComputations =
113
- (modifiedFields && !modifiedFields.length) || stackLevel > 1000
114
- ? currentComputations !== null && currentComputations !== void 0 ? currentComputations : {}
115
- : this.computeDependentValues(this.computeInitialValues(Object.fromEntries(Object.entries(currentComputations !== null && currentComputations !== void 0 ? currentComputations : {}).filter(([, c]) => c.status === 'pending')), modifiedFields), modifiedFields);
116
- //console.log(`bFVC with uuid ${this.uuid} has the following initial computations`, Object.keys(this.currentComputations).join(', '))
117
- Object.entries(this.currentComputations).forEach(([label, { metadata, revisionsFilter, computation: computationPromise, status }]) => {
118
- computationPromise
119
- .then((computationResult) => {
120
- var _a;
121
- if (isFormValueContainerObsolete.current) {
122
- return;
123
- }
124
- //console.log(`Computed value for ${label} in ${this.uuid} with computation`, computation)
125
- const newValue = this.convertRawValue(computationResult);
126
- const currentValue = this.getValues(revisionsFilter);
127
- if (newValue !== undefined || currentValue != undefined) {
128
- const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
129
- if (newValue && !newValue.content[lng] && newValue.content['*']) {
130
- newValue.content[lng] = newValue.content['*'];
131
- }
132
- if (newValue) {
133
- delete newValue.content['*'];
134
- }
135
- console.log(`${this._id}: setValue for ${label}`);
136
- if (this.setValue(label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata, undefined, true)) {
137
- console.log(`${this._id}: Obsolete because of update`);
138
- }
139
- else {
140
- if (status === 'pending' && !isFormValueContainerObsolete.current) {
141
- isFormValueContainerObsolete.current = true;
142
- console.log(`${this._id}: Obsolete because of prune`);
143
- const newBridgedFormValueContainer = new BridgedFormValuesContainer(Object.assign(Object.assign({}, this.options()), { currentComputations: Object.entries(this.currentComputations).reduce((acc, [cLabel, c]) => (cLabel !== label ? Object.assign(Object.assign({}, acc), { [cLabel]: c }) : Object.assign(Object.assign({}, acc), { [cLabel]: Object.assign(Object.assign({}, c), { status: 'resolved' }) })), {}), modifiedFields: [], context: 'Prune computed value' }));
144
- this.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer, [], 'Prune computed value', this._id));
145
- }
146
- }
147
- }
148
- })
149
- .catch(console.error); // Ignore errors in computations, they will be logged in the console
76
+ this.contact = contact !== null && contact !== void 0 ? contact : contactFormValuesContainer.currentContact;
77
+ }
78
+ init() {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ if (this.contactFormValuesContainer.mustBeInitialised()) {
81
+ yield this.computeInitialValues();
82
+ }
83
+ yield this.computeDependentValues();
84
+ return this;
150
85
  });
151
86
  }
152
87
  getLabel() {
@@ -164,6 +99,13 @@ export class BridgedFormValuesContainer {
164
99
  unregisterChangeListener(listener) {
165
100
  this.changeListeners = this.changeListeners.filter((l) => l !== listener);
166
101
  }
102
+ getDefaultValue(label) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ var _a;
105
+ const formula = (_a = this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).find(({ metadata }) => metadata.label === label)) === null || _a === void 0 ? void 0 : _a.formula;
106
+ return formula ? this.convertRawValue(yield this.compute(formula)) : undefined;
107
+ });
108
+ }
167
109
  getValues(revisionsFilter) {
168
110
  return Object.entries(this.contactFormValuesContainer.getValues((id, history) => revisionsFilter(id, history
169
111
  .filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)
@@ -247,46 +189,92 @@ export class BridgedFormValuesContainer {
247
189
  }
248
190
  return undefined;
249
191
  }
250
- computeInitialValues(currentComputations, modifiedFields) {
251
- return this.contactFormValuesContainer.rootForm.formTemplateId
252
- ? this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId, modifiedFields).reduce((acc, { metadata, revisionsFilter, formula }) => {
253
- if (currentComputations[metadata.label] === undefined) {
254
- const currentValue = this.getValues(revisionsFilter);
255
- return !currentValue || !Object.keys(currentValue).length
256
- ? Object.assign(Object.assign({}, acc), { [metadata.label]: { metadata, revisionsFilter, computation: this.compute(formula), status: 'pending' } }) : acc;
257
- }
258
- else {
259
- return acc;
260
- }
261
- }, currentComputations)
262
- : currentComputations;
192
+ //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
193
+ computeInitialValues() {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ if (this.contactFormValuesContainer.rootForm.formTemplateId) {
196
+ yield Promise.all(this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).map((_a) => __awaiter(this, [_a], void 0, function* ({ metadata, revisionsFilter, formula }) {
197
+ var _b;
198
+ try {
199
+ const currentValue = this.getValues(revisionsFilter);
200
+ if (!currentValue || !Object.keys(currentValue).length) {
201
+ const newValue = this.convertRawValue((yield this.compute(formula)));
202
+ if (newValue !== undefined) {
203
+ const lng = (_b = this.language) !== null && _b !== void 0 ? _b : 'en';
204
+ if (newValue && !newValue.content[lng] && newValue.content['*']) {
205
+ newValue.content[lng] = newValue.content['*'];
206
+ }
207
+ if (newValue) {
208
+ delete newValue.content['*'];
209
+ }
210
+ setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc) => {
211
+ const currentContact = this.contactFormValuesContainer.currentContact;
212
+ this.contactFormValuesContainer = fvc;
213
+ if (this.contact === currentContact) {
214
+ this.contact = fvc.currentContact;
215
+ }
216
+ });
217
+ }
218
+ }
219
+ }
220
+ catch (e) {
221
+ console.log(`Error while computing formula : ${formula}`, e);
222
+ }
223
+ })));
224
+ }
225
+ });
263
226
  }
264
- computeDependentValues(currentComputations, modifiedFields) {
265
- return this.contactFormValuesContainer.rootForm.formTemplateId
266
- ? this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId, modifiedFields).reduce((acc, { metadata, revisionsFilter, formula }) => {
267
- return currentComputations[metadata.label] === undefined
268
- ? Object.assign(Object.assign({}, acc), { [metadata.label]: { metadata, revisionsFilter, computation: this.compute(formula), status: 'pending' } }) : acc;
269
- }, currentComputations)
270
- : currentComputations;
227
+ //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
228
+ computeDependentValues() {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ if (this.contactFormValuesContainer.rootForm.formTemplateId) {
231
+ yield Promise.all(this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).map((_a) => __awaiter(this, [_a], void 0, function* ({ metadata, revisionsFilter, formula }) {
232
+ var _b;
233
+ try {
234
+ const currentValue = this.getValues(revisionsFilter);
235
+ const newValue = this.convertRawValue((yield this.compute(formula)));
236
+ if (newValue !== undefined || currentValue != undefined) {
237
+ const lng = (_b = this.language) !== null && _b !== void 0 ? _b : 'en';
238
+ if (newValue && !newValue.content[lng] && newValue.content['*']) {
239
+ newValue.content[lng] = newValue.content['*'];
240
+ }
241
+ if (newValue) {
242
+ delete newValue.content['*'];
243
+ }
244
+ const interceptor = (fvc) => {
245
+ const currentContact = this.contactFormValuesContainer.currentContact;
246
+ this.contactFormValuesContainer = fvc;
247
+ if (this.contact === currentContact) {
248
+ this.contact = fvc.currentContact;
249
+ }
250
+ };
251
+ setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata, interceptor);
252
+ }
253
+ }
254
+ catch (e) {
255
+ console.log(`Error while computing formula : ${formula}`, e);
256
+ }
257
+ })));
258
+ }
259
+ });
271
260
  }
272
- setValue(label, language, fv, id, metadata, _, recurse = false) {
273
- console.log(`${this._id}: setValue on ${this.contactFormValuesContainer._id}`);
274
- return setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata, recurse);
261
+ setValue(label, language, fv, id, metadata) {
262
+ setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata);
275
263
  }
276
264
  setMetadata(meta, id) {
277
265
  var _a;
278
- return this.contactFormValuesContainer.setMetadata({
266
+ this.contactFormValuesContainer.setMetadata({
279
267
  label: meta.label,
280
268
  responsible: meta.owner,
281
269
  valueDate: meta.valueDate,
282
- tags: (_a = meta.tags) === null || _a === void 0 ? void 0 : _a.map((x) => new CodeStubWithId(x)),
270
+ tags: (_a = meta.tags) === null || _a === void 0 ? void 0 : _a.map((x) => new CodeStub(x)),
283
271
  }, id);
284
272
  }
285
273
  delete(serviceId) {
286
274
  this.contactFormValuesContainer.delete(serviceId);
287
275
  }
288
276
  getVersionedValuesForKey(key) {
289
- return this.getValues((_id, history) => { var _a, _b, _c; return (((_b = (_a = history === null || history === void 0 ? void 0 : history[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.label) && key === history[0].value.label ? [(_c = history === null || history === void 0 ? void 0 : history[0]) === null || _c === void 0 ? void 0 : _c.revision] : []); });
277
+ return this.getValues((id, history) => { var _a, _b, _c; return (((_b = (_a = history === null || history === void 0 ? void 0 : history[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.label) && key === history[0].value.label ? [(_c = history === null || history === void 0 ? void 0 : history[0]) === null || _c === void 0 ? void 0 : _c.revision] : []); });
290
278
  }
291
279
  compute(formula, sandbox) {
292
280
  return __awaiter(this, void 0, void 0, function* () {
@@ -311,7 +299,6 @@ export class BridgedFormValuesContainer {
311
299
  .join(', ');
312
300
  };
313
301
  const log = console.log;
314
- // noinspection JSUnusedGlobalSymbols
315
302
  const native = {
316
303
  parseInt: parseInt,
317
304
  parseFloat: parseFloat,
@@ -350,8 +337,8 @@ export class BridgedFormValuesContainer {
350
337
  Promise,
351
338
  };
352
339
  const proxy = new Proxy({}, {
353
- has: (_target, key) => { var _a; return !!native[key] || key === 'self' || !!this.interpreterContext[key] || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
354
- get: (_target, key) => {
340
+ has: (target, key) => { var _a; return !!native[key] || key === 'self' || !!this.interpreterContext[key] || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
341
+ get: (target, key) => {
355
342
  if (key === 'undefined') {
356
343
  return undefined;
357
344
  }
@@ -365,24 +352,9 @@ export class BridgedFormValuesContainer {
365
352
  return (_a = this.interpreter) === null || _a === void 0 ? void 0 : _a.call(this, formula, sandbox !== null && sandbox !== void 0 ? sandbox : proxy);
366
353
  });
367
354
  }
368
- isFieldBeingComputed(label) {
369
- var _a;
370
- return ((_a = this.currentComputations[label]) === null || _a === void 0 ? void 0 : _a.status) === 'pending';
371
- }
372
355
  getChildren() {
373
356
  return __awaiter(this, void 0, void 0, function* () {
374
- const children = yield Promise.all((yield this.contactFormValuesContainer.getChildren()).map((fvc) => new BridgedFormValuesContainer({
375
- responsible: this.responsible,
376
- contactFormValuesContainer: fvc,
377
- interpreter: this.interpreter,
378
- contact: this.contact,
379
- initialValuesProvider: this.initialValuesProvider,
380
- dependentValuesProvider: this.dependentValuesProvider,
381
- validatorsProvider: this.validatorsProvider,
382
- language: this.language,
383
- interpreterContext: this.interpreterContext,
384
- context: 'New child form',
385
- })));
357
+ const children = yield Promise.all((yield this.contactFormValuesContainer.getChildren()).map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, [], this.interpreterContext).init()));
386
358
  console.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider);
387
359
  return children;
388
360
  });
@@ -400,7 +372,7 @@ export class BridgedFormValuesContainer {
400
372
  }
401
373
  }
402
374
  catch (e) {
403
- console.warn(`Error while computing validation : ${validation}`, e);
375
+ console.log(`Error while computing validation : ${validation}`, e);
404
376
  }
405
377
  return res;
406
378
  }), resPromise);
@@ -438,6 +410,9 @@ export class ContactFormValuesContainer {
438
410
  toString() {
439
411
  return `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`;
440
412
  }
413
+ mustBeInitialised() {
414
+ return !this._initialised;
415
+ }
441
416
  /**
442
417
  * Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children
443
418
  */
@@ -457,9 +432,10 @@ export class ContactFormValuesContainer {
457
432
  allForms() {
458
433
  return [this.rootForm].concat(this.children.flatMap((c) => c.allForms()));
459
434
  }
460
- constructor(rootForm, currentContact, contactsHistory, serviceFactory, children, formFactory, formRecycler, changeListeners = []) {
461
- //console.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`)
462
- this._id = `C-${(cfvcIdGen++).toString()}`;
435
+ constructor(rootForm, currentContact, contactsHistory, serviceFactory, children, formFactory, formRecycler, changeListeners = [], initialised = true) {
436
+ this._id = uuidv4();
437
+ this._initialised = false;
438
+ console.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`);
463
439
  if (contactsHistory.includes(currentContact)) {
464
440
  throw new Error('Illegal argument, the history must not contain the currentContact');
465
441
  }
@@ -471,9 +447,10 @@ export class ContactFormValuesContainer {
471
447
  this.formFactory = formFactory;
472
448
  this.formRecycler = formRecycler;
473
449
  this.changeListeners = changeListeners;
450
+ this._initialised = initialised;
474
451
  this.indexedServices = [this.currentContact].concat(this.contactsHistory).reduce((acc, ctc) => {
475
452
  var _a, _b, _c;
476
- return ((_c = (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter((s) => { var _a; return (_a = ctc.subContacts) === null || _a === void 0 ? void 0 : _a.some((sc) => { var _a; return sc.formId === this.rootForm.id && ((_a = sc.services) === null || _a === void 0 ? void 0 : _a.some((sss) => sss.serviceId === s.id)); }); })) === null || _b === void 0 ? void 0 : _b.reduce((acc, s) => {
453
+ const services = (_c = (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter((s) => { var _a; return (_a = ctc.subContacts) === null || _a === void 0 ? void 0 : _a.some((sc) => { var _a; return sc.formId === this.rootForm.id && ((_a = sc.services) === null || _a === void 0 ? void 0 : _a.some((sss) => sss.serviceId === s.id)); }); })) === null || _b === void 0 ? void 0 : _b.reduce((acc, s) => {
477
454
  var _a, _b;
478
455
  return s.id
479
456
  ? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({
@@ -481,7 +458,8 @@ export class ContactFormValuesContainer {
481
458
  modified: ctc.created,
482
459
  value: s,
483
460
  }) }) : acc;
484
- }, acc)) !== null && _c !== void 0 ? _c : acc);
461
+ }, acc)) !== null && _c !== void 0 ? _c : acc;
462
+ return services;
485
463
  }, {});
486
464
  this.synchronise();
487
465
  }
@@ -499,7 +477,7 @@ export class ContactFormValuesContainer {
499
477
  const newContactFormValuesContainer = new ContactFormValuesContainer(this.rootForm, this.currentContact, this.contactsHistory, this.serviceFactory, this.children.map((c) => {
500
478
  return c.rootForm.id === childFormValueContainer.rootForm.id ? newValue : c;
501
479
  }), this.formFactory, this.formRecycler);
502
- this.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer, [], `Child ${childFormValueContainer.rootForm.formTemplateId} changed`, this._id));
480
+ this.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer));
503
481
  },
504
482
  ];
505
483
  }
@@ -509,7 +487,7 @@ export class ContactFormValuesContainer {
509
487
  ? yield Promise.all((yield formChildrenProvider(rootForm.id)).map((f) => __awaiter(this, void 0, void 0, function* () {
510
488
  // eslint-disable-next-line max-len
511
489
  return yield ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory, formRecycler); })))
512
- : [], formFactory, formRecycler, changeListeners);
490
+ : [], formFactory, formRecycler, changeListeners, false);
513
491
  contactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC));
514
492
  return contactFormValuesContainer;
515
493
  });
@@ -538,6 +516,9 @@ export class ContactFormValuesContainer {
538
516
  throw new Error('Validation not supported at contact level');
539
517
  });
540
518
  }
519
+ getDefaultValue() {
520
+ return Promise.resolve(undefined);
521
+ }
541
522
  getValues(revisionsFilter) {
542
523
  return Object.entries(this.getServicesInHistory(revisionsFilter)).reduce((acc, [id, history]) => history.length
543
524
  ? Object.assign(Object.assign({}, acc), { [id]: [...history].sort((a, b) => ((b === null || b === void 0 ? void 0 : b.modified) || +new Date()) - ((a === null || a === void 0 ? void 0 : a.modified) || +new Date())) }) : acc, {});
@@ -560,7 +541,7 @@ export class ContactFormValuesContainer {
560
541
  label: (_c = s.label) !== null && _c !== void 0 ? _c : s.id,
561
542
  responsible: s.responsible,
562
543
  valueDate: s.valueDate,
563
- tags: normalizeCodes(s.tags),
544
+ tags: s.tags,
564
545
  },
565
546
  }) }) : acc;
566
547
  }, acc)) !== null && _b !== void 0 ? _b : acc;
@@ -581,24 +562,20 @@ export class ContactFormValuesContainer {
581
562
  meta.valueDate && (newService.valueDate = meta.valueDate);
582
563
  meta.codes && (newService.codes = normalizeCodes(meta.codes));
583
564
  meta.tags && (newService.tags = normalizeCodes(meta.tags));
584
- const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => (s.id === service.id ? newService : s)) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
585
- this.changeListeners.forEach((l) => notify(l, newFormValuesContainer, [meta], `Metadata change for service ${service.id}`, this._id));
586
- return true;
587
- }
588
- else {
589
- return false;
565
+ const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, new DecryptedContact(Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => (s.id === service.id ? newService : s)) })), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
566
+ this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
590
567
  }
591
568
  }
592
- setValue(label, language, value, id, metadata, changeListenersOverrider, recurse = false) {
569
+ setValue(label, language, value, id, metadata, changeListenersOverrider) {
593
570
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
594
571
  const service = (id && ((_b = (_a = this.getServicesInHistory((sid, history) => (sid === id ? history.map((x) => x.revision) : []))[id]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value)) || this.serviceFactory(label, id);
595
572
  if (!service.id) {
596
573
  throw new Error('Service id must be defined');
597
574
  }
575
+ console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata);
598
576
  const newContent = (_c = value === null || value === void 0 ? void 0 : value.content) === null || _c === void 0 ? void 0 : _c[language];
599
577
  const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? normalizeCodes(value.codes) : [];
600
578
  if (!isContentEqual((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !areCodesEqual(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
601
- //console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata)
602
579
  const newService = new DecryptedService(Object.assign(Object.assign({}, service), { modified: Date.now() }));
603
580
  const newContents = newContent
604
581
  ? Object.assign(Object.assign({}, (service.content || {})), { [language]: newContent }) : Object.assign({}, (service.content || {}));
@@ -607,11 +584,11 @@ export class ContactFormValuesContainer {
607
584
  }
608
585
  let newCurrentContact;
609
586
  if (!Object.entries(newContents).filter(([, cnt]) => cnt !== undefined).length) {
610
- newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_f = this.currentContact.subContacts) !== null && _f !== void 0 ? _f : []).some((sc) => sc.formId === this.rootForm.id)
587
+ newCurrentContact = new DecryptedContact(Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_f = this.currentContact.subContacts) !== null && _f !== void 0 ? _f : []).some((sc) => sc.formId === this.rootForm.id)
611
588
  ? ((_g = this.currentContact.subContacts) !== null && _g !== void 0 ? _g : []).map((sc) => {
612
589
  var _a;
613
590
  if (sc.formId === this.rootForm.id) {
614
- return Object.assign(Object.assign({}, sc), { services: ((_a = sc.services) !== null && _a !== void 0 ? _a : []).filter((s) => s.serviceId !== service.id).concat([{ serviceId: service.id }]) });
591
+ return new DecryptedSubContact(Object.assign(Object.assign({}, sc), { services: ((_a = sc.services) !== null && _a !== void 0 ? _a : []).filter((s) => s.serviceId !== service.id).concat([new ServiceLink({ serviceId: service.id })]) }));
615
592
  }
616
593
  else {
617
594
  return sc;
@@ -619,10 +596,10 @@ export class ContactFormValuesContainer {
619
596
  })
620
597
  : ((_h = this.currentContact.subContacts) !== null && _h !== void 0 ? _h : []).concat(new DecryptedSubContact({
621
598
  formId: this.rootForm.id,
622
- services: [{ serviceId: service.id }],
599
+ services: [new ServiceLink({ serviceId: service.id })],
623
600
  })), services: ((_j = this.currentContact.services) !== null && _j !== void 0 ? _j : []).some((s) => s.id === service.id)
624
601
  ? ((_k = this.currentContact.services) !== null && _k !== void 0 ? _k : []).filter((s) => s.id !== service.id)
625
- : [...((_l = this.currentContact.services) !== null && _l !== void 0 ? _l : [])] });
602
+ : [...((_l = this.currentContact.services) !== null && _l !== void 0 ? _l : [])] }));
626
603
  }
627
604
  else {
628
605
  newService.content = newContents;
@@ -633,11 +610,11 @@ export class ContactFormValuesContainer {
633
610
  newService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags;
634
611
  newService.label = (_p = metadata.label) !== null && _p !== void 0 ? _p : newService.label;
635
612
  }
636
- newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_q = this.currentContact.subContacts) !== null && _q !== void 0 ? _q : []).some((sc) => sc.formId === this.rootForm.id)
613
+ newCurrentContact = new DecryptedContact(Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_q = this.currentContact.subContacts) !== null && _q !== void 0 ? _q : []).some((sc) => sc.formId === this.rootForm.id)
637
614
  ? ((_r = this.currentContact.subContacts) !== null && _r !== void 0 ? _r : []).map((sc) => {
638
615
  var _a;
639
616
  if (sc.formId === this.rootForm.id) {
640
- return Object.assign(Object.assign({}, sc), { services: ((_a = sc.services) !== null && _a !== void 0 ? _a : []).filter((s) => s.serviceId !== service.id).concat([{ serviceId: service.id }]) });
617
+ return new DecryptedSubContact(Object.assign(Object.assign({}, sc), { services: ((_a = sc.services) !== null && _a !== void 0 ? _a : []).filter((s) => s.serviceId !== service.id).concat([new ServiceLink({ serviceId: service.id })]) }));
641
618
  }
642
619
  else {
643
620
  return sc;
@@ -645,38 +622,23 @@ export class ContactFormValuesContainer {
645
622
  })
646
623
  : ((_s = this.currentContact.subContacts) !== null && _s !== void 0 ? _s : []).concat(new DecryptedSubContact({
647
624
  formId: this.rootForm.id,
648
- services: [{ serviceId: service.id }],
625
+ services: [new ServiceLink({ serviceId: service.id })],
649
626
  })), services: ((_t = this.currentContact.services) !== null && _t !== void 0 ? _t : []).some((s) => s.id === service.id)
650
627
  ? ((_u = this.currentContact.services) !== null && _u !== void 0 ? _u : []).map((s) => (s.id === service.id ? newService : s))
651
- : [...((_v = this.currentContact.services) !== null && _v !== void 0 ? _v : []), newService] });
628
+ : [...((_v = this.currentContact.services) !== null && _v !== void 0 ? _v : []), newService] }));
652
629
  }
653
630
  const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, newCurrentContact, this.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)), this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
654
- changeListenersOverrider
655
- ? changeListenersOverrider(newFormValuesContainer)
656
- : this.changeListeners.forEach((l) => {
657
- var _a;
658
- return notify(l, newFormValuesContainer, [
659
- {
660
- valueDate: newService.valueDate,
661
- tags: normalizeCodes(newService.tags),
662
- label: (_a = newService.label) !== null && _a !== void 0 ? _a : label,
663
- },
664
- ], `Set value of service ${service.id}}`, this._id, recurse);
665
- });
666
- return true;
667
- }
668
- else {
669
- return false;
631
+ changeListenersOverrider ? changeListenersOverrider(newFormValuesContainer) : this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
670
632
  }
671
633
  }
672
634
  delete(serviceId) {
673
635
  var _a;
674
636
  const service = this.getServiceInCurrentContact(serviceId);
675
637
  if (service) {
676
- const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => s.id === serviceId
638
+ const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, new DecryptedContact(Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => s.id === serviceId
677
639
  ? new DecryptedService(Object.assign(Object.assign({}, service), { endOfLife: Date.now() }))
678
- : s) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
679
- this.changeListeners.forEach((l) => notify(l, newFormValuesContainer, [], `Delete service ${serviceId}`, this._id));
640
+ : s) })), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
641
+ this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
680
642
  }
681
643
  }
682
644
  compute() {
@@ -684,9 +646,6 @@ export class ContactFormValuesContainer {
684
646
  throw new Error('Compute not supported at contact level');
685
647
  });
686
648
  }
687
- isFieldBeingComputed() {
688
- return false;
689
- }
690
649
  /** returns all services in history that match a selector
691
650
  *
692
651
  * @private
@@ -706,7 +665,7 @@ export class ContactFormValuesContainer {
706
665
  owner: s.responsible,
707
666
  valueDate: s.valueDate,
708
667
  codes: s.codes,
709
- tags: normalizeCodes(s.tags),
668
+ tags: s.tags,
710
669
  },
711
670
  });
712
671
  }));
@@ -720,10 +679,10 @@ export class ContactFormValuesContainer {
720
679
  if (!parentId)
721
680
  return;
722
681
  const newForm = yield this.formFactory(parentId, anchorId, templateId, label);
723
- const childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory, this.formRecycler, []);
682
+ const childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory, this.formRecycler, [], false);
724
683
  const newContactFormValuesContainer = new ContactFormValuesContainer(this.rootForm, this.currentContact, this.contactsHistory, this.serviceFactory, [...this.children, childFVC], this.formFactory, this.formRecycler, this.changeListeners);
725
684
  newContactFormValuesContainer.registerChildFormValuesContainer(childFVC);
726
- this.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer, [], `Add child form ${newForm.formTemplateId} to contact form ${this.rootForm.formTemplateId}`, this._id));
685
+ this.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer));
727
686
  });
728
687
  }
729
688
  getServiceInCurrentContact(id) {
@@ -734,14 +693,14 @@ export class ContactFormValuesContainer {
734
693
  removeChild(container) {
735
694
  return __awaiter(this, void 0, void 0, function* () {
736
695
  const newContactFormValuesContainer = new ContactFormValuesContainer(this.rootForm, this.currentContact, this.contactsHistory, this.serviceFactory, this.children.filter((c) => c.rootForm.id !== container.rootForm.id), this.formFactory, this.formRecycler, this.changeListeners);
737
- this.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer, [], `Remove child form ${container.rootForm.formTemplateId} from contact form ${this.rootForm.formTemplateId}`, this._id));
696
+ this.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer));
738
697
  });
739
698
  }
740
699
  }
741
- const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, metadata, recurse = false) => {
700
+ const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, metadata, changeListenersOverrider) => {
742
701
  var _a, _b, _c, _d;
743
702
  const value = fv === null || fv === void 0 ? void 0 : fv.content[language];
744
- return cfvc.setValue(label, language, new DecryptedService({
703
+ cfvc.setValue(label, language, new DecryptedService({
745
704
  id: id,
746
705
  codes: (_b = (_a = fv === null || fv === void 0 ? void 0 : fv.codes) === null || _a === void 0 ? void 0 : _a.map((x) => new CodeStub(x))) !== null && _b !== void 0 ? _b : [],
747
706
  content: value
@@ -754,8 +713,8 @@ const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, met
754
713
  label: (_c = metadata === null || metadata === void 0 ? void 0 : metadata.label) !== null && _c !== void 0 ? _c : label,
755
714
  responsible: metadata === null || metadata === void 0 ? void 0 : metadata.owner,
756
715
  valueDate: metadata === null || metadata === void 0 ? void 0 : metadata.valueDate,
757
- tags: normalizeCodes((_d = metadata === null || metadata === void 0 ? void 0 : metadata.tags) === null || _d === void 0 ? void 0 : _d.map((x) => new CodeStub(x))),
716
+ tags: (_d = metadata === null || metadata === void 0 ? void 0 : metadata.tags) === null || _d === void 0 ? void 0 : _d.map((x) => new CodeStub(x)),
758
717
  }
759
- : undefined, undefined, recurse);
718
+ : undefined, changeListenersOverrider);
760
719
  };
761
720
  //# sourceMappingURL=form-values-container.js.map