datasync-dynamic-form 1.0.2 → 1.0.4
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 +15 -188
- package/package.json +11 -3
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "CGUID", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _datasyncCommonLibrary.CGUID;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.DsDynamicForm = void 0;
|
|
7
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
14
|
var _multiselectReactDropdown = _interopRequireDefault(require("multiselect-react-dropdown"));
|
|
15
|
+
var _datasyncCore = require("datasync-core");
|
|
16
|
+
var _datasyncCommonLibrary = require("datasync-common-library");
|
|
9
17
|
var _reactstrap = require("reactstrap");
|
|
10
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -15,9 +23,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
15
23
|
<Blob
|
|
16
24
|
import Blob from "components/Blob/Blob";*/}
|
|
17
25
|
|
|
18
|
-
//Defined as const import {saveDataTierToDatasync} from '../DataSync3/DataSync3.jsx'
|
|
19
|
-
//2DO disabled import "./DynamicForm3Tiers2.css"
|
|
20
|
-
|
|
21
26
|
// reactstrap components
|
|
22
27
|
|
|
23
28
|
const debugging = true;
|
|
@@ -25,189 +30,13 @@ const local = true;
|
|
|
25
30
|
const production = !local;
|
|
26
31
|
const globals = {
|
|
27
32
|
parameters: {
|
|
28
|
-
root_url: "/topics-page",
|
|
29
|
-
admin_url: "/authent",
|
|
30
33
|
debugging: debugging,
|
|
31
|
-
cookie_debugging: true,
|
|
32
|
-
master_detail_debugging: true,
|
|
33
34
|
local: true,
|
|
34
35
|
production: false,
|
|
35
36
|
use_navigate: false,
|
|
36
37
|
save_failed_alert: false,
|
|
37
38
|
form_version: "1.0",
|
|
38
39
|
form_modified_version: 2
|
|
39
|
-
},
|
|
40
|
-
home: {
|
|
41
|
-
...(local && {
|
|
42
|
-
url: 'http://localhost:3000'
|
|
43
|
-
}),
|
|
44
|
-
...(production && {
|
|
45
|
-
url: 'https://www.chainedeprieres.com'
|
|
46
|
-
})
|
|
47
|
-
},
|
|
48
|
-
datasync: {
|
|
49
|
-
/*DATASYNC*/
|
|
50
|
-
praychain_company_guid: local ? "36178327-E810-3A73-A833-8417F639295E" : "2EA619F2-2A23-7905-69C7-6ABA65BDF585",
|
|
51
|
-
praychain_time_table_guid: local ? "CA09A7FB-431C-29A6-A974-72E4F949EC81" : "566062CD-30F8-B1E2-DF80-6AB667F466C4",
|
|
52
|
-
invitation_table_guid: local ? "AE99F45B-9D22-D280-13DA-29B4860C7FEE" : "3F92D25C-4223-E5D2-8484-4880B6B83E9A",
|
|
53
|
-
praychain_contact_table_guid: local ? "E2AEE1AB-838F-A68A-355C-C1A912698002" : "0458D1BE-3E8D-049D-09FB-5A8E14F76A53",
|
|
54
|
-
praychain_authent_table_guid: local ? "B5A0C0AA-200F-B88B-67DE-355D222A6E52" : "21A2464D-B413-6A0C-0848-EDA45266DAC0",
|
|
55
|
-
praychain_user_table_guid: local ? "7841F7FF-1BF9-8716-7C66-BD8C5634E1F6" : "1D65037E-9A04-51EB-5CAE-06BCB7BE30AF",
|
|
56
|
-
praychain_topics_table_guid: local ? "E25E87B5-5E0C-7446-AF58-ECAE4301AE40" : "CE2A92BE-47A5-8AAE-7014-64FF5986A2BD",
|
|
57
|
-
/* MAC local */
|
|
58
|
-
...(local && {
|
|
59
|
-
syncTestUrl: "http://localhost:8888/datasync-service/test.php",
|
|
60
|
-
syncPushUrl: "http://localhost:8888/datasync-service/Sync.php",
|
|
61
|
-
syncPushSerializedUrl: "http://localhost:8888/datasync-service/Sync.php",
|
|
62
|
-
syncStartUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncStart",
|
|
63
|
-
syncDeleteUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncDelete",
|
|
64
|
-
syncSeekUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncSeek",
|
|
65
|
-
syncStopUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncStop",
|
|
66
|
-
syncPullUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncPull",
|
|
67
|
-
syncPullSerializedUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncPullSerialized",
|
|
68
|
-
syncMobilePullUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncMobilePull",
|
|
69
|
-
syncPassThruUrl: "http://localhost:8888/datasync-service/Sync.php?action=syncPassThru"
|
|
70
|
-
}),
|
|
71
|
-
/* chainedeprieres.com Production Server */
|
|
72
|
-
...(production && {
|
|
73
|
-
syncTestUrl: "https://rest.datasync.ovh/test.php",
|
|
74
|
-
syncPushUrl: "https://rest.datasync.ovh/Sync.php",
|
|
75
|
-
syncPushSerializedUrl: "https://rest.datasync.ovh/Sync.php",
|
|
76
|
-
syncStartUrl: "https://rest.datasync.ovh/Sync.php?action=syncStart",
|
|
77
|
-
syncDeleteUrl: "http://rest.datasync.ovh/Sync.php?action=syncDelete",
|
|
78
|
-
syncSeekUrl: "https://rest.datasync.ovh/Sync.php?action=syncSeek",
|
|
79
|
-
syncStopUrl: "https://rest.datasync.ovh/Sync.php?action=syncStop",
|
|
80
|
-
syncPullUrl: "https://rest.datasync.ovh/Sync.php?action=syncPull",
|
|
81
|
-
syncPullSerializedUrl: "https://rest.datasync.ovh/Sync.php?action=syncPullSerialized",
|
|
82
|
-
syncMobilePullUrl: "https://rest.datasync.ovh/Sync.php?action=syncMobilePull",
|
|
83
|
-
syncPassThruUrl: "https://rest.datasync.ovh/Sync.php?action=syncPassThru"
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const randomize = (min, max) => {
|
|
88
|
-
return Math.floor(min + Math.random() * (max - min));
|
|
89
|
-
};
|
|
90
|
-
const cTimeStamp = () => {
|
|
91
|
-
let lDate = new Date();
|
|
92
|
-
let l_sTimeStamp = '';
|
|
93
|
-
l_sTimeStamp = 1900 + lDate.getYear();
|
|
94
|
-
l_sTimeStamp += '-';
|
|
95
|
-
l_sTimeStamp += ('0' + (lDate.getMonth() + 1)).slice(-2);
|
|
96
|
-
l_sTimeStamp += '-';
|
|
97
|
-
l_sTimeStamp += ('0' + lDate.getDate()).slice(-2);
|
|
98
|
-
l_sTimeStamp += ' ';
|
|
99
|
-
l_sTimeStamp += ('0' + lDate.getHours()).slice(-2);
|
|
100
|
-
l_sTimeStamp += ('0' + lDate.getMinutes()).slice(-2);
|
|
101
|
-
l_sTimeStamp += ('0' + lDate.getSeconds()).slice(-2);
|
|
102
|
-
return l_sTimeStamp;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/* Prototype : cGUID
|
|
106
|
-
* Purpose : Generates a Global Unique ID
|
|
107
|
-
* Return : Return GUID
|
|
108
|
-
* History : Created on 2015-02-06
|
|
109
|
-
*
|
|
110
|
-
**/
|
|
111
|
-
const CGUID = () => {
|
|
112
|
-
let d = new Date().getTime();
|
|
113
|
-
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
114
|
-
var r = (d + Math.random() * 16) % 16 | 0;
|
|
115
|
-
d = Math.floor(d / 16);
|
|
116
|
-
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
|
117
|
-
});
|
|
118
|
-
return uuid;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Write data_tier form to data blob
|
|
123
|
-
*/
|
|
124
|
-
exports.CGUID = CGUID;
|
|
125
|
-
const saveDataTierToDatasync = async (p_data_guid, p_o_data_blob, p_s_company_guid, p_s_table_guid, p_dt_createstamp, p_dt_updatestamp, p_dt_deletestamp, on_save_handler, on_update_handler, on_failed_handler, p_extra_data) => {
|
|
126
|
-
if (globals.parameters.debugging_data_tier) console.log(`10/07:this.data_tier:${JSON.stringify(p_o_data_blob)}`);
|
|
127
|
-
|
|
128
|
-
//Post object using DataSyncLayer
|
|
129
|
-
//Copy datasync compliant object data from state structure
|
|
130
|
-
let formBlobObject = {
|
|
131
|
-
data_guid: p_data_guid ? p_data_guid : CGUID(),
|
|
132
|
-
data_blob: {
|
|
133
|
-
data_tier: p_o_data_blob.data_tier
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
if (p_dt_createstamp) {
|
|
137
|
-
formBlobObject.createstamp = p_dt_createstamp;
|
|
138
|
-
}
|
|
139
|
-
if (p_dt_updatestamp) {
|
|
140
|
-
formBlobObject.updatestamp = p_dt_updatestamp;
|
|
141
|
-
}
|
|
142
|
-
if (p_dt_deletestamp) {
|
|
143
|
-
formBlobObject.deletestamp = p_dt_deletestamp;
|
|
144
|
-
}
|
|
145
|
-
let l_o_datasync = Object.assign({}, formBlobObject);
|
|
146
|
-
if (globals.parameters.debugging) {
|
|
147
|
-
console.log("l_o_datasync to be stored => ", l_o_datasync);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//Set datasync container sytem properties values
|
|
151
|
-
//Set user custom data_blob properties values
|
|
152
|
-
l_o_datasync.data_blob.modified = globals.parameters.form_modified_version; //ReUse moidified flag as modified version
|
|
153
|
-
//and so on...
|
|
154
|
-
|
|
155
|
-
//Stringify whole datasync object one more time
|
|
156
|
-
let l_s_sync_object_stringified;
|
|
157
|
-
try {
|
|
158
|
-
l_s_sync_object_stringified = JSON.stringify(l_o_datasync).replace(/'/g, "'").replace(/\\n/g, '\\\\n');
|
|
159
|
-
if (globals.parameters.debugging) console.log(`l_s_sync_object_stringified succedeed :${l_s_sync_object_stringified}`);
|
|
160
|
-
} catch (err) {
|
|
161
|
-
console.error(`l_s_sync_object_stringified:${l_s_sync_object_stringified}`);
|
|
162
|
-
alert(`l_s_sync_object_stringified StringiFy failed with error:${err}`);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
//Prepare datasync syncPush POST request
|
|
166
|
-
const POSTform = new FormData();
|
|
167
|
-
POSTform.append("action", "syncPushSerialized"); //
|
|
168
|
-
POSTform.append("company_guid", p_s_company_guid);
|
|
169
|
-
POSTform.append("table_guid", p_s_table_guid);
|
|
170
|
-
POSTform.append("data_sync", l_s_sync_object_stringified);
|
|
171
|
-
|
|
172
|
-
//SyncPush Data
|
|
173
|
-
fetch(`${globals.datasync.syncPushSerializedUrl}`, {
|
|
174
|
-
method: "POST",
|
|
175
|
-
body: POSTform
|
|
176
|
-
}).then(results => {
|
|
177
|
-
return results.text();
|
|
178
|
-
}).then(sync_server_response => {
|
|
179
|
-
let json_response = JSON.parse(sync_server_response);
|
|
180
|
-
if (globals.parameters.debugging) console.log("json_response ->", json_response);
|
|
181
|
-
if (json_response.data_blob) {
|
|
182
|
-
//Save succedeed
|
|
183
|
-
if (p_data_guid == null && on_save_handler) on_save_handler(json_response, p_extra_data);
|
|
184
|
-
//Update succedeed
|
|
185
|
-
if (p_data_guid != null && on_update_handler) on_update_handler(json_response, p_extra_data);
|
|
186
|
-
|
|
187
|
-
//debugging
|
|
188
|
-
if (globals.parameters.debugging) {
|
|
189
|
-
let data_blob = json_response.data_blob;
|
|
190
|
-
console.log("data_blob", data_blob);
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
//Save or update failed
|
|
194
|
-
console.error("DataSync::saveFormToDatasync => Save or update failed");
|
|
195
|
-
if (on_failed_handler) on_failed_handler("Internal DataSync save error", p_extra_data);
|
|
196
|
-
}
|
|
197
|
-
}).catch(err => {
|
|
198
|
-
alert(`Erreur de sauvegarde ${err}`);
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
const wScrollTo = pStargetAnchorId => {
|
|
202
|
-
let targetDomAnchor = document.getElementById(pStargetAnchorId);
|
|
203
|
-
if (targetDomAnchor) targetDomAnchor.scrollIntoView({
|
|
204
|
-
behavior: "smooth",
|
|
205
|
-
block: "start",
|
|
206
|
-
inline: "nearest"
|
|
207
|
-
});else {
|
|
208
|
-
if (globals.parameters.debugging) {
|
|
209
|
-
console.log(`wScrollTo failed => ${pStargetAnchorId} not found in DOM !`);
|
|
210
|
-
}
|
|
211
40
|
}
|
|
212
41
|
};
|
|
213
42
|
class DsDynamicForm extends _react.Component {
|
|
@@ -274,8 +103,8 @@ class DsDynamicForm extends _react.Component {
|
|
|
274
103
|
this.setState({
|
|
275
104
|
fieldError: [],
|
|
276
105
|
form: {},
|
|
277
|
-
captcha1:
|
|
278
|
-
captcha2:
|
|
106
|
+
captcha1: (0, _datasyncCommonLibrary.Randomize)(0, 5),
|
|
107
|
+
captcha2: (0, _datasyncCommonLibrary.Randomize)(0, 5)
|
|
279
108
|
},
|
|
280
109
|
//Clear forced
|
|
281
110
|
() => {
|
|
@@ -310,7 +139,7 @@ class DsDynamicForm extends _react.Component {
|
|
|
310
139
|
fieldError: nextFieldError
|
|
311
140
|
});
|
|
312
141
|
//Scroll form to first erroneous field
|
|
313
|
-
|
|
142
|
+
(0, _datasyncCommonLibrary.WScrollTo)(pFieldObject.name);
|
|
314
143
|
} catch (e) {
|
|
315
144
|
console.log(`Error caught on ${e}`);
|
|
316
145
|
}
|
|
@@ -488,7 +317,7 @@ class DsDynamicForm extends _react.Component {
|
|
|
488
317
|
saveFormToDatasyncProcess = () => {
|
|
489
318
|
//Everything sounds ok in Form, Go ahead
|
|
490
319
|
let hasDataGuid = this.props.datasync_object && this.props.datasync_object.data_guid;
|
|
491
|
-
|
|
320
|
+
(0, _datasyncCore.SaveDataTierToDatasync)(hasDataGuid ? this.props.datasync_object.data_guid : null,
|
|
492
321
|
//data_guid
|
|
493
322
|
this.data_blob,
|
|
494
323
|
//p_o_data_blob,
|
|
@@ -496,9 +325,9 @@ class DsDynamicForm extends _react.Component {
|
|
|
496
325
|
//p_s_company_guid,
|
|
497
326
|
this.props.table_guid,
|
|
498
327
|
//p_s_table_guid,
|
|
499
|
-
hasDataGuid ? this.props.datasync_object.createstamp :
|
|
328
|
+
hasDataGuid ? this.props.datasync_object.createstamp : (0, _datasyncCommonLibrary.CTimeStamp)(),
|
|
500
329
|
//p_dt_createstamp,
|
|
501
|
-
hasDataGuid ?
|
|
330
|
+
hasDataGuid ? (0, _datasyncCommonLibrary.CTimeStamp)() : null,
|
|
502
331
|
//p_dt_updatestamp,
|
|
503
332
|
null,
|
|
504
333
|
//p_dt_deletestamp,
|
|
@@ -541,8 +370,6 @@ class DsDynamicForm extends _react.Component {
|
|
|
541
370
|
//Call save anyway
|
|
542
371
|
this.saveFormToDatasyncProcess();
|
|
543
372
|
}
|
|
544
|
-
|
|
545
|
-
//this.saveFormToDatasync_OLD((this.props.datasync_object && this.props.datasync_object.data_guid)?this.props.datasync_object.data_guid:null);
|
|
546
373
|
};
|
|
547
374
|
onFormSavedLocalHandler = blob => {
|
|
548
375
|
if (this.props.onFormSaved) this.props.onFormSaved(blob);else console.error("DynamicForm3Tiers2.onFormSaved props is not defined !");
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datasync-dynamic-form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Datasync Dynamic Form component",
|
|
5
5
|
"main": "./dist/components/DsDynamicForm",
|
|
6
6
|
"types": "./dist/components/DsDynamicForm",
|
|
7
|
-
"files":[
|
|
7
|
+
"files": [
|
|
8
|
+
"./dist"
|
|
9
|
+
],
|
|
8
10
|
"repository": {
|
|
9
11
|
"type": "git",
|
|
10
12
|
"url": "https://github.com/pmabiala/datasync-dynamic-form.git"
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
"reactstrap": "^9.2.2"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
|
32
|
+
"multiselect-react-dropdown": "^2.0.25",
|
|
30
33
|
"react": "^ 18.2.0"
|
|
31
34
|
},
|
|
32
35
|
"scripts": {
|
|
@@ -36,5 +39,10 @@
|
|
|
36
39
|
},
|
|
37
40
|
"keywords": [],
|
|
38
41
|
"author": "",
|
|
39
|
-
"license": "ISC"
|
|
42
|
+
"license": "ISC",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"axios": "^1.7.2",
|
|
45
|
+
"datasync-common-library": "^1.0.5",
|
|
46
|
+
"datasync-core": "^1.0.8"
|
|
47
|
+
}
|
|
40
48
|
}
|