@capillarytech/creatives-library 6.9.2 → 6.9.5

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.
Files changed (101) hide show
  1. package/components/CapTagList/index.js +1 -1
  2. package/components/Edmeditor/index.js +1 -1
  3. package/components/FormBuilder/index.js +1 -0
  4. package/components/TemplatePreview/_templatePreview.scss +6 -0
  5. package/components/TemplatePreview/index.js +35 -28
  6. package/config/app.js +1 -1
  7. package/containers/TagList/index.js +4 -5
  8. package/index.html +0 -5
  9. package/package.json +1 -2
  10. package/services/api.js +1 -16
  11. package/v2Components/CapTagList/index.js +26 -55
  12. package/v2Components/Carousel/index.js +120 -0
  13. package/v2Components/Carousel/style.scss +40 -0
  14. package/v2Components/CmsTemplatesComponent/index.js +4 -4
  15. package/v2Components/Edmeditor/index.js +1 -1
  16. package/v2Components/EmailPreview/_emailPreview.scss +2 -2
  17. package/v2Components/FormBuilder/index.js +43 -79
  18. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +151 -151
  19. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +33 -33
  20. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/tests/index.test.js +10 -10
  21. package/v2Components/TemplatePreview/_templatePreview.scss +1 -0
  22. package/v2Components/TemplatePreview/assets/images/androidPushMessage.svg +44 -44
  23. package/v2Components/TemplatePreview/assets/images/home-screen-android.svg +21 -21
  24. package/v2Components/TemplatePreview/assets/images/home-screen-ios.svg +16 -16
  25. package/v2Components/TemplatePreview/assets/images/iPhonePushMessage.svg +134 -134
  26. package/v2Components/TemplatePreview/assets/images/mobile.svg +23 -23
  27. package/v2Components/TemplatePreview/assets/images/sms_mobile_android.svg +22 -22
  28. package/v2Components/TemplatePreview/assets/images/user-icon.svg +18 -18
  29. package/v2Components/TemplatePreview/assets/images/wechat-home-screen-android.svg +21 -21
  30. package/v2Components/TemplatePreview/assets/images/wechat-mobile.svg +77 -77
  31. package/v2Components/TemplatePreview/assets/images/wechat_mobile_android.svg +20 -20
  32. package/v2Components/TemplatePreview/index.js +36 -29
  33. package/v2Components/TemplatePreview/tests/index.test.js +10 -10
  34. package/v2Containers/CreativesContainer/SlideBoxContent.js +7 -1
  35. package/v2Containers/CreativesContainer/SlideBoxFooter.js +51 -51
  36. package/v2Containers/CreativesContainer/actions.js +27 -27
  37. package/v2Containers/CreativesContainer/constants.js +17 -17
  38. package/v2Containers/CreativesContainer/index.js +2 -7
  39. package/v2Containers/CreativesContainer/index.scss +44 -44
  40. package/v2Containers/CreativesContainer/messages.js +305 -305
  41. package/v2Containers/CreativesContainer/reducer.js +29 -29
  42. package/v2Containers/CreativesContainer/sagas.js +11 -11
  43. package/v2Containers/CreativesContainer/selectors.js +30 -30
  44. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -18
  45. package/v2Containers/CreativesContainer/tests/index.test.js +10 -10
  46. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -9
  47. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -15
  48. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -10
  49. package/v2Containers/Email/constants.js +0 -1
  50. package/v2Containers/Email/index.js +115 -169
  51. package/v2Containers/Email/initialSchema.js +3 -18
  52. package/v2Containers/Email/sagas.js +2 -2
  53. package/v2Containers/Email/selectors.js +0 -5
  54. package/v2Containers/EmailWrapper/index.js +3 -19
  55. package/v2Containers/Line/Container/Image/index.js +21 -19
  56. package/v2Containers/Line/Container/ImageCarousel/Content.js +554 -0
  57. package/v2Containers/Line/Container/ImageCarousel/constants.js +10 -0
  58. package/v2Containers/Line/Container/ImageCarousel/index.js +526 -0
  59. package/v2Containers/Line/Container/ImageCarousel/messages.js +178 -0
  60. package/v2Containers/Line/Container/ImageCarousel/style.js +61 -0
  61. package/v2Containers/Line/Container/ImageMap/constants.js +2 -1
  62. package/v2Containers/Line/Container/ImageMap/index.js +31 -6
  63. package/v2Containers/Line/Container/ImageMap/messages.js +12 -0
  64. package/v2Containers/Line/Container/Wrapper/index.js +5 -1
  65. package/v2Containers/Line/Container/Wrapper/messages.js +4 -0
  66. package/v2Containers/Line/Container/Wrapper/utils.js +15 -16
  67. package/v2Containers/Line/Container/_lineCreate.scss +2 -2
  68. package/v2Containers/Line/Container/actions.js +4 -2
  69. package/v2Containers/Line/Container/constants.js +3 -0
  70. package/v2Containers/Line/Container/index.js +49 -11
  71. package/v2Containers/Line/Container/reducer.js +2 -2
  72. package/v2Containers/Line/Container/sagas.js +2 -2
  73. package/v2Containers/Line/Container/style.js +2 -1
  74. package/v2Containers/TagList/index.js +0 -6
  75. package/v2Containers/Templates/_templates.scss +9 -0
  76. package/v2Containers/Templates/actions.js +117 -122
  77. package/v2Containers/Templates/constants.js +47 -49
  78. package/v2Containers/Templates/index.js +47 -36
  79. package/v2Containers/Templates/messages.js +4 -8
  80. package/v2Containers/Templates/reducer.js +145 -153
  81. package/v2Containers/Templates/sagas.js +179 -179
  82. package/v2Containers/Templates/selectors.js +1 -19
  83. package/v2Containers/Templates/tests/actions.test.js +18 -18
  84. package/v2Containers/Templates/tests/index.test.js +10 -10
  85. package/v2Containers/Templates/tests/reducer.test.js +9 -9
  86. package/v2Containers/Templates/tests/sagas.test.js +15 -15
  87. package/v2Containers/Templates/tests/selectors.test.js +10 -10
  88. package/v2Containers/TemplatesV2/TemplatesV2.style.js +29 -29
  89. package/v2Containers/TemplatesV2/actions.js +16 -16
  90. package/v2Containers/TemplatesV2/constants.js +10 -10
  91. package/v2Containers/TemplatesV2/messages.js +61 -61
  92. package/v2Containers/TemplatesV2/selectors.js +25 -25
  93. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -18
  94. package/v2Containers/TemplatesV2/tests/index.test.js +10 -10
  95. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -9
  96. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -15
  97. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -10
  98. package/v2Components/BeeEditor/index.js +0 -272
  99. package/v2Components/BeeEditor/index.scss +0 -11
  100. package/v2Components/BeeEditor/messages.js +0 -47
  101. package/v2Components/BeeEditor/tests/index.test.js +0 -10
