@capillarytech/creatives-library 3.0.5 → 3.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.
Files changed (71) hide show
  1. package/components/FormBuilder/index.js +15 -15
  2. package/containers/Dashboard/index.js +5 -0
  3. package/containers/Email/index.js +5 -4
  4. package/containers/Line/Create/index.js +3 -3
  5. package/containers/MobilePush/Edit/index.js +2 -2
  6. package/containers/WeChat/MapTemplates/index.js +64 -58
  7. package/containers/WeChat/RichmediaTemplates/Create/index.js +3 -3
  8. package/index.html +3 -0
  9. package/package.json +1 -1
  10. package/routes.js +1 -3
  11. package/v2Components/FormBuilder/index.js +12 -18
  12. package/v2Components/NavigationBar/index.js +7 -4
  13. package/v2Components/NavigationBar/messages.js +6 -2
  14. package/v2Containers/Cap/index.js +2 -1
  15. package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -2
  16. package/v2Containers/Email/index.js +27 -42
  17. package/v2Containers/Email/initialSchema.js +2 -58
  18. package/v2Containers/Email/messages.js +4 -0
  19. package/v2Containers/Email/sagas.js +0 -2
  20. package/v2Containers/MobilePush/Create/actions.js +2 -2
  21. package/v2Containers/MobilePush/Create/index.js +17 -16
  22. package/v2Containers/MobilePush/Create/messages.js +1 -1
  23. package/v2Containers/MobilePush/Create/sagas.js +3 -0
  24. package/v2Containers/MobilePush/Edit/index.js +13 -7
  25. package/v2Containers/MobilePush/initialSchema.js +3 -0
  26. package/v2Containers/MobilepushWrapper/index.js +3 -1
  27. package/v2Containers/Templates/index.js +14 -11
  28. package/assets/android-message-gui-2.svg +0 -55
  29. package/components/CallTaskPreview/_callTaskPreview.scss +0 -17
  30. package/components/CallTaskPreview/images/Footer.png +0 -0
  31. package/components/CallTaskPreview/images/Header.png +0 -0
  32. package/components/CallTaskPreview/index.js +0 -37
  33. package/components/CallTaskPreview/messages.js +0 -13
  34. package/components/CallTaskPreview/tests/index.test.js +0 -15
  35. package/components/CmsTemplatesComponent/index.js +0 -33
  36. package/components/CmsTemplatesComponent/messages.js +0 -17
  37. package/components/CmsTemplatesComponent/tests/index.test.js +0 -10
  38. package/components/EmailMobilePreview/index.js +0 -129
  39. package/components/EmailMobilePreview/index.scss +0 -55
  40. package/components/EmailPreviewV2/_emailPreviewV2.scss +0 -69
  41. package/components/EmailPreviewV2/index.js +0 -132
  42. package/components/EmailPreviewV2/messages.js +0 -41
  43. package/components/EmailPreviewV2/tests/index.test.js +0 -10
  44. package/components/MobilePushPreviewV2/index.js +0 -120
  45. package/components/MobilePushPreviewV2/messages.js +0 -13
  46. package/components/MobilePushPreviewV2/tests/index.test.js +0 -10
  47. package/components/NewCallTask/_newCallTask.scss +0 -9
  48. package/components/NewCallTask/index.js +0 -152
  49. package/components/NewCallTask/messages.js +0 -29
  50. package/components/NewCallTask/tests/index.test.js +0 -10
  51. package/components/SmsPreviewV2/_smsPreviewV2.scss +0 -353
  52. package/components/SmsPreviewV2/index.js +0 -69
  53. package/components/SmsPreviewV2/messages.js +0 -13
  54. package/components/SmsPreviewV2/tests/index.test.js +0 -10
  55. package/v2Components/DateFilter/index.js +0 -349
  56. package/v2Components/DateFilter/messages.js +0 -17
  57. package/v2Components/DateFilter/tests/index.test.js +0 -15
  58. package/v2Components/DateRange/index.js +0 -113
  59. package/v2Components/DateRange/messages.js +0 -13
  60. package/v2Components/DateRange/tests/index.test.js +0 -10
  61. package/v2Components/PageHeader/_pageHeader.scss +0 -22
  62. package/v2Components/PageHeader/index.js +0 -37
  63. package/v2Components/PageHeader/messages.js +0 -13
  64. package/v2Components/PageHeader/tests/index.test.js +0 -10
  65. package/v2Components/Sidebar/_sidebar.scss +0 -115
  66. package/v2Components/Sidebar/index.js +0 -208
  67. package/v2Components/Sidebar/messages.js +0 -21
  68. package/v2Components/Sidebar/tests/index.test.js +0 -10
  69. package/v2Components/SmsEditor/index.js +0 -55
  70. package/v2Components/SmsEditor/tests/index.test.js +0 -10
  71. package/v2Components/TopBar/_topbar.scss +0 -46
