@formio/js 5.1.0-dev.6000.fab85ea → 5.1.0-dev.6007.fade2e3

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.
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
190
190
  get language(): string;
191
191
  root: this;
192
192
  localRoot: this;
193
+ beforeInit(): void;
194
+ executeFormController: any;
193
195
  get emptyValue(): null;
196
+ get shouldCallFormController(): any;
194
197
  get shadowRoot(): any;
195
198
  /**
196
199
  * Add a language for translations
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
360
363
  * @returns {Promise} - The promise that is triggered when the form is built.
361
364
  */
362
365
  init(): Promise<any>;
363
- executeFormController(): false | undefined;
366
+ _executeFormController(): void;
364
367
  build(element: any): Promise<any>;
365
368
  getClassName(): string;
366
369
  render(): string;
@@ -315,12 +315,24 @@ class Webform extends NestedDataComponent_1.default {
315
315
  this.localRoot = this;
316
316
  }
317
317
  /* eslint-enable max-statements */
318
+ beforeInit() {
319
+ this.executeFormController = lodash_1.default.once(this._executeFormController);
320
+ }
318
321
  get language() {
319
322
  return this.options.language;
320
323
  }
321
324
  get emptyValue() {
322
325
  return null;
323
326
  }
327
+ get shouldCallFormController() {
328
+ // If no controller value or
329
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
330
+ return (this.form &&
331
+ this.form.controller &&
332
+ !((!this.visible || this.component.hidden) &&
333
+ this.component.clearOnHide &&
334
+ !this.rootPristine));
335
+ }
324
336
  componentContext() {
325
337
  return this._data;
326
338
  }
@@ -899,19 +911,12 @@ class Webform extends NestedDataComponent_1.default {
899
911
  this.on('resetForm', () => this.resetValue(), true);
900
912
  this.on('deleteSubmission', () => this.deleteSubmission(), true);
901
913
  this.on('refreshData', () => this.updateValue(), true);
902
- this.executeFormController();
914
+ if (this.shouldCallFormController) {
915
+ this.executeFormController();
916
+ }
903
917
  return this.formReady;
904
918
  }