@@ -33,6 +33,7 @@ import { EMAIL } from '../CreativesContainer/constants';
33
33
  import { GA } from '@capillarytech/cap-ui-utils';
34
34
  import { TRACK_CREATE_EMAIL, TRACK_EDIT_EMAIL } from '../App/constants';
35
35
  import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
36
+
36
37
  const {CapCustomCardList} = CapCustomCard;
37
38
  export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
38
39
  constructor(props) {
@@ -178,23 +179,24 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
178
179
  // "template-content": (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''),
179
180
  // };
180
181
  // if (this.props.Templates.CmsSettings) {}
181
-
182
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
182
183
  if (this.props.location.query.module === "library" && this.props.templateData) {
183
184
  this.props.templatesActions.resetTemplateData();
184
185
  }
185
- const isBEESupport = (this.props.location.query.isBEESupport !== "false") || false;
186
-
187
- if (!_.isEmpty(this.props.Templates.BEETemplate) ) {
188
- if (this.props.Templates.BEETemplate.versions.base.is_drag_drop) {
186
+ if (!_.isEmpty(this.props.Templates.edmTemplate)) {
187
+ if (this.props.Templates.edmTemplate.versions.base.is_drag_drop) {
189
188
  this.setState({isDragDrop: true});
190
189
  }
191
190
  if (this.props.params.id) {
192
- this.props.actions.getCmsSetting('BEE', this.props.Templates.BEETemplate._id, 'open', undefined, isBEESupport);
191
+ this.props.actions.getCmsSetting('edm', this.props.Templates.edmTemplate.versions.base.drag_drop_id, 'open', undefined, isEdmSupport);
193
192
  } else if (this.props.location.query.module !== "library" || (this.props.location.query.module === "library" && !this.props.templateData)) {
194
- this.props.actions.getCmsSetting('BEE', this.props.Templates.BEETemplate._id, 'create', undefined, isBEESupport);
193
+ this.props.actions.getCmsSetting('edm', this.props.Templates.edmTemplate.versions.base.drag_drop_id, 'create', undefined, isEdmSupport);
195
194
  }
196
195
  }
197
- this.setState({ content: (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''), formData});
196
+
197
+ this.setState({ content: (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''), formData}, () => {
198
+ // this.injectEvents(this.state.schema);
199
+ });
198
200
 
199
201
  // setTimeout(() => {
200
202
  // // this.getFormData();
@@ -214,6 +216,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
214
216
  this.showNext();
215
217
  }
216
218
  }
219
+
217
220
  componentWillReceiveProps(nextProps) {
218
221
  // if (this.props.location.query.type === 'embedded') {
219
222
  // this.showNext();
@@ -313,16 +316,16 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
313
316
  this.startTemplateCreation(nextProps.templateData);
314
317
  }
315
318
  if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
316
- const formData = this.state.formData;
317
- let isBeeEditor = false;
318
- _.forEach(formData[0].selectedLanguages, (language) => {
319
- if (formData[0][language].is_drag_drop) {
320
- isBeeEditor = true;
321
- }
322
- });
323
319
  if (this.props.isFullMode) {
324
320
  let triggerGetFormData = true;
325
- triggerGetFormData = isBeeEditor ? (!nextProps.Email.fetchingCmsData && _.isEmpty(nextProps.Email.cmsData)) : !nextProps.Email.createTemplateInProgress && _.isEmpty(nextProps.Email.createResponse); // if edm editor selected check for getCmsData call in progress or not before triggering save
321
+ let isEdmEditor = false;
322
+ const formData = this.state.formData;
323
+ _.forEach(formData[0].selectedLanguages, (language) => {
324
+ if (formData[0][language].is_drag_drop) {
325
+ isEdmEditor = true;
326
+ }
327
+ });
328
+ triggerGetFormData = isEdmEditor ? (!nextProps.Email.fetchingCmsData && _.isEmpty(nextProps.Email.cmsData)) : !nextProps.Email.createTemplateInProgress && _.isEmpty(nextProps.Email.createResponse); // if edm editor selected check for getCmsData call in progress or not before triggering save
326
329
  if (triggerGetFormData) {
327
330
  this.getFormData();
328
331
  }
@@ -332,9 +335,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
332
335
  }
333
336
  this.getFormData();
334
337
  }
