@capillarytech/creatives-library 0.0.4 → 0.0.6
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 +11 -3
- package/components/Ckeditor/index.js +20 -17
- package/components/CustomPopOver/index.js +4 -1
- package/components/EmailPreview/index.js +1 -1
- package/components/FormBuilder/index.js +225 -71
- package/components/TemplatePreview/index.js +3 -0
- package/components/Toastr/index.js +1 -1
- package/containers/Cap/sagas.js +14 -1
- package/containers/Ebill/reducer.js +4 -1
- package/containers/Ebill/selectors.js +1 -1
- package/containers/Email/index.js +595 -158
- package/containers/Email/messages.js +12 -0
- package/containers/Email/reducer.js +4 -1
- package/containers/Email/selectors.js +7 -1
- package/containers/Sms/Create/index.js +3 -3
- package/containers/Templates/actions.js +13 -0
- package/containers/Templates/constants.js +2 -1
- package/containers/Templates/index.js +57 -57
- package/containers/Templates/messages.js +1 -1
- package/containers/Templates/reducer.js +9 -2
- package/initialState.js +6 -0
- package/package.json +2 -1
- package/reducers.js +4 -0
- package/routes.js +24 -2
- package/translations/en.json +17 -1
- package/translations/zh.json +16 -0
|
@@ -46,6 +46,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
46
46
|
currentEvent: {},
|
|
47
47
|
currentEventData: {},
|
|
48
48
|
popoverVisible: false,
|
|
49
|
+
customPopoverVisible: false,
|
|
49
50
|
};
|
|
50
51
|
this.renderForm = this.renderForm.bind(this);
|
|
51
52
|
this.updateFormData = this.updateFormData.bind(this);
|
|
@@ -95,7 +96,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
componentWillReceiveProps(nextProps) {
|
|
98
|
-
console.log('nextprops', nextProps, this.state.formData);
|
|
99
|
+
console.log('outgoing nextprops', nextProps, this.state.formData);
|
|
99
100
|
const type = this.props.location.query.type;
|
|
100
101
|
if (this.state.usingTabContainer && nextProps.tabCount !== this.props.tabCount) {
|
|
101
102
|
this.setState({tabCount: nextProps.tabCount});
|
|
@@ -163,16 +164,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
163
164
|
( !this.state.usingTabContainer || (this.state.usingTabContainer && nextProps.tabKey !== ''))
|
|
164
165
|
&& !_.isEqual(nextProps.formData, this.state.formData) &&
|
|
165
166
|
!_.isEqual(nextProps.formData, this.props.formData)) {
|
|
166
|
-
console.log('hahaha', nextProps.tabKey);
|
|
167
|
+
console.log('outgoing hahaha', nextProps.tabKey);
|
|
167
168
|
this.setState({formData: nextProps.formData, tabKey: nextProps.tabKey}, () => {
|
|
168
169
|
this.validateForm();
|
|
169
170
|
});
|
|
170
171
|
//this.resetTabKeys(nextProps.formData, nextProps.tabCount);
|
|
171
172
|
} else if ((_.isEmpty(this.props.formData) || !this.props.formData) && _.isEmpty(this.state.formData)) {
|
|
172
|
-
console.log('init when empty');
|
|
173
|
+
console.log('outgoing init when empty');
|
|
173
174
|
this.initialiseForm(nextProps.schema, true);
|
|
174
175
|
} else if (_.isEmpty(this.props.formData) && !_.isEmpty(nextProps.formData)) {
|
|
175
|
-
console.log('clean form data');
|
|
176
|
+
console.log('outgoing clean form data');
|
|
176
177
|
this.setState({formData: nextProps.formData});
|
|
177
178
|
}
|
|
178
179
|
|
|
@@ -186,12 +187,18 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
if (!_.isEmpty(nextProps.formData) && !_.isEqual(this.state.formData, nextProps.formData)) {
|
|
190
|
+
console.log('outgoing always', nextProps.formData);
|
|
189
191
|
if (nextProps.isNewVersionFlow) {
|
|
192
|
+
console.log('outgoing new flow');
|
|
190
193
|
const tabKey = (this.state.tabKey !== nextProps.formData[nextProps.currentTab - 1].tabKey) ? nextProps.formData[nextProps.currentTab - 1].tabKey : this.state.tabKey;
|
|
191
|
-
console.log('tab key form builder', this.state.tabKey, nextProps.formData[nextProps.currentTab - 1].tabKey, nextProps.formData, this.state.formData);
|
|
194
|
+
console.log('outgoing tab key form builder', this.state.tabKey, nextProps.formData[nextProps.currentTab - 1].tabKey, nextProps.formData, this.state.formData);
|
|
192
195
|
this.setState({tabKey});
|
|
193
196
|
}
|
|
194
197
|
this.setState({formData: nextProps.formData, currentLangTab}, () => {
|
|
198
|
+
if (nextProps.isNewVersionFlow && !this.state.formData[this.state.currentTab - 1][this.state.formData[this.state.currentTab - 1].activeTab].tabKey) {
|
|
199
|
+
console.log('outgoing have to reset tab keys');
|
|
200
|
+
this.resetTabKeys(nextProps.formData, nextProps.tabCount, false, true);
|
|
201
|
+
}
|
|
195
202
|
if (type === 'embedded') {
|
|
196
203
|
this.validateForm();
|
|
197
204
|
}
|
|
@@ -201,15 +208,22 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
201
208
|
});
|
|
202
209
|
}
|
|
203
210
|
|
|
204
|
-
console.log('Next prop schema ', nextProps.schema);
|
|
211
|
+
console.log('outgoing Next prop schema ', nextProps.schema);
|
|
205
212
|
if (!_.isEqual(nextProps.schema, this.props.schema)) {
|
|
206
|
-
console.log('Reinitializing form ', nextProps.schema, this.props.schema);
|
|
213
|
+
console.log('outgoing Reinitializing form ', nextProps.schema, this.props.schema);
|
|
207
214
|
this.setState({ isFormValid: (this.props.isEdit ? this.props.isEdit : true) }, () => {
|
|
215
|
+
console.log('outgoing set validity');
|
|
208
216
|
if (!this.props.isEdit || (this.props.isEdit && !_.isEmpty(nextProps.formData))) {
|
|
217
|
+
console.log('outgoing 1', this.state.formData, nextProps.formData);
|
|
209
218
|
let resetTabKeys = (this.state.formData.tabKey === undefined);
|
|
210
219
|
if ((this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === 'MOBILEPUSH')) {
|
|
211
220
|
resetTabKeys = false;
|
|
221
|
+
console.log('outgoing 2');
|
|
212
222
|
}
|
|
223
|
+
if (this.props.isNewVersionFlow) {
|
|
224
|
+
resetTabKeys = false;
|
|
225
|
+
}
|
|
226
|
+
console.log('outgoing 3', resetTabKeys);
|
|
213
227
|
this.initialiseForm(nextProps.schema, false, resetTabKeys);
|
|
214
228
|
this.validateForm();
|
|
215
229
|
}
|
|
@@ -312,17 +326,46 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
312
326
|
this.setState({ popoverVisible });
|
|
313
327
|
};
|
|
314
328
|
|
|
315
|
-
|
|
329
|
+
handleCustomPopoverVisibleChange = (customPopoverVisible) => {
|
|
330
|
+
this.setState({ customPopoverVisible });
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
resetTabKeys(form, count, changeDefaultTab, setFormTabKey) {
|
|
316
334
|
const tabCount = count || this.state.tabCount;
|
|
335
|
+
console.log('outgoing reset', form, count, changeDefaultTab);
|
|
317
336
|
console.log('incoming reset', form, tabCount);
|
|
318
337
|
const formData = _.cloneDeep(form);
|
|
319
338
|
let baseIndex = 0;
|
|
320
339
|
for (let idx = 0; idx < tabCount; idx += 1) {
|
|
321
340
|
if (this.props.isNewVersionFlow && formData[idx].selectedLanguages.length > 0) {
|
|
322
341
|
for (let langIndex = 0; langIndex < formData[idx].selectedLanguages.length; langIndex += 1 ) {
|
|
342
|
+
const id = _.uniqueId();
|
|
323
343
|
if (formData[idx][formData[idx].selectedLanguages[langIndex]]) {
|
|
324
344
|
if (!formData[idx][formData[idx].selectedLanguages[langIndex]].tabKey) {
|
|
325
|
-
formData[idx][formData[idx].selectedLanguages[langIndex]].tabKey =
|
|
345
|
+
formData[idx][formData[idx].selectedLanguages[langIndex]].tabKey = id;
|
|
346
|
+
}
|
|
347
|
+
if (formData[idx].base) {
|
|
348
|
+
formData.base[formData.base.selectedLanguages[langIndex]].tabKey = id;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (setFormTabKey) {
|
|
353
|
+
if (!formData[idx].activeTab) {
|
|
354
|
+
const baseLanguage = this.props.baseLanguage;
|
|
355
|
+
console.log('outgoing reset do not have active tab');
|
|
356
|
+
formData[idx].tabKey = formData[idx][baseLanguage].tabKey;
|
|
357
|
+
} else {
|
|
358
|
+
console.log('outgoing reset have active tab');
|
|
359
|
+
formData[idx].tabKey = formData[idx][formData[idx].activeTab].tabKey;
|
|
360
|
+
}
|
|
361
|
+
if (formData[idx].base) {
|
|
362
|
+
if (!formData.base.activeTab) {
|
|
363
|
+
console.log('outgoing reset do not have active tab base');
|
|
364
|
+
const baseLanguage = this.props.baseLanguage;
|
|
365
|
+
formData.base.tabKey = formData.base[baseLanguage].tabKey;
|
|
366
|
+
} else {
|
|
367
|
+
console.log('outgoing reset have active tab base');
|
|
368
|
+
formData.base.tabKey = formData.base[formData[idx].activeTab].tabKey;
|
|
326
369
|
}
|
|
327
370
|
}
|
|
328
371
|
}
|
|
@@ -353,11 +396,19 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
353
396
|
console.log('setting tab key', formData.base.tabKey, this.state.tabKey);
|
|
354
397
|
if (this.state.currentTab === 1 && !this.props.isNewVersionFlow) {
|
|
355
398
|
this.setState({tabKey: formData.base.tabKey});
|
|
399
|
+
} else if (this.props.isNewVersionFlow && this.state.tabKey !== formData[this.state.currentTab - 1].tabKey) {
|
|
400
|
+
this.setState({tabKey: formData[this.state.currentTab - 1].tabKey});
|
|
356
401
|
}
|
|
357
402
|
}
|
|
403
|
+
if (setFormTabKey) {
|
|
404
|
+
console.log('outgoing reset form builder tab key', formData.base.tabKey, formData[0].tabKey, formData);
|
|
405
|
+
this.setState({tabKey: formData.base.tabKey});
|
|
406
|
+
}
|
|
358
407
|
console.log('form data before adding key', formData);
|
|
408
|
+
console.log('outgoing reset final before set', formData);
|
|
359
409
|
if (changeDefaultTab) {
|
|
360
410
|
this.setState({formData}, () => {
|
|
411
|
+
console.log('outgoing reset set data', formData);
|
|
361
412
|
this.props.onChange(formData, this.state.tabCount);
|
|
362
413
|
this.validateForm();
|
|
363
414
|
});
|
|
@@ -453,7 +504,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
453
504
|
androidData[data] = this.state.formData[0][data];
|
|
454
505
|
}
|
|
455
506
|
}
|
|
456
|
-
if(_.isEmpty(androidData)
|
|
507
|
+
if(_.isEmpty(androidData)){
|
|
457
508
|
isOnlyIos = true;
|
|
458
509
|
}
|
|
459
510
|
const iosData = {};
|
|
@@ -462,7 +513,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
462
513
|
iosData[data] = this.state.formData[1][data];
|
|
463
514
|
}
|
|
464
515
|
}
|
|
465
|
-
if(_.isEmpty(iosData)
|
|
516
|
+
if(_.isEmpty(iosData)){
|
|
466
517
|
isOnlyAndroid = true;
|
|
467
518
|
}
|
|
468
519
|
_.forEach(this.state.formData, (tab, index) => {
|
|
@@ -688,31 +739,92 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
688
739
|
}
|
|
689
740
|
}
|
|
690
741
|
|
|
742
|
+
// Form Data Validation for Email Channel
|
|
691
743
|
if (this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === "EMAIL") {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
// if (tagValidationResponse.valid) {
|
|
698
|
-
// errorData[count][`template-content${index > 1 ? index : ''}`] = false;
|
|
699
|
-
// } else {
|
|
700
|
-
// errorData[count][`template-content${index > 1 ? index : ''}`] = true;
|
|
701
|
-
// isValid = false;
|
|
702
|
-
// }
|
|
703
|
-
}
|
|
704
|
-
if (type.toLowerCase() === 'embedded' && (currentModule.toLowerCase() === 'loyalty' || currentModule.toLowerCase() === 'dvs' || currentModule.toLowerCase() === 'subscription')) {
|
|
705
|
-
if (this.state.formData['template-subject'] && this.state.formData['template-subject'].trim() === '') {
|
|
706
|
-
errorData['template-subject'] = true;
|
|
744
|
+
// Validating Email By iterating all elements of FormBuilder
|
|
745
|
+
_.forEach(this.state.formData, (data, index) => {
|
|
746
|
+
console.log("Form Iteration Data ", data, index);
|
|
747
|
+
if (!this.state.formData["template-subject"]) {
|
|
748
|
+
errorData["template-subject"] = true;
|
|
707
749
|
isValid = false;
|
|
708
750
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
751
|
+
// Check if template subject present in form data from Loyalty, DVS, Timeline
|
|
752
|
+
if (index === 'template-subject' && type.toLowerCase() === 'embedded' && (currentModule.toLowerCase() === 'loyalty' || currentModule.toLowerCase() === 'dvs' || currentModule.toLowerCase() === 'timeline')) {
|
|
753
|
+
if (data.trim() === '') {
|
|
754
|
+
errorData[index] = true;
|
|
755
|
+
isValid = false;
|
|
756
|
+
} else {
|
|
757
|
+
errorData[index] = false;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// Check if Template name present in full mode
|
|
762
|
+
if(type !== 'embedded' && index === 'template-name' && data === '') {
|
|
763
|
+
errorData[index] = true;
|
|
764
|
+
isValid = false;
|
|
765
|
+
} else if(type !== 'embedded' && index === 'template-name' && data !== '') {
|
|
766
|
+
errorData[index] = false;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// Check formData if selected version present or not
|
|
770
|
+
if(index === 'template-version' && data === '') {
|
|
771
|
+
errorData[index] = true;
|
|
772
|
+
isValid = false;
|
|
773
|
+
} else if(index === 'template-version' && data !== '') {
|
|
774
|
+
errorData[index] = false;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// Check error for the versions
|
|
778
|
+
if (!isNaN(index) || index === 'base') {
|
|
779
|
+
if (errorData[index] === undefined) {
|
|
780
|
+
errorData[index] = {};
|
|
781
|
+
}
|
|
782
|
+
for (var i = 0; i < data.selectedLanguages.length; i+= 1) {
|
|
783
|
+
const currentLang = data.selectedLanguages[i];
|
|
784
|
+
const content = data[currentLang]['template-content'];
|
|
785
|
+
const tagValidationResponse = this.validateTags(content, tags, injectedTags);
|
|
786
|
+
if (errorData[index][currentLang] === undefined) {
|
|
787
|
+
errorData[index][currentLang] = {};
|
|
788
|
+
}
|
|
789
|
+
console.log('tag valid response', tagValidationResponse);
|
|
790
|
+
if (tagValidationResponse.valid) {
|
|
791
|
+
errorData[index][currentLang]['template-content'] = false;
|
|
792
|
+
} else {
|
|
793
|
+
errorData[index][currentLang]['template-content'] = true;
|
|
794
|
+
isValid = false;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
_.forEach(errorData[index], (versionData, key) => {
|
|
798
|
+
if (data.selectedLanguages.indexOf(key) === -1) {
|
|
799
|
+
delete errorData[index][key];
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
// for (let count = 0; count < this.state.tabCount; count += 1) {
|
|
805
|
+
// const index = count + 1;
|
|
806
|
+
// // const content = this.state.formData[count][`template-content${index > 1 ? index : ''}`];
|
|
807
|
+
// // const tagValidationResponse = this.validateTags(content, tags, injectedTags);
|
|
808
|
+
// // console.log('tag valid response', tagValidationResponse);
|
|
809
|
+
// // if (tagValidationResponse.valid) {
|
|
810
|
+
// // errorData[count][`template-content${index > 1 ? index : ''}`] = false;
|
|
811
|
+
// // } else {
|
|
812
|
+
// // errorData[count][`template-content${index > 1 ? index : ''}`] = true;
|
|
813
|
+
// // isValid = false;
|
|
814
|
+
// // }
|
|
815
|
+
// }
|
|
816
|
+
// if (type.toLowerCase() === 'embedded' && (currentModule.toLowerCase() === 'loyalty' || currentModule.toLowerCase() === 'dvs' || currentModule.toLowerCase() === 'timeline')) {
|
|
817
|
+
// if (this.state.formData['template-subject'] && this.state.formData['template-subject'].trim() === '') {
|
|
818
|
+
// errorData['template-subject'] = true;
|
|
819
|
+
// isValid = false;
|
|
820
|
+
// }
|
|
821
|
+
// }
|
|
822
|
+
// if(type !== 'embedded' && (!this.state.formData['template-name'] || this.state.formData['template-name'] === '')) {
|
|
823
|
+
// errorData['template-name'] = true;
|
|
824
|
+
// isValid = false;
|
|
825
|
+
// } else {
|
|
826
|
+
// errorData['template-name'] = false;
|
|
827
|
+
// }
|
|
716
828
|
}
|
|
717
829
|
this.setState({isFormValid : isValid, errorData});
|
|
718
830
|
console.log('final validity', this.state.formData, this.state, isValid);
|
|
@@ -857,10 +969,22 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
857
969
|
if (!errorData[idx]) {
|
|
858
970
|
errorData[idx] = {};
|
|
859
971
|
}
|
|
860
|
-
if (key === 'tabKey' || key === 'base') {
|
|
972
|
+
if (key === 'tabKey' || key === 'base' || key === 'selectedLanguages') {
|
|
861
973
|
return true;
|
|
862
974
|
}
|
|
863
|
-
|
|
975
|
+
if (this.props.isNewVersionFlow && formData[0].selectedLanguages.indexOf(key) > -1) {
|
|
976
|
+
_.forEach(formData[0].selectedLanguages, (lang) => {
|
|
977
|
+
if (errorData[idx] === undefined) {
|
|
978
|
+
errorData[idx] = {};
|
|
979
|
+
}
|
|
980
|
+
if (errorData[idx][lang] === undefined) {
|
|
981
|
+
errorData[idx][lang] = {};
|
|
982
|
+
}
|
|
983
|
+
errorData[idx][lang]['template-content'] = false;
|
|
984
|
+
});
|
|
985
|
+
} else {
|
|
986
|
+
errorData[idx][key] = false;
|
|
987
|
+
}
|
|
864
988
|
return true;
|
|
865
989
|
});
|
|
866
990
|
}
|
|
@@ -880,8 +1004,15 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
880
1004
|
formData[index] = {};
|
|
881
1005
|
}
|
|
882
1006
|
if (isContainer && this.props.isNewVersionFlow) {
|
|
1007
|
+
// if (formData[index] && formData[index].selectedLanguages && formData[index].selectedLanguages.length > 0) {
|
|
1008
|
+
// for (let i = 0; i < formData[index].selectedLanguages.length; i += 1 ) {
|
|
1009
|
+
// formData[index][formData[index].selectedLanguages[i]] = {};
|
|
1010
|
+
// }
|
|
1011
|
+
// } else {
|
|
1012
|
+
// formData[index][`${this.props.baseLanguage ? this.props.baseLanguage : 'en'}`] = {};
|
|
1013
|
+
// }
|
|
883
1014
|
_.forEach(this.props.supportedLanguages, (language) => {
|
|
884
|
-
if (!formData[index][language.iso_code]) {
|
|
1015
|
+
if (!formData[index][language.iso_code] && this.props.baseLanguage === language.iso_code) {
|
|
885
1016
|
formData[index][language.iso_code] = {};
|
|
886
1017
|
}
|
|
887
1018
|
});
|
|
@@ -1056,6 +1187,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1056
1187
|
}
|
|
1057
1188
|
|
|
1058
1189
|
initialiseForm(schema, makeFormEmpty, resetTabKeys) {
|
|
1190
|
+
console.log('outgoing init form xxx', schema, makeFormEmpty, this.state.formData, resetTabKeys);
|
|
1059
1191
|
console.log('init form xxx', schema, makeFormEmpty, this.state.formData, resetTabKeys);
|
|
1060
1192
|
let formData = makeFormEmpty ? {} : _.cloneDeep(this.state.formData);
|
|
1061
1193
|
let errorData = {};
|
|
@@ -1436,14 +1568,19 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1436
1568
|
}
|
|
1437
1569
|
|
|
1438
1570
|
updateFormData(data, val, event) {
|
|
1439
|
-
console.log('updating data', data, val, event);
|
|
1571
|
+
console.log('updating data', data, val, event, this.props.addLanguageType);
|
|
1440
1572
|
const formData = _.cloneDeep(this.state.formData);
|
|
1573
|
+
console.log('oform data before updating', JSON.stringify(formData));
|
|
1441
1574
|
const tabIndex = this.state.currentTab - 1;
|
|
1442
1575
|
let currentTab = _.cloneDeep(this.state.currentTab);
|
|
1576
|
+
console.log('setting form data1', JSON.stringify(formData));
|
|
1443
1577
|
if (this.state.usingTabContainer && !val.standalone) {
|
|
1444
1578
|
const data1 = data;
|
|
1445
1579
|
if (event === "addLanguage") {
|
|
1446
1580
|
const addLanguageType = this.props.addLanguageType;
|
|
1581
|
+
if (addLanguageType === '') {
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1447
1584
|
const currentLang = formData[tabIndex].activeTab;
|
|
1448
1585
|
let baseTab = _.cloneDeep(formData[tabIndex][currentLang]);
|
|
1449
1586
|
let id = _.uniqueId();
|
|
@@ -1458,10 +1595,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1458
1595
|
while (!validId) {
|
|
1459
1596
|
validId = true;
|
|
1460
1597
|
for (let idx = 0; idx < formData[tabIndex].selectedLanguages.length; idx += 1) {
|
|
1461
|
-
if (!formData[
|
|
1598
|
+
if (!formData[tabIndex]) {
|
|
1462
1599
|
continue;
|
|
1463
1600
|
}
|
|
1464
|
-
|
|
1601
|
+
console.log('comparing tab keys', id, formData, formData[tabIndex][formData[tabIndex].selectedLanguages[idx]].tabKey);
|
|
1602
|
+
if (id === formData[tabIndex][formData[tabIndex].selectedLanguages[idx]].tabKey) {
|
|
1465
1603
|
validId = false;
|
|
1466
1604
|
}
|
|
1467
1605
|
}
|
|
@@ -1492,7 +1630,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1492
1630
|
if (!formData[idx]) {
|
|
1493
1631
|
continue;
|
|
1494
1632
|
}
|
|
1495
|
-
if (id === formData[idx].tabKey) {
|
|
1633
|
+
if (id === formData[tabIndex][formData[tabIndex].selectedLanguages[idx]].tabKey) {
|
|
1496
1634
|
validId = false;
|
|
1497
1635
|
}
|
|
1498
1636
|
}
|
|
@@ -1508,6 +1646,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1508
1646
|
formData[tabIndex].activeTab = data.iso_code;
|
|
1509
1647
|
formData[tabIndex].tabKey = baseTab.tabKey;
|
|
1510
1648
|
break;
|
|
1649
|
+
case '':
|
|
1650
|
+
return;
|
|
1511
1651
|
default:
|
|
1512
1652
|
break;
|
|
1513
1653
|
}
|
|
@@ -1516,11 +1656,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1516
1656
|
that.setState({tabKey: baseTab.tabKey});
|
|
1517
1657
|
}, 0);
|
|
1518
1658
|
}
|
|
1659
|
+
console.log('setting form data2', JSON.stringify(formData));
|
|
1519
1660
|
if (!this.props.isNewVersionFlow) {
|
|
1520
1661
|
formData[tabIndex][val.id] = data1;
|
|
1521
|
-
} else if (event !== "addLanguage") {
|
|
1662
|
+
} else if (this.props.isNewVersionFlow && event !== "addLanguage" && event !== "onContentChange") {
|
|
1522
1663
|
formData[tabIndex][this.props.baseLanguage][val.id] = data1;
|
|
1523
1664
|
}
|
|
1665
|
+
console.log('setting form data3', JSON.stringify(formData));
|
|
1524
1666
|
if (formData[tabIndex].base) {
|
|
1525
1667
|
if (!this.props.isNewVersionFlow) {
|
|
1526
1668
|
formData.base[val.id] = data1;
|
|
@@ -1531,9 +1673,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1531
1673
|
formData.base.selectedLanguages = formData[tabIndex].selectedLanguages;
|
|
1532
1674
|
}
|
|
1533
1675
|
}
|
|
1676
|
+
console.log('setting form data4', JSON.stringify(formData));
|
|
1534
1677
|
} else {
|
|
1535
1678
|
formData[val.id] = data;
|
|
1536
1679
|
}
|
|
1680
|
+
console.log('setting form data5', JSON.stringify(formData));
|
|
1537
1681
|
if (this.props.isNewVersionFlow) {
|
|
1538
1682
|
console.log('Version Select ', data, val, event);
|
|
1539
1683
|
if (event === 'onSelect' && data === 'New Version') {
|
|
@@ -1547,6 +1691,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1547
1691
|
val.injectedEvents[event].call(this, this.state.formData['template-version-options'][currentTab - 1].key, formData, val);
|
|
1548
1692
|
});
|
|
1549
1693
|
}
|
|
1694
|
+
console.log('setting form data6', JSON.stringify(formData));
|
|
1550
1695
|
if (event === 'onContentChange') {
|
|
1551
1696
|
console.log('onContentChange ', data, val, event, data.editor.getData());
|
|
1552
1697
|
// formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = data.editor.getData();
|
|
@@ -1555,6 +1700,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1555
1700
|
//}
|
|
1556
1701
|
}
|
|
1557
1702
|
}
|
|
1703
|
+
console.log('setting form data7', JSON.stringify(formData));
|
|
1558
1704
|
console.log('setting form data', formData);
|
|
1559
1705
|
this.setState({formData}, () => {
|
|
1560
1706
|
this.validateForm();
|
|
@@ -1565,6 +1711,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1565
1711
|
} else if (this.props.isNewVersionFlow && event !== 'onSelect') {
|
|
1566
1712
|
if (event === 'addLanguage') {
|
|
1567
1713
|
val.injectedEvents[event].call(this, data, formData, val);
|
|
1714
|
+
this.setState({currentEventVal: {}, currentEvent: {}, currentEventData: {}});
|
|
1568
1715
|
} else {
|
|
1569
1716
|
val.injectedEvents[event].call(this, true, formData, val);
|
|
1570
1717
|
}
|
|
@@ -1742,6 +1889,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1742
1889
|
if (!this.allowAddSecondaryCta(val)) {
|
|
1743
1890
|
return;
|
|
1744
1891
|
}
|
|
1892
|
+
} else if (event === "onContentChange") {
|
|
1893
|
+
val.injectedEvents[event].call(this.props.parent, data, val.id);
|
|
1745
1894
|
} else if (event === 'deleteLanguage') {
|
|
1746
1895
|
this.setState({currentEvent: val.injectedEvents[event], currentEventData: data }, () => {
|
|
1747
1896
|
this.props.setModalContent('delete-language');
|
|
@@ -1797,14 +1946,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1797
1946
|
value: 'ok',
|
|
1798
1947
|
};
|
|
1799
1948
|
this.props.iframeParent.postMessage(JSON.stringify(response), '*');
|
|
1949
|
+
const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
|
|
1800
1950
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
1801
1951
|
this.props.router.push({
|
|
1802
1952
|
pathname: `/${this.props.schema.channel.toLowerCase()}/`,
|
|
1803
|
-
query: type === 'embedded' ? {type: 'embedded', module} : {module},
|
|
1953
|
+
query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport} : {module, isLanguageSupport},
|
|
1804
1954
|
});
|
|
1805
1955
|
} else if (id === "email-language-delete-modal") {
|
|
1806
1956
|
console.log('Delete languages ');
|
|
1807
1957
|
this.deleteLanguage();
|
|
1958
|
+
this.props.handleCancelModal();
|
|
1808
1959
|
// this.setState({currentEvent: {}, currentEventData: {}});
|
|
1809
1960
|
} else if (id === 'email-version-delete-modal') {
|
|
1810
1961
|
this.deleteVersion(false, this.state.currentTab);
|
|
@@ -1866,11 +2017,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1866
2017
|
} else {
|
|
1867
2018
|
this.setState({hoveredItem: ''});
|
|
1868
2019
|
}
|
|
1869
|
-
}
|
|
2020
|
+
}
|
|
1870
2021
|
|
|
1871
2022
|
handleOnItemClick = (isClicked, id) => {
|
|
1872
2023
|
this.setState({clickedItem: id});
|
|
1873
|
-
}
|
|
2024
|
+
}
|
|
1874
2025
|
|
|
1875
2026
|
populateTemplatesList(data) {
|
|
1876
2027
|
if (!data) {
|
|
@@ -1910,7 +2061,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1910
2061
|
}
|
|
1911
2062
|
|
|
1912
2063
|
handleAddLanguageFlow(data, val, event) {
|
|
1913
|
-
this.setState({currentEventData: data, currentEventVal: val, currentEvent: event}, () => {
|
|
2064
|
+
this.setState({currentEventData: data, currentEventVal: val, currentEvent: event, customPopoverVisible: false}, () => {
|
|
1914
2065
|
this.props.setModalContent('add-language', data);
|
|
1915
2066
|
});
|
|
1916
2067
|
}
|
|
@@ -2122,7 +2273,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2122
2273
|
content={(this.state.formData[`${this.state.currentTab - 1}`][val.id] ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : '')}
|
|
2123
2274
|
events={val.events}
|
|
2124
2275
|
getEditorInstanse={val.getEditorInstanse}
|
|
2125
|
-
|
|
2276
|
+
// this.callChildEvent(data, val, 'addVersion', event);
|
|
2277
|
+
handleContentChange={(event) => this.callChildEvent(event, val, 'onContentChange')}
|
|
2126
2278
|
/>
|
|
2127
2279
|
</Col>
|
|
2128
2280
|
);
|
|
@@ -2271,25 +2423,25 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2271
2423
|
if (val.id.match(/edmeditor/g)) {
|
|
2272
2424
|
console.log('current language first', val.id);
|
|
2273
2425
|
}
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2426
|
+
console.log('Multi col Render 1', val.id, !val.standalone, !val.onlyDisplay, (!this.state.formData[`${this.state.currentTab - 1}`] || (!this.state.formData[`${this.state.currentTab - 1}`] && this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null)), this.state.formData[`${this.state.currentTab - 1}`], this.state.currentTab);
|
|
2427
|
+
console.log('Multi col render ', val, this.state.formData, this.state.errorData, this.state.currentTab);
|
|
2428
|
+
if (!this.props.isNewVersionFlow && !val.standalone && !val.onlyDisplay && isVersionEnable && !this.state.formData[`${this.state.currentTab - 1}`]) {
|
|
2429
|
+
return true;
|
|
2430
|
+
}
|
|
2431
|
+
if (!val.standalone && !val.onlyDisplay &&
|
|
2432
|
+
(!this.state.formData[`${this.state.currentTab - 1}`] ||
|
|
2433
|
+
(!this.props.isNewVersionFlow && !this.state.formData[`${this.state.currentTab - 1}`] &&
|
|
2434
|
+
this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null)) &&
|
|
2435
|
+
(this.props.isNewVersionFlow && !this.state.formData[`${this.state.currentTab - 1}`] &&
|
|
2436
|
+
this.state.errorData[`${this.state.currentTab - 1}`] && this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null)) {
|
|
2437
|
+
return true;
|
|
2438
|
+
}
|
|
2439
|
+
if (!val.onlyDisplay && !val.standalone &&
|
|
2440
|
+
(!this.props.isNewVersionFlow && (!this.state.errorData[`${this.state.currentTab - 1}`] ||
|
|
2441
|
+
(!this.state.errorData[`${this.state.currentTab - 1}`] &&
|
|
2442
|
+
this.state.errorData[`${this.state.currentTab - 1}`][val.id] === null)))) {
|
|
2443
|
+
return true;
|
|
2444
|
+
}
|
|
2293
2445
|
console.log('Render 3');
|
|
2294
2446
|
let ifError = false;
|
|
2295
2447
|
if (val.primitive) {
|
|
@@ -2300,7 +2452,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2300
2452
|
}
|
|
2301
2453
|
}
|
|
2302
2454
|
columns.push(
|
|
2303
|
-
<Col style={val.colStyle ? val.colStyle : {}} key={val.id} span={val.width}>
|
|
2455
|
+
<Col style={val.colStyle ? val.colStyle : {}} offset={val.offset} key={val.id} span={val.width}>
|
|
2304
2456
|
{this.renderPrimitiveElement(val, childIndex)}
|
|
2305
2457
|
</Col>
|
|
2306
2458
|
);
|
|
@@ -2647,8 +2799,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2647
2799
|
id={val.id}
|
|
2648
2800
|
content={content}
|
|
2649
2801
|
events={val.events}
|
|
2650
|
-
getEditorInstanse={(evt) => val.injectedEvents.getEditorInstanse.call(this, evt)}
|
|
2651
|
-
handleContentChange={(event) => this.
|
|
2802
|
+
getEditorInstanse={(evt, id) => val.injectedEvents.getEditorInstanse.call(this, evt, id)}
|
|
2803
|
+
handleContentChange={(event) => this.callChildEvent(event, val, 'onContentChange')}
|
|
2652
2804
|
/>
|
|
2653
2805
|
</Col>
|
|
2654
2806
|
);
|
|
@@ -2704,6 +2856,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2704
2856
|
popOverList={this.props.supportedLanguages}
|
|
2705
2857
|
excludeList={this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages}
|
|
2706
2858
|
handlePopOverClick={(data) => this.handleAddLanguageFlow(data, val, "addLanguage")}
|
|
2859
|
+
visible={this.state.customPopoverVisible}
|
|
2860
|
+
onVisibleChange={this.handleCustomPopoverVisibleChange}
|
|
2707
2861
|
/>
|
|
2708
2862
|
</Col>
|
|
2709
2863
|
);
|
|
@@ -2961,17 +3115,17 @@ FormBuilder.propTypes = {
|
|
|
2961
3115
|
onFormValidityChange: PropTypes.func,
|
|
2962
3116
|
checkValidation: PropTypes.bool,
|
|
2963
3117
|
onContextChange: PropTypes.func,
|
|
2964
|
-
tabCount: PropTypes.
|
|
3118
|
+
tabCount: PropTypes.number,
|
|
2965
3119
|
isSchemaChanged: PropTypes.bool,
|
|
2966
3120
|
modal: PropTypes.object,
|
|
2967
3121
|
isNewVersionFlow: PropTypes.bool,
|
|
2968
3122
|
baseLanguage: PropTypes.string,
|
|
2969
3123
|
supportedLanguages: PropTypes.array,
|
|
2970
3124
|
router: PropTypes.object,
|
|
2971
|
-
currentTab: PropTypes.
|
|
3125
|
+
currentTab: PropTypes.number,
|
|
2972
3126
|
showModal: PropTypes.bool,
|
|
2973
3127
|
handleCancelModal: PropTypes.func,
|
|
2974
|
-
cmsTemplates: PropTypes.
|
|
3128
|
+
cmsTemplates: PropTypes.array,
|
|
2975
3129
|
getCmsTemplatesInProgress: PropTypes.bool,
|
|
2976
3130
|
showEdmEmailTemplates: PropTypes.bool,
|
|
2977
3131
|
toggleEdmEmailTemplateSelection: PropTypes.func,
|
|
@@ -27,6 +27,9 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
27
27
|
// let smsText = '';
|
|
28
28
|
if (this.props.content && this.props.charCounterEnabled) {
|
|
29
29
|
smsDetails = charCount.updateCharCount(this.props.content);
|
|
30
|
+
if (document.getElementById("msg_count")) {
|
|
31
|
+
document.getElementById("msg_count").val = smsDetails.msgCount;
|
|
32
|
+
}
|
|
30
33
|
//smsText = this.props.intl.formatMessage(messages.previewGenerationMessage);
|
|
31
34
|
//console.log('message text', smsText);
|
|
32
35
|
}
|
|
@@ -13,7 +13,7 @@ const StyledMessageContainer = styled.div`
|
|
|
13
13
|
font-family: open-sans,sans-serif;
|
|
14
14
|
margin-top: 64px;
|
|
15
15
|
margin-right: 32px;
|
|
16
|
-
z-index:
|
|
16
|
+
z-index: 10005;
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
class Toastr extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
package/containers/Cap/sagas.js
CHANGED
|
@@ -75,9 +75,22 @@ export function* fetchUserInfo() {
|
|
|
75
75
|
const userData = result.user;
|
|
76
76
|
// const orgId = yield select(makeSelectOrgId());
|
|
77
77
|
// yield put({type: types.GET_ORG_DETAILS_REQUEST, orgId});
|
|
78
|
+
const currentOrgDetails = result.currentOrgDetails;
|
|
79
|
+
if (!(currentOrgDetails && currentOrgDetails.basic_details && currentOrgDetails.basic_details.base_language && (currentOrgDetails.basic_details.base_language !== "" || currentOrgDetails.basic_details.base_language === null))) {
|
|
80
|
+
currentOrgDetails.basic_details.base_language = 'en';
|
|
81
|
+
}
|
|
82
|
+
if (!(currentOrgDetails && currentOrgDetails.basic_details && currentOrgDetails.basic_details.supported_languages && currentOrgDetails.basic_details.supported_languages.length > 0)) {
|
|
83
|
+
currentOrgDetails.basic_details.supported_languages = [
|
|
84
|
+
{
|
|
85
|
+
lang_id: 69,
|
|
86
|
+
language: "English",
|
|
87
|
+
iso_code: "en",
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}
|
|
78
91
|
yield call(LocalStorage.saveItem, 'orgID', result.currentOrgId);
|
|
79
92
|
yield call(LocalStorage.saveItem, 'user', userData);
|
|
80
|
-
yield put({type: types.GET_USER_DATA_SUCCESS, userData, currentOrgId: result.currentOrgId, currentOrgDetails
|
|
93
|
+
yield put({type: types.GET_USER_DATA_SUCCESS, userData, currentOrgId: result.currentOrgId, currentOrgDetails});
|
|
81
94
|
} catch (error) {
|
|
82
95
|
yield call(LocalStorage.clearItem, 'user');
|
|
83
96
|
yield put({
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
import { fromJS } from 'immutable';
|
|
8
8
|
import * as types from './constants';
|
|
9
9
|
|
|
10
|
-
const initialState = fromJS({
|
|
10
|
+
const initialState = fromJS({
|
|
11
|
+
createTemplateInProgress: false,
|
|
12
|
+
createResponse: {},
|
|
13
|
+
});
|
|
11
14
|
|
|
12
15
|
function ebillReducer(state = initialState, action) {
|
|
13
16
|
switch (action.type) {
|