datasync-dynamic-form 1.0.19 → 1.0.20

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.
@@ -50,11 +50,6 @@ class DsDynamicForm extends _react.Component {
50
50
  this.state = {
51
51
  form: {}
52
52
  };
53
- //this.data_blob = {data_tier:{}}
54
- //2DO debug this.data_tier = (this.props.data_blob && this.props.data_blob.data_tier)?this.props.data_blob.data_tier:{}
55
- this.data_blob = this.props.data_blob && this.props.data_blob.data_tier ? this.props.data_blob : {
56
- data_tier: {}
57
- };
58
53
  }
59
54
  componentDidMount = () => {
60
55
  //Component initialization in edit mode
@@ -94,13 +89,13 @@ class DsDynamicForm extends _react.Component {
94
89
  /** Override data with foreign keys wne props.foreign_key is available */
95
90
  if (this.props.foreign_keys) {
96
91
  clearObject2.data_tier = Object.assign(clearObject2.data_tier, this.props.foreign_keys); //Dead code to be checked !!!
97
- this.data_blob.data_tier = Object.assign(clearObject2.data_tier, this.props.foreign_keys); //Dead code to be checked !!!
92
+ this.local_data_blob.data_tier = Object.assign(clearObject2.data_tier, this.props.foreign_keys); //Dead code to be checked !!!
98
93
  }
99
94
  if (globals.parameters.debugging) {
100
95
  console.log("01:----- clearForm -----");
101
96
  console.log("01:clearForm::this.props.form->", this.props.form);
102
97
  console.log("01:clearForm::clearObject2 mixed with data_tier ->", clearObject2);
103
- console.log("01:clearForm::internal this.data_blob ->", this.data_blob);
98
+ console.log("01:clearForm::internal this.data_blob ->", this.local_data_blob);
104
99
  }
105
100
  this.setState({
106
101
  fieldError: [],
@@ -116,18 +111,15 @@ class DsDynamicForm extends _react.Component {
116
111
  form: clearObject2
117
112
  });
118
113
  });
119
-
120
- //Real clear fix
121
- //this.data_blob.data_tier = Object.assign(clearObject2);
122
- this.data_blob.data_tier = {};
123
- console.log("27:this.data_blob.data_tier ->", this.data_blob.data_tier);
124
114
  };
125
115
 
126
116
  /**
127
117
  * Prototype : clearForm
128
118
  */