335
- if (!nextProps.Email.createTemplateInProgress && isBeeEditor) {
336
- this.beeInstance && this.beeInstance.save();
337
- }
338
338
  }
339
339
 
340
340
  if (!_.isEmpty(nextProps.Email.CmsSettings) && !_.isEqual(this.props.Email.CmsSettings, nextProps.Email.CmsSettings) && !_.isEmpty(this.state.schema)) {
@@ -348,26 +348,16 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
348
348
 
349
349
  const temp = schema.containers[this.state.currentTab - 1];
350
350
 
351
- const { currentTab } = this.state;
351
+
352
352
  if (nextProps.Email.CmsSettings.isDragDrop) {
353
- const beeJson = `BEEeditor${currentTab > 1 ? currentTab : ''}json`;
354
- const beeToken = `BEEeditor${currentTab > 1 ? currentTab : ''}token`;
355
- let beeJsonValue = _.get(nextProps, 'Templates.BEETemplate.versions.base.json-content', '');
356
- const selectedId = _.get(this.props, 'Email.templateDetails._id', '') || _.get(this.props, 'Templates.BEETemplate._id', '');
357
- if (this.state.isEdit) {
358
- if (this.props.location.query.module === "library") {
359
- beeJsonValue = _.get(this.state, `formData[${currentTab - 1}][${langId}].json-content`, '');
360
- } else {
361
- beeJsonValue = _.get(nextProps, `Email.templateDetails.versions.base[${langId}].json-content`, '');
362
- }
353
+ formData[`${this.state.currentTab - 1}`][langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
354
+ formData[`${this.state.currentTab - 1}`][langId][`drag_drop_id`] = this.getParameterByName("projectId", nextProps.Email.CmsSettings.url);
355
+ formData[`${this.state.currentTab - 1}`][langId][`is_drag_drop`] = true;
356
+ if (formData[`${this.state.currentTab - 1}`].base) {
357
+ formData.base[langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
358
+ formData.base[langId][`drag_drop_id`] = this.getParameterByName("projectId", nextProps.Email.CmsSettings.url);
359
+ formData.base[langId][`is_drag_drop`] = true;
363
360
  }
364
- formData[`${currentTab - 1}`][langId] = {
365
- ...formData[`${currentTab - 1}`][langId],
366
- is_drag_drop: true,
367
- [beeJson]: beeJsonValue,
368
- [beeToken]: nextProps.Email.CmsSettings.tokenData,
369
- id: selectedId,
370
- };
371
361
  _.forEach(temp.panes, (pane, index) => {
372
362
  const tempPane = pane;
373
363
  //
@@ -377,6 +367,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
377
367
  tempPane.sections[0].inputFields[0].cols[0].colStyle = {display: "none"};
378
368
  }
379
369
  });
370
+
380
371
  this.setState({schema, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1});
381
372
  } else {
382
373
  _.forEach(temp.panes, (pane, index) => {
@@ -393,7 +384,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
393
384
  html = html.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\\&quot;/g, '"');
394
385
 
395
386
  formData[this.state.currentTab - 1][langId]["template-content"] = html;
396
- if (window.CKEDITOR && apiLangId !== "undefined" && !this.props.Email.fetchingCmsSettings && !this.props.Email.getTemplateDetailsInProgress) {
387
+ if (window.CKEDITOR && apiLangId !== "undefined") {
397
388
  const instanceName = `template-content${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`;
398
389
 
399
390
  _.forEach(window.CKEDITOR.instances, (winInstance) => {
@@ -431,26 +422,23 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
431
422
  if (formData[`${this.state.currentTab - 1}`].base) {
432
423
  formData.base[formData.base.activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
433
424
  }
434
- } else if (!nextProps.Email.getTemplateDetailsInProgress) {
425
+ } else {
435
426
  const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(formData[this.state.currentTab - 1].activeTab);
436
427
  const instanceName = `template-content${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`;
437
428
 
438
- if (window.CKEDITOR) {
439
- _.forEach(window.CKEDITOR.instances, (winInstance) => {
440
- const temp = winInstance;
429
+ _.forEach(window.CKEDITOR.instances, (winInstance) => {
430
+ const temp = winInstance;
441
431
 
442
- if (winInstance.name === instanceName) {
443
- temp.setData(decodeURIComponent(nextProps.Email.cmsData));
444
- } else if (winInstance.name.indexOf('editor') !== -1) {
445
- temp.setData(decodeURIComponent(nextProps.Email.cmsData));
446
- }
447
- });
448
- }
432
+ if (winInstance.name === instanceName) {
433
+ temp.setData(decodeURIComponent(nextProps.Email.cmsData));
434
+ } else if (winInstance.name.indexOf('editor') !== -1) {
435
+ temp.setData(decodeURIComponent(nextProps.Email.cmsData));
436
+ }
437
+ });
449
438
  formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
450
439
  formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop = false;
451
440
  formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id = "";
452
441
  delete formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].edmeditorsrc;
453
- // from edm to ck editor
454
442
  if (formData[`${this.state.currentTab - 1}`].base) {
455
443
  formData.base[formData.base.activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
456
444
  formData.base[formData.base.activeTab].is_drag_drop = false;
@@ -468,8 +456,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
468
456
 
469
457
  if ( !_.isEqual(nextProps.Email.uploadAssetSuccess, this.props.Email.uploadAssetSuccess) && nextProps.Email.uploadAssetSuccess) {
470
458
  const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
471
- const isBEESupport = (this.props.location.query.isBEESupport !== "false") || false;
472
- if (isDragDrop && isBEESupport) {
459
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
460
+ if (isDragDrop && isEdmSupport) {
473
461
  const evtData = JSON.parse(this.edmEvent.data);
474
462
  if (evtData.action === 'editBackground') {
475
463
  this.edmEvent.source.postMessage(JSON.stringify({
@@ -513,12 +501,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
513
501
  this.setState({totalCount: nextProps.Email.assetList[0].totalCount});
514
502
  }
515
503
  }
516
- if (!_.isEmpty(nextProps.Email.templateDetails) && _.isEmpty(this.props.Email.templateDetails) ) {
517
- const base = nextProps.Email.templateDetails.versions.base;
518
- if (nextProps.Email.templateDetails.versions.base[base.activeTab].is_drag_drop) {
519
- this.setState({isDragDrop: true});
520
- }
521
- }
522
504
  }
523
505
 
524
506
  componentWillUnmount() {
@@ -603,9 +585,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
603
585
  onTagSelect = (data) => {
604
586
  const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
605
587
  const formData = _.cloneDeep(this.state.formData);
606
- const isBEESupport = (this.props.location.query.isBEESupport !== "false") || false;
588
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
607
589
 
608
- if (isDragDrop && isBEESupport) {
590
+ if (isDragDrop && isEdmSupport) {
609
591
  let msg = {};
610
592
  if (data === "unsubscribe") {
611
593
  const anchor = `<a href='{{${data}}}'>${data}</a>`;
@@ -646,12 +628,10 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
646
628
  onUpdateTemplateComplete = (createResponse) => {
647
629
  const {isEdit, formData = {} } = this.state || {};
648
630
  const base = formData.base || {};
649
- const isDragDrop = _.get(base[base.activeTab], 'is_drag_drop');
650
- let editorType = '';
651
- if ( isDragDrop === true) {
631
+ const isDragDrop = _.get(base[base.activeTab], 'is_drag_drop', false);
632
+ let editorType = 'ckEditor';
633
+ if ( isDragDrop ) {
652
634
  editorType = 'edmEditor';
653
- } else if (isDragDrop === false) {
654
- editorType = 'ckEditor';
655
635
  }
656
636
  GA.timeTracker.stopTimer(isEdit ? TRACK_EDIT_EMAIL : TRACK_CREATE_EMAIL, {
657
637
  category: 'Creatives',
@@ -670,14 +650,14 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
670
650
  const module = this.props.location.query.module ? this.props.location.query.module : 'default';
671
651
  const type = this.props.location.query.type;
672
652
  const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
673
- const isBEESupport = (this.props.location.query.isBEESupport !== "false") || false;
653
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
674
654
  if (this.props.isFullMode) {
675
655
  const {versions, ...rest} = createResponse.templateId;
676
656
  this.props.getFormSubscriptionData({ value: versions, ...rest, validity: true});
677
657
  } else {
678
658
  this.props.router.push({
679
659
  pathname: `/email`,
680
- query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isBEESupport} : {module, isLanguageSupport, isBEESupport},
660
+ query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport},
681
661
  });
682
662
  }
683
663
  }
@@ -695,10 +675,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
695
675
  }
696
676
  getValidationData = () => {
697
677
  const that = this;
698
- let id = _.get(this.props, 'Email.templateDetails._id', '') || _.get(this.props, 'Templates.BEETemplate._id', '');
699
- if (!id) {
700
- id = _.get(formData, `base[${formData.base.activeTab}].id`, '');
701
- }
702
678
  const formData = _.cloneDeep(this.state.formData);
703
679
  if (!this.props.Email.fetchingCmsData) {
704
680
  // checking wheather getCmsData in progress or not cuz getValidationData gets called multiple times from handleEdmSave
@@ -706,7 +682,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
706
682
  if (!isNaN(index)) {
707
683
  _.forEach(val.selectedLanguages, (language) => {
708
684
  if (val[language].is_drag_drop) {
709
- that.props.actions.getCmsData('BEE', id, language);
685
+ that.props.actions.getCmsData('edm', val[language].drag_drop_id, language);
710
686
  }
711
687
  });
712
688
  }
@@ -771,7 +747,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
771
747
  }
772
748
 
773
749
  setEditData(editData) {
774
- const isBEESupport = (this.props.location.query.isBEESupport !== "false") || false;
750
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
775
751
  const formData = _.cloneDeep(this.state.formData);
776
752
 
777
753
  const schema = (this.props.location.query.type === 'embedded') ? this.removeStandAlone(this.state.schema) : _.cloneDeep(this.state.schema);
@@ -914,7 +890,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
914
890
  // formData.base.activeTab = language;
915
891
  // }
916
892
  if (language && editData.versions.base[language].is_drag_drop) {
917
- this.props.actions.getCmsSetting('BEE', editData._id, 'open', language, isBEESupport);
893
+ this.props.actions.getCmsSetting('edm', editData.versions.base[language].drag_drop_id, 'open', language, isEdmSupport);
918
894
  }
919
895
  });
920
896
 
@@ -931,6 +907,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
931
907
  value: 'edit',
932
908
  direction: e.value,
933
909
  };
910
+ parent.postMessage(JSON.stringify(response), '*');
934
911
  }
935
912
 
936
913
  getEditorInstanse = () => {
@@ -1010,8 +987,17 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1010
987
  if (saveCount === 0) {
1011
988
  //gets exicuted when ck editor is used
1012
989
  this.startValidation(true);
990
+ return;
1013
991
  }
1014
- this.setState({targetSaveCount: saveCount, mode: "save", saveCount: 0, cmsDataCount: 0});
992
+ this.setState({targetSaveCount: saveCount, mode: "save", saveCount: 0, cmsDataCount: 0}, () => {
993
+ const data = this.state.formData[this.state.currentTab - 1];
994
+ _.forEach(data.selectedLanguages, (language, langIndex) => {
995
+ if (data[language].is_drag_drop) {
996
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
997
+ win.postMessage("saveProject", '*');
998
+ }
999
+ });
1000
+ });
1015
1001
  });
1016
1002
  }
1017
1003
 
@@ -1125,7 +1111,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1125
1111
  const currentTab = this.state.currentTab - 1;
1126
1112
  const baseLanguage = this.props.currentOrgDetails.basic_details.base_language ? this.props.currentOrgDetails.basic_details.base_language : 'en';
1127
1113
  if (formData[currentTab][baseLanguage].is_drag_drop) {
1128
- this.props.actions.getCmsSetting('BEE', formData[currentTab][baseLanguage].drag_drop_id, 'duplicate', baseLanguage, isEdmSupport);
1114
+ this.props.actions.getCmsSetting('edm', formData[currentTab][baseLanguage].drag_drop_id, 'duplicate', baseLanguage, isEdmSupport);
1129
1115
  }
1130
1116
  });
1131
1117
  }
@@ -1254,7 +1240,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1254
1240
  const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})] || {iso_code: baseLanguage || 'en', lang_id: -1, language: baseLanguage || "English"};
1255
1241
  baseData.activeTab = baseLanguage;
1256
1242
  baseData[languageObject.iso_code] = {};
1257
- baseData[languageObject.iso_code].is_drag_drop = undefined;
1243
+ baseData[languageObject.iso_code].is_drag_drop = false;
1258
1244
  baseData[languageObject.iso_code].lang_id = languageObject.lang_id;
1259
1245
  baseData[languageObject.iso_code].iso_code = languageObject.iso_code;
1260
1246
  baseData[languageObject.iso_code].language = languageObject.language;
@@ -1284,13 +1270,12 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1284
1270
  return;
1285
1271
  }
1286
1272
  tmpData.html_content = content['template-content'];
1287
- tmpData.json_content = content['json-content'];
1288
1273
  tmpData.is_drag_drop = content.is_drag_drop;
1289
1274
  tmpData.lang_id = content.lang_id;
1290
1275
  tmpData.iso_code = content.iso_code;
1291
1276
  tmpData.language = content.language;
1292
- if (content.id) {
1293
- tmpData.id = content.id;
1277
+ if (content.is_drag_drop) {
1278
+ tmpData.drag_drop_id = (content.drag_drop_id ? content.drag_drop_id : "");
1294
1279
  }
1295
1280
 
1296
1281
  if (index === this.props.currentOrgDetails.basic_details.base_language) {
@@ -1328,10 +1313,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1328
1313
  this.onImageSelect();
1329
1314
  }
1330
1315
  break;
1331
- case "create": {
1316
+ case "create":
1332
1317
  this.edmEvent = e;
1333
1318
  break;
1334
- }
1335
1319
  case "select":
1336
1320
  //this.edmEvent = e;
1337
1321
  break;
@@ -1399,14 +1383,10 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1399
1383
  }
1400
1384
  });
1401
1385
  } else if (this.state.mode === 'preview' || this.state.mode === 'switchEditor') {
1402
- let id = _.get(this.props, 'Email.templateDetails._id', '') || _.get(this.props, 'Templates.BEETemplate._id', '');
1403
- const formData = _.cloneDeep(this.state.formData);
1404
- if (!id) {
1405
- id = _.get(formData, `base[${formData.base.activeTab}].id`, '');
1406
- }
1407
- this.props.actions.getCmsData('BEE', id);
1386
+ this.props.actions.getCmsData('edm', this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id);
1408
1387
  if (this.state.mode === 'switchEditor') {
1409
1388
  let schema = _.cloneDeep(this.state.schema);
1389
+ const formData = _.cloneDeep(this.state.formData);
1410
1390
  _.forEach(schema.containers, (container, index) => {
1411
1391
  if (parseInt(index, 10) === (this.state.currentTab - 1)) {
1412
1392
  const temp = container;
@@ -1548,8 +1528,14 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1548
1528
  toggleEmailPreview = () => {
1549
1529
  const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
1550
1530
  if (isDragDrop && !this.state.showEmailPreview) {
1551
- this.handleEdmSave();
1531
+ const activeLangTab = this.state.formData[`${this.state.currentTab - 1}`].activeTab;
1532
+ const langIndex = this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
1533
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
1534
+ win.postMessage("saveProject", '*');
1552
1535
  this.setState({mode: "preview", gettingPreviewData: true});
1536
+ // this.setState({gettingPreviewData: true}, () => {
1537
+ // this.props.actions.getCmsData('edm', this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id);
1538
+ // });
1553
1539
  } else if (this.state.showEmailPreview) {
1554
1540
  const formData = _.cloneDeep(this.state.formData);
1555
1541
  formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = "";
@@ -1751,6 +1737,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1751
1737
  schema.containers[`${this.state.currentTab - 1}`].panes.push(firstPane);
1752
1738
  // schema.containers[0].tabContent.sections.push(tabContent);
1753
1739
  }
1740
+ //this.props.templatesActions.getEdmDefaultTemplates();
1754
1741
  const container = schema.containers[this.state.currentTab - 1];
1755
1742
  const temp = container;
1756
1743
  if (this.state.addLanguageType === "upload") {
@@ -1851,7 +1838,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1851
1838
  action: "showNext",
1852
1839
  value: true,
1853
1840
  };
1854
-
1841
+ parent.postMessage(JSON.stringify(response), '*');
1855
1842
  }
1856
1843
 
1857
1844
  moveToTemplates = () => {
@@ -2006,7 +1993,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2006
1993
  const response = {
2007
1994
  action: 'startTemplateCreation',
2008
1995
  };
2009
- parent && parent.postMessage(JSON.stringify(response), '*');
1996
+ parent.postMessage(JSON.stringify(response), '*');
2010
1997
  }
2011
1998
  });
2012
1999
  return temp;
@@ -2099,8 +2086,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2099
2086
  "iso_code": this.supportedLanguages[languageIndex].iso_code,
2100
2087
  "language": this.supportedLanguages[languageIndex].language,
2101
2088
  "template-content": !data.base.is_drag_drop && data.base.is_drag_drop !== 1 ? data.base.html_content : "",
2102
- "json-content": data.base.json_content,
2103
- "id": data.base.id,
2104
2089
  };
2105
2090
  const dragDropId = _.get(data, 'base.drag_drop_id');
2106
2091
  if (dragDropId) {
@@ -2129,7 +2114,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2129
2114
  };
2130
2115
  if (templates.drag_drop_id) {
2131
2116
  tempData.drag_drop_id = templates.drag_drop_id;
2132
- this.props.actions.getCmsSetting('BEE', tempData._id, 'open', tempData.iso_code, isEdmSupport);
2117
+ this.props.actions.getCmsSetting('edm', tempData.drag_drop_id, 'open', tempData.iso_code, isEdmSupport);
2133
2118
  }
2134
2119
  // formData.usingTabContainer = true;
2135
2120
  // formData.tabCount = 1;
@@ -2155,7 +2140,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2155
2140
  // this.setState({tabKey: ''});
2156
2141
  _.forEach(formData[0].selectedLanguages, (language) => {
2157
2142
  if (formData[0][language].is_drag_drop) {
2158
- this.props.actions.getCmsSetting('BEE', formData[0][language].drag_drop_id, 'open', language, isEdmSupport);
2143
+ this.props.actions.getCmsSetting('edm', formData[0][language].drag_drop_id, 'open', language, isEdmSupport);
2159
2144
  }
2160
2145
  });
2161
2146
  });
@@ -2348,6 +2333,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2348
2333
 
2349
2334
  saveFormData = (passedData) => {
2350
2335
  //saveFormData gets called only when validation result is true
2336
+
2351
2337
  if (this.state.gettingFormData && !this.props.isFullMode) {
2352
2338
  const response = {
2353
2339
  action: "getFormData",
@@ -2361,13 +2347,12 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2361
2347
  if (this.props.location.query.module === 'library' && this.props.isGetFormData) {
2362
2348
  this.props.getFormSubscriptionData(response);
2363
2349
  }
2350
+ parent.postMessage(JSON.stringify(response), "*");
2364
2351
  this.setState({gettingFormData: false, startValidation: false, loading: true});
2365
2352
  return;
2366
2353
  }
2367
2354
  const formData = _.cloneDeep(passedData);
2368
- const { currentTab } = _.cloneDeep(this.state);
2369
- delete formData[currentTab - 1][formData[currentTab - 1].activeTab][`BEEeditor${currentTab > 1 ? currentTab : ''}json`];
2370
- delete formData[currentTab - 1][formData[currentTab - 1].activeTab][`BEEeditor${currentTab > 1 ? currentTab : ''}token`];
2355
+
2371
2356
  const obj = {};
2372
2357
  obj.versions = {
2373
2358
  base: {},
@@ -2437,7 +2422,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2437
2422
  const langIndex = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
2438
2423
 
2439
2424
  this.setState({mode: "switchEditor"}, () => {
2440
- this.handleEdmSave();
2425
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
2426
+ win.postMessage("saveProject", '*');
2441
2427
  });
2442
2428
  }
2443
2429
 
@@ -2479,7 +2465,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2479
2465
  this.setState( (prevState) => ({
2480
2466
  showEdmEmailTemplates: !prevState.showEdmEmailTemplates}), () => {
2481
2467
  if (this.state.showEdmEmailTemplates) {
2482
- this.props.templatesActions.getDefaultBeeTemplates();
2468
+ this.props.templatesActions.getEdmDefaultTemplates();
2483
2469
  }
2484
2470
  });
2485
2471
  };
@@ -2493,7 +2479,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2493
2479
  // let getQuery = '';
2494
2480
  const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
2495
2481
 
2496
- this.props.actions.getCmsSetting('BEE', data._id, 'create', this.state.formData[this.state.currentTab - 1].activeTab, isEdmSupport);
2482
+ this.props.actions.getCmsSetting('edm', data.versions.base.drag_drop_id, 'create', this.state.formData[this.state.currentTab - 1].activeTab, isEdmSupport);
2497
2483
  // this.props.templatesActions.setEdmTemplate(data);
2498
2484
  this.toggleEdmEmailTemplateSelection();
2499
2485
  // if (type && type.toLowerCase() === 'email') {
@@ -2509,22 +2495,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2509
2495
  };
2510
2496
  isEmailLoading = () => {
2511
2497
  //let {isLoading} = this.props;
2512
- const { Email, isLoadingMetaEntities, setIsLoadingContent } = this.props;
2513
- const {
2514
- fetchingCmsData,
2515
- getTemplateDetailsInProgress,
2516
- assetUploading,
2517
- createTemplateInProgress,
2518
- } = this.props.Email;
2519
- let isLoading =
2520
- isLoadingMetaEntities ||
2521
- this.state.loading || (
2522
- Email && "createTemplateInProgress" in Email && createTemplateInProgress
2523
- ) || (
2524
- assetUploading !== undefined && assetUploading
2525
- ) || (
2526
- Email && (fetchingCmsData || getTemplateDetailsInProgress)
2527
- );
2498
+ let isLoading = this.props.isLoadingMetaEntities || this.state.loading || (this.props.Email && "createTemplateInProgress" in this.props.Email && this.props.Email.createTemplateInProgress) || (this.props.Email.assetUploading !== undefined && this.props.Email.assetUploading);
2528
2499
 
2529
2500
  if (!isLoading) {
2530
2501
  isLoading = this.state.loadingStatus < 2;
@@ -2532,7 +2503,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2532
2503
  // if (isLoading) {
2533
2504
  // this.props.creativesContainerActions.hideCreativesContanerLoader();
2534
2505
  // }
2535
- if (!isLoading && setIsLoadingContent) {
2506
+ if (!isLoading && this.props.setIsLoadingContent) {
2536
2507
  this.props.setIsLoadingContent(isLoading);
2537
2508
  }
2538
2509
  return isLoading;
@@ -2581,26 +2552,30 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2581
2552
  </div>
2582
2553
  </div>
2583
2554
  );
2584
- getImagePreviewContent = () => {
2585
- const { assetList = [], fetchingAllAssets, fetchAllAssetSuccess } = this.props.Email || {};
2586
- return (
2587
- <div key="creatives-email-add-image-container">
2588
- {this.getFilterContent()}
2589
- <Pagination onPageChange={() => { this.fetchAllAssets({getNextPage: true}); }} paginationSelector="pagination-container">
2590
- {(!fetchingAllAssets && (!fetchAllAssetSuccess || (fetchAllAssetSuccess && !assetList.length))) ? (
2591
- <FormattedMessage {...messages.noImgInGallery}/>
2592
- ) : this.getTemplateDataForGrid({
2593
- isLoading: fetchingAllAssets,
2594
- loadingTip: <FormattedMessage {...messages.loadingImages}/>,
2595
- channel: this.state.channel,
2596
- templates: assetList,
2597
- handlers: {onItemClick: this.handleOnItemClick}})
2598
- }
2599
-
2600
- </Pagination>
2601
- </div>
2602
- );
2603
- };
2555
+ getImagePreviewContent = () => (
2556
+ <div key="creatives-email-add-image-container">
2557
+ {this.getFilterContent()}
2558
+ <Pagination onPageChange={() => { this.fetchAllAssets({getNextPage: true}); }} paginationSelector="pagination-container">
2559
+ {/* <CardGrid
2560
+ listItem={this.prepareImageData()}
2561
+ filterContent={filterContent}
2562
+ onHoverItem={this.handleOnHoverItem}
2563
+ onItemClick={this.handleOnItemClick}
2564
+ colNumber={2}
2565
+ enablePagination
2566
+ isLoading={}
2567
+ /> */}
2568
+ {this.props.Email.assetList && this.props.Email.assetList.length ? this.getTemplateDataForGrid({
2569
+ isLoading: this.props.Email.fetchingAllAssets,
2570
+ loadingTip: <FormattedMessage {...messages.loadingImages}/>,
2571
+ channel: this.state.channel,
2572
+ templates: this.props.Email.assetList,
2573
+ handlers: {onItemClick: this.handleOnItemClick}})
2574
+ : <FormattedMessage {...messages.noImgInGallery}/>}
2575
+
2576
+ </Pagination>
2577
+ </div>
2578
+ );
2604
2579
 
2605
2580
  showTestAndPreviewIcons = (action) => {
2606
2581
  const { formData = [] } = this.state;
@@ -2627,29 +2602,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2627
2602
  </CapButton>
2628
2603
  );
2629
2604
  };
2630
- saveBeeInstance = (instance) => {
2631
- this.beeInstance = instance;
2632
- }
2633
- saveBeeData = (json, html) => {
2634
- this.setState((prevState) => {
2635
- const { currentTab, formData } = _.cloneDeep(prevState);
2636
- const activeTab = formData[currentTab - 1].activeTab;
2637
- formData[currentTab - 1][activeTab]['template-content'] = html;
2638
- formData[currentTab - 1][activeTab]['json-content'] = json;
2639
-
2640
- formData.base[activeTab]['template-content'] = html;
2641
- formData.base[activeTab]['json-content'] = json;
2642
-
2643
- return {
2644
- ...prevState,
2645
- formData,
2646
- };
2647
- }, () => {
2648
- this.setState({
2649
- startValidation: true,
2650
- });
2651
- });
2652
- }
2653
2605
 
2654
2606
  render() {
2655
2607
  // const pageHeading = (this.state.isEdit) ? this.props.intl.formatMessage(messages.editHeading) : this.props.intl.formatMessage(messages.createHeading);
@@ -2659,7 +2611,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2659
2611
  const previewHeader = (<h3>{this.props.intl.formatMessage(messages.h3emailPreview)}</h3>);
2660
2612
  const imagePreviewHeader = (<h3>{this.props.intl.formatMessage(messages.h3imageSelection)}</h3>);
2661
2613
  const imagePreviewContent = this.getImagePreviewContent();
2662
- const { selectedOfferDetails, getDefaultTags, Email: { CmsSettings = {} } = {} } = this.props;
2614
+ const { selectedOfferDetails, getDefaultTags } = this.props;
2663
2615
  if (!this.props.currentOrgDetails || !this.props.currentOrgDetails.basic_details) {
2664
2616
  return (<div>Loading...</div>);
2665
2617
  }
@@ -2720,11 +2672,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2720
2672
  saveForm={this.state.saveForm}
2721
2673
  stopValidation={this.stopValidation}
2722
2674
  selectedOfferDetails={selectedOfferDetails}
2723
- saveBeeInstance={this.saveBeeInstance}
2724
- saveBeeData={this.saveBeeData}
2725
- uuid={CmsSettings.uuid}
2726
- type={CmsSettings.type}
2727
- isEmailLoading={isLoading}
2728
2675
  /> : ''}
2729
2676
  </Col>
2730
2677
  </Row>
@@ -2743,9 +2690,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2743
2690
  show={this.state.showImageSelectionBox}
2744
2691
  handleClose={this.handleImagePreviewClose}
2745
2692
  isLoading={this.props.Email.fetchingAllAssets}
2746
- size="size-xl"
2693
+ size="size-l"
2747
2694
  />
2748
- {/* <div id="bee-plugin-container" style={{ height: '600px'}}></div> */}
2749
2695
  {this.state.showConfirmationModal && this.renderConfirmationModal()}
2750
2696
  </div>
2751
2697
  );