@@ -285,14 +285,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
285
285
  if (!_.isEmpty(this.state.schema)) {
286
286
  const schema = _.cloneDeep(this.state.schema);
287
287
 
288
- const formData = _.cloneDeep(this.state.formData);
289
- const container = schema.containers[0];
290
288
  // const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
291
- if (baseLanguage === formData[0].activeTab) {
292
- container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
293
- } else {
294
- container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
295
- }
289
+
296
290
  this.setState({schema, loadingStatus: this.state.loadingStatus + 1});
297
291
  }
298
292
 
@@ -338,7 +332,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
338
332
  }
339
333
  }
340
334
 
341
- if (!_.isEmpty(nextProps.Email.CmsSettings) && !_.isEqual(this.props.Email.CmsSettings, nextProps.Email.CmsSettings)) {
335
+ if (!_.isEmpty(nextProps.Email.CmsSettings) && !_.isEqual(this.props.Email.CmsSettings, nextProps.Email.CmsSettings) && !_.isEmpty(this.state.schema)) {
342
336
  const apiLangId = nextProps.Email.CmsSettings.langId;
343
337
  const langId = nextProps.Email.CmsSettings.langId !== "undefined" ? nextProps.Email.CmsSettings.langId : nextProps.currentOrgDetails.basic_details.base_language;
344
338
 
@@ -348,11 +342,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
348
342
  const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
349
343
 
350
344
  const temp = schema.containers[this.state.currentTab - 1];
351
- if (baseLanguage === langId && (apiLangId === "undefined" || apiLangId === formData[this.state.currentTab - 1].activeTab)) {
352
- temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
353
- } else if (apiLangId === "undefined" || apiLangId === formData[this.state.currentTab - 1].activeTab) {
354
- temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
355
- }
345
+
356
346
 
357
347
  if (nextProps.Email.CmsSettings.isDragDrop) {
358
348
  formData[`${this.state.currentTab - 1}`][langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
@@ -409,8 +399,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
409
399
  });
410
400
  }
411
401
  if (nextProps.Email.createTemplateError && !_.isEqual(nextProps.Email.createTemplateError, this.props.Email.createTemplateError)) {
412
- const message = getMessageObject('error', (nextProps.Email.createTemplateErrorMessage && nextProps.Email.createTemplateErrorMessage !== '') ? nextProps.Email.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
413
- this.props.globalActions.addMessageToQueue(message);
402
+ const message = (nextProps.Email.createTemplateErrorMessage && nextProps.Email.createTemplateErrorMessage !== '') ? nextProps.Email.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong);
403
+ CapNotification.error({key: 'createTemplateError', message});
404
+ this.stopValidation();
414
405
  }
415
406
  if (!nextProps.Email.fetchingCmsData && !_.isEqual(nextProps.Email.cmsData, this.props.Email.cmsData) && !_.isEmpty(nextProps.Email.cmsData)) {
416
407
  const formData = _.cloneDeep(this.state.formData);
@@ -493,8 +484,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
493
484
  }
494
485
 
495
486
  if ( !_.isEqual(nextProps.Email.assetUploading, this.props.Email.assetUploading) && !nextProps.Email.assetUploading && !nextProps.Email.uploadAssetSuccess) {
496
- const message = getMessageObject('error', this.props.intl.formatMessage(messages.assetUploadFailed), true);
497
- this.props.globalActions.addMessageToQueue(message);
487
+ const message = this.props.intl.formatMessage(messages.assetUploadFailed);
488
+ CapNotification.error({key: 'uploadAssesIssue', message});
498
489
  }
499
490
 
500
491
  if (!_.isEqual(nextProps.currentOrgDetails.basic_details.supported_languages, this.props.currentOrgDetails.basic_details.supported_languages)) {
@@ -634,11 +625,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
634
625
  // this.resetSchema();
635
626
  let message;
636
627
  if (this.state.isEdit) {
637
- message = getMessageObject('success', this.props.intl.formatMessage(messages.emailEditSuccess), true);
628
+ message = this.props.intl.formatMessage(messages.emailEditSuccess);
638
629
  } else {
639
- message = getMessageObject('success', this.props.intl.formatMessage(messages.emailCreateSuccess), true);
630
+ message = this.props.intl.formatMessage(messages.emailCreateSuccess);
640
631
  }
641
- CapNotification.success({message});
632
+ CapNotification.success({message, key: 'create-template-succes'});
642
633
  const module = this.props.location.query.module ? this.props.location.query.module : 'default';
643
634
  const type = this.props.location.query.type;
644
635
  const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
@@ -660,7 +651,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
660
651
  let supportedLanguages = [];
661
652
  if (!_.isEmpty(currentOrgDetails)) {
662
653
  const {basic_details} = currentOrgDetails;
663
- supportedLanguages = basic_details.supported_languages || [];
654
+ const baseLanguage = basic_details.base_language || 'en';
655
+ supportedLanguages = _.isEmpty(basic_details.supported_languages) ? [{iso_code: baseLanguage || 'en', lang_id: -1, language: baseLanguage || "English"}] : basic_details.supported_languages;
664
656
  }
665
657
  return supportedLanguages;
666
658
  }
@@ -734,7 +726,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
734
726
  }