129
119
  clearForm = () => {
130
- console.log("27:ClearForm");
120
+ console.log("28:ClearForm");
121
+ console.log("28:this.local_data_blob.data_tier INITIAL ->", this.local_data_blob && this.local_data_blob.data_tier ? this.local_data_blob.data_tier : "this.local_data_blob.data_tier not defined");
122
+ console.log("28:this.props.data_blob.data_tier ->", this.props.data_blob && this.props.data_blob.data_tier ? this.props.data_blob.data_tier : "props data_blob not set");
131
123
  this.setState({
132
124
  fieldError: [],
133
125
  form: {},
@@ -144,22 +136,27 @@ class DsDynamicForm extends _react.Component {
144
136
  });
145
137
 
146
138
  //Real efficient fix
147
- let duplicate_data_tier = this.props.data_blob && this.props.data_blob.data_tier ? this.props.data_blob.data_tier : {};
148
- this.data_blob.data_tier = Object.assign({}, duplicate_data_tier);
149
- console.log("28:this.data_blob.data_tier ->", this.data_blob.data_tier);
150
- console.log("28:this.props.data_blob.data_tier ->", this.props.data_blob.data_tier);
139
+ let duplicate_data_tier = this.props.data_blob && this.props.data_blob.data_tier ? JSON.parse(JSON.stringify(this.props.data_blob.data_tier)) : {};
140
+
141
+ //duplicate_data_tier = Object.assign(duplicate_data_tier, (this.props.data_blob && this.props.data_blob.data_tier)?this.props.data_blob.data_tier:{})
142
+ this.local_data_blob = {
143
+ data_tier: {}
144
+ };
145
+ this.local_data_blob.data_tier = Object.assign({}, duplicate_data_tier);
146
+ console.log("28:this.local_data_blob.data_tier ->", this.local_data_blob.data_tier);
147
+ console.log("28:this.props.data_blob.data_tier ->", this.props.data_blob && this.props.data_blob.data_tier ? this.props.data_blob.data_tier : "props data_blob not set");
151
148
  };
152
149
  getFieldData = pFieldObject => {
153
150
  /** Return data value form field object */
154
- let nextFieldData = this.data_blob.data_tier[pFieldObject.name] ? this.data_blob.data_tier[pFieldObject.name] : "";
151
+ let nextFieldData = this.local_data_blob.data_tier[pFieldObject.name] ? this.local_data_blob.data_tier[pFieldObject.name] : "";
155
152
  if (globals.parameters.debugging) console.log("01:getFieldData[", pFieldObject.name, "] nextFieldData->", nextFieldData);
156
153
  return nextFieldData;
157
154
  };
158
155
  setFieldData = (pFieldObject, value) => {
159
- this.data_blob.data_tier[pFieldObject.name] = value;
156
+ this.local_data_blob.data_tier[pFieldObject.name] = value;
160
157
  if (globals.parameters.debugging) console.log("01:setFieldData[", pFieldObject.name, "] value->", value);
161
- console.log("01:setFieldData[", pFieldObject.name, "] this.data_blob.data_tier ->", this.data_blob.data_tier);
162
- console.log("01:setFieldData[", pFieldObject.name, "] this.data_blob ->", this.data_blob);
158
+ console.log("01:setFieldData[", pFieldObject.name, "] this.local_data_blob.data_tier ->", this.local_data_blob.data_tier);
159
+ console.log("01:setFieldData[", pFieldObject.name, "] this.data_blob ->", this.local_data_blob);
163
160
  };
164
161
  getSelectedFieldValues_V1 = pFieldObject => {
165
162
  return pFieldObject.selected_values ? pFieldObject.selected_values : "";
@@ -353,7 +350,7 @@ class DsDynamicForm extends _react.Component {
353
350
  let hasDataGuid = this.props.datasync_object && this.props.datasync_object.data_guid;
354
351
  (0, _datasyncCore.SaveDataTierToDatasync)(this.props.datasync_url, hasDataGuid ? this.props.datasync_object.data_guid : null,
355
352
  //data_guid
356
- this.data_blob,
353
+ this.local_data_blob,
357
354
  //p_o_data_blob,
358
355
  this.props.company_guid,
359
356
  //p_s_company_guid,
@@ -399,7 +396,7 @@ class DsDynamicForm extends _react.Component {
399
396
  if (this.props.onFormSubmit) {
400
397
  if (globals.parameters.debugging) alert("onFormSubmit => filter log with AsyncDebug:: prefixe");
401
398
  //If props function return false then cancel form submit and do not save !
402
- this.props.onFormSubmit(this.data_blob);
399
+ this.props.onFormSubmit(this.local_data_blob);
403
400
  } else {
404
401
  //Call save anyway
405
402
  this.saveFormToDatasyncProcess();
@@ -518,7 +515,7 @@ class DsDynamicForm extends _react.Component {
518
515
  };
519
516
  migrate_field = (pFieldObject, migrated_value) => {
520
517
  //Set data_tier property with former form value
521
- this.data_blob.data_tier[pFieldObject.name] = migrated_value;
518
+ this.local_data_blob.data_tier[pFieldObject.name] = migrated_value;
522
519
  if (globals.parameters.debugging) console.log("09/07:migrate_field -> pFieldObject.name=", pFieldObject.name);
523
520
  };
524
521
  data_tier_migration = (field, ii) => {
@@ -526,9 +523,9 @@ class DsDynamicForm extends _react.Component {
526
523
  return;
527
524
  //data_tier_migration disbled
528
525
  console.log("09/07:data_tier_migration ### Migration check !!!");
529
- console.log("09/07:this.data_blob.modified ->", this.data_blob && this.data_blob.modified ? this.data_blob.modified : "null");
526
+ console.log("09/07:this.data_blob.modified ->", this.local_data_blob && this.local_data_blob.modified ? this.local_data_blob.modified : "null");
530
527
  //Check if migration required
531
- if (this.data_blob && this.data_blob.modified && this.data_blob.modified < globals.parameters.form_modified_version) if (globals.parameters.debugging) console.log("09/07:field needs migration from version 1 to version 2");else {
528
+ if (this.local_data_blob && this.local_data_blob.modified && this.local_data_blob.modified < globals.parameters.form_modified_version) if (globals.parameters.debugging) console.log("09/07:field needs migration from version 1 to version 2");else {
532
529
  if (globals.parameters.debugging) console.log("09/07:Field is up to date");
533
530
  //Don't care migration process
534
531
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datasync-dynamic-form",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "Datasync Dynamic Form component",
5
5
  "main": "./dist/components/DsDynamicForm",
6
6
  "types": "./dist/components/DsDynamicForm",