905
- executeFormController() {
906
- // If no controller value or
907
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
908
- if (!this.form ||
909
- !this.form.controller ||
910
- ((!this.visible || this.component.hidden) &&
911
- this.component.clearOnHide &&
912
- !this.rootPristine)) {
913
- return false;
914
- }
919
+ _executeFormController() {
915
920
  this.formReady.then(() => {
916
921
  this.evaluate(this.form.controller, {
917
922
  components: this.components,
@@ -2,6 +2,7 @@ export default class Components {
2
2
  static _editFormUtils: {
3
3
  sortAndFilterComponents(components: any): any;
4
4
  unifyComponents(objValue: any, srcValue: any): any;
5
+ tokenVariableDescription(): string;
5
6
  logicVariablesTable(additional: any): {
6
7
  type: string;
7
8
  tag: string;
@@ -86,6 +87,7 @@ export default class Components {
86
87
  static set EditFormUtils(value: {
87
88
  sortAndFilterComponents(components: any): any;
88
89
  unifyComponents(objValue: any, srcValue: any): any;
90
+ tokenVariableDescription(): string;
89
91
  logicVariablesTable(additional: any): {
90
92
  type: string;
91
93
  tag: string;
@@ -169,6 +171,7 @@ export default class Components {
169
171
  static get EditFormUtils(): {
170
172
  sortAndFilterComponents(components: any): any;
171
173
  unifyComponents(objValue: any, srcValue: any): any;
174
+ tokenVariableDescription(): string;
172
175
  logicVariablesTable(additional: any): {
173
176
  type: string;
174
177
  tag: string;
@@ -453,6 +453,9 @@ class Component extends Element_1.default {
453
453
  // Allow anyone to hook into the component creation.
454
454
  this.hook('component');
455
455
  if (!this.options.skipInit) {
456
+ if (typeof this.beforeInit === 'function') {
457
+ this.beforeInit();
458
+ }
456
459
  this.init();
457
460
  }
458
461
  }
@@ -50,6 +50,6 @@ exports.default = [
50
50
  },
51
51
  utils_1.default.javaScriptValue('Advanced Conditions', 'customConditional', 'conditional.json', 110, '<p>You must assign the <strong>show</strong> variable a boolean result.</p>' +
52
52
  '<p><strong>Note: Advanced Conditional logic will override the results of the Simple Conditional logic.</strong></p>' +
53
- '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
53
+ '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', utils_1.default.tokenVariableDescription())
54
54
  ];
55
55
  /* eslint-enable quotes, max-len */
@@ -140,7 +140,7 @@ exports.default = [
140
140
  input: true
141
141
  },
142
142
  utils_1.default.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
143
- utils_1.default.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
143
+ utils_1.default.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', utils_1.default.tokenVariableDescription()),
144
144
  {
145
145
  type: 'checkbox',
146
146
  input: true,
@@ -2,6 +2,7 @@ export default EditFormUtils;
2
2
  declare namespace EditFormUtils {
3
3
  function sortAndFilterComponents(components: any): any;
4
4
  function unifyComponents(objValue: any, srcValue: any): any;
5
+ function tokenVariableDescription(): string;
5
6
  function logicVariablesTable(additional: any): {
6
7
  type: string;
7
8
  tag: string;
@@ -37,6 +37,9 @@ const EditFormUtils = {
37
37
  }
38
38
  return lodash_1.default.isEqual(objValue, srcValue);
39
39
  },
40
+ tokenVariableDescription() {
41
+ return '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>';
42
+ },
40
43
  logicVariablesTable(additional) {
41
44
  additional = additional || '';
42
45
  return {
@@ -69,7 +69,7 @@ exports.default = [
69
69
  input: true,
70
70
  weight: 20,
71
71
  key: 'reference',
72
- label: 'Save as reference',
73
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.'
72
+ label: 'Submit as reference',
73
+ tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
74
74
  }
75
75
  ];
@@ -641,8 +641,8 @@ exports.default = [
641
641
  input: true,
642
642
  weight: 25,
643
643
  key: 'reference',
644
- label: 'Save as reference',
645
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.',
644
+ label: 'Submit as reference',
645
+ tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
646
646
  conditional: {
647
647
  json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
648
648
  },
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
190
190
  get language(): string;
191
191
  root: this;
192
192
  localRoot: this;
193
+ beforeInit(): void;
194
+ executeFormController: any;
193
195
  get emptyValue(): null;
196
+ get shouldCallFormController(): any;
194
197
  get shadowRoot(): any;
195
198
  /**
196
199
  * Add a language for translations
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
360
363
  * @returns {Promise} - The promise that is triggered when the form is built.
361
364
  */
362
365
  init(): Promise<any>;
363
- executeFormController(): false | undefined;
366
+ _executeFormController(): void;
364
367
  build(element: any): Promise<any>;
365
368
  getClassName(): string;
366
369
  render(): string;
@@ -287,12 +287,24 @@ export default class Webform extends NestedDataComponent {
287
287
  this.localRoot = this;
288
288
  }
289
289
  /* eslint-enable max-statements */
290
+ beforeInit() {
291
+ this.executeFormController = _.once(this._executeFormController);
292
+ }
290
293
  get language() {
291
294
  return this.options.language;
292
295
  }
293
296
  get emptyValue() {
294
297
  return null;
295
298
  }
299
+ get shouldCallFormController() {
300
+ // If no controller value or
301
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
302
+ return (this.form &&
303
+ this.form.controller &&
304
+ !((!this.visible || this.component.hidden) &&
305
+ this.component.clearOnHide &&
306
+ !this.rootPristine));
307
+ }
296
308
  componentContext() {
297
309
  return this._data;
298
310
  }
@@ -902,19 +914,12 @@ export default class Webform extends NestedDataComponent {
902
914
  this.on('resetForm', () => this.resetValue(), true);
903
915
  this.on('deleteSubmission', () => this.deleteSubmission(), true);
904
916
  this.on('refreshData', () => this.updateValue(), true);
905
- this.executeFormController();
917
+ if (this.shouldCallFormController) {
918
+ this.executeFormController();
919
+ }
906
920
  return this.formReady;
907
921
  }
908
- executeFormController() {
909
- // If no controller value or
910
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
911
- if (!this.form ||
912
- !this.form.controller ||
913
- ((!this.visible || this.component.hidden) &&
914
- this.component.clearOnHide &&
915
- !this.rootPristine)) {
916
- return false;
917
- }
922
+ _executeFormController() {
918
923
  this.formReady.then(() => {
919
924
  this.evaluate(this.form.controller, {
920
925
  components: this.components,
@@ -2,6 +2,7 @@ export default class Components {
2
2
  static _editFormUtils: {
3
3
  sortAndFilterComponents(components: any): any;
4
4
  unifyComponents(objValue: any, srcValue: any): any;
5
+ tokenVariableDescription(): string;
5
6
  logicVariablesTable(additional: any): {
6
7
  type: string;
7
8
  tag: string;
@@ -86,6 +87,7 @@ export default class Components {
86
87
  static set EditFormUtils(value: {
87
88
  sortAndFilterComponents(components: any): any;
88
89
  unifyComponents(objValue: any, srcValue: any): any;
90
+ tokenVariableDescription(): string;
89
91
  logicVariablesTable(additional: any): {
90
92
  type: string;
91
93
  tag: string;
@@ -169,6 +171,7 @@ export default class Components {
169
171
  static get EditFormUtils(): {
170
172
  sortAndFilterComponents(components: any): any;
171
173
  unifyComponents(objValue: any, srcValue: any): any;
174
+ tokenVariableDescription(): string;
172
175
  logicVariablesTable(additional: any): {
173
176
  type: string;
174
177
  tag: string;
@@ -418,6 +418,9 @@ export default class Component extends Element {
418
418
  // Allow anyone to hook into the component creation.
419
419
  this.hook('component');
420
420
  if (!this.options.skipInit) {
421
+ if (typeof this.beforeInit === 'function') {
422
+ this.beforeInit();
423
+ }
421
424
  this.init();
422
425
  }
423
426
  }
@@ -45,6 +45,6 @@ export default [
45
45
  },
46
46
  EditFormUtils.javaScriptValue('Advanced Conditions', 'customConditional', 'conditional.json', 110, '<p>You must assign the <strong>show</strong> variable a boolean result.</p>' +
47
47
  '<p><strong>Note: Advanced Conditional logic will override the results of the Simple Conditional logic.</strong></p>' +
48
- '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
48
+ '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', EditFormUtils.tokenVariableDescription())
49
49
  ];
50
50
  /* eslint-enable quotes, max-len */
@@ -135,7 +135,7 @@ export default [
135
135
  input: true
136
136
  },
137
137
  EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
138
- EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
138
+ EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', EditFormUtils.tokenVariableDescription()),
139
139
  {
140
140
  type: 'checkbox',
141
141
  input: true,
@@ -2,6 +2,7 @@ export default EditFormUtils;
2
2
  declare namespace EditFormUtils {
3
3
  function sortAndFilterComponents(components: any): any;
4
4
  function unifyComponents(objValue: any, srcValue: any): any;
5
+ function tokenVariableDescription(): string;
5
6
  function logicVariablesTable(additional: any): {
6
7
  type: string;
7
8
  tag: string;
@@ -32,6 +32,9 @@ const EditFormUtils = {
32
32
  }
33
33
  return _.isEqual(objValue, srcValue);
34
34
  },
35
+ tokenVariableDescription() {
36
+ return '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>';
37
+ },
35
38
  logicVariablesTable(additional) {
36
39
  additional = additional || '';
37
40
  return {
@@ -66,7 +66,7 @@ export default [
66
66
  input: true,
67
67
  weight: 20,
68
68
  key: 'reference',
69
- label: 'Save as reference',
70
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.'
69
+ label: 'Submit as reference',
70
+ tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
71
71
  }
72
72
  ];
@@ -635,8 +635,8 @@ export default [
635
635
  input: true,
636
636
  weight: 25,
637
637
  key: 'reference',
638
- label: 'Save as reference',
639
- tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.',
638
+ label: 'Submit as reference',
639
+ tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
640
640
  conditional: {
641
641
  json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
642
642
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6000.fab85ea",
3
+ "version": "5.1.0-dev.6007.fade2e3",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {