@capillarytech/creatives-library 2.0.88 → 2.0.90
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/package.json
CHANGED
|
@@ -24,6 +24,7 @@ import EDMEditor from "../Edmeditor";
|
|
|
24
24
|
import CustomPopOver from '../CustomPopOver';
|
|
25
25
|
import './_formBuilder.scss';
|
|
26
26
|
import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
|
|
27
|
+
import {SMS} from '../../v2Containers/CreativesContainer/constants';
|
|
27
28
|
const TabPane = Tabs.TabPane;
|
|
28
29
|
const {Column} = Table;
|
|
29
30
|
const {TextArea} = CapInput;
|
|
@@ -421,16 +422,28 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
421
422
|
}
|
|
422
423
|
return true;
|
|
423
424
|
}
|
|
425
|
+
errorFieldsPresent(errorData, channel) {
|
|
426
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
427
|
+
let isPresent = true;
|
|
428
|
+
if (channel === SMS) {
|
|
429
|
+
const formDataKeys = Object.keys(formData[0]);
|
|
430
|
+
const errorDataKeys = Object.keys(errorData[0]);
|
|
431
|
+
isPresent = _.isEqualWith(formDataKeys, errorDataKeys, (formDataKey, errorDataKey) => formDataKeys.includes(errorDataKey));
|
|
432
|
+
}
|
|
433
|
+
return isPresent;
|
|
434
|
+
}
|
|
424
435
|
/* eslint-disable */
|
|
425
436
|
validateForm(tags, injectedTags, isSave, showMessages) {
|
|
426
|
-
|
|
427
|
-
|
|
437
|
+
const channel = _.get(this, "props.schema.channel");
|
|
428
438
|
let isValid = true;
|
|
429
439
|
const type = (this.props.location && this.props.location.query.type) ? this.props.location.query.type : 'full';
|
|
430
440
|
const currentModule = (this.props.location && this.props.location.query.module) ? this.props.location.query.module : 'default';
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
441
|
+
let errorData = _.cloneDeep(this.state.errorData);
|
|
442
|
+
const stateFormData = _.cloneDeep(this.state.formData);
|
|
443
|
+
if (channel && channel.toUpperCase() === SMS) {
|
|
444
|
+
if(!this.errorFieldsPresent(errorData, SMS)){
|
|
445
|
+
errorData = this.initializeEditErrorData(stateFormData, 1, true);
|
|
446
|
+
}
|
|
434
447
|
for (let count = 0; count < this.state.tabCount; count += 1) {
|
|
435
448
|
if (_.isEmpty(errorData[count])) {
|
|
436
449
|
return;
|
|
@@ -1075,7 +1088,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1075
1088
|
return formData;
|
|
1076
1089
|
}
|
|
1077
1090
|
|
|
1078
|
-
initializeEditErrorData(formData, tabCount) {
|
|
1091
|
+
initializeEditErrorData(formData, tabCount, isReturnErrorData) {
|
|
1079
1092
|
const errorData = {};
|
|
1080
1093
|
for (let idx = 0; idx < tabCount; idx += 1 ) {
|
|
1081
1094
|
_.forEach(formData[0], (val, key) => {
|
|
@@ -1101,6 +1114,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1101
1114
|
return true;
|
|
1102
1115
|
});
|
|
1103
1116
|
}
|
|
1117
|
+
if (isReturnErrorData) {
|
|
1118
|
+
return errorData;
|
|
1119
|
+
}
|
|
1104
1120
|
this.setState({errorData});
|
|
1105
1121
|
}
|
|
1106
1122
|
|
|
@@ -1218,15 +1234,23 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1218
1234
|
|
|
1219
1235
|
initializeStandAloneSections(schema, formDataObj, ifError) {
|
|
1220
1236
|
let formData = _.cloneDeep(formDataObj);
|
|
1237
|
+
const channel = _.get(this, "props.schema.channel");
|
|
1238
|
+
let isContainer = false;
|
|
1239
|
+
let index = -1;
|
|
1240
|
+
if (channel && channel.toUpperCase() === SMS) {
|
|
1241
|
+
// sms v2 scema does not have any containers section the input ant preview fields are in stand alon section and v1 FormBuilder did not have valiation support for stand alone input fields
|
|
1242
|
+
isContainer = true;
|
|
1243
|
+
index = 0;
|
|
1244
|
+
}
|
|
1221
1245
|
if (schema.standalone) {
|
|
1222
1246
|
_.forEach(schema.standalone.sections, (section) => {
|
|
1223
1247
|
if (section) {
|
|
1224
1248
|
if (section.type === 'multicols') {
|
|
1225
|
-
formData = this.initializeMultiColSection(section, formData,
|
|
1249
|
+
formData = this.initializeMultiColSection(section, formData, isContainer, index, ifError);
|
|
1226
1250
|
} else if (section.type === 'col-label') {
|
|
1227
|
-
formData = this.initializeColLabelSection(section, formData,
|
|
1251
|
+
formData = this.initializeColLabelSection(section, formData, isContainer, index, ifError);
|
|
1228
1252
|
} else if (section.type === 'parent') {
|
|
1229
|
-
formData = this.initializeParentSection(section, formData,
|
|
1253
|
+
formData = this.initializeParentSection(section, formData, isContainer, index, ifError);
|
|
1230
1254
|
}
|
|
1231
1255
|
}
|
|
1232
1256
|
});
|
|
@@ -39,7 +39,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
39
39
|
loading: false,
|
|
40
40
|
isFormValid: true,
|
|
41
41
|
injectedTags: {},
|
|
42
|
-
checkValidation: true,
|
|
43
42
|
tabKey: '',
|
|
44
43
|
showModal: false,
|
|
45
44
|
modalContent: {title: "Alert", body: "Do you really want to delete this version?", type: 'confirm', id: 'sms-version-modal'},
|
|
@@ -251,7 +250,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
251
250
|
validity: this.state.isFormValid,
|
|
252
251
|
type: 'SMS',
|
|
253
252
|
};
|
|
254
|
-
this.
|
|
253
|
+
this.setState({checkValidation: true}, this.showError);
|
|
255
254
|
|
|
256
255
|
if (e) {
|
|
257
256
|
e.source.postMessage(JSON.stringify(response), e.origin);
|