735
727
 
736
728
  setFormValidity = (isFormValid) => {
737
- this.setState({isFormValid, startValidation: false});
729
+ this.setState({isFormValid});
738
730
  }
739
731
 
740
732
  setEditData(editData) {
@@ -1140,8 +1132,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1140
1132
  const file = files[0];
1141
1133
  const fileSize = (file.size / ( 1024 * 1024 ));
1142
1134
  if (fileSize > 5) {
1143
- const message = getMessageObject('error', this.props.intl.formatMessage(messages.uploadSizeError), true);
1144
- this.props.globalActions.addMessageToQueue(message);
1135
+ const message = this.props.intl.formatMessage(messages.uploadSizeError);
1136
+ CapNotification.error({key: 'uploadImageIssue', message});
1145
1137
  document.getElementById("fileName").value = "";
1146
1138
  return;
1147
1139
  }
@@ -1226,7 +1218,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1226
1218
  const baseData = {};
1227
1219
  const baseLanguage = props.currentOrgDetails.basic_details.base_language;
1228
1220
  this.supportedLanguages = this.getSupportedLanguages(props);
1229
- const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})] || {iso_code: 'en', lang_id: 1, language: "English"};
1221
+ const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})] || {iso_code: baseLanguage || 'en', lang_id: -1, language: baseLanguage || "English"};
1230
1222
  baseData.activeTab = baseLanguage;
1231
1223
  baseData[languageObject.iso_code] = {};
1232
1224
  baseData[languageObject.iso_code].is_drag_drop = false;
@@ -1383,7 +1375,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1383
1375
 
1384
1376
  temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
1385
1377
  temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
1386
- temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
1378
+ temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].colStyle.display = "none";
1387
1379
  }
1388
1380
  });
1389
1381
  schema = this.showInsertImageButton(schema);
@@ -1429,10 +1421,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1429
1421
  newContainerInputFieldCol.style.display = isDragDrop ? "none" : '';
1430
1422
  }
