@capillarytech/creatives-library 2.0.35 → 2.0.37
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/components/CardGrid/index.js +15 -10
- package/components/FormBuilder/index.js +122 -214
- package/containers/Sms/Create/index.js +9 -9
- package/containers/Sms/Edit/index.js +7 -7
- package/containers/Templates/index.js +82 -81
- package/containers/TemplatesV2/index.js +24 -16
- package/index.js +7 -1
- package/package.json +1 -1
|
@@ -85,20 +85,17 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
85
85
|
componentWillMount() {
|
|
86
86
|
this.setState({usingTabContainer: this.props.usingTabContainer ? this.props.usingTabContainer : false});
|
|
87
87
|
if (this.props.formData && (this.props.isEdit || (!this.props.isEdit && !_.isEmpty(this.props.formData)))) {
|
|
88
|
-
|
|
89
88
|
this.setState({formData: this.props.formData}, () => {
|
|
90
89
|
// if (!this.props.isNewVersionFlow) {
|
|
91
90
|
this.initialiseForm(this.props.schema, false, true);
|
|
92
91
|
// }
|
|
93
92
|
});
|
|
94
93
|
} else {
|
|
95
|
-
|
|
96
94
|
this.initialiseForm(this.props.schema, true);
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
componentWillReceiveProps(nextProps) {
|
|
101
|
-
|
|
102
99
|
const type = this.props.location.query.type;
|
|
103
100
|
if (this.state.usingTabContainer && nextProps.tabCount !== this.props.tabCount) {
|
|
104
101
|
this.setState({tabCount: nextProps.tabCount});
|
|
@@ -106,7 +103,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
106
103
|
if (nextProps.startValidation && nextProps.startValidation !== false && this.props.startValidation !== nextProps.startValidation) {
|
|
107
104
|
this.setState({checkValidation: true});
|
|
108
105
|
const ifValid = this.validateForm(null, null, null, true);
|
|
109
|
-
|
|
106
|
+
|
|
110
107
|
if (ifValid) {
|
|
111
108
|
this.saveForm(true);
|
|
112
109
|
} else {
|
|
@@ -117,9 +114,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
117
114
|
// this.saveForm(saveForm);
|
|
118
115
|
// }
|
|
119
116
|
if (nextProps.isEdit) {
|
|
120
|
-
|
|
121
117
|
if (!_.isEqual(nextProps.formData, this.state.formData) && !_.isEmpty(nextProps.formData)) {
|
|
122
|
-
|
|
123
118
|
if (type === 'embedded') { //TODO: has to be checked and changed.
|
|
124
119
|
this.setState({checkValidation: true, formData: nextProps.formData}, () => {
|
|
125
120
|
this.validateForm();
|
|
@@ -137,11 +132,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
137
132
|
} else if (this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === 'EMAIL') {
|
|
138
133
|
this.setState({formData: nextProps.formData});
|
|
139
134
|
}
|
|
140
|
-
|
|
135
|
+
|
|
141
136
|
if (this.state.usingTabContainer && this.state.tabKey === '') {
|
|
142
137
|
//this.setState({formData: nextProps.formData});
|
|
143
138
|
if (nextProps.isNewVersionFlow && !_.isEqual(this.state.tabKey, nextProps.tabKey)) {
|
|
144
|
-
|
|
145
139
|
this.setState({tabKey: nextProps.tabKey});
|
|
146
140
|
} else if (!nextProps.isNewVersionFlow) {
|
|
147
141
|
this.resetTabKeys(nextProps.formData, nextProps.tabCount);
|
|
@@ -150,18 +144,15 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
146
|
if (_.isEmpty(this.props.formData) && !_.isEmpty(nextProps.formData)) {
|
|
153
|
-
|
|
154
147
|
if (this.state.usingTabContainer) {
|
|
155
148
|
this.resetTabKeys(nextProps.formData, nextProps.tabCount);
|
|
156
149
|
}
|
|
157
150
|
this.initializeEditErrorData(nextProps.formData, nextProps.tabCount);
|
|
158
151
|
}
|
|
159
152
|
if (!_.isEmpty(this.props.formData) && this.props.formData !== this.state.formData && _.isEmpty(this.state.formData) && this.state.usingTabContainer) {
|
|
160
|
-
|
|
161
153
|
this.resetTabKeys(this.props.formData, nextProps.tabCount);
|
|
162
154
|
}
|
|
163
155
|
if ( this.state.usingTabContainer && nextProps.formData && !_.isEmpty(nextProps.formData) && _.isEmpty(this.props.formData) && nextProps.tabCount && this.state.tabCount !== nextProps.tabCount) {
|
|
164
|
-
|
|
165
156
|
this.setState({ formData: nextProps.formData, tabCount: nextProps.tabCount }, () => {
|
|
166
157
|
this.initializeEditErrorData(nextProps.formData, nextProps.tabCount);
|
|
167
158
|
if (this.state.usingTabContainer) {
|
|
@@ -179,16 +170,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
179
170
|
( !this.state.usingTabContainer || (this.state.usingTabContainer && nextProps.tabKey !== ''))
|
|
180
171
|
&& !_.isEqual(nextProps.formData, this.state.formData) &&
|
|
181
172
|
!_.isEqual(nextProps.formData, this.props.formData)) {
|
|
182
|
-
|
|
183
173
|
this.setState({formData: nextProps.formData, tabKey: nextProps.tabKey}, () => {
|
|
184
174
|
this.validateForm();
|
|
185
175
|
});
|
|
186
176
|
//this.resetTabKeys(nextProps.formData, nextProps.tabCount);
|
|
187
177
|
} else if ((_.isEmpty(this.props.formData) || !this.props.formData) && _.isEmpty(this.state.formData)) {
|
|
188
|
-
|
|
189
178
|
this.initialiseForm(nextProps.schema, true);
|
|
190
179
|
} else if (_.isEmpty(this.props.formData) && !_.isEmpty(nextProps.formData)) {
|
|
191
|
-
|
|
192
180
|
this.setState({formData: nextProps.formData});
|
|
193
181
|
}
|
|
194
182
|
|
|
@@ -202,16 +190,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
202
190
|
}
|
|
203
191
|
|
|
204
192
|
if (!_.isEmpty(nextProps.formData) && !_.isEqual(this.state.formData, nextProps.formData)) {
|
|
205
|
-
|
|
206
193
|
if (nextProps.isNewVersionFlow) {
|
|
207
|
-
|
|
208
194
|
const tabKey = (this.state.tabKey !== nextProps.formData[nextProps.currentTab - 1].tabKey) ? nextProps.formData[nextProps.currentTab - 1].tabKey : this.state.tabKey;
|
|
209
|
-
|
|
195
|
+
|
|
210
196
|
this.setState({tabKey});
|
|
211
197
|
}
|
|
212
198
|
this.setState({formData: nextProps.formData, currentLangTab}, () => {
|
|
213
199
|
if (nextProps.isNewVersionFlow && !this.state.formData[this.state.currentTab - 1][this.state.formData[this.state.currentTab - 1].activeTab].tabKey) {
|
|
214
|
-
|
|
215
200
|
this.resetTabKeys(nextProps.formData, nextProps.tabCount, false, true);
|
|
216
201
|
}
|
|
217
202
|
if (type === 'embedded' || this.props.schema.channel.toUpperCase() === 'EMAIL') {
|
|
@@ -223,29 +208,24 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
223
208
|
});
|
|
224
209
|
}
|
|
225
210
|
|
|
226
|
-
|
|
211
|
+
|
|
227
212
|
if (!_.isEqual(nextProps.schema, this.props.schema)) {
|
|
228
|
-
|
|
229
213
|
this.setState({ isFormValid: (this.props.isEdit ? this.props.isEdit : true) }, () => {
|
|
230
|
-
|
|
231
214
|
if (!this.props.isEdit || (this.props.isEdit && !_.isEmpty(nextProps.formData))) {
|
|
232
|
-
|
|
233
215
|
let resetTabKeys = (this.state.formData.tabKey === undefined);
|
|
234
216
|
if ((this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === 'MOBILEPUSH')) {
|
|
235
217
|
resetTabKeys = false;
|
|
236
|
-
|
|
237
218
|
}
|
|
238
219
|
if (this.props.isNewVersionFlow) {
|
|
239
220
|
resetTabKeys = false;
|
|
240
221
|
}
|
|
241
|
-
|
|
222
|
+
|
|
242
223
|
this.initialiseForm(nextProps.schema, false, resetTabKeys);
|
|
243
224
|
this.validateForm();
|
|
244
225
|
}
|
|
245
226
|
});
|
|
246
227
|
}
|
|
247
228
|
if (!_.isEqual(nextProps.checkValidation, this.props.checkValidation)) {
|
|
248
|
-
|
|
249
229
|
this.setState({ checkValidation: nextProps.checkValidation });
|
|
250
230
|
}
|
|
251
231
|
|
|
@@ -254,32 +234,27 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
254
234
|
}
|
|
255
235
|
|
|
256
236
|
if (!_.isEmpty(nextProps.injectedTags) && !_.isEqual(nextProps.injectedTags, this.props.injectedTags)) {
|
|
257
|
-
|
|
258
237
|
this.validateForm(nextProps.tags, nextProps.injectedTags);
|
|
259
238
|
}
|
|
260
239
|
if (!_.isEmpty(nextProps.tags) && !_.isEqual(nextProps.tags, this.props.tags)) {
|
|
261
|
-
|
|
262
240
|
this.validateForm(nextProps.tags, nextProps.injectedTags);
|
|
263
241
|
}
|
|
264
242
|
if (!_.isEqual(nextProps.showModal, this.props.showModal)) {
|
|
265
|
-
|
|
266
243
|
this.setState({showModal: nextProps.showModal});
|
|
267
244
|
}
|
|
268
245
|
if (nextProps.modal && (!_.isEqual(nextProps.modal, this.props.modal) || _.isEmpty(this.state.modal))) {
|
|
269
|
-
|
|
270
246
|
this.setState({modal: nextProps.modal});
|
|
271
247
|
}
|
|
272
248
|
}
|
|
273
249
|
|
|
274
|
-
onEdit(
|
|
275
|
-
|
|
250
|
+
onEdit() {
|
|
251
|
+
|
|
276
252
|
}
|
|
277
253
|
|
|
278
254
|
getModal = () => {
|
|
279
255
|
let modal;
|
|
280
256
|
if (this.state.modal) {
|
|
281
257
|
if (this.state.modal.type === 'confirm') {
|
|
282
|
-
|
|
283
258
|
modal = (<Modal
|
|
284
259
|
visible={this.state.showModal}
|
|
285
260
|
title={this.state.modal.title}
|
|
@@ -332,8 +307,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
332
307
|
});
|
|
333
308
|
}
|
|
334
309
|
|
|
335
|
-
handleCloseModal = (data
|
|
336
|
-
|
|
310
|
+
handleCloseModal = (data) => {
|
|
337
311
|
const event = this.state.currentEvent;
|
|
338
312
|
if (!_.isEmpty(this.state.currentEvent)) {
|
|
339
313
|
switch (event) {
|
|
@@ -356,8 +330,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
356
330
|
|
|
357
331
|
resetTabKeys(form, count, changeDefaultTab, setFormTabKey) {
|
|
358
332
|
const tabCount = count || this.state.tabCount;
|
|
359
|
-
|
|
360
|
-
|
|
333
|
+
|
|
334
|
+
|
|
361
335
|
const formData = _.cloneDeep(form);
|
|
362
336
|
let baseIndex = 0;
|
|
363
337
|
for (let idx = 0; idx < tabCount; idx += 1) {
|
|
@@ -376,64 +350,53 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
376
350
|
if (setFormTabKey) {
|
|
377
351
|
if (!formData[idx].activeTab) {
|
|
378
352
|
const baseLanguage = this.props.baseLanguage;
|
|
379
|
-
|
|
353
|
+
|
|
380
354
|
formData[idx].tabKey = formData[idx][baseLanguage].tabKey;
|
|
381
355
|
} else {
|
|
382
|
-
|
|
383
356
|
formData[idx].tabKey = formData[idx][formData[idx].activeTab].tabKey;
|
|
384
357
|
}
|
|
385
358
|
if (formData[idx].base) {
|
|
386
359
|
if (!formData.base.activeTab) {
|
|
387
|
-
|
|
388
360
|
const baseLanguage = this.props.baseLanguage;
|
|
389
361
|
formData.base.tabKey = formData.base[baseLanguage].tabKey;
|
|
390
362
|
} else {
|
|
391
|
-
|
|
392
363
|
formData.base.tabKey = formData.base[formData[idx].activeTab].tabKey;
|
|
393
364
|
}
|
|
394
365
|
}
|
|
395
366
|
}
|
|
396
|
-
|
|
367
|
+
|
|
397
368
|
if (formData[idx].base && formData.base.activeTab) {
|
|
398
|
-
|
|
399
369
|
// if (!formData.base.tabKey) {
|
|
400
|
-
|
|
370
|
+
|
|
401
371
|
formData.base.tabKey = formData[idx][formData[idx].activeTab].tabKey;
|
|
402
372
|
//}
|
|
403
373
|
baseIndex = idx;
|
|
404
374
|
}
|
|
405
|
-
} else {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
formData.base = formData[idx];
|
|
413
|
-
baseIndex = idx;
|
|
414
|
-
}
|
|
375
|
+
} else if (formData[idx]) {
|
|
376
|
+
if (!formData[idx].tabKey) {
|
|
377
|
+
formData[idx].tabKey = _.uniqueId();
|
|
378
|
+
}
|
|
379
|
+
if (formData[idx].base) {
|
|
380
|
+
formData.base = formData[idx];
|
|
381
|
+
baseIndex = idx;
|
|
415
382
|
}
|
|
416
383
|
}
|
|
417
384
|
}
|
|
418
|
-
|
|
385
|
+
|
|
419
386
|
if ((formData.base && formData.base.tabKey && formData.base.tabKey !== '' && !changeDefaultTab) || (formData.base && this.state.tabKey !== formData.base.tabKey)) {
|
|
420
|
-
|
|
421
387
|
if (this.state.currentTab === 1 && !this.props.isNewVersionFlow) {
|
|
422
388
|
this.setState({tabKey: formData.base.tabKey});
|
|
423
389
|
} else if (this.props.isNewVersionFlow && this.state.tabKey !== formData[this.state.currentTab - 1].tabKey) {
|
|
424
|
-
|
|
425
390
|
this.setState({tabKey: formData[this.state.currentTab - 1].tabKey});
|
|
426
391
|
}
|
|
427
392
|
}
|
|
428
393
|
if (setFormTabKey) {
|
|
429
|
-
|
|
430
394
|
this.setState({tabKey: formData.base.tabKey});
|
|
431
395
|
}
|
|
432
|
-
|
|
433
|
-
|
|
396
|
+
|
|
397
|
+
|
|
434
398
|
if (changeDefaultTab) {
|
|
435
399
|
this.setState({formData}, () => {
|
|
436
|
-
|
|
437
400
|
this.props.onChange(formData, this.state.tabCount);
|
|
438
401
|
this.validateForm();
|
|
439
402
|
});
|
|
@@ -1105,15 +1068,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1105
1068
|
this.setState({errorData});
|
|
1106
1069
|
}
|
|
1107
1070
|
|
|
1108
|
-
initializeMultiColSection(section, formDataObj, isContainer, index, ifError
|
|
1109
|
-
|
|
1071
|
+
initializeMultiColSection(section, formDataObj, isContainer, index, ifError) {
|
|
1110
1072
|
const formData = _.cloneDeep(formDataObj);
|
|
1111
1073
|
const newFormData = {};
|
|
1112
1074
|
newFormData[index] = {};
|
|
1113
1075
|
_.forEach(section.inputFields, (inputField) => {
|
|
1114
|
-
|
|
1115
1076
|
_.forEach(inputField.cols, (col) => {
|
|
1116
|
-
|
|
1117
1077
|
if (isContainer && !formData[index]) {
|
|
1118
1078
|
formData[index] = {};
|
|
1119
1079
|
}
|
|
@@ -1153,24 +1113,20 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1153
1113
|
} else if (!isContainer && !ifError && formData[col.id] === undefined) {
|
|
1154
1114
|
formData[col.id] = '';
|
|
1155
1115
|
}
|
|
1156
|
-
} else {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
} else {
|
|
1165
|
-
formData[index][this.props.baseLanguage][col.id] = '';
|
|
1166
|
-
}
|
|
1167
|
-
} else if (!isContainer && ifError && formData[col.id] === undefined) {
|
|
1168
|
-
formData[col.id] = false;
|
|
1169
|
-
} else if (!isContainer && !ifError && formData[col.id] === undefined) {
|
|
1170
|
-
formData[col.id] = '';
|
|
1116
|
+
} else if (!(col.id.indexOf('template-content') > -1 && col.id !== 'template-content')) {
|
|
1117
|
+
if (isContainer && formData[index] && formData[index][this.props.baseLanguage] && formData[index][this.props.baseLanguage][col.id] === undefined) {
|
|
1118
|
+
if (ifError) {
|
|
1119
|
+
formData[index][this.props.baseLanguage][col.id] = false;
|
|
1120
|
+
} else if (isContainer && formData[index][this.props.baseLanguage][col.id] === undefined && col.value) {
|
|
1121
|
+
formData[index][this.props.baseLanguage][col.id] = col.value;
|
|
1122
|
+
} else {
|
|
1123
|
+
formData[index][this.props.baseLanguage][col.id] = '';
|
|
1171
1124
|
}
|
|
1125
|
+
} else if (!isContainer && ifError && formData[col.id] === undefined) {
|
|
1126
|
+
formData[col.id] = false;
|
|
1127
|
+
} else if (!isContainer && !ifError && formData[col.id] === undefined) {
|
|
1128
|
+
formData[col.id] = '';
|
|
1172
1129
|
}
|
|
1173
|
-
|
|
1174
1130
|
}
|
|
1175
1131
|
}
|
|
1176
1132
|
if (col.type === 'checkbox') {
|
|
@@ -1247,12 +1203,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1247
1203
|
if (this.props.isNewVersionFlow) {
|
|
1248
1204
|
_.forEach(schema.containers, (val, index) => {
|
|
1249
1205
|
if (val.type === 'tabs') {
|
|
1250
|
-
|
|
1251
1206
|
this.setState({usingTabContainer: true});
|
|
1252
1207
|
_.forEach(val.panes, (pane, paneIndex) => {
|
|
1253
1208
|
_.forEach(pane.sections, (section) => {
|
|
1254
1209
|
if (section.type === 'multicols') {
|
|
1255
|
-
|
|
1256
1210
|
formData = this.initializeMultiColSection(section, formData, true, index, ifError, paneIndex);
|
|
1257
1211
|
} else if (section.type === 'col-label') {
|
|
1258
1212
|
formData = this.initializeColLabelSection(section, formData, true, index, ifError);
|
|
@@ -1273,12 +1227,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1273
1227
|
} else {
|
|
1274
1228
|
_.forEach(schema.containers, (val) => {
|
|
1275
1229
|
if (val.type === 'tabs') {
|
|
1276
|
-
|
|
1277
1230
|
this.setState({usingTabContainer: true});
|
|
1278
1231
|
_.forEach(val.panes, (pane, index) => {
|
|
1279
1232
|
_.forEach(pane.sections, (section) => {
|
|
1280
1233
|
if (section.type === 'multicols') {
|
|
1281
|
-
|
|
1282
1234
|
formData = this.initializeMultiColSection(section, formData, true, index, ifError);
|
|
1283
1235
|
} else if (section.type === 'col-label') {
|
|
1284
1236
|
formData = this.initializeColLabelSection(section, formData, true, index, ifError);
|
|
@@ -1301,8 +1253,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1301
1253
|
}
|
|
1302
1254
|
|
|
1303
1255
|
initialiseForm(schema, makeFormEmpty, resetTabKeys) {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
1256
|
let formData = makeFormEmpty ? {} : _.cloneDeep(this.state.formData);
|
|
1307
1257
|
let errorData = {};
|
|
1308
1258
|
this.formElements = [];
|
|
@@ -1314,7 +1264,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1314
1264
|
formData = this.initializeContainers(schema, formData);
|
|
1315
1265
|
errorData = this.initializeContainers(schema, errorData, true);
|
|
1316
1266
|
|
|
1317
|
-
|
|
1267
|
+
|
|
1318
1268
|
if (!this.props.isEdit) {
|
|
1319
1269
|
if (!formData[0]) {
|
|
1320
1270
|
formData[0] = {};
|
|
@@ -1354,7 +1304,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1354
1304
|
}
|
|
1355
1305
|
|
|
1356
1306
|
cloneVersionData(ifError) {
|
|
1357
|
-
|
|
1358
1307
|
if (this.state.tabCount === 0) {
|
|
1359
1308
|
this.initialiseForm(this.props.schema, true);
|
|
1360
1309
|
return;
|
|
@@ -1372,10 +1321,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1372
1321
|
newTabIndex = this.state.tabCount;
|
|
1373
1322
|
}
|
|
1374
1323
|
formData[newTabIndex] = {};
|
|
1375
|
-
|
|
1324
|
+
|
|
1376
1325
|
const newTabCount = newTabIndex + 1;
|
|
1377
1326
|
_.forEach(formData[0], (val, key) => {
|
|
1378
|
-
|
|
1379
1327
|
if (key === 'base') {
|
|
1380
1328
|
return true;
|
|
1381
1329
|
}
|
|
@@ -1385,17 +1333,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1385
1333
|
if (typeof val === 'string') {
|
|
1386
1334
|
if (ifError) {
|
|
1387
1335
|
formData[newTabIndex][`${key}${newTabCount}`] = false;
|
|
1388
|
-
} else {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
if (key.indexOf('activeTab') > -1) {
|
|
1392
|
-
formData[newTabIndex][`${key}`] = this.props.baseLanguage;
|
|
1393
|
-
} else {
|
|
1394
|
-
formData[newTabIndex][`${key}${newTabCount}`] = '';
|
|
1395
|
-
}
|
|
1336
|
+
} else if (this.props.isNewVersionFlow) {
|
|
1337
|
+
if (key.indexOf('activeTab') > -1) {
|
|
1338
|
+
formData[newTabIndex][`${key}`] = this.props.baseLanguage;
|
|
1396
1339
|
} else {
|
|
1397
1340
|
formData[newTabIndex][`${key}${newTabCount}`] = '';
|
|
1398
1341
|
}
|
|
1342
|
+
} else {
|
|
1343
|
+
formData[newTabIndex][`${key}${newTabCount}`] = '';
|
|
1399
1344
|
}
|
|
1400
1345
|
} else if (typeof val === 'boolean') {
|
|
1401
1346
|
formData[newTabIndex][`${key}${newTabCount}`] = false;
|
|
@@ -1403,31 +1348,26 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1403
1348
|
if (this.props.isNewVersionFlow) {
|
|
1404
1349
|
if (key.indexOf('selectedLanguages') > -1) {
|
|
1405
1350
|
formData[newTabIndex][key] = [this.props.baseLanguage];
|
|
1406
|
-
} else {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
formData[newTabIndex][key] = {};
|
|
1410
|
-
_.forEach(val, (subVal, index) => {
|
|
1411
|
-
|
|
1351
|
+
} else if (key === this.props.baseLanguage) {
|
|
1352
|
+
formData[newTabIndex][key] = {};
|
|
1353
|
+
_.forEach(val, (subVal, index) => {
|
|
1412
1354
|
// if (subVal === 'is_drag_drop' || subVal === 'lang_id' || subVal === 'iso_code' === 'language') {
|
|
1413
|
-
//
|
|
1355
|
+
//
|
|
1414
1356
|
// formData[newTabIndex][key][index] = formData[0][this.props.baseLanguage][subVal];
|
|
1415
1357
|
// } else {
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1358
|
+
if (index === 'tabKey') {
|
|
1359
|
+
formData[newTabIndex][key][index] = _.uniqueId();
|
|
1360
|
+
} else if (index === 'template-content') {
|
|
1361
|
+
formData[newTabIndex][key][index] = "";
|
|
1362
|
+
} else {
|
|
1363
|
+
formData[newTabIndex][key][index] = _.cloneDeep(formData[0][key][index]);
|
|
1364
|
+
}
|
|
1423
1365
|
// }
|
|
1424
|
-
|
|
1425
|
-
}
|
|
1366
|
+
});
|
|
1426
1367
|
}
|
|
1427
1368
|
} else {
|
|
1428
1369
|
formData[newTabIndex][key] = {};
|
|
1429
1370
|
_.forEach(val, (subVal, index) => {
|
|
1430
|
-
|
|
1431
1371
|
formData[newTabIndex][key][index] = '';
|
|
1432
1372
|
});
|
|
1433
1373
|
}
|
|
@@ -1435,7 +1375,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1435
1375
|
return true;
|
|
1436
1376
|
});
|
|
1437
1377
|
let id = (this.props.isNewVersionFlow && formData[newTabIndex][this.props.baseLanguage].tabKey) ? formData[newTabIndex][this.props.baseLanguage].tabKey : _.uniqueId();
|
|
1438
|
-
|
|
1378
|
+
|
|
1439
1379
|
if (!ifError) {
|
|
1440
1380
|
let validId = false;
|
|
1441
1381
|
while (!validId) {
|
|
@@ -1454,12 +1394,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1454
1394
|
}
|
|
1455
1395
|
// if (!this.props.isEdit) {
|
|
1456
1396
|
if (ifError) {
|
|
1457
|
-
|
|
1458
1397
|
this.setState({errorData: formData});
|
|
1459
1398
|
} else {
|
|
1460
|
-
|
|
1461
1399
|
this.props.onChange(formData, newTabCount, newTabIndex + 1);
|
|
1462
|
-
|
|
1400
|
+
|
|
1463
1401
|
this.setState({tabCount: newTabCount, formData, currentTab: newTabIndex + 1, tabKey: id}, () => {
|
|
1464
1402
|
this.cloneVersionData(true);
|
|
1465
1403
|
});
|
|
@@ -1477,7 +1415,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1477
1415
|
markFinalTabVersion() {
|
|
1478
1416
|
const formData = _.cloneDeep(this.state.formData);
|
|
1479
1417
|
if (this.state.usingTabContainer) {
|
|
1480
|
-
|
|
1481
1418
|
for (let count = 0; count < this.state.tabCount; count += 1) {
|
|
1482
1419
|
if (parseInt(this.state.currentTab - 1, 10) !== count) {
|
|
1483
1420
|
formData[count].base = false;
|
|
@@ -1502,7 +1439,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1502
1439
|
tabKey: '',
|
|
1503
1440
|
}, () => {
|
|
1504
1441
|
if (!isEdit) {
|
|
1505
|
-
|
|
1506
1442
|
this.initialiseForm(this.props.schema, true);
|
|
1507
1443
|
}
|
|
1508
1444
|
});
|
|
@@ -1578,9 +1514,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1578
1514
|
}
|
|
1579
1515
|
|
|
1580
1516
|
deleteVersion(ifError, currentTab) {
|
|
1581
|
-
|
|
1582
1517
|
if (!ifError && this.state.tabCount === 1) {
|
|
1583
|
-
|
|
1584
1518
|
return;
|
|
1585
1519
|
}
|
|
1586
1520
|
let formData = {};
|
|
@@ -1600,7 +1534,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1600
1534
|
if (tabCount > 1 && currentTab !== tabCount) {
|
|
1601
1535
|
finalActiveTabKey = formData[currentTab].tabKey;
|
|
1602
1536
|
}
|
|
1603
|
-
|
|
1537
|
+
|
|
1604
1538
|
if (tabCount > 1 && currentTab === tabCount) {
|
|
1605
1539
|
finalActiveTabKey = formData[currentTab - 2].tabKey;
|
|
1606
1540
|
finalCurrentTab = currentTab - 1;
|
|
@@ -1649,14 +1583,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1649
1583
|
|
|
1650
1584
|
deleteLanguage = () => {
|
|
1651
1585
|
if (this.state.formData[`${this.state.currentTab - 1}`].activeTab === this.props.baseLanguage) {
|
|
1652
|
-
|
|
1586
|
+
|
|
1653
1587
|
} else {
|
|
1654
1588
|
const formData = _.cloneDeep(this.state.formData);
|
|
1655
1589
|
const currentTab = `${this.state.currentTab - 1}`;
|
|
1656
1590
|
const currentLang = formData[`${this.state.currentTab - 1}`].activeTab;
|
|
1657
1591
|
const deleteLanguageIndex = formData[currentTab].selectedLanguages.indexOf(currentLang);
|
|
1658
1592
|
const baseLangTabKey = formData[currentTab][this.props.baseLanguage].tabKey;
|
|
1659
|
-
|
|
1593
|
+
|
|
1660
1594
|
delete formData[currentTab][currentLang];
|
|
1661
1595
|
formData[currentTab].activeTab = this.props.baseLanguage;
|
|
1662
1596
|
formData[currentTab].selectedLanguages.splice(deleteLanguageIndex, 1);
|
|
@@ -1667,7 +1601,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1667
1601
|
formData.base.tabKey = baseLangTabKey;
|
|
1668
1602
|
formData.base.activeTab = this.props.baseLanguage;
|
|
1669
1603
|
}
|
|
1670
|
-
|
|
1604
|
+
|
|
1671
1605
|
this.setState({formData, currentLangTab: this.props.baseLanguage, tabKey: baseLangTabKey}, () => {
|
|
1672
1606
|
this.state.currentEvent.call(this.props.parent, formData, deleteLanguageIndex);
|
|
1673
1607
|
this.setState({currentEvent: {}, currentEventData: {}});
|
|
@@ -1676,18 +1610,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1676
1610
|
};
|
|
1677
1611
|
|
|
1678
1612
|
renameVersion(currentTab) {
|
|
1679
|
-
|
|
1680
1613
|
document.getElementById(`tab-header${currentTab > 1 ? currentTab : ''}`).contentEditable = "true";
|
|
1681
1614
|
document.getElementById(`tab-header${currentTab > 1 ? currentTab : ''}`).focus();
|
|
1682
1615
|
}
|
|
1683
1616
|
|
|
1684
1617
|
updateFormData(data, val, event) {
|
|
1685
|
-
|
|
1686
1618
|
const formData = _.cloneDeep(this.state.formData);
|
|
1687
|
-
|
|
1619
|
+
|
|
1688
1620
|
const tabIndex = this.state.currentTab - 1;
|
|
1689
1621
|
let currentTab = _.cloneDeep(this.state.currentTab);
|
|
1690
|
-
|
|
1622
|
+
|
|
1691
1623
|
if (this.state.usingTabContainer && !val.standalone) {
|
|
1692
1624
|
const data1 = data;
|
|
1693
1625
|
if (event === "addLanguage") {
|
|
@@ -1702,7 +1634,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1702
1634
|
switch (addLanguageType) {
|
|
1703
1635
|
case "upload":
|
|
1704
1636
|
baseTab = _.cloneDeep(formData[tabIndex][currentLang]);
|
|
1705
|
-
|
|
1637
|
+
|
|
1706
1638
|
baseTab.iso_code = data.iso_code;
|
|
1707
1639
|
baseTab.lang_id = data.lang_id;
|
|
1708
1640
|
baseTab.language = data.language;
|
|
@@ -1712,7 +1644,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1712
1644
|
if (!formData[tabIndex]) {
|
|
1713
1645
|
continue;
|
|
1714
1646
|
}
|
|
1715
|
-
|
|
1647
|
+
|
|
1716
1648
|
if (id === formData[tabIndex][formData[tabIndex].selectedLanguages[idx]].tabKey) {
|
|
1717
1649
|
validId = false;
|
|
1718
1650
|
}
|
|
@@ -1725,14 +1657,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1725
1657
|
baseTab.tabKey = id;
|
|
1726
1658
|
//formData[tabIndex].selectedLanguages.push(data.iso_code);
|
|
1727
1659
|
formData[tabIndex][data.iso_code] = baseTab;
|
|
1728
|
-
|
|
1660
|
+
|
|
1729
1661
|
formData[tabIndex].activeTab = data.iso_code;
|
|
1730
1662
|
formData[tabIndex].tabKey = baseTab.tabKey;
|
|
1731
1663
|
break;
|
|
1732
1664
|
case "copyPrimaryLanguage":
|
|
1733
1665
|
case "useEditor":
|
|
1734
1666
|
baseTab = _.cloneDeep(formData[tabIndex][this.props.baseLanguage]);
|
|
1735
|
-
|
|
1667
|
+
|
|
1736
1668
|
//baseTab['template-content'] = '';
|
|
1737
1669
|
baseTab.iso_code = data.iso_code;
|
|
1738
1670
|
baseTab.lang_id = data.lang_id;
|
|
@@ -1756,7 +1688,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1756
1688
|
baseTab.tabKey = id;
|
|
1757
1689
|
formData[tabIndex].selectedLanguages.push(data.iso_code);
|
|
1758
1690
|
formData[tabIndex][data.iso_code] = baseTab;
|
|
1759
|
-
|
|
1691
|
+
|
|
1760
1692
|
formData[tabIndex].activeTab = data.iso_code;
|
|
1761
1693
|
formData[tabIndex].tabKey = baseTab.tabKey;
|
|
1762
1694
|
break;
|
|
@@ -1770,13 +1702,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1770
1702
|
that.setState({tabKey: baseTab.tabKey});
|
|
1771
1703
|
}, 0);
|
|
1772
1704
|
}
|
|
1773
|
-
|
|
1705
|
+
|
|
1774
1706
|
if (!this.props.isNewVersionFlow) {
|
|
1775
1707
|
formData[tabIndex][val.id] = data1;
|
|
1776
1708
|
} else if (this.props.isNewVersionFlow && event !== "addLanguage" && event !== "onContentChange") {
|
|
1777
1709
|
formData[tabIndex][this.props.baseLanguage][val.id] = data1;
|
|
1778
1710
|
}
|
|
1779
|
-
|
|
1711
|
+
|
|
1780
1712
|
if (formData[tabIndex].base) {
|
|
1781
1713
|
if (!this.props.isNewVersionFlow) {
|
|
1782
1714
|
formData.base[val.id] = data1;
|
|
@@ -1787,35 +1719,30 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1787
1719
|
formData.base.selectedLanguages = formData[tabIndex].selectedLanguages;
|
|
1788
1720
|
}
|
|
1789
1721
|
}
|
|
1790
|
-
|
|
1791
1722
|
} else {
|
|
1792
1723
|
formData[val.id] = data;
|
|
1793
1724
|
}
|
|
1794
|
-
|
|
1725
|
+
|
|
1795
1726
|
if (this.props.isNewVersionFlow) {
|
|
1796
|
-
|
|
1797
1727
|
if (event === 'onSelect' && data === 'New Version') {
|
|
1798
1728
|
this.callChildEvent(data, val, 'addVersion', event);
|
|
1799
1729
|
} else if (event === 'onSelect' && data !== 'New Version') {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
1730
|
currentTab = _.findIndex(this.state.formData['template-version-options'], { key: data}) + 1;
|
|
1803
1731
|
this.setState({currentTab, tabKey: formData[`${currentTab - 1}`].tabKey}, () => {
|
|
1804
|
-
|
|
1805
1732
|
val.injectedEvents[event].call(this, this.state.formData['template-version-options'][currentTab - 1].key, formData, val);
|
|
1806
1733
|
});
|
|
1807
1734
|
}
|
|
1808
|
-
|
|
1735
|
+
|
|
1809
1736
|
if (event === 'onContentChange') {
|
|
1810
|
-
|
|
1737
|
+
|
|
1811
1738
|
// formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = data.editor.getData();
|
|
1812
1739
|
// if (formData[`${this.state.currentTab - 1}`].tabKey === formData.base.tabKey) {
|
|
1813
1740
|
// formData.base[formData[`${this.state.currentTab - 1}`].activeTab][`template-content`] = data.editor.getData();
|
|
1814
1741
|
//}
|
|
1815
1742
|
}
|
|
1816
1743
|
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1744
|
+
|
|
1745
|
+
|
|
1819
1746
|
this.setState({formData}, () => {
|
|
1820
1747
|
this.validateForm();
|
|
1821
1748
|
});
|
|
@@ -1830,7 +1757,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1830
1757
|
val.injectedEvents[event].call(this, true, formData, val);
|
|
1831
1758
|
}
|
|
1832
1759
|
} else if (!this.props.isNewVersionFlow) {
|
|
1833
|
-
|
|
1834
1760
|
val.injectedEvents[event].call(this, true, formData, val);
|
|
1835
1761
|
}
|
|
1836
1762
|
} else if (val.injectedEvents && val.injectedEvents.onChange) {
|
|
@@ -1838,7 +1764,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1838
1764
|
}
|
|
1839
1765
|
|
|
1840
1766
|
if (!((event === 'onSelect' && data === 'New Version') || event === 'onContentChange')) {
|
|
1841
|
-
|
|
1842
1767
|
this.props.onChange(formData, this.state.tabCount, currentTab);
|
|
1843
1768
|
}
|
|
1844
1769
|
}
|
|
@@ -1877,15 +1802,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1877
1802
|
}
|
|
1878
1803
|
return true;
|
|
1879
1804
|
};
|
|
1880
|
-
callChildEvent(data, val, event
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1805
|
+
callChildEvent(data, val, event) {
|
|
1884
1806
|
if (!event) {
|
|
1885
|
-
|
|
1886
1807
|
return;
|
|
1887
1808
|
}
|
|
1888
|
-
|
|
1809
|
+
|
|
1889
1810
|
const tab = this.state.tabCount;
|
|
1890
1811
|
// const parent = this._reactInternalInstance._currentElement._owner._instance;
|
|
1891
1812
|
if (event === 'onTabChange') {
|
|
@@ -1896,35 +1817,33 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1896
1817
|
const formData = _.cloneDeep(this.state.formData);
|
|
1897
1818
|
let activeTabIndex = '1';
|
|
1898
1819
|
const elems = document.getElementsByClassName("ant-tabs-tab");
|
|
1899
|
-
|
|
1820
|
+
|
|
1900
1821
|
for (let i = 0; i < elems.length; i += 1) {
|
|
1901
|
-
|
|
1902
1822
|
if (elems.item(i).classList.contains("ant-tabs-tab-active")) {
|
|
1903
1823
|
activeTabIndex = i + 1;
|
|
1904
1824
|
}
|
|
1905
1825
|
}
|
|
1906
|
-
|
|
1826
|
+
|
|
1907
1827
|
formData[(this.state.currentTab - 1)].activeTab = formData[(this.state.currentTab - 1)].selectedLanguages[activeTabIndex - 1];
|
|
1908
1828
|
formData[(this.state.currentTab - 1)].tabKey = `${data}`;
|
|
1909
1829
|
if (formData[(this.state.currentTab - 1)].base) {
|
|
1910
1830
|
formData.base.activeTab = formData[(this.state.currentTab - 1)].selectedLanguages[activeTabIndex - 1];
|
|
1911
1831
|
formData.base.tabKey = `${data}`;
|
|
1912
1832
|
}
|
|
1913
|
-
|
|
1833
|
+
|
|
1914
1834
|
that.setState({formData, currentLangTab: formData[(this.state.currentTab - 1)].activeTab, tabKey: formData[(this.state.currentTab - 1)][formData[(this.state.currentTab - 1)].activeTab].tabKey}, () => {
|
|
1915
1835
|
val.injectedEvents[event].call(that.props.parent, this.state.currentTab, formData);
|
|
1916
1836
|
});
|
|
1917
1837
|
} else {
|
|
1918
1838
|
let activeTabIndex = '1';
|
|
1919
1839
|
const elems = document.getElementsByClassName("ant-tabs-tab");
|
|
1920
|
-
|
|
1840
|
+
|
|
1921
1841
|
for (let i = 0; i < elems.length; i += 1) {
|
|
1922
|
-
|
|
1923
1842
|
if (elems.item(i).classList.contains("ant-tabs-tab-active")) {
|
|
1924
1843
|
activeTabIndex = i + 1;
|
|
1925
1844
|
}
|
|
1926
1845
|
}
|
|
1927
|
-
|
|
1846
|
+
|
|
1928
1847
|
that.setState({currentTab: activeTabIndex});
|
|
1929
1848
|
val.injectedEvents[event].call(that.props.parent, activeTabIndex);
|
|
1930
1849
|
}
|
|
@@ -1935,7 +1854,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1935
1854
|
this.setState({ popoverVisible: false });
|
|
1936
1855
|
const that = this;
|
|
1937
1856
|
setTimeout(() => {
|
|
1938
|
-
|
|
1939
1857
|
val.injectedEvents[event].call(that.props.parent, tab);
|
|
1940
1858
|
}, 0);
|
|
1941
1859
|
return;
|
|
@@ -1961,14 +1879,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1961
1879
|
_.forEach(formData[this.state.tabCount].selectedLanguages, (lang) => {
|
|
1962
1880
|
const tmptabData = formData[this.state.tabCount][lang];
|
|
1963
1881
|
_.forEach(formData[this.state.tabCount][lang], (tabData, index) => {
|
|
1964
|
-
|
|
1965
1882
|
if (index === 'tabKey') {
|
|
1966
1883
|
tmptabData.tabKey = _.uniqueId();
|
|
1967
1884
|
}
|
|
1968
1885
|
});
|
|
1969
1886
|
});
|
|
1970
1887
|
formData[this.state.tabCount].tabKey = formData[this.state.tabCount][formData[this.state.tabCount].activeTab].tabKey;
|
|
1971
|
-
|
|
1888
|
+
|
|
1972
1889
|
this.setState({formData, tabKey: formData[this.state.tabCount].tabKey}, () => {
|
|
1973
1890
|
val.injectedEvents[event].call(this.props.parent, formData, this.state.currentTab);
|
|
1974
1891
|
});
|
|
@@ -2021,24 +1938,24 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2021
1938
|
// };
|
|
2022
1939
|
// debugger;
|
|
2023
1940
|
// if (this.state.formData[`${this.state.currentTab - 1}`].activeTab === this.props.baseLanguage) {
|
|
2024
|
-
//
|
|
1941
|
+
//
|
|
2025
1942
|
// } else {
|
|
2026
1943
|
// const formData = _.cloneDeep(this.state.formData);
|
|
2027
1944
|
// const currentTab = `${this.state.currentTab - 1}`;
|
|
2028
1945
|
// const currentLang = formData[`${this.state.currentTab - 1}`].activeTab;
|
|
2029
1946
|
// const deleteLanguageIndex = formData[currentTab].selectedLanguages.indexOf(currentLang);
|
|
2030
|
-
//
|
|
1947
|
+
//
|
|
2031
1948
|
// delete formData[currentTab][currentLang];
|
|
2032
1949
|
// formData[currentTab].activeTab = this.props.baseLanguage;
|
|
2033
1950
|
// formData[currentTab].selectedLanguages.splice(deleteLanguageIndex, 1);
|
|
2034
|
-
//
|
|
1951
|
+
//
|
|
2035
1952
|
// this.setState({formData, currentLangTab: this.props.baseLanguage}, () => {
|
|
2036
1953
|
// val.injectedEvents[event].call(this.props.parent, formData, deleteLanguageIndex);
|
|
2037
1954
|
// });
|
|
2038
1955
|
// }
|
|
2039
1956
|
return;
|
|
2040
1957
|
}
|
|
2041
|
-
|
|
1958
|
+
|
|
2042
1959
|
val.injectedEvents[event].call(this.props.parent, data);
|
|
2043
1960
|
}
|
|
2044
1961
|
openFileDialog = () => {
|
|
@@ -2046,14 +1963,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2046
1963
|
};
|
|
2047
1964
|
handleOk = (ev) => {
|
|
2048
1965
|
const id = ev.target.id;
|
|
2049
|
-
|
|
1966
|
+
|
|
2050
1967
|
this.setState({showModal: false});
|
|
2051
1968
|
if (id === "android" && this.state.androidValid) {
|
|
2052
1969
|
this.props.onSubmit(this.state.formData);
|
|
2053
1970
|
} else if (id === "ios" && this.state.iosValid) {
|
|
2054
1971
|
this.props.onSubmit(this.state.formData);
|
|
2055
1972
|
} else if (id === "sms-version-modal") {
|
|
2056
|
-
|
|
2057
1973
|
this.state.currentEvent.call(this.props.parent, this.state.currentEventData, this.state.currentTab);
|
|
2058
1974
|
this.setState({currentEvent: {}, currentEventData: {}});
|
|
2059
1975
|
this.deleteVersion(false, this.state.currentTab);
|
|
@@ -2072,7 +1988,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2072
1988
|
query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport},
|
|
2073
1989
|
});
|
|
2074
1990
|
} else if (id === "email-language-delete-modal") {
|
|
2075
|
-
|
|
2076
1991
|
this.deleteLanguage();
|
|
2077
1992
|
this.props.handleCancelModal();
|
|
2078
1993
|
// this.setState({currentEvent: {}, currentEventData: {}});
|
|
@@ -2095,7 +2010,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2095
2010
|
}
|
|
2096
2011
|
};
|
|
2097
2012
|
handleConfirmations = () => {
|
|
2098
|
-
|
|
2099
2013
|
this.setState({showModal: true});
|
|
2100
2014
|
};
|
|
2101
2015
|
|
|
@@ -2126,7 +2040,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2126
2040
|
baseTab = i;
|
|
2127
2041
|
}
|
|
2128
2042
|
}
|
|
2129
|
-
|
|
2043
|
+
|
|
2130
2044
|
return baseTab;
|
|
2131
2045
|
};
|
|
2132
2046
|
|
|
@@ -2148,15 +2062,15 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2148
2062
|
}
|
|
2149
2063
|
const items = [];
|
|
2150
2064
|
data.map( (template) => {
|
|
2151
|
-
//
|
|
2065
|
+
//
|
|
2152
2066
|
const temp = {};
|
|
2153
2067
|
temp.id = template._id;
|
|
2154
2068
|
if (this.props.schema.channel.toLowerCase() === 'email') {
|
|
2155
|
-
//
|
|
2069
|
+
//
|
|
2156
2070
|
const imgSrc = template && template.versions && template.versions.base ? template.versions.base.preview_http_url : '';
|
|
2157
2071
|
const ifPreviewGenerated = template && template.versions && template.versions.base ? template.versions.base.isPreviewGenerated : 0;
|
|
2158
2072
|
const content = <img src={imgSrc || ''} alt="" />;
|
|
2159
|
-
|
|
2073
|
+
|
|
2160
2074
|
temp.content = (
|
|
2161
2075
|
<div
|
|
2162
2076
|
className="sms-template-content">
|
|
@@ -2206,7 +2120,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2206
2120
|
if (!val.onlyDisplay && !val.standalone && (!this.state.errorData[`${this.state.currentTab - 1}`] || (!this.state.errorData[`${this.state.currentTab - 1}`][val.id] && this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null))) {
|
|
2207
2121
|
return true;
|
|
2208
2122
|
}
|
|
2209
|
-
//
|
|
2123
|
+
//
|
|
2210
2124
|
columns.push(
|
|
2211
2125
|
<Col key="label" span={4}>
|
|
2212
2126
|
<Label style={val.labelStyle ? val.labelStyle : {}}>{val.label}</Label>
|
|
@@ -2232,12 +2146,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2232
2146
|
case "input":
|
|
2233
2147
|
if (styling === 'semantic') {
|
|
2234
2148
|
ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
|
|
2235
|
-
|
|
2149
|
+
|
|
2236
2150
|
columns.push(
|
|
2237
2151
|
<Col key={val.id} span={val.width}>
|
|
2238
2152
|
<CapInput
|
|
2239
2153
|
id={val.id}
|
|
2240
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2154
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2241
2155
|
className={`input-primary chart-name-input${ifError ? ' error' : ''}`}
|
|
2242
2156
|
// fluid={val.fluid}
|
|
2243
2157
|
style={val.style ? val.style : {}}
|
|
@@ -2270,7 +2184,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2270
2184
|
<TextArea
|
|
2271
2185
|
id={val.id}
|
|
2272
2186
|
className={`${ifError ? 'error' : ''}`}
|
|
2273
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2187
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2274
2188
|
autosize={val.autosize ? val.autosizeParams : false}
|
|
2275
2189
|
onChange={(e) => this.updateFormData(e.target.value, val)}
|
|
2276
2190
|
style={val.style ? val.style : {}}
|
|
@@ -2298,7 +2212,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2298
2212
|
<Col key="input" span={val.width} offset={val.offset}>
|
|
2299
2213
|
<CapCheckbox
|
|
2300
2214
|
className={`${ifError ? 'error' : ''}`}
|
|
2301
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2215
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2302
2216
|
style={val.style ? val.style : {}}
|
|
2303
2217
|
onChange={(e) => this.updateFormData(e, val)}
|
|
2304
2218
|
checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
|
|
@@ -2396,7 +2310,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2396
2310
|
}
|
|
2397
2311
|
break;
|
|
2398
2312
|
case "ckeditor":
|
|
2399
|
-
|
|
2313
|
+
|
|
2400
2314
|
columns.push(
|
|
2401
2315
|
<Col style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
2402
2316
|
<CKEditor
|
|
@@ -2421,11 +2335,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2421
2335
|
}
|
|
2422
2336
|
}
|
|
2423
2337
|
const edmSrc = this.state.formData[`${this.state.currentTab - 1}`][this.state.currentLangTab][`edmeditor${langTab > 1 ? langTab : ''}src`];
|
|
2424
|
-
|
|
2338
|
+
|
|
2425
2339
|
if (!edmSrc) {
|
|
2426
2340
|
return false;
|
|
2427
2341
|
}
|
|
2428
|
-
|
|
2342
|
+
|
|
2429
2343
|
columns.push(
|
|
2430
2344
|
<Col style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
2431
2345
|
<EDMEditor
|
|
@@ -2551,11 +2465,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2551
2465
|
const type = val.type;
|
|
2552
2466
|
const styling = val.styling;
|
|
2553
2467
|
const isVersionEnable = (this.state.usingTabContainer && !val.standalone);
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
}
|
|
2557
|
-
|
|
2558
|
-
|
|
2468
|
+
|
|
2469
|
+
|
|
2559
2470
|
if (!this.props.isNewVersionFlow && !val.standalone && !val.onlyDisplay && isVersionEnable && !this.state.formData[`${this.state.currentTab - 1}`]) {
|
|
2560
2471
|
return true;
|
|
2561
2472
|
}
|
|
@@ -2573,7 +2484,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2573
2484
|
this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null)))) {
|
|
2574
2485
|
return true;
|
|
2575
2486
|
}
|
|
2576
|
-
|
|
2487
|
+
|
|
2577
2488
|
let ifError = false;
|
|
2578
2489
|
if (val.primitive) {
|
|
2579
2490
|
if (val.id === "mark-final-version-label") {
|
|
@@ -2589,17 +2500,17 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2589
2500
|
);
|
|
2590
2501
|
return true;
|
|
2591
2502
|
}
|
|
2592
|
-
|
|
2503
|
+
|
|
2593
2504
|
switch (type) {
|
|
2594
2505
|
case "input":
|
|
2595
2506
|
ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
|
|
2596
|
-
|
|
2507
|
+
|
|
2597
2508
|
if (styling === 'semantic') {
|
|
2598
2509
|
columns.push(
|
|
2599
2510
|
<Col key={val.id} span={val.width}>
|
|
2600
2511
|
<CapInput
|
|
2601
2512
|
id={val.id}
|
|
2602
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2513
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2603
2514
|
className={`input-primary chart-name-input${ifError ? ' error' : ''}`}
|
|
2604
2515
|
// fluid={val.fluid}
|
|
2605
2516
|
style={val.style ? val.style : {}}
|
|
@@ -2634,7 +2545,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2634
2545
|
placeholder={val.placeholder ? val.placeholder : ''}
|
|
2635
2546
|
disabled={val.disabled}
|
|
2636
2547
|
className={`${ifError ? 'error' : ''}`}
|
|
2637
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2548
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2638
2549
|
autosize={val.autosize ? val.autosizeParams : false}
|
|
2639
2550
|
onChange={(e) => this.updateFormData(e.target.value, val)}
|
|
2640
2551
|
style={val.style ? val.style : {}}
|
|
@@ -2654,7 +2565,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2654
2565
|
<Col key="input" span={val.width} offset={val.offset}>
|
|
2655
2566
|
<CapCheckbox
|
|
2656
2567
|
className={`${ifError ? 'error' : ''}`}
|
|
2657
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2568
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2658
2569
|
onChange={(e) => this.updateFormData(e.target.checked, val)}
|
|
2659
2570
|
checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
|
|
2660
2571
|
defaultChecked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
|
|
@@ -2674,7 +2585,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2674
2585
|
<Col key={`input-${val.id}`} span={val.width} offset={val.offset}>
|
|
2675
2586
|
<CapRadio
|
|
2676
2587
|
className={`${ifError ? 'error' : ''}`}
|
|
2677
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2588
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2678
2589
|
onChange={(e) => this.updateFormData(e.target.checked, val)}
|
|
2679
2590
|
checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
|
|
2680
2591
|
defaultChecked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
|
|
@@ -2694,7 +2605,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2694
2605
|
<CapRadioGroup
|
|
2695
2606
|
key={`${val.id}-radio-group`}
|
|
2696
2607
|
className={`${ifError ? 'error' : ''}`}
|
|
2697
|
-
errorMessage={val.errorMessage ? val.errorMessage : ''}
|
|
2608
|
+
errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
|
|
2698
2609
|
onChange={(e) => this.updateFormData(e.target.value, val)}
|
|
2699
2610
|
style={val.style ? val.style : {}}
|
|
2700
2611
|
value={this.state.formData[`${self.state.currentTab - 1}`] && this.state.formData[`${self.state.currentTab - 1}`][val.id] !== "" ? this.state.formData[`${self.state.currentTab - 1}`][val.id] : val.value}
|
|
@@ -2806,7 +2717,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2806
2717
|
}
|
|
2807
2718
|
break;
|
|
2808
2719
|
case "line-preview": {
|
|
2809
|
-
|
|
2810
2720
|
const content = {
|
|
2811
2721
|
bodyText: isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][`message-editor${this.state.currentTab > 1 ? this.state.currentTab : ''}`] : this.state.formData[val.id],
|
|
2812
2722
|
bodyImage: this.state.formData[`${this.state.currentTab - 1}`].imagePreview,
|
|
@@ -2814,7 +2724,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2814
2724
|
if (!this.state.formData[`${this.state.currentTab - 1}`]) {
|
|
2815
2725
|
return true;
|
|
2816
2726
|
}
|
|
2817
|
-
|
|
2727
|
+
|
|
2818
2728
|
columns.push(
|
|
2819
2729
|
<Col key="input" span={23} offset={1}>
|
|
2820
2730
|
<TemplatePreview
|
|
@@ -2942,10 +2852,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2942
2852
|
if (val.id.indexOf('template-content') > -1 && val.id !== 'template-content') {
|
|
2943
2853
|
langIndex = parseInt(val.id.replace('template-content', ''), 10) - 1;
|
|
2944
2854
|
}
|
|
2945
|
-
|
|
2855
|
+
|
|
2946
2856
|
const currentLang = (!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage;
|
|
2947
2857
|
const content = (!_.isEmpty(this.state.formData) && this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] ? this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] : '');
|
|
2948
|
-
|
|
2858
|
+
|
|
2949
2859
|
if (this.state.formData[`${this.state.currentTab - 1}`][currentLang].is_drag_drop) {
|
|
2950
2860
|
// content = "";
|
|
2951
2861
|
}
|
|
@@ -2968,9 +2878,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2968
2878
|
// }
|
|
2969
2879
|
let langTab = 1;
|
|
2970
2880
|
if (val.id.match(/edmeditor/g)) {
|
|
2971
|
-
|
|
2972
2881
|
if (val.id.length > 9 && val.id.charAt(9)) {
|
|
2973
|
-
|
|
2974
2882
|
langTab = val.id.charAt(9);
|
|
2975
2883
|
}
|
|
2976
2884
|
}
|
|
@@ -2983,13 +2891,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2983
2891
|
// const currentLang = (!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage;
|
|
2984
2892
|
const currentLang = supportedLanguages[langTab - 1];
|
|
2985
2893
|
const edmSrc = this.state.formData[`${this.state.currentTab - 1}`][currentLang] && this.state.formData[`${this.state.currentTab - 1}`][currentLang][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`];
|
|
2986
|
-
|
|
2987
|
-
|
|
2894
|
+
|
|
2895
|
+
|
|
2988
2896
|
if (!edmSrc) {
|
|
2989
2897
|
return false;
|
|
2990
2898
|
}
|
|
2991
|
-
|
|
2992
|
-
|
|
2899
|
+
|
|
2900
|
+
|
|
2993
2901
|
columns.push(
|
|
2994
2902
|
<Col style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
2995
2903
|
<EDMEditor
|
|
@@ -3101,7 +3009,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3101
3009
|
result = this.renderSection(section, paneIndex);
|
|
3102
3010
|
return result;
|
|
3103
3011
|
});
|
|
3104
|
-
|
|
3012
|
+
|
|
3105
3013
|
const sectionHeadeers = pane.sectionsHeaders ? pane.sectionsHeaders : container.tabContent && container.tabContent.sections;
|
|
3106
3014
|
renderedContentSections = sectionHeadeers.map( (tabContentSection) => {
|
|
3107
3015
|
result = this.renderSection(tabContentSection, paneIndex);
|
|
@@ -3120,7 +3028,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3120
3028
|
const currentLang = this.state.formData[this.state.currentTab - 1].selectedLanguages[index];
|
|
3121
3029
|
paneTabKey = this.state.formData[this.state.currentTab - 1] && this.state.formData[this.state.currentTab - 1][currentLang] && this.state.formData[this.state.currentTab - 1][currentLang].tabKey;
|
|
3122
3030
|
}
|
|
3123
|
-
|
|
3031
|
+
|
|
3124
3032
|
renderedPanes.push(
|
|
3125
3033
|
<TabPane
|
|
3126
3034
|
forceRender
|
|
@@ -3209,9 +3117,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3209
3117
|
}
|
|
3210
3118
|
return null;
|
|
3211
3119
|
});
|
|
3212
|
-
|
|
3120
|
+
|
|
3213
3121
|
allElements.push(renderedContainers);
|
|
3214
|
-
|
|
3122
|
+
|
|
3215
3123
|
const modal = this.getModal();
|
|
3216
3124
|
allElements.push(modal);
|
|
3217
3125
|
}
|
|
@@ -3231,7 +3139,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3231
3139
|
</CardGrid>
|
|
3232
3140
|
);
|
|
3233
3141
|
|
|
3234
|
-
|
|
3142
|
+
|
|
3235
3143
|
return (
|
|
3236
3144
|
<Row>
|
|
3237
3145
|
{
|