datasync-dynamic-form 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DsDynamicForm.js +24 -26
- package/package.json +1 -1
|
@@ -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.
|
|
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.
|
|
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("
|
|
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,28 @@ 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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
+
this.local_data_blob.data_tier = Object.assign(this.props.foreign_keys ? this.props.foreign_keys : {}, duplicate_data_tier);
|
|
147
|
+
console.log("28:this.local_data_blob.data_tier ->", this.local_data_blob.data_tier);
|
|
148
|
+
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
149
|
};
|
|
152
150
|
getFieldData = pFieldObject => {
|
|
153
151
|
/** Return data value form field object */
|
|
154
|
-
let nextFieldData = this.
|
|
152
|
+
let nextFieldData = this.local_data_blob.data_tier[pFieldObject.name] ? this.local_data_blob.data_tier[pFieldObject.name] : "";
|
|
155
153
|
if (globals.parameters.debugging) console.log("01:getFieldData[", pFieldObject.name, "] nextFieldData->", nextFieldData);
|
|
156
154
|
return nextFieldData;
|
|
157
155
|
};
|
|
158
156
|
setFieldData = (pFieldObject, value) => {
|
|
159
|
-
this.
|
|
157
|
+
this.local_data_blob.data_tier[pFieldObject.name] = value;
|
|
160
158
|
if (globals.parameters.debugging) console.log("01:setFieldData[", pFieldObject.name, "] value->", value);
|
|
161
|
-
console.log("01:setFieldData[", pFieldObject.name, "] this.
|
|
162
|
-
console.log("01:setFieldData[", pFieldObject.name, "] this.data_blob ->", this.
|
|
159
|
+
console.log("01:setFieldData[", pFieldObject.name, "] this.local_data_blob.data_tier ->", this.local_data_blob.data_tier);
|
|
160
|
+
console.log("01:setFieldData[", pFieldObject.name, "] this.data_blob ->", this.local_data_blob);
|
|
163
161
|
};
|
|
164
162
|
getSelectedFieldValues_V1 = pFieldObject => {
|
|
165
163
|
return pFieldObject.selected_values ? pFieldObject.selected_values : "";
|
|
@@ -353,7 +351,7 @@ class DsDynamicForm extends _react.Component {
|
|
|
353
351
|
let hasDataGuid = this.props.datasync_object && this.props.datasync_object.data_guid;
|
|
354
352
|
(0, _datasyncCore.SaveDataTierToDatasync)(this.props.datasync_url, hasDataGuid ? this.props.datasync_object.data_guid : null,
|
|
355
353
|
//data_guid
|
|
356
|
-
this.
|
|
354
|
+
this.local_data_blob,
|
|
357
355
|
//p_o_data_blob,
|
|
358
356
|
this.props.company_guid,
|
|
359
357
|
//p_s_company_guid,
|
|
@@ -399,7 +397,7 @@ class DsDynamicForm extends _react.Component {
|
|
|
399
397
|
if (this.props.onFormSubmit) {
|
|
400
398
|
if (globals.parameters.debugging) alert("onFormSubmit => filter log with AsyncDebug:: prefixe");
|
|
401
399
|
//If props function return false then cancel form submit and do not save !
|
|
402
|
-
this.props.onFormSubmit(this.
|
|
400
|
+
this.props.onFormSubmit(this.local_data_blob);
|
|
403
401
|
} else {
|
|
404
402
|
//Call save anyway
|
|
405
403
|
this.saveFormToDatasyncProcess();
|
|
@@ -518,7 +516,7 @@ class DsDynamicForm extends _react.Component {
|
|
|
518
516
|
};
|
|
519
517
|
migrate_field = (pFieldObject, migrated_value) => {
|
|
520
518
|
//Set data_tier property with former form value
|
|
521
|
-
this.
|
|
519
|
+
this.local_data_blob.data_tier[pFieldObject.name] = migrated_value;
|
|
522
520
|
if (globals.parameters.debugging) console.log("09/07:migrate_field -> pFieldObject.name=", pFieldObject.name);
|
|
523
521
|
};
|
|
524
522
|
data_tier_migration = (field, ii) => {
|
|
@@ -526,9 +524,9 @@ class DsDynamicForm extends _react.Component {
|
|
|
526
524
|
return;
|
|
527
525
|
//data_tier_migration disbled
|
|
528
526
|
console.log("09/07:data_tier_migration ### Migration check !!!");
|
|
529
|
-
console.log("09/07:this.data_blob.modified ->", this.
|
|
527
|
+
console.log("09/07:this.data_blob.modified ->", this.local_data_blob && this.local_data_blob.modified ? this.local_data_blob.modified : "null");
|
|
530
528
|
//Check if migration required
|
|
531
|
-
if (this.
|
|
529
|
+
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
530
|
if (globals.parameters.debugging) console.log("09/07:Field is up to date");
|
|
533
531
|
//Don't care migration process
|
|
534
532
|
return;
|