1431
1423
  if (containerInputFieldCol.id === 'tab-options-popover') {
1424
+ containerInputFieldCol.colStyle.display = isDragDrop ? "flex" : "none";
1432
1425
  _.forEach(containerInputFieldCol.content.sections[0].inputFields, (tabPopoverSection) => {
1433
1426
  if (tabPopoverSection.cols[0].id === 'switch-editor-label') {
1434
1427
  const newTabPopoverSection = tabPopoverSection;
1435
- newTabPopoverSection.cols[0].style.display = isDragDrop ? "" : 'none';
1428
+ newTabPopoverSection.cols[0].style.display = isDragDrop ? "" : "none";
1436
1429
  }
1437
1430
  });
1438
1431
  }
@@ -1457,6 +1450,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1457
1450
  });
1458
1451
 
1459
1452
  this.setState({schema, isSchemaChanged: true});
1453
+ return schema;
1460
1454
  }
1461
1455
 
1462
1456
  showSubject = () => {
@@ -1923,14 +1917,14 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1923
1917
  const baseLanguage = this.props.currentOrgDetails && this.props.currentOrgDetails.basic_details && this.props.currentOrgDetails.basic_details.base_language && this.props.currentOrgDetails.basic_details.base_language !== "" ? this.props.currentOrgDetails.basic_details.base_language : 'en';
1924
1918
  const supportedLanguages = this.getSupportedLanguages(this.props);
1925
1919
  if (!supportedLanguages) {
1926
- tempEl.value = 'English';
1920
+ tempEl.value = baseLanguage || 'English';
1927
1921
  return;
1928
1922
  }
1929
1923
  const langObject = supportedLanguages.find( (lang) => lang.iso_code === baseLanguage);
1930
1924
  if (langObject) {
1931
1925
  tempEl.value = langObject.language;
1932
1926
  } else {
1933
- tempEl.value = 'English';
1927
+ tempEl.value = baseLanguage || 'English';
1934
1928
  }
1935
1929
  }
1936
1930
  });
@@ -1966,13 +1960,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1966
1960
  });
1967
1961
  }
1968
1962
  });
1969
- _.forEach(temp.standalone.sections[1].inputFields[0].cols, (inputField) => {
1970
- if (inputField.id === "template-version") {
1971
- const iF = inputField;
1972
- iF.colStyle = {};
1973
- iF.colStyle.display = "none";
1974
- }
1975
- });
1976
1963
  //}
1977
1964
  temp = type === 'embedded' ? this.removeStandAlone(temp) : temp;
