@capillarytech/creatives-library 2.0.36 → 2.0.38

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.
@@ -10,8 +10,8 @@ import PropTypes from 'prop-types';
10
10
  import React from 'react';
11
11
  import { Label } from 'semantic-ui-react';
12
12
  import _ from 'lodash';
13
- import { Tabs, Row, Col, Table, Modal, notification} from 'antd';
14
- import { CapButton, CapInput, CapPopover, CapCheckbox, CapRadio, CapSelect, CapTable, CapColumn} from '@capillarytech/cap-ui-library';
13
+ import { Tabs, Row, Col, Table, Modal} from 'antd';
14
+ import { CapButton, CapInput, CapPopover, CapCheckbox, CapRadio, CapSelect, CapTable, CapColumn, CapNotification} from '@capillarytech/cap-ui-library';
15
15
  import TemplatePreview from '../../components/TemplatePreview';
16
16
  import TagList from '../../containers/TagList';
17
17
  import SmsEditor from '../SmsEditor';
@@ -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(data, e) {
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}
@@ -324,16 +299,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
324
299
  };
325
300
 
326
301
  openNotificationWithIcon = (type, message) => {
327
- const dur = (type === 'error' || type === 'warning') ? null : 5;
328
- notification[type]({
302
+ CapNotification.error({
329
303
  message: (`${type.toUpperCase()} ! ! ! `),
330
304
  description: message, //'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
331
- duration: dur,
332
305
  });
333
306
  }
334
307
 
335
- handleCloseModal = (data, e) => {
336
-
308
+ handleCloseModal = (data) => {
337
309
  const event = this.state.currentEvent;
338
310
  if (!_.isEmpty(this.state.currentEvent)) {
339
311
  switch (event) {
@@ -356,8 +328,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
356
328
 
357
329
  resetTabKeys(form, count, changeDefaultTab, setFormTabKey) {
358
330
  const tabCount = count || this.state.tabCount;
359
-
360
-
331
+
332
+
361
333
  const formData = _.cloneDeep(form);
362
334
  let baseIndex = 0;
363
335
  for (let idx = 0; idx < tabCount; idx += 1) {
@@ -376,64 +348,53 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
376
348
  if (setFormTabKey) {
377
349
  if (!formData[idx].activeTab) {
378
350
  const baseLanguage = this.props.baseLanguage;
379
-
351
+
380
352
  formData[idx].tabKey = formData[idx][baseLanguage].tabKey;
381
353
  } else {
382
-
383
354
  formData[idx].tabKey = formData[idx][formData[idx].activeTab].tabKey;
384
355
  }
385
356
  if (formData[idx].base) {
386
357
  if (!formData.base.activeTab) {
387
-
388
358
  const baseLanguage = this.props.baseLanguage;
389
359
  formData.base.tabKey = formData.base[baseLanguage].tabKey;
390
360
  } else {
391
-
392
361
  formData.base.tabKey = formData.base[formData[idx].activeTab].tabKey;
393
362
  }
394
363
  }
395
364
  }
396
-
365
+
397
366
  if (formData[idx].base && formData.base.activeTab) {
398
-
399
367
  // if (!formData.base.tabKey) {
400
-
368
+
401
369
  formData.base.tabKey = formData[idx][formData[idx].activeTab].tabKey;
402
370
  //}
403
371
  baseIndex = idx;
404
372
  }
405
- } else {
406
-
407
- if (formData[idx]) {
408
- if (!formData[idx].tabKey) {
409
- formData[idx].tabKey = _.uniqueId();
410
- }
411
- if (formData[idx].base) {
412
- formData.base = formData[idx];
413
- baseIndex = idx;
414
- }
373
+ } else if (formData[idx]) {
374
+ if (!formData[idx].tabKey) {
375
+ formData[idx].tabKey = _.uniqueId();
376
+ }
377
+ if (formData[idx].base) {
378
+ formData.base = formData[idx];
379
+ baseIndex = idx;
415
380
  }
416
381
  }
417
382
  }
418
-
383
+
419
384
  if ((formData.base && formData.base.tabKey && formData.base.tabKey !== '' && !changeDefaultTab) || (formData.base && this.state.tabKey !== formData.base.tabKey)) {
420
-
421
385
  if (this.state.currentTab === 1 && !this.props.isNewVersionFlow) {
422
386
  this.setState({tabKey: formData.base.tabKey});
423
387
  } else if (this.props.isNewVersionFlow && this.state.tabKey !== formData[this.state.currentTab - 1].tabKey) {
424
-
425
388
  this.setState({tabKey: formData[this.state.currentTab - 1].tabKey});
426
389
  }
427
390
  }
428
391
  if (setFormTabKey) {
429
-
430
392
  this.setState({tabKey: formData.base.tabKey});
431
393
  }
432
-
433
-
394
+
395
+
434
396
  if (changeDefaultTab) {
435
397
  this.setState({formData}, () => {
436
-
437
398
  this.props.onChange(formData, this.state.tabCount);
438
399
  this.validateForm();
439
400
  });
@@ -1105,15 +1066,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1105
1066
  this.setState({errorData});
1106
1067
  }
1107
1068
 
1108
- initializeMultiColSection(section, formDataObj, isContainer, index, ifError, paneIndex) {
1109
-
1069
+ initializeMultiColSection(section, formDataObj, isContainer, index, ifError) {
1110
1070
  const formData = _.cloneDeep(formDataObj);
1111
1071
  const newFormData = {};
1112
1072
  newFormData[index] = {};
1113
1073
  _.forEach(section.inputFields, (inputField) => {
1114
-
1115
1074
  _.forEach(inputField.cols, (col) => {
1116
-
1117
1075
  if (isContainer && !formData[index]) {
1118
1076
  formData[index] = {};
1119
1077
  }
@@ -1153,24 +1111,20 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1153
1111
  } else if (!isContainer && !ifError && formData[col.id] === undefined) {
1154
1112
  formData[col.id] = '';
1155
1113
  }
1156
- } else {
1157
-
1158
- if (!(col.id.indexOf('template-content') > -1 && col.id !== 'template-content')) {
1159
- if (isContainer && formData[index] && formData[index][this.props.baseLanguage] && formData[index][this.props.baseLanguage][col.id] === undefined) {
1160
- if (ifError) {
1161
- formData[index][this.props.baseLanguage][col.id] = false;
1162
- } else if (isContainer && formData[index][this.props.baseLanguage][col.id] === undefined && col.value) {
1163
- formData[index][this.props.baseLanguage][col.id] = col.value;
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] = '';
1114
+ } else if (!(col.id.indexOf('template-content') > -1 && col.id !== 'template-content')) {
1115
+ if (isContainer && formData[index] && formData[index][this.props.baseLanguage] && formData[index][this.props.baseLanguage][col.id] === undefined) {
1116
+ if (ifError) {
1117
+ formData[index][this.props.baseLanguage][col.id] = false;
1118
+ } else if (isContainer && formData[index][this.props.baseLanguage][col.id] === undefined && col.value) {
1119
+ formData[index][this.props.baseLanguage][col.id] = col.value;
1120
+ } else {
1121
+ formData[index][this.props.baseLanguage][col.id] = '';
1171
1122
  }
1123
+ } else if (!isContainer && ifError && formData[col.id] === undefined) {
1124
+ formData[col.id] = false;
1125
+ } else if (!isContainer && !ifError && formData[col.id] === undefined) {
1126
+ formData[col.id] = '';
1172
1127
  }
1173
-
1174
1128
  }
1175
1129
  }
1176
1130
  if (col.type === 'checkbox') {
@@ -1247,12 +1201,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1247
1201
  if (this.props.isNewVersionFlow) {
1248
1202
  _.forEach(schema.containers, (val, index) => {
1249
1203
  if (val.type === 'tabs') {
1250
-
1251
1204
  this.setState({usingTabContainer: true});
1252
1205
  _.forEach(val.panes, (pane, paneIndex) => {
1253
1206
  _.forEach(pane.sections, (section) => {
1254
1207
  if (section.type === 'multicols') {
1255
-
1256
1208
  formData = this.initializeMultiColSection(section, formData, true, index, ifError, paneIndex);
1257
1209
  } else if (section.type === 'col-label') {
1258
1210
  formData = this.initializeColLabelSection(section, formData, true, index, ifError);
@@ -1273,12 +1225,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1273
1225
  } else {
1274
1226
  _.forEach(schema.containers, (val) => {
1275
1227
  if (val.type === 'tabs') {
1276
-
1277
1228
  this.setState({usingTabContainer: true});
1278
1229
  _.forEach(val.panes, (pane, index) => {
1279
1230
  _.forEach(pane.sections, (section) => {
1280
1231
  if (section.type === 'multicols') {
1281
-
1282
1232
  formData = this.initializeMultiColSection(section, formData, true, index, ifError);
1283
1233
  } else if (section.type === 'col-label') {
1284
1234
  formData = this.initializeColLabelSection(section, formData, true, index, ifError);
@@ -1301,8 +1251,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1301
1251
  }
1302
1252
 
1303
1253
  initialiseForm(schema, makeFormEmpty, resetTabKeys) {
1304
-
1305
-
1306
1254
  let formData = makeFormEmpty ? {} : _.cloneDeep(this.state.formData);
1307
1255
  let errorData = {};
1308
1256
  this.formElements = [];
@@ -1314,7 +1262,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1314
1262
  formData = this.initializeContainers(schema, formData);
1315
1263
  errorData = this.initializeContainers(schema, errorData, true);
1316
1264
 
1317
-
1265
+
1318
1266
  if (!this.props.isEdit) {
1319
1267
  if (!formData[0]) {
1320
1268
  formData[0] = {};
@@ -1354,7 +1302,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1354
1302
  }
1355
1303
 
1356
1304
  cloneVersionData(ifError) {
1357
-
1358
1305
  if (this.state.tabCount === 0) {
1359
1306
  this.initialiseForm(this.props.schema, true);
1360
1307
  return;
@@ -1372,10 +1319,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1372
1319
  newTabIndex = this.state.tabCount;
1373
1320
  }
1374
1321
  formData[newTabIndex] = {};
1375
-
1322
+
1376
1323
  const newTabCount = newTabIndex + 1;
1377
1324
  _.forEach(formData[0], (val, key) => {
1378
-
1379
1325
  if (key === 'base') {
1380
1326
  return true;
1381
1327
  }
@@ -1385,17 +1331,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1385
1331
  if (typeof val === 'string') {
1386
1332
  if (ifError) {
1387
1333
  formData[newTabIndex][`${key}${newTabCount}`] = false;
1388
- } else {
1389
-
1390
- if (this.props.isNewVersionFlow) {
1391
- if (key.indexOf('activeTab') > -1) {
1392
- formData[newTabIndex][`${key}`] = this.props.baseLanguage;
1393
- } else {
1394
- formData[newTabIndex][`${key}${newTabCount}`] = '';
1395
- }
1334
+ } else if (this.props.isNewVersionFlow) {
1335
+ if (key.indexOf('activeTab') > -1) {
1336
+ formData[newTabIndex][`${key}`] = this.props.baseLanguage;
1396
1337
  } else {
1397
1338
  formData[newTabIndex][`${key}${newTabCount}`] = '';
1398
1339
  }
1340
+ } else {
1341
+ formData[newTabIndex][`${key}${newTabCount}`] = '';
1399
1342
  }
1400
1343
  } else if (typeof val === 'boolean') {
1401
1344
  formData[newTabIndex][`${key}${newTabCount}`] = false;
@@ -1403,31 +1346,26 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1403
1346
  if (this.props.isNewVersionFlow) {
1404
1347
  if (key.indexOf('selectedLanguages') > -1) {
1405
1348
  formData[newTabIndex][key] = [this.props.baseLanguage];
1406
- } else {
1407
-
1408
- if (key === this.props.baseLanguage) {
1409
- formData[newTabIndex][key] = {};
1410
- _.forEach(val, (subVal, index) => {
1411
-
1349
+ } else if (key === this.props.baseLanguage) {
1350
+ formData[newTabIndex][key] = {};
1351
+ _.forEach(val, (subVal, index) => {
1412
1352
  // if (subVal === 'is_drag_drop' || subVal === 'lang_id' || subVal === 'iso_code' === 'language') {
1413
- //
1353
+ //
1414
1354
  // formData[newTabIndex][key][index] = formData[0][this.props.baseLanguage][subVal];
1415
1355
  // } else {
1416
- if (index === 'tabKey') {
1417
- formData[newTabIndex][key][index] = _.uniqueId();
1418
- } else if (index === 'template-content') {
1419
- formData[newTabIndex][key][index] = "";
1420
- } else {
1421
- formData[newTabIndex][key][index] = _.cloneDeep(formData[0][key][index]);
1422
- }
1356
+ if (index === 'tabKey') {
1357
+ formData[newTabIndex][key][index] = _.uniqueId();
1358
+ } else if (index === 'template-content') {
1359
+ formData[newTabIndex][key][index] = "";
1360
+ } else {
1361
+ formData[newTabIndex][key][index] = _.cloneDeep(formData[0][key][index]);
1362
+ }
1423
1363
  // }
1424
- });
1425
- }
1364
+ });
1426
1365
  }
1427
1366
  } else {
1428
1367
  formData[newTabIndex][key] = {};
1429
1368
  _.forEach(val, (subVal, index) => {
1430
-
1431
1369
  formData[newTabIndex][key][index] = '';
1432
1370
  });
1433
1371
  }
@@ -1435,7 +1373,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1435
1373
  return true;
1436
1374
  });
1437
1375
  let id = (this.props.isNewVersionFlow && formData[newTabIndex][this.props.baseLanguage].tabKey) ? formData[newTabIndex][this.props.baseLanguage].tabKey : _.uniqueId();
1438
-
1376
+
1439
1377
  if (!ifError) {
1440
1378
  let validId = false;
1441
1379
  while (!validId) {
@@ -1454,12 +1392,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1454
1392
  }
1455
1393
  // if (!this.props.isEdit) {
1456
1394
  if (ifError) {
1457
-
1458
1395
  this.setState({errorData: formData});
1459
1396
  } else {
1460
-
1461
1397
  this.props.onChange(formData, newTabCount, newTabIndex + 1);
1462
-
1398
+
1463
1399
  this.setState({tabCount: newTabCount, formData, currentTab: newTabIndex + 1, tabKey: id}, () => {
1464
1400
  this.cloneVersionData(true);
1465
1401
  });
@@ -1477,7 +1413,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1477
1413
  markFinalTabVersion() {
1478
1414
  const formData = _.cloneDeep(this.state.formData);
1479
1415
  if (this.state.usingTabContainer) {
1480
-
1481
1416
  for (let count = 0; count < this.state.tabCount; count += 1) {
1482
1417
  if (parseInt(this.state.currentTab - 1, 10) !== count) {
1483
1418
  formData[count].base = false;
@@ -1502,7 +1437,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1502
1437
  tabKey: '',
1503
1438
  }, () => {
1504
1439
  if (!isEdit) {
1505
-
1506
1440
  this.initialiseForm(this.props.schema, true);
1507
1441
  }
1508
1442
  });
@@ -1578,9 +1512,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1578
1512
  }
1579
1513
 
1580
1514
  deleteVersion(ifError, currentTab) {
1581
-
1582
1515
  if (!ifError && this.state.tabCount === 1) {
1583
-
1584
1516
  return;
1585
1517
  }
1586
1518
  let formData = {};
@@ -1600,7 +1532,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1600
1532
  if (tabCount > 1 && currentTab !== tabCount) {
1601
1533
  finalActiveTabKey = formData[currentTab].tabKey;
1602
1534
  }
1603
-
1535
+
1604
1536
  if (tabCount > 1 && currentTab === tabCount) {
1605
1537
  finalActiveTabKey = formData[currentTab - 2].tabKey;
1606
1538
  finalCurrentTab = currentTab - 1;
@@ -1649,14 +1581,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1649
1581
 
1650
1582
  deleteLanguage = () => {
1651
1583
  if (this.state.formData[`${this.state.currentTab - 1}`].activeTab === this.props.baseLanguage) {
1652
-
1584
+
1653
1585
  } else {
1654
1586
  const formData = _.cloneDeep(this.state.formData);
1655
1587
  const currentTab = `${this.state.currentTab - 1}`;
1656
1588
  const currentLang = formData[`${this.state.currentTab - 1}`].activeTab;
1657
1589
  const deleteLanguageIndex = formData[currentTab].selectedLanguages.indexOf(currentLang);
1658
1590
  const baseLangTabKey = formData[currentTab][this.props.baseLanguage].tabKey;
1659
-
1591
+
1660
1592
  delete formData[currentTab][currentLang];
1661
1593
  formData[currentTab].activeTab = this.props.baseLanguage;
1662
1594
  formData[currentTab].selectedLanguages.splice(deleteLanguageIndex, 1);
@@ -1667,7 +1599,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1667
1599
  formData.base.tabKey = baseLangTabKey;
1668
1600
  formData.base.activeTab = this.props.baseLanguage;
1669
1601
  }
1670
-
1602
+
1671
1603
  this.setState({formData, currentLangTab: this.props.baseLanguage, tabKey: baseLangTabKey}, () => {
1672
1604
  this.state.currentEvent.call(this.props.parent, formData, deleteLanguageIndex);
1673
1605
  this.setState({currentEvent: {}, currentEventData: {}});
@@ -1676,18 +1608,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1676
1608
  };
1677
1609
 
1678
1610
  renameVersion(currentTab) {
1679
-
1680
1611
  document.getElementById(`tab-header${currentTab > 1 ? currentTab : ''}`).contentEditable = "true";
1681
1612
  document.getElementById(`tab-header${currentTab > 1 ? currentTab : ''}`).focus();
1682
1613
  }
1683
1614
 
1684
1615
  updateFormData(data, val, event) {
1685
-
1686
1616
  const formData = _.cloneDeep(this.state.formData);
1687
-
1617
+
1688
1618
  const tabIndex = this.state.currentTab - 1;
1689
1619
  let currentTab = _.cloneDeep(this.state.currentTab);
1690
-
1620
+
1691
1621
  if (this.state.usingTabContainer && !val.standalone) {
1692
1622
  const data1 = data;
1693
1623
  if (event === "addLanguage") {
@@ -1702,7 +1632,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1702
1632
  switch (addLanguageType) {
1703
1633
  case "upload":
1704
1634
  baseTab = _.cloneDeep(formData[tabIndex][currentLang]);
1705
-
1635
+
1706
1636
  baseTab.iso_code = data.iso_code;
1707
1637
  baseTab.lang_id = data.lang_id;
1708
1638
  baseTab.language = data.language;
@@ -1712,7 +1642,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1712
1642
  if (!formData[tabIndex]) {
1713
1643
  continue;
1714
1644
  }
1715
-
1645
+
1716
1646
  if (id === formData[tabIndex][formData[tabIndex].selectedLanguages[idx]].tabKey) {
1717
1647
  validId = false;
1718
1648
  }
@@ -1725,14 +1655,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1725
1655
  baseTab.tabKey = id;
1726
1656
  //formData[tabIndex].selectedLanguages.push(data.iso_code);
1727
1657
  formData[tabIndex][data.iso_code] = baseTab;
1728
-
1658
+
1729
1659
  formData[tabIndex].activeTab = data.iso_code;
1730
1660
  formData[tabIndex].tabKey = baseTab.tabKey;
1731
1661
  break;
1732
1662
  case "copyPrimaryLanguage":
1733
1663
  case "useEditor":
1734
1664
  baseTab = _.cloneDeep(formData[tabIndex][this.props.baseLanguage]);
1735
-
1665
+
1736
1666
  //baseTab['template-content'] = '';
1737
1667
  baseTab.iso_code = data.iso_code;
1738
1668
  baseTab.lang_id = data.lang_id;
@@ -1756,7 +1686,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1756
1686
  baseTab.tabKey = id;
1757
1687
  formData[tabIndex].selectedLanguages.push(data.iso_code);
1758
1688
  formData[tabIndex][data.iso_code] = baseTab;
1759
-
1689
+
1760
1690
  formData[tabIndex].activeTab = data.iso_code;
1761
1691
  formData[tabIndex].tabKey = baseTab.tabKey;
1762
1692
  break;
@@ -1770,13 +1700,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1770
1700
  that.setState({tabKey: baseTab.tabKey});
1771
1701
  }, 0);
1772
1702
  }
1773
-
1703
+
1774
1704
  if (!this.props.isNewVersionFlow) {
1775
1705
  formData[tabIndex][val.id] = data1;
1776
1706
  } else if (this.props.isNewVersionFlow && event !== "addLanguage" && event !== "onContentChange") {
1777
1707
  formData[tabIndex][this.props.baseLanguage][val.id] = data1;
1778
1708
  }
1779
-
1709
+
1780
1710
  if (formData[tabIndex].base) {
1781
1711
  if (!this.props.isNewVersionFlow) {
1782
1712
  formData.base[val.id] = data1;
@@ -1787,35 +1717,30 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1787
1717
  formData.base.selectedLanguages = formData[tabIndex].selectedLanguages;
1788
1718
  }
1789
1719
  }
1790
-
1791
1720
  } else {
1792
1721
  formData[val.id] = data;
1793
1722
  }
1794
-
1723
+
1795
1724
  if (this.props.isNewVersionFlow) {
1796
-
1797
1725
  if (event === 'onSelect' && data === 'New Version') {
1798
1726
  this.callChildEvent(data, val, 'addVersion', event);
1799
1727
  } else if (event === 'onSelect' && data !== 'New Version') {
1800
-
1801
-
1802
1728
  currentTab = _.findIndex(this.state.formData['template-version-options'], { key: data}) + 1;
1803
1729
  this.setState({currentTab, tabKey: formData[`${currentTab - 1}`].tabKey}, () => {
1804
-
1805
1730
  val.injectedEvents[event].call(this, this.state.formData['template-version-options'][currentTab - 1].key, formData, val);
1806
1731
  });
1807
1732
  }
1808
-
1733
+
1809
1734
  if (event === 'onContentChange') {
1810
-
1735
+
1811
1736
  // formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = data.editor.getData();
1812
1737
  // if (formData[`${this.state.currentTab - 1}`].tabKey === formData.base.tabKey) {
1813
1738
  // formData.base[formData[`${this.state.currentTab - 1}`].activeTab][`template-content`] = data.editor.getData();
1814
1739
  //}
1815
1740
  }
1816
1741
  }
1817
-
1818
-
1742
+
1743
+
1819
1744
  this.setState({formData}, () => {
1820
1745
  this.validateForm();
1821
1746
  });
@@ -1830,7 +1755,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1830
1755
  val.injectedEvents[event].call(this, true, formData, val);
1831
1756
  }
1832
1757
  } else if (!this.props.isNewVersionFlow) {
1833
-
1834
1758
  val.injectedEvents[event].call(this, true, formData, val);
1835
1759
  }
1836
1760
  } else if (val.injectedEvents && val.injectedEvents.onChange) {
@@ -1838,7 +1762,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1838
1762
  }
1839
1763
 
1840
1764
  if (!((event === 'onSelect' && data === 'New Version') || event === 'onContentChange')) {
1841
-
1842
1765
  this.props.onChange(formData, this.state.tabCount, currentTab);
1843
1766
  }
1844
1767
  }
@@ -1877,15 +1800,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1877
1800
  }
1878
1801
  return true;
1879
1802
  };
1880
- callChildEvent(data, val, event, e) {
1881
-
1882
-
1883
-
1803
+ callChildEvent(data, val, event) {
1884
1804
  if (!event) {
1885
-
1886
1805
  return;
1887
1806
  }
1888
-
1807
+
1889
1808
  const tab = this.state.tabCount;
1890
1809
  // const parent = this._reactInternalInstance._currentElement._owner._instance;
1891
1810
  if (event === 'onTabChange') {
@@ -1896,35 +1815,33 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1896
1815
  const formData = _.cloneDeep(this.state.formData);
1897
1816
  let activeTabIndex = '1';
1898
1817
  const elems = document.getElementsByClassName("ant-tabs-tab");
1899
-
1818
+
1900
1819
  for (let i = 0; i < elems.length; i += 1) {
1901
-
1902
1820
  if (elems.item(i).classList.contains("ant-tabs-tab-active")) {
1903
1821
  activeTabIndex = i + 1;
1904
1822
  }
1905
1823
  }
1906
-
1824
+
1907
1825
  formData[(this.state.currentTab - 1)].activeTab = formData[(this.state.currentTab - 1)].selectedLanguages[activeTabIndex - 1];
1908
1826
  formData[(this.state.currentTab - 1)].tabKey = `${data}`;
1909
1827
  if (formData[(this.state.currentTab - 1)].base) {
1910
1828
  formData.base.activeTab = formData[(this.state.currentTab - 1)].selectedLanguages[activeTabIndex - 1];
1911
1829
  formData.base.tabKey = `${data}`;
1912
1830
  }
1913
-
1831
+
1914
1832
  that.setState({formData, currentLangTab: formData[(this.state.currentTab - 1)].activeTab, tabKey: formData[(this.state.currentTab - 1)][formData[(this.state.currentTab - 1)].activeTab].tabKey}, () => {
1915
1833
  val.injectedEvents[event].call(that.props.parent, this.state.currentTab, formData);
1916
1834
  });
1917
1835
  } else {
1918
1836
  let activeTabIndex = '1';
1919
1837
  const elems = document.getElementsByClassName("ant-tabs-tab");
1920
-
1838
+
1921
1839
  for (let i = 0; i < elems.length; i += 1) {
1922
-
1923
1840
  if (elems.item(i).classList.contains("ant-tabs-tab-active")) {
1924
1841
  activeTabIndex = i + 1;
1925
1842
  }
1926
1843
  }
1927
-
1844
+
1928
1845
  that.setState({currentTab: activeTabIndex});
1929
1846
  val.injectedEvents[event].call(that.props.parent, activeTabIndex);
1930
1847
  }
@@ -1935,7 +1852,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1935
1852
  this.setState({ popoverVisible: false });
1936
1853
  const that = this;
1937
1854
  setTimeout(() => {
1938
-
1939
1855
  val.injectedEvents[event].call(that.props.parent, tab);
1940
1856
  }, 0);
1941
1857
  return;
@@ -1961,14 +1877,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1961
1877
  _.forEach(formData[this.state.tabCount].selectedLanguages, (lang) => {
1962
1878
  const tmptabData = formData[this.state.tabCount][lang];
1963
1879
  _.forEach(formData[this.state.tabCount][lang], (tabData, index) => {
1964
-
1965
1880
  if (index === 'tabKey') {
1966
1881
  tmptabData.tabKey = _.uniqueId();
1967
1882
  }
1968
1883
  });
1969
1884
  });
1970
1885
  formData[this.state.tabCount].tabKey = formData[this.state.tabCount][formData[this.state.tabCount].activeTab].tabKey;
1971
-
1886
+
1972
1887
  this.setState({formData, tabKey: formData[this.state.tabCount].tabKey}, () => {
1973
1888
  val.injectedEvents[event].call(this.props.parent, formData, this.state.currentTab);
1974
1889
  });
@@ -2021,24 +1936,24 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2021
1936
  // };
2022
1937
  // debugger;
2023
1938
  // if (this.state.formData[`${this.state.currentTab - 1}`].activeTab === this.props.baseLanguage) {
2024
- //
1939
+ //
2025
1940
  // } else {
2026
1941
  // const formData = _.cloneDeep(this.state.formData);
2027
1942
  // const currentTab = `${this.state.currentTab - 1}`;
2028
1943
  // const currentLang = formData[`${this.state.currentTab - 1}`].activeTab;
2029
1944
  // const deleteLanguageIndex = formData[currentTab].selectedLanguages.indexOf(currentLang);
2030
- //
1945
+ //
2031
1946
  // delete formData[currentTab][currentLang];
2032
1947
  // formData[currentTab].activeTab = this.props.baseLanguage;
2033
1948
  // formData[currentTab].selectedLanguages.splice(deleteLanguageIndex, 1);
2034
- //
1949
+ //
2035
1950
  // this.setState({formData, currentLangTab: this.props.baseLanguage}, () => {
2036
1951
  // val.injectedEvents[event].call(this.props.parent, formData, deleteLanguageIndex);
2037
1952
  // });
2038
1953
  // }
2039
1954
  return;
2040
1955
  }
2041
-
1956
+
2042
1957
  val.injectedEvents[event].call(this.props.parent, data);
2043
1958
  }
2044
1959
  openFileDialog = () => {
@@ -2046,14 +1961,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2046
1961
  };
2047
1962
  handleOk = (ev) => {
2048
1963
  const id = ev.target.id;
2049
-
1964
+
2050
1965
  this.setState({showModal: false});
2051
1966
  if (id === "android" && this.state.androidValid) {
2052
1967
  this.props.onSubmit(this.state.formData);
2053
1968
  } else if (id === "ios" && this.state.iosValid) {
2054
1969
  this.props.onSubmit(this.state.formData);
2055
1970
  } else if (id === "sms-version-modal") {
2056
-
2057
1971
  this.state.currentEvent.call(this.props.parent, this.state.currentEventData, this.state.currentTab);
2058
1972
  this.setState({currentEvent: {}, currentEventData: {}});
2059
1973
  this.deleteVersion(false, this.state.currentTab);
@@ -2072,7 +1986,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2072
1986
  query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport},
2073
1987
  });
2074
1988
  } else if (id === "email-language-delete-modal") {
2075
-
2076
1989
  this.deleteLanguage();
2077
1990
  this.props.handleCancelModal();
2078
1991
  // this.setState({currentEvent: {}, currentEventData: {}});
@@ -2095,7 +2008,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2095
2008
  }
2096
2009
  };
2097
2010
  handleConfirmations = () => {
2098
-
2099
2011
  this.setState({showModal: true});
2100
2012
  };
2101
2013
 
@@ -2126,7 +2038,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2126
2038
  baseTab = i;
2127
2039
  }
2128
2040
  }
2129
-
2041
+
2130
2042
  return baseTab;
2131
2043
  };
2132
2044
 
@@ -2148,15 +2060,15 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2148
2060
  }
2149
2061
  const items = [];
2150
2062
  data.map( (template) => {
2151
- //
2063
+ //
2152
2064
  const temp = {};
2153
2065
  temp.id = template._id;
2154
2066
  if (this.props.schema.channel.toLowerCase() === 'email') {
2155
- //
2067
+ //
2156
2068
  const imgSrc = template && template.versions && template.versions.base ? template.versions.base.preview_http_url : '';
2157
2069
  const ifPreviewGenerated = template && template.versions && template.versions.base ? template.versions.base.isPreviewGenerated : 0;
2158
2070
  const content = <img src={imgSrc || ''} alt="" />;
2159
-
2071
+
2160
2072
  temp.content = (
2161
2073
  <div
2162
2074
  className="sms-template-content">
@@ -2206,7 +2118,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2206
2118
  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
2119
  return true;
2208
2120
  }
2209
- //
2121
+ //
2210
2122
  columns.push(
2211
2123
  <Col key="label" span={4}>
2212
2124
  <Label style={val.labelStyle ? val.labelStyle : {}}>{val.label}</Label>
@@ -2232,12 +2144,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2232
2144
  case "input":
2233
2145
  if (styling === 'semantic') {
2234
2146
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2235
-
2147
+
2236
2148
  columns.push(
2237
2149
  <Col key={val.id} span={val.width}>
2238
2150
  <CapInput
2239
2151
  id={val.id}
2240
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2152
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2241
2153
  className={`input-primary chart-name-input${ifError ? ' error' : ''}`}
2242
2154
  // fluid={val.fluid}
2243
2155
  style={val.style ? val.style : {}}
@@ -2270,7 +2182,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2270
2182
  <TextArea
2271
2183
  id={val.id}
2272
2184
  className={`${ifError ? 'error' : ''}`}
2273
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2185
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2274
2186
  autosize={val.autosize ? val.autosizeParams : false}
2275
2187
  onChange={(e) => this.updateFormData(e.target.value, val)}
2276
2188
  style={val.style ? val.style : {}}
@@ -2298,7 +2210,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2298
2210
  <Col key="input" span={val.width} offset={val.offset}>
2299
2211
  <CapCheckbox
2300
2212
  className={`${ifError ? 'error' : ''}`}
2301
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2213
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2302
2214
  style={val.style ? val.style : {}}
2303
2215
  onChange={(e) => this.updateFormData(e, val)}
2304
2216
  checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
@@ -2396,7 +2308,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2396
2308
  }
2397
2309
  break;
2398
2310
  case "ckeditor":
2399
-
2311
+
2400
2312
  columns.push(
2401
2313
  <Col style={val.colStyle ? val.colStyle : {}} span={val.width}>
2402
2314
  <CKEditor
@@ -2421,11 +2333,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2421
2333
  }
2422
2334
  }
2423
2335
  const edmSrc = this.state.formData[`${this.state.currentTab - 1}`][this.state.currentLangTab][`edmeditor${langTab > 1 ? langTab : ''}src`];
2424
-
2336
+
2425
2337
  if (!edmSrc) {
2426
2338
  return false;
2427
2339
  }
2428
-
2340
+
2429
2341
  columns.push(
2430
2342
  <Col style={val.colStyle ? val.colStyle : {}} span={val.width}>
2431
2343
  <EDMEditor
@@ -2551,11 +2463,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2551
2463
  const type = val.type;
2552
2464
  const styling = val.styling;
2553
2465
  const isVersionEnable = (this.state.usingTabContainer && !val.standalone);
2554
- if (val.id.match(/edmeditor/g)) {
2555
-
2556
- }
2557
-
2558
-
2466
+
2467
+
2559
2468
  if (!this.props.isNewVersionFlow && !val.standalone && !val.onlyDisplay && isVersionEnable && !this.state.formData[`${this.state.currentTab - 1}`]) {
2560
2469
  return true;
2561
2470
  }
@@ -2573,7 +2482,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2573
2482
  this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null)))) {
2574
2483
  return true;
2575
2484
  }
2576
-
2485
+
2577
2486
  let ifError = false;
2578
2487
  if (val.primitive) {
2579
2488
  if (val.id === "mark-final-version-label") {
@@ -2589,17 +2498,17 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2589
2498
  );
2590
2499
  return true;
2591
2500
  }
2592
-
2501
+
2593
2502
  switch (type) {
2594
2503
  case "input":
2595
2504
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2596
-
2505
+
2597
2506
  if (styling === 'semantic') {
2598
2507
  columns.push(
2599
2508
  <Col key={val.id} span={val.width}>
2600
2509
  <CapInput
2601
2510
  id={val.id}
2602
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2511
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2603
2512
  className={`input-primary chart-name-input${ifError ? ' error' : ''}`}
2604
2513
  // fluid={val.fluid}
2605
2514
  style={val.style ? val.style : {}}
@@ -2634,7 +2543,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2634
2543
  placeholder={val.placeholder ? val.placeholder : ''}
2635
2544
  disabled={val.disabled}
2636
2545
  className={`${ifError ? 'error' : ''}`}
2637
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2546
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2638
2547
  autosize={val.autosize ? val.autosizeParams : false}
2639
2548
  onChange={(e) => this.updateFormData(e.target.value, val)}
2640
2549
  style={val.style ? val.style : {}}
@@ -2654,7 +2563,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2654
2563
  <Col key="input" span={val.width} offset={val.offset}>
2655
2564
  <CapCheckbox
2656
2565
  className={`${ifError ? 'error' : ''}`}
2657
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2566
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2658
2567
  onChange={(e) => this.updateFormData(e.target.checked, val)}
2659
2568
  checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2660
2569
  defaultChecked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
@@ -2674,7 +2583,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2674
2583
  <Col key={`input-${val.id}`} span={val.width} offset={val.offset}>
2675
2584
  <CapRadio
2676
2585
  className={`${ifError ? 'error' : ''}`}
2677
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2586
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2678
2587
  onChange={(e) => this.updateFormData(e.target.checked, val)}
2679
2588
  checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2680
2589
  defaultChecked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
@@ -2694,7 +2603,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2694
2603
  <CapRadioGroup
2695
2604
  key={`${val.id}-radio-group`}
2696
2605
  className={`${ifError ? 'error' : ''}`}
2697
- errorMessage={val.errorMessage ? val.errorMessage : ''}
2606
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2698
2607
  onChange={(e) => this.updateFormData(e.target.value, val)}
2699
2608
  style={val.style ? val.style : {}}
2700
2609
  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 +2715,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2806
2715
  }
2807
2716
  break;
2808
2717
  case "line-preview": {
2809
-
2810
2718
  const content = {
2811
2719
  bodyText: isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][`message-editor${this.state.currentTab > 1 ? this.state.currentTab : ''}`] : this.state.formData[val.id],
2812
2720
  bodyImage: this.state.formData[`${this.state.currentTab - 1}`].imagePreview,
@@ -2814,7 +2722,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2814
2722
  if (!this.state.formData[`${this.state.currentTab - 1}`]) {
2815
2723
  return true;
2816
2724
  }
2817
-
2725
+
2818
2726
  columns.push(
2819
2727
  <Col key="input" span={23} offset={1}>
2820
2728
  <TemplatePreview
@@ -2942,10 +2850,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2942
2850
  if (val.id.indexOf('template-content') > -1 && val.id !== 'template-content') {
2943
2851
  langIndex = parseInt(val.id.replace('template-content', ''), 10) - 1;
2944
2852
  }
2945
-
2853
+
2946
2854
  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
2855
  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
-
2856
+
2949
2857
  if (this.state.formData[`${this.state.currentTab - 1}`][currentLang].is_drag_drop) {
2950
2858
  // content = "";
2951
2859
  }
@@ -2968,9 +2876,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2968
2876
  // }
2969
2877
  let langTab = 1;
2970
2878
  if (val.id.match(/edmeditor/g)) {
2971
-
2972
2879
  if (val.id.length > 9 && val.id.charAt(9)) {
2973
-
2974
2880
  langTab = val.id.charAt(9);
2975
2881
  }
2976
2882
  }
@@ -2983,13 +2889,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2983
2889
  // 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
2890
  const currentLang = supportedLanguages[langTab - 1];
2985
2891
  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
-
2892
+
2893
+
2988
2894
  if (!edmSrc) {
2989
2895
  return false;
2990
2896
  }
2991
-
2992
-
2897
+
2898
+
2993
2899
  columns.push(
2994
2900
  <Col style={val.colStyle ? val.colStyle : {}} span={val.width}>
2995
2901
  <EDMEditor
@@ -3101,7 +3007,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3101
3007
  result = this.renderSection(section, paneIndex);
3102
3008
  return result;
3103
3009
  });
3104
-
3010
+
3105
3011
  const sectionHeadeers = pane.sectionsHeaders ? pane.sectionsHeaders : container.tabContent && container.tabContent.sections;
3106
3012
  renderedContentSections = sectionHeadeers.map( (tabContentSection) => {
3107
3013
  result = this.renderSection(tabContentSection, paneIndex);
@@ -3120,7 +3026,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3120
3026
  const currentLang = this.state.formData[this.state.currentTab - 1].selectedLanguages[index];
3121
3027
  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
3028
  }
3123
-
3029
+
3124
3030
  renderedPanes.push(
3125
3031
  <TabPane
3126
3032
  forceRender
@@ -3209,9 +3115,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3209
3115
  }
3210
3116
  return null;
3211
3117
  });
3212
-
3118
+
3213
3119
  allElements.push(renderedContainers);
3214
-
3120
+
3215
3121
  const modal = this.getModal();
3216
3122
  allElements.push(modal);
3217
3123
  }
@@ -3231,7 +3137,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3231
3137
  </CardGrid>
3232
3138
  );
3233
3139
 
3234
-
3140
+
3235
3141
  return (
3236
3142
  <Row>
3237
3143
  {