1978
1965
  this.setState({schema: temp, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1}, () => {
@@ -2033,7 +2020,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2033
2020
  _.forEach(section.inputFields, (inputFields) => {
2034
2021
  if (section.type === "multicols") {
2035
2022
  _.forEach(inputFields.cols, (col) => {
2036
- if ((col.id === "tab-options-popover" || col.id === "add-language-button") && this.props.location.query.type === 'embedded' && (this.props.location.query.module === "library")) {
2023
+ if ((col.id === "tab-options-popover" || col.id === "add-language-button") && !this.props.isFullMode) {
2037
2024
  const colStyle = col.colStyle;
2038
2025
  colStyle.display = "none";
2039
2026
  }
@@ -2324,7 +2311,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2324
2311
  saveFormData = (passedData) => {
2325
2312
  //saveFormData gets called only when validation result is true
2326
2313
 
2327
-
2328
2314
  if (this.state.gettingFormData && !this.props.isFullMode) {
2329
2315
  const response = {
2330
2316
  action: "getFormData",
@@ -2430,7 +2416,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2430
2416
  document.getElementById("fileName").click();
2431
2417
  }
2432
2418
  // eslint-disable-next-line react/sort-comp
2433
- getTemplateDataForGrid = ({templates, handlers, filterContent, isLoading, loadingTip}) => {
2419
+ getTemplateDataForGrid = ({templates, handlers, isLoading, loadingTip}) => {
2434
2420
  const currentChannel = 'gallery';
2435
2421
  const cardDataList = templates.length ? _.map(templates, (template) => {
2436
2422
  const templateData =
@@ -2444,7 +2430,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2444
2430
  return templateData;
2445
2431
  }) : [];
2446
2432
  return (<div>
2447
- {filterContent}
2448
2433
  <CapSpin spinning={isLoading} tip={loadingTip}>
2449
2434
  {!_.isEmpty(templates) && <div className="pagination-container">
2450
2435
  <CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={'Email'} />
@@ -2546,6 +2531,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2546
2531
  );
2547
2532
  getImagePreviewContent = () => (
2548
2533
  <div key="creatives-email-add-image-container">
2534
+ {this.getFilterContent()}
2549
2535
  <Pagination onPageChange={() => { this.fetchAllAssets({getNextPage: true}); }} paginationSelector="pagination-container">
2550
2536
  {/* <CardGrid
2551
2537
  listItem={this.prepareImageData()}
@@ -2561,9 +2547,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2561
2547
  loadingTip: <FormattedMessage {...messages.loadingImages}/>,
2562
2548
  channel: this.state.channel,
2563
2549
  templates: this.props.Email.assetList,
2564
- filterContent: this.getFilterContent(),
2565
2550
  handlers: {onItemClick: this.handleOnItemClick}})
2566
- : ''}
2551
+ : <FormattedMessage {...messages.noImgInGallery}/>}
2567
2552
 
2568
2553
  </Pagination>
2569
2554
  </div>
@@ -357,7 +357,7 @@ export const response = {
357
357
  colStyle: {
358
358
  textAlign: "right",
359
359
  flex: 0,
360
- display: "flex",
360
+ display: "none",
361
361
  alignItems: "center",
362
362
  },
363
363
  type: "popover",
@@ -375,62 +375,6 @@ export const response = {
375
375
  {
376
376
  type: "multicols",
377
377
  inputFields: [
378
- {
379
- cols: [
380
- {
381
- id: "duplicate-version-label",
382
- metaType: "label",
383
- type: "div",
384
- primitive: true,
385
- value: "Duplicate Version",
386
- onlyDisplay: true,
387
- customComponent: false,
388
- order: 3,
389
- fluid: false,
390
- colStyle: { display: "" },
391
- className: "version-popover",
392
- submitAction: "duplicateVersion",
393
- supportedEvents: ["duplicateVersion"],
394
- },
395
- ],
396
- },
397
- {
398
- cols: [
399
- {
400
- id: "delete-version-label",
401
- metaType: "label",
402
- type: "div",
403
- primitive: true,
404
- value: "Delete Version",
405
- onlyDisplay: true,
406
- customComponent: false,
407
- order: 3,
408
- fluid: false,
409
- colStyle: { display: "" },
410
- className: "version-popover",
411
- submitAction: "deleteVersion",
412
- supportedEvents: ["deleteVersion"],
413
- },
414
- ],
415
- },
416
- {
417
- cols: [
418
- {
419
- id: "delete-language-label",
420
- metaType: "label",
421
- type: "div",
422
- primitive: true,
423
- value: "Delete Language",
424
- onlyDisplay: true,
425
- customComponent: false,
426
- order: 3,
427
- fluid: false,
428
- className: "version-popover",
429
- submitAction: "deleteLanguage",
430
- supportedEvents: ["deleteLanguage"],
431
- },
432
- ],
433
- },
434
378
  {
435
379
  cols: [
436
380
  {
@@ -446,7 +390,7 @@ export const response = {
446
390
  className: "version-popover",
447
391
  submitAction: "switchEditor",
448
392
  supportedEvents: ["switchEditor"],
449
- style: { display: "none" },
393
+ style: { display: 'none'},
450
394
  },
451
395
  ],
452
396
  },
@@ -234,4 +234,8 @@ export default defineMessages({
234
234
  id: 'app.containers.Email.assetUploadFailed',
235
235
  defaultMessage: 'Image uploaded failed',
236
236
  },
237
+ "noImgInGallery": {
238
+ id: 'app.containers.Email.noImgInGallery',
239
+ defaultMessage: 'No images in the gallery. Please upload images in gallery.',
240
+ },
237
241
  });
@@ -1,6 +1,5 @@
1
1
  import { take, cancel, call, put, takeLatest, takeEvery } from 'redux-saga/effects';
2
2
  import { LOCATION_CHANGE } from 'react-router-redux';
3
- import {CapNotification} from '@capillarytech/cap-ui-library';
4
3
  import * as Api from '../../services/api';
5
4
  import * as types from './constants';
6
5
 
@@ -10,7 +9,6 @@ export function* createTemplate(template) {
10
9
  const result = yield call(Api.createEmailTemplate, template);
11
10
  if (result.status.code === 500) {
12
11
  errorMsg = result.message;
13
- CapNotification.error({message: errorMsg, key: 'create-email-template-error'});
14
12
  yield put({ type: types.CREATE_TEMPLATE_FAILURE, errorMsg });
15
13
  } else {
16
14
  yield put({ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
@@ -6,10 +6,10 @@
6
6
 
7
7
  import * as types from './constants';
8
8
 
9
- export function createTemplate(template) {
9
+ export function createTemplate(template, callback) {
10
10
  console.log('action trigereed createtemplate');
11
11
  return {
12
- type: types.CREATE_TEMPLATE_REQUEST, template,
12
+ type: types.CREATE_TEMPLATE_REQUEST, template, callback,
13
13
  };
14
14
  }
15
15
 
@@ -81,7 +81,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
81
81
  componentWillReceiveProps = (nextProps) => {
82
82
  if (nextProps.isGetFormData && !this.props.isFullMode) {
83
83
  nextProps.getFormLibraryData(this.getFormData());
84
- } else if (nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
84
+ } else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
85
85
  this.startValidation();
86
86
  }
87
87
  if (nextProps.Create.uploadedAssetData) {
@@ -90,18 +90,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
90
90
  this.setState({formData});
91
91
  this.props.actions.clearAsset();
92
92
  }
93
- if (nextProps.createResponse && nextProps.createResponse.templateId) {
94
- this.discardValues();
95
- const message = getMessageObject('success', this.props.intl.formatMessage(messages["Mobile Push Template Created Successfully"]), true);
96
- this.props.globalActions.addMessageToQueue(message);
97
- this.props.actions.clearCreateResponse();
98
- const type = this.props.location.query.type;
99
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
100
- this.props.router.push({
101
- pathname: `/mobilepush/`,
102
- query: type === 'embedded' ? {type: 'embedded', module} : {module},
103
- });
104
- }
105
93
  if (nextProps.params.mode) {
106
94
  this.setState({mode: nextProps.params.mode});
107
95
  }
@@ -633,7 +621,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
633
621
  }
634
622
  }
635
623
  stopValidation = () => {
636
- this.setState({startValidation: false});
624
+ this.setState({startValidation: false}, () => {
625
+ this.showError();
626
+ this.props.onValidationFail();
627
+ });
637
628
  }
638
629
  startValidation = () => {
639
630
  this.setState({startValidation: true});
@@ -648,7 +639,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
648
639
  }
649
640
 
650
641
  handleCancelModal = () => {
651
- this.setState({showModal: false});
642
+ this.setState({showModal: false}, this.stopValidation);
652
643
  };
653
644
 
654
645
  moveToTemplates = () => {
@@ -1410,8 +1401,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1410
1401
  this.injectEvents(schema);
1411
1402
  };
1412
1403
  saveFormData = (formData) => {
1404
+ //this function gets called from form bulder only when the form data is valid
1413
1405
  const obj = this.getTransformedData(formData);
1414
- this.props.actions.createTemplate(obj);
1406
+ this.props.actions.createTemplate(obj, () => {
1407
+ this.discardValues();
1408
+ const message = this.props.intl.formatMessage(messages.messageCreateSuccess);
1409
+ CapNotification.success({message, key: 'createMpushSuccess'});
1410
+ this.props.actions.clearCreateResponse();
1411
+ this.props.getFormLibraryData({validity: true});
1412
+ });
1415
1413
  };
1416
1414
  deleteSecondaryCtaIos = (callback) => {
1417
1415
  const schema = cloneDeep(this.state.schema);
@@ -1794,6 +1792,9 @@ Create.propTypes = {
1794
1792
  injectedTags: PropTypes.object,
1795
1793
  defaultData: PropTypes.object,
1796
1794
  showTemplateName: PropTypes.func,
1795
+ isGetFormData: PropTypes.bool,
1796
+ onValidationFail: PropTypes.func,
1797
+ getFormLibraryData: PropTypes.func,
1797
1798
  };
1798
1799
 
1799
1800
  const mapStateToProps = createStructuredSelector({
@@ -134,7 +134,7 @@ export default defineMessages({
134
134
  id: 'app.containers.MobilePush.Create.uploadImage',
135
135
  defaultMessage: 'Upload image',
136
136
  },
137
- "Mobile Push Template Created Successfully": {
137
+ "messageCreateSuccess": {
138
138
  id: 'app.containers.MobilePush.Create.templateCreatedSuccessfully',
139
139
  defaultMessage: 'Mobile push template created successfully',
140
140
  },
@@ -14,6 +14,9 @@ export function* createTemplate(template) {
14
14
  if (result.message || result.status.code === 500) {
15
15
  errorMsg = result.message;
16
16
  }
17
+ if (template.callback) {
18
+ yield call(template.callback, result.response);
19
+ }
17
20
  yield put({ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
18
21
  } catch (error) {
19
22
  yield put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg });
@@ -100,7 +100,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
100
100
  componentWillReceiveProps(nextProps) {
101
101
  if (nextProps.isGetFormData && !this.props.isFullMode) {
102
102
  nextProps.getFormLibraryData(this.getFormData());
103
- } else if (nextProps.isGetFormData && this.props.isFullMode && !this.props.Edit.editTemplateInProgress) {
103
+ } else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
104
104
  this.startValidation();
105
105
  }
106
106
  const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
@@ -279,11 +279,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
279
279
  currentTab: 1,
280
280
  editData: {},
281
281
  });
282
- const message = getMessageObject('success', this.props.intl.formatMessage(messages['MOBILEPUSH Template Edited Successfully']), true);
283
- this.props.globalActions.addMessageToQueue(message);
282
+ const message = this.props.intl.formatMessage(messages['MOBILEPUSH Template Edited Successfully']);
283
+ CapNotification.success({message, key: 'editMpushSuccess'});
284
284
  this.props.actions.clearEditResponse();
285
285
  if (this.props.isFullMode) {
286
- this.props.getFormLibraryData(this.getFormData());
286
+ this.props.getFormLibraryData({validity: true});
287
287
  } else {
288
288
  const module = this.props.location.query.module ? this.props.location.query.module : 'default';
289
289
  const type = this.props.location.query.type;
@@ -879,7 +879,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
879
879
  }
880
880
 
881
881
  handleCancelModal = () => {
882
- this.setState({showModal: false});
882
+ this.setState({showModal: false}, this.stopValidation);
883
883
  };
884
884
 
885
885
  insertAtCursor = (field, myValue, currentTab) => {
@@ -1748,7 +1748,10 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1748
1748
  this.setState({startValidation: true});
1749
1749
  }
1750
1750
  stopValidation = () => {
1751
- this.setState({startValidation: false});
1751
+ this.setState({startValidation: false}, () => {
1752
+ this.showError();
1753
+ this.props.onValidationFail();
1754
+ });
1752
1755
  }
1753
1756
 
1754
1757
  render() {
@@ -1760,7 +1763,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1760
1763
  tags = this.props.supportedTags;
1761
1764
  }
1762
1765
  return (
1763
- <div className="creatives-mobilepush-edit">
1766
+ <div className="creatives-mobilepush-edit mobilepush-wrapper">
1764
1767
  <CapSpin spinning={spinning}>
1765
1768
  <CapRow>
1766
1769
  <CapColumn>
@@ -1879,6 +1882,9 @@ Edit.propTypes = {
1879
1882
  defaultData: PropTypes.object,
1880
1883
  showTemplateName: PropTypes.func,
1881
1884
  getFormLibraryData: PropTypes.func,
1885
+ isGetFormData: PropTypes.bool,
1886
+ Create: PropTypes.object,
1887
+ onValidationFail: PropTypes.bool,
1882
1888
  };
1883
1889
 
1884
1890
  const mapStateToProps = createStructuredSelector({
@@ -1613,6 +1613,9 @@ export const response = {
1613
1613
  required: true,
1614
1614
  fluid: true,
1615
1615
  styling: "semantic",
1616
+ style: {
1617
+ display: 'flex',
1618
+ },
1616
1619
  order: 1,
1617
1620
  customComponent: true,
1618
1621
  submitAction: "onUpload",
@@ -69,7 +69,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
69
69
  }
70
70
  }
71
71
  render() {
72
- const {mobilePushCreateMode, step, getFormData, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type} = this.props;
72
+ const {mobilePushCreateMode, step, getFormData, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail} = this.props;
73
73
  const {templateName} = this.state;
74
74
  const isShowMobilepushCreate = !isEmpty(mobilePushCreateMode);
75
75
  return (
@@ -111,6 +111,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
111
111
  showTemplateName={showTemplateName}
112
112
  route={{ name: 'mobilepush' }}
113
113
  getDefaultTags={type}
114
+ onValidationFail={onValidationFail}
114
115
  />
115
116
 
116
117
 
@@ -135,6 +136,7 @@ MobilepushWrapper.propTypes = {
135
136
  isFullMode: PropTypes.bool,
136
137
  showTemplateName: PropTypes.func,
137
138
  type: PropTypes.string,
139
+ onValidationFail: PropTypes.func,
138
140
  };
139
141
 
140
142
 
@@ -255,13 +255,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
255
255
  }
256
256
  }
257
257
  if (this.state.channel.toLowerCase() === "mobilepush" && nextProps.CreateMobilePush && nextProps.CreateMobilePush.response && nextProps.CreateMobilePush.response.templateId && nextProps.CreateMobilePush.response.templateId !== '') {
258
- if (this.state.channel.toLowerCase() === "mobilepush" && !_.isEmpty(nextProps.Templates.selectedWeChatAccount)) {
259
- params.accountId = nextProps.Templates.selectedWeChatAccount.id;
260
- }
261
- const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
262
- CapNotification.success({key: 'duplicateSuccess', message});
263
- this.getAllTemplates({params});
264
- this.props.mobilepushActions.clearCreateResponse();
258
+
265
259
  }
266
260
 
267
261
  if (this.state.channel.toLowerCase() === "ebill" && nextProps.CreateEbill && nextProps.CreateEbill.createResponse && nextProps.CreateEbill.createResponse.templateId && nextProps.CreateEbill.createResponse.templateId !== '') {
@@ -391,8 +385,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
391
385
  });
392
386
  }
393
387
  onPaginationChange = () => { this.getAllTemplates({getNextPage: true}); }
394
- onCreateComplete = () => {
395
- this.setState({routeParams: null, previewOpen: false});
388
+ onCreateComplete = (isReloadTemplates) => {
389
+ this.setState({routeParams: null, previewOpen: false}, () => {
390
+ if (this.isFullMode() && isReloadTemplates) {
391
+ this.getAllTemplates({params: {}}, true);
392
+ }
393
+ });
396
394
  }
397
395
  getCurrentWindow(e) {
398
396
  const response = {
@@ -976,7 +974,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
976
974
  });
977
975
  } else if (this.state.channel.toLowerCase() === "mobilepush") {
978
976
  duplicateObj.definition.accountId = this.props.Templates.selectedWeChatAccount.id;
979
- this.props.mobilepushActions.createTemplate(duplicateObj);
977
+ this.props.mobilepushActions.createTemplate(duplicateObj, () => {
978
+ const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
979
+ CapNotification.success({key: 'duplicateSuccess', message});
980
+ this.getAllTemplates({params: {}}, true);
981
+ this.props.mobilepushActions.clearCreateResponse();
982
+ });
980
983
  } else if (this.state.channel.toLowerCase() === "ebill") {
981
984
  this.props.ebillActions.createTemplate(duplicateObj);
982
985
  } else if (this.state.channel.toLowerCase() === "email") {
@@ -1634,7 +1637,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1634
1637
  messages={messages}
1635
1638
  isFullMode={isFullMode}
1636
1639
  templateData={creativesParams}
1637
- getCreativesData={this.onCreateComplete}
1640
+ getCreativesData={() => { this.onCreateComplete(true); }}
1638
1641
  channel={route.name.toUpperCase()}
1639
1642
  handleCloseCreatives={this.onCreateComplete}/>
1640
1643
  }