@capillarytech/creatives-library 8.0.136-alpha.4 → 8.0.136-beta.3
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/BreadCrumbs/index.js +65 -0
- package/components/BreadCrumbs/messages.js +13 -0
- package/components/CapTagList/index.js +235 -0
- package/components/CapTagList/messages.js +45 -0
- package/components/Card/_customCard.scss +40 -0
- package/components/Card/index.js +78 -0
- package/components/Card/tests/__snapshots__/index.test.js.snap +22 -0
- package/components/Card/tests/index.test.js +20 -0
- package/components/CardGrid/index.js +71 -0
- package/components/Ckeditor/index.js +238 -0
- package/components/Ckeditor/messages.js +13 -0
- package/components/Ckeditor/style.scss +3 -0
- package/components/Component/index.js +29 -0
- package/components/CustomPopOver/index.js +81 -0
- package/components/CustomPopOver/messages.js +17 -0
- package/components/DateFilter/index.js +349 -0
- package/components/DateFilter/messages.js +57 -0
- package/components/DateRange/index.js +114 -0
- package/components/DateRange/messages.js +25 -0
- package/components/Edmeditor/index.js +65 -0
- package/components/Edmeditor/messages.js +13 -0
- package/components/EmailPreview/_emailPreview.scss +119 -0
- package/components/EmailPreview/assets/images/iPad.svg +10 -0
- package/components/EmailPreview/assets/images/mobile.png +0 -0
- package/components/EmailPreview/index.js +107 -0
- package/components/EmailPreview/messages.js +33 -0
- package/components/Footer/index.js +27 -0
- package/components/Footer/messages.js +13 -0
- package/components/FormBuilder/_formBuilder.scss +83 -0
- package/components/FormBuilder/index.js +3279 -0
- package/components/FormBuilder/messages.js +61 -0
- package/components/Header/index.js +44 -0
- package/components/Header/messages.js +29 -0
- package/components/ImagePreview/_imagePreview.scss +63 -0
- package/components/ImagePreview/index.js +52 -0
- package/components/ImagePreview/messages.js +17 -0
- package/components/PageHeader/_pageHeader.scss +22 -0
- package/components/PageHeader/index.js +37 -0
- package/components/PageHeader/messages.js +13 -0
- package/components/Pagination/_pagination.scss +5 -0
- package/components/Pagination/index.js +49 -0
- package/components/PreviewSideBar/_previewsidebar.scss +28 -0
- package/components/PreviewSideBar/index.js +152 -0
- package/components/PreviewSideBar/messages.js +41 -0
- package/components/Sidebar/_sidebar.scss +115 -0
- package/components/Sidebar/index.js +214 -0
- package/components/Sidebar/messages.js +21 -0
- package/components/SlideBox/_slideBox.scss +63 -0
- package/components/SlideBox/index.js +47 -0
- package/components/SlideBox/tests/index.test.js +103 -0
- package/components/SmsEditor/index.js +55 -0
- package/components/SmsTest/index.js +117 -0
- package/components/SmsTest/messages.js +21 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +42 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +141 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +21 -0
- package/components/TemplatePreview/_templatePreview.scss +642 -0
- package/components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
- package/components/TemplatePreview/assets/images/androidPushMessage.svg +45 -0
- package/components/TemplatePreview/assets/images/home-screen-android.svg +21 -0
- package/components/TemplatePreview/assets/images/home-screen-ios.svg +16 -0
- package/components/TemplatePreview/assets/images/iPhonePushMessage.svg +135 -0
- package/components/TemplatePreview/assets/images/mobile.svg +24 -0
- package/components/TemplatePreview/assets/images/sms-body.png +0 -0
- package/components/TemplatePreview/assets/images/sms-icon.png +0 -0
- package/components/TemplatePreview/assets/images/sms_mobile.png +0 -0
- package/components/TemplatePreview/assets/images/sms_mobile_android.svg +22 -0
- package/components/TemplatePreview/assets/images/sms_mobile_ios.svg +16 -0
- package/components/TemplatePreview/assets/images/user-icon.svg +19 -0
- package/components/TemplatePreview/assets/images/wechat-mobile.svg +78 -0
- package/components/TemplatePreview/assets/images/wechat_mobile_android.svg +20 -0
- package/components/TemplatePreview/index.js +617 -0
- package/components/TemplatePreview/messages.js +78 -0
- package/components/Toastr/index.js +60 -0
- package/components/Toastr/messages.js +13 -0
- package/components/ToastrMessage/index.js +113 -0
- package/components/ToastrMessage/messages.js +17 -0
- package/components/TopBar/_topbar.scss +46 -0
- package/components/TopBar/assets/images/capillary_logo.png +0 -0
- package/components/TopBar/assets/images/old_capillary_logo.png +0 -0
- package/components/TopBar/index.js +113 -0
- package/components/TopBar/messages.js +29 -0
- package/containers/App/actions.js +7 -0
- package/containers/App/constants.js +114 -0
- package/containers/App/index.js +52 -0
- package/containers/App/reducer.js +19 -0
- package/containers/App/sagas.js +31 -0
- package/containers/App/selectors.js +25 -0
- package/containers/App/test/saga.test.js +11 -0
- package/containers/Assets/Gallery/_gallery.scss +126 -0
- package/containers/Assets/Gallery/actions.js +37 -0
- package/containers/Assets/Gallery/constants.js +23 -0
- package/containers/Assets/Gallery/index.js +473 -0
- package/containers/Assets/Gallery/messages.js +93 -0
- package/containers/Assets/Gallery/reducer.js +81 -0
- package/containers/Assets/Gallery/sagas.js +80 -0
- package/containers/Assets/Gallery/selectors.js +25 -0
- package/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +9 -0
- package/containers/Assets/Gallery/tests/actions.test.js +25 -0
- package/containers/Assets/Gallery/tests/reducer.test.js +96 -0
- package/containers/Assets/Gallery/tests/saga.test.js +157 -0
- package/containers/Cap/actions.js +66 -0
- package/containers/Cap/constants.js +25 -0
- package/containers/Cap/index.js +402 -0
- package/containers/Cap/messages.js +75 -0
- package/containers/Cap/reducer.js +113 -0
- package/containers/Cap/sagas.js +159 -0
- package/containers/Cap/selectors.js +75 -0
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +2269 -0
- package/containers/Cap/tests/index.test.js +22 -0
- package/containers/Cap/tests/saga.test.js +284 -0
- package/containers/Dashboard/actions.js +15 -0
- package/containers/Dashboard/constants.js +7 -0
- package/containers/Dashboard/index.js +76 -0
- package/containers/Dashboard/messages.js +13 -0
- package/containers/Dashboard/reducer.js +21 -0
- package/containers/Dashboard/sagas.js +17 -0
- package/containers/Dashboard/selectors.js +25 -0
- package/containers/Dashboard/test/saga.test.js +9 -0
- package/containers/Ebill/_ebill.scss +5 -0
- package/containers/Ebill/actions.js +43 -0
- package/containers/Ebill/constants.js +20 -0
- package/containers/Ebill/index.js +1278 -0
- package/containers/Ebill/messages.js +77 -0
- package/containers/Ebill/reducer.js +72 -0
- package/containers/Ebill/sagas.js +74 -0
- package/containers/Ebill/selectors.js +25 -0
- package/containers/Ebill/test/saga.test.js +11 -0
- package/containers/Email/_email.scss +141 -0
- package/containers/Email/actions.js +81 -0
- package/containers/Email/constants.js +36 -0
- package/containers/Email/index.js +3325 -0
- package/containers/Email/messages.js +289 -0
- package/containers/Email/reducer.js +142 -0
- package/containers/Email/sagas.js +135 -0
- package/containers/Email/selectors.js +31 -0
- package/containers/Email/test/saga.test.js +671 -0
- package/containers/LanguageProvider/actions.js +17 -0
- package/containers/LanguageProvider/constants.js +8 -0
- package/containers/LanguageProvider/index.js +80 -0
- package/containers/LanguageProvider/reducer.js +30 -0
- package/containers/LanguageProvider/selectors.js +20 -0
- package/containers/LanguageProvider/tests/actions.test.js +19 -0
- package/containers/LanguageProvider/tests/index.test.js +78 -0
- package/containers/LanguageProvider/tests/reducer.test.js +20 -0
- package/containers/LanguageProvider/tests/selectors.test.js +15 -0
- package/containers/Line/Create/_lineCreate.scss +54 -0
- package/containers/Line/Create/actions.js +90 -0
- package/containers/Line/Create/constants.js +39 -0
- package/containers/Line/Create/index.js +836 -0
- package/containers/Line/Create/messages.js +189 -0
- package/containers/Line/Create/reducer.js +99 -0
- package/containers/Line/Create/sagas.js +121 -0
- package/containers/Line/Create/selectors.js +36 -0
- package/containers/Line/Create/tests/saga.test.js +202 -0
- package/containers/Line/Edit/_lineEdit.scss +35 -0
- package/containers/Line/Edit/actions.js +79 -0
- package/containers/Line/Edit/constants.js +27 -0
- package/containers/Line/Edit/index.js +1050 -0
- package/containers/Line/Edit/messages.js +177 -0
- package/containers/Line/Edit/reducer.js +83 -0
- package/containers/Line/Edit/sagas.js +80 -0
- package/containers/Line/Edit/selectors.js +29 -0
- package/containers/Line/Edit/test/saga.test.js +160 -0
- package/containers/Login/assets/images/capillary_logo.png +0 -0
- package/containers/Login/components/LoginForm/index.js +62 -0
- package/containers/Login/components/LoginForm/messages.js +33 -0
- package/containers/Login/index.js +130 -0
- package/containers/Login/messages.js +25 -0
- package/containers/Login/selectors.js +25 -0
- package/containers/MobilePush/Create/_mobilePushCreate.scss +39 -0
- package/containers/MobilePush/Create/actions.js +46 -0
- package/containers/MobilePush/Create/constants.js +23 -0
- package/containers/MobilePush/Create/index.js +2303 -0
- package/containers/MobilePush/Create/messages.js +269 -0
- package/containers/MobilePush/Create/reducer.js +70 -0
- package/containers/MobilePush/Create/sagas.js +74 -0
- package/containers/MobilePush/Create/selectors.js +28 -0
- package/containers/MobilePush/Create/test/saga.test.js +19 -0
- package/containers/MobilePush/Edit/_mobilePushCreate.scss +39 -0
- package/containers/MobilePush/Edit/actions.js +91 -0
- package/containers/MobilePush/Edit/constants.js +35 -0
- package/containers/MobilePush/Edit/index.js +2601 -0
- package/containers/MobilePush/Edit/messages.js +266 -0
- package/containers/MobilePush/Edit/reducer.js +112 -0
- package/containers/MobilePush/Edit/sagas.js +126 -0
- package/containers/MobilePush/Edit/selectors.js +29 -0
- package/containers/MobilePush/Edit/tests/saga.test.js +255 -0
- package/containers/NotFoundPage/index.js +25 -0
- package/containers/NotFoundPage/messages.js +13 -0
- package/containers/NotFoundPage/tests/index.test.js +17 -0
- package/containers/Sms/Create/_smsCreate.scss +42 -0
- package/containers/Sms/Create/actions.js +27 -0
- package/containers/Sms/Create/constants.js +16 -0
- package/containers/Sms/Create/index.js +1488 -0
- package/containers/Sms/Create/messages.js +109 -0
- package/containers/Sms/Create/reducer.js +41 -0
- package/containers/Sms/Create/sagas.js +40 -0
- package/containers/Sms/Create/selectors.js +28 -0
- package/containers/Sms/Create/test/saga.test.js +11 -0
- package/containers/Sms/Edit/actions.js +40 -0
- package/containers/Sms/Edit/constants.js +17 -0
- package/containers/Sms/Edit/index.js +1472 -0
- package/containers/Sms/Edit/messages.js +105 -0
- package/containers/Sms/Edit/reducer.js +50 -0
- package/containers/Sms/Edit/sagas.js +60 -0
- package/containers/Sms/Edit/selectors.js +32 -0
- package/containers/Sms/Edit/test/saga.test.js +13 -0
- package/containers/TagList/_tagList.scss +8 -0
- package/containers/TagList/actions.js +15 -0
- package/containers/TagList/constants.js +32 -0
- package/containers/TagList/index.js +236 -0
- package/containers/TagList/messages.js +13 -0
- package/containers/TagList/reducer.js +23 -0
- package/containers/TagList/sagas.js +11 -0
- package/containers/TagList/selectors.js +25 -0
- package/containers/Templates/_templates.scss +333 -0
- package/containers/Templates/actions.js +103 -0
- package/containers/Templates/constants.js +60 -0
- package/containers/Templates/index.js +1756 -0
- package/containers/Templates/messages.js +337 -0
- package/containers/Templates/reducer.js +142 -0
- package/containers/Templates/sagas.js +163 -0
- package/containers/Templates/selectors.js +28 -0
- package/containers/Templates/test/saga.test.js +241 -0
- package/containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
- package/containers/WeChat/MapTemplates/actions.js +52 -0
- package/containers/WeChat/MapTemplates/constants.js +28 -0
- package/containers/WeChat/MapTemplates/index.js +1610 -0
- package/containers/WeChat/MapTemplates/messages.js +157 -0
- package/containers/WeChat/MapTemplates/reducer.js +74 -0
- package/containers/WeChat/MapTemplates/sagas.js +84 -0
- package/containers/WeChat/MapTemplates/selectors.js +25 -0
- package/containers/WeChat/MapTemplates/test/saga.test.js +155 -0
- package/containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
- package/containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
- package/containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
- package/containers/WeChat/RichmediaTemplates/Create/index.js +1071 -0
- package/containers/WeChat/RichmediaTemplates/Create/messages.js +165 -0
- package/containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
- package/containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
- package/containers/WeChat/RichmediaTemplates/Create/sagas.js +51 -0
- package/containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
- package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +13 -0
- package/containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
- package/containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
- package/containers/WeChat/RichmediaTemplates/Edit/index.js +136 -0
- package/containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
- package/containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
- package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +36 -0
- package/containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
- package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +12 -0
- package/containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
- package/containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
- package/containers/WeChat/RichmediaTemplates/View/index.js +47 -0
- package/containers/WeChat/RichmediaTemplates/View/messages.js +21 -0
- package/containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
- package/containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
- package/containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
- package/index.js +2 -4
- package/package.json +1 -1
- package/routes.js +202 -136
- package/services/getSchema.js +1 -1
- package/services/localStorageApi.js +0 -1
- package/tests/i18n.test.js +1 -1
- package/utils/asyncInjectors.js +78 -0
- package/utils/authWrapper.js +1 -1
- package/utils/callNativeEvent.js +16 -0
- package/utils/checkStore.js +21 -0
- package/utils/common.js +2 -2
- package/utils/customAuthWrapper.js +62 -0
- package/utils/customConnectedAuthWrapper.js +26 -0
- package/utils/tagValidations.js +1 -1
- package/utils/tests/checkStore.test.js +1 -1
- package/utils/tests/customAuth.test.js +1 -1
- package/utils/transformerUtils.js +195 -1
- package/v2Components/CapTagList/index.js +14 -9
- package/v2Components/Carousel/style.scss +1 -1
- package/v2Components/EmailMobilePreview/index.js +2 -2
- package/v2Components/FormBuilder/index.js +2 -2
- package/v2Components/TemplatePreview/index.js +1 -2
- package/v2Containers/Cap/tests/saga.test.js +1 -1
- package/v2Containers/Email/index.js +1 -1
- package/v2Containers/FTP/index.js +1 -1
- package/v2Containers/Line/Container/Text/index.js +6 -6
- package/v2Containers/Sms/Create/index.js +2 -2
- package/v2Containers/Sms/Edit/index.js +1 -1
- package/v2Containers/TagList/index.js +1 -1
- package/v2Containers/TagList/utils.js +1 -1
- package/v2Containers/Templates/index.js +1 -1
- package/v2Containers/Templates/sagas.js +1 -1
- package/constants/unified.js +0 -189
|
@@ -0,0 +1,3325 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Email
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { connect } from 'react-redux';
|
|
11
|
+
import { bindActionCreators, compose } from 'redux';
|
|
12
|
+
import Helmet from 'react-helmet';
|
|
13
|
+
import { Row, Col, Spin, Breadcrumb, Popover, Modal, Select } from 'antd';
|
|
14
|
+
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
15
|
+
import { CapButton, CapInput } from '@capillarytech/cap-react-ui-library';
|
|
16
|
+
import { createStructuredSelector } from 'reselect';
|
|
17
|
+
import _ from 'lodash';
|
|
18
|
+
import moment from "moment";
|
|
19
|
+
import FormBuilder from '../../components/FormBuilder';
|
|
20
|
+
import { makeSelectMetaEntities, makeSelectAuthenticated, setInjectedTags } from '../Cap/selectors';
|
|
21
|
+
import * as actions from './actions';
|
|
22
|
+
import * as templatesActions from '../Templates/actions';
|
|
23
|
+
import * as globalActions from '../../containers/Cap/actions';
|
|
24
|
+
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
25
|
+
import makeSelectEmail from './selectors';
|
|
26
|
+
import { makeSelectTemplates } from '../Templates/selectors';
|
|
27
|
+
import messages from './messages';
|
|
28
|
+
// import PageHeader from '../../components/PageHeader';
|
|
29
|
+
import './_email.scss';
|
|
30
|
+
import {getMessageObject} from '../../utils/messageUtils';
|
|
31
|
+
import EmailPreview from '../../components/EmailPreview';
|
|
32
|
+
import ImagePreview from '../../components/ImagePreview';
|
|
33
|
+
import CardGrid from '../../components/CardGrid';
|
|
34
|
+
import Pagination from '../../components/Pagination';
|
|
35
|
+
import injectSaga from '../../utils/injectSaga';
|
|
36
|
+
import injectReducer from '../../utils/injectReducer';
|
|
37
|
+
import reducer from './reducer';
|
|
38
|
+
import { emailSaga } from './sagas';
|
|
39
|
+
import { templateSaga } from '../Templates/sagas';
|
|
40
|
+
import { createQueryString } from '../../utils/common';
|
|
41
|
+
|
|
42
|
+
const BreadcrumbItem = Breadcrumb.Item;
|
|
43
|
+
|
|
44
|
+
export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
45
|
+
constructor(props) {
|
|
46
|
+
super(props);
|
|
47
|
+
this.state = {
|
|
48
|
+
formData: {},
|
|
49
|
+
tabCount: 1,
|
|
50
|
+
currentTab: 1,
|
|
51
|
+
events: {
|
|
52
|
+
blur: this.onBlur,
|
|
53
|
+
afterPaste: this.afterPaste,
|
|
54
|
+
change: this.onChange,
|
|
55
|
+
},
|
|
56
|
+
isEdit: false,
|
|
57
|
+
schema: {},
|
|
58
|
+
// schema: {
|
|
59
|
+
// standalone: {
|
|
60
|
+
// sections: [
|
|
61
|
+
// {
|
|
62
|
+
// type: "col-label",
|
|
63
|
+
// inputFields: [
|
|
64
|
+
// {
|
|
65
|
+
// id: "template-subject",
|
|
66
|
+
// placeholder: "Enter Email Subject",
|
|
67
|
+
// type: "input",
|
|
68
|
+
// metaType: "text",
|
|
69
|
+
// datatype: "string",
|
|
70
|
+
// required: true,
|
|
71
|
+
// label: "Subject",
|
|
72
|
+
// style: {
|
|
73
|
+
// fontSize: "20px",
|
|
74
|
+
// fontFamily: "proxima-nova,sans-serif",
|
|
75
|
+
// fontStyle: "normal",
|
|
76
|
+
// fontWeight: 600,
|
|
77
|
+
// display: (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs")) ? "" : "none",
|
|
78
|
+
// },
|
|
79
|
+
// labelStyle: {
|
|
80
|
+
// fontSize: "18px",
|
|
81
|
+
// fontFamily: "proxima-nova,sans-serif",
|
|
82
|
+
// fontStyle: "normal",
|
|
83
|
+
// fontWeight: 600,
|
|
84
|
+
// display: (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs")) ? "" : "none",
|
|
85
|
+
// background: "white",
|
|
86
|
+
// },
|
|
87
|
+
// styling: "semantic",
|
|
88
|
+
// order: 1,
|
|
89
|
+
// width: 9,
|
|
90
|
+
// customComponent: false,
|
|
91
|
+
// standalone: true,
|
|
92
|
+
// onlyDisplay: false,
|
|
93
|
+
// errorMessage: "Email Subject cannot be empty.",
|
|
94
|
+
// // supportedEvents: [
|
|
95
|
+
// // "onChange",
|
|
96
|
+
// // ],
|
|
97
|
+
// },
|
|
98
|
+
// ],
|
|
99
|
+
// },
|
|
100
|
+
// {
|
|
101
|
+
// type: "multicols",
|
|
102
|
+
// inputFields: [
|
|
103
|
+
// {
|
|
104
|
+
// cols: [
|
|
105
|
+
// {
|
|
106
|
+
// id: "template-name",
|
|
107
|
+
// placeholder: "Enter template name",
|
|
108
|
+
// type: "input",
|
|
109
|
+
// metaType: "text",
|
|
110
|
+
// datatype: "string",
|
|
111
|
+
// required: true,
|
|
112
|
+
// style: {
|
|
113
|
+
// fontSize: "20px",
|
|
114
|
+
// fontFamily: "proxima-nova,sans-serif",
|
|
115
|
+
// fontStyle: "normal",
|
|
116
|
+
// fontWeight: 600,
|
|
117
|
+
// },
|
|
118
|
+
// styling: "semantic",
|
|
119
|
+
// order: 1,
|
|
120
|
+
// width: 9,
|
|
121
|
+
// customComponent: false,
|
|
122
|
+
// standalone: true,
|
|
123
|
+
// onlyDisplay: false,
|
|
124
|
+
// errorMessage: "Template name cannot be empty.",
|
|
125
|
+
// supportedEvents: [
|
|
126
|
+
// "onChange",
|
|
127
|
+
// ],
|
|
128
|
+
// },
|
|
129
|
+
// {
|
|
130
|
+
// id: "template-version",
|
|
131
|
+
// type: "select", //Resembles component to be used
|
|
132
|
+
// options: [],
|
|
133
|
+
// metaType: "text",
|
|
134
|
+
// datatype: "string",
|
|
135
|
+
// required: true,
|
|
136
|
+
// fluid: true,
|
|
137
|
+
// style: {
|
|
138
|
+
// fontSize: '14px',
|
|
139
|
+
// fontFamily: 'open-sans',
|
|
140
|
+
// fontStyle: 'normal',
|
|
141
|
+
// marginBottom: '16px',
|
|
142
|
+
// },
|
|
143
|
+
// styling: "semantic",
|
|
144
|
+
// order: 1,
|
|
145
|
+
// width: 5,
|
|
146
|
+
// customComponent: false,
|
|
147
|
+
// standalone: true,
|
|
148
|
+
// supportedEvents: [
|
|
149
|
+
// 'onSelect',
|
|
150
|
+
// 'addVersion',
|
|
151
|
+
// ],
|
|
152
|
+
// },
|
|
153
|
+
// {
|
|
154
|
+
// id: "preview-button",
|
|
155
|
+
// width: 3,
|
|
156
|
+
// offset: 3,
|
|
157
|
+
// metaType: "submit-button",
|
|
158
|
+
// colStyle: {
|
|
159
|
+
// textAlign: "right",
|
|
160
|
+
// paddingRight: "12px",
|
|
161
|
+
// },
|
|
162
|
+
// type: "button",
|
|
163
|
+
// buttonType: "cancel",
|
|
164
|
+
// value: "Preview",
|
|
165
|
+
// customComponent: false,
|
|
166
|
+
// standalone: true,
|
|
167
|
+
// styling: "semantic",
|
|
168
|
+
// order: 3,
|
|
169
|
+
// fluid: false,
|
|
170
|
+
// submitAction: "previewTemplate",
|
|
171
|
+
// onlyDisplay: true,
|
|
172
|
+
// supportedEvents: [
|
|
173
|
+
// "previewTemplate",
|
|
174
|
+
// ],
|
|
175
|
+
// },
|
|
176
|
+
// {
|
|
177
|
+
// id: "cancel-button",
|
|
178
|
+
// width: 2,
|
|
179
|
+
// metaType: "submit-button",
|
|
180
|
+
// colStyle: {
|
|
181
|
+
// textAlign: "right",
|
|
182
|
+
// width: "9%",
|
|
183
|
+
// },
|
|
184
|
+
// type: "button",
|
|
185
|
+
// buttonType: "cancel",
|
|
186
|
+
// value: "Cancel",
|
|
187
|
+
// customComponent: false,
|
|
188
|
+
// standalone: true,
|
|
189
|
+
// styling: "semantic",
|
|
190
|
+
// order: 3,
|
|
191
|
+
// fluid: false,
|
|
192
|
+
// onlyDisplay: true,
|
|
193
|
+
// submitAction: "cancelTemplate",
|
|
194
|
+
// supportedEvents: [
|
|
195
|
+
// "cancelTemplate",
|
|
196
|
+
// ],
|
|
197
|
+
// },
|
|
198
|
+
// {
|
|
199
|
+
// id: "save-button",
|
|
200
|
+
// width: 2,
|
|
201
|
+
// metaType: "submit-button",
|
|
202
|
+
// colStyle: {
|
|
203
|
+
// textAlign: "right",
|
|
204
|
+
// width: "7%",
|
|
205
|
+
// },
|
|
206
|
+
// type: "button",
|
|
207
|
+
// buttonType: "primary",
|
|
208
|
+
// value: "Save",
|
|
209
|
+
// customComponent: false,
|
|
210
|
+
// styling: "semantic",
|
|
211
|
+
// order: 3,
|
|
212
|
+
// fluid: false,
|
|
213
|
+
// standalone: true,
|
|
214
|
+
// onlyDisplay: true,
|
|
215
|
+
// submitAction: "saveFormData",
|
|
216
|
+
// supportedEvents: [
|
|
217
|
+
// "saveFormData",
|
|
218
|
+
// ],
|
|
219
|
+
// },
|
|
220
|
+
// ],
|
|
221
|
+
// },
|
|
222
|
+
// ],
|
|
223
|
+
// actionFields: [],
|
|
224
|
+
// },
|
|
225
|
+
// ],
|
|
226
|
+
// },
|
|
227
|
+
// containers: [
|
|
228
|
+
// {
|
|
229
|
+
// panes: [
|
|
230
|
+
// {
|
|
231
|
+
// sections: [
|
|
232
|
+
// {
|
|
233
|
+
// type: "multicols",
|
|
234
|
+
// width: 24,
|
|
235
|
+
// rowStyle: {
|
|
236
|
+
// // height: "calc(100vh - 142px)",
|
|
237
|
+
// },
|
|
238
|
+
// actionFields: [],
|
|
239
|
+
// inputFields: [
|
|
240
|
+
// {
|
|
241
|
+
// cols: [
|
|
242
|
+
// {
|
|
243
|
+
// id: "template-content",
|
|
244
|
+
// type: "ckeditor",
|
|
245
|
+
// metaType: "text",
|
|
246
|
+
// datatype: "string",
|
|
247
|
+
// required: true,
|
|
248
|
+
// onlyDisplay: false,
|
|
249
|
+
// standalone: false,
|
|
250
|
+
// order: 2,
|
|
251
|
+
// width: 24,
|
|
252
|
+
// events: {
|
|
253
|
+
// blur: this.onBlur,
|
|
254
|
+
// afterPaste: this.afterPaste,
|
|
255
|
+
// // change: this.onChange,
|
|
256
|
+
// },
|
|
257
|
+
// colStyle: {
|
|
258
|
+
// display: (!_.isEmpty(this.props.Templates.edmTemplate) && this.props.Templates.edmTemplate.versions.base.drag_drop_id) ? 'none' : '',
|
|
259
|
+
// },
|
|
260
|
+
// customComponent: true,
|
|
261
|
+
// getEditorInstanse: this.getEditorInstanse,
|
|
262
|
+
// supportedEvents: [
|
|
263
|
+
// "onContentChange",
|
|
264
|
+
// ],
|
|
265
|
+
// },
|
|
266
|
+
// {
|
|
267
|
+
// id: "edmeditor",
|
|
268
|
+
// type: "edmeditor",
|
|
269
|
+
// metaType: "text",
|
|
270
|
+
// datatype: "string",
|
|
271
|
+
// required: true,
|
|
272
|
+
// onlyDisplay: true,
|
|
273
|
+
// standalone: false,
|
|
274
|
+
// width: 24,
|
|
275
|
+
// order: 2,
|
|
276
|
+
// customComponent: true,
|
|
277
|
+
// // getEditorInstanse: this.getEditorInstanse,
|
|
278
|
+
// colStyle: {
|
|
279
|
+
// display: (!_.isEmpty(this.props.Templates.edmTemplate) && this.props.Templates.edmTemplate.versions.base.drag_drop_id) ? '' : 'none',
|
|
280
|
+
// },
|
|
281
|
+
// supportedEvents: [
|
|
282
|
+
// // "onContentChange",
|
|
283
|
+
// ],
|
|
284
|
+
// },
|
|
285
|
+
// ],
|
|
286
|
+
// },
|
|
287
|
+
// ],
|
|
288
|
+
// },
|
|
289
|
+
// ],
|
|
290
|
+
// },
|
|
291
|
+
// ],
|
|
292
|
+
// type: "tabs",
|
|
293
|
+
// defaultPanes: 1,
|
|
294
|
+
// additionalPanes: 0,
|
|
295
|
+
// id: "pane",
|
|
296
|
+
// tabBarExtraContent: {
|
|
297
|
+
// sections: [
|
|
298
|
+
// {
|
|
299
|
+
// type: "multicols",
|
|
300
|
+
// actionFields: [],
|
|
301
|
+
// inputFields: [
|
|
302
|
+
// {
|
|
303
|
+
// cols: [
|
|
304
|
+
// {
|
|
305
|
+
// id: "add-language-button",
|
|
306
|
+
// metaType: "submit-button",
|
|
307
|
+
// type: "customPopover",
|
|
308
|
+
// customComponent: true,
|
|
309
|
+
// onlyDisplay: true,
|
|
310
|
+
// styling: "semantic",
|
|
311
|
+
// order: 3,
|
|
312
|
+
// width: 3,
|
|
313
|
+
// colStyle: {
|
|
314
|
+
// color: `rgb(78, 146, 229)`,
|
|
315
|
+
// fontSize: '14px',
|
|
316
|
+
// fontFamily: 'open-sans',
|
|
317
|
+
// lineHeight: '24px',
|
|
318
|
+
// textAlign: 'center',
|
|
319
|
+
// cursor: 'pointer',
|
|
320
|
+
// display: (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "timeline" )) ? 'none' : '',
|
|
321
|
+
// },
|
|
322
|
+
// popOverList: this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details.supported_languages ? this.props.Global.currentOrgDetails.basic_details.supported_languages : [],
|
|
323
|
+
// baseLanguage: this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details.base_language ? this.props.Global.currentOrgDetails.basic_details.base_language : 'en',
|
|
324
|
+
// submitAction: "addLanguage",
|
|
325
|
+
// supportedEvents: [
|
|
326
|
+
// "addLanguage",
|
|
327
|
+
// ],
|
|
328
|
+
// },
|
|
329
|
+
// {
|
|
330
|
+
// id: "tagList",
|
|
331
|
+
// label: "Tags",
|
|
332
|
+
// type: "tag-list", //Resembles component to be used
|
|
333
|
+
// metaType: "List",
|
|
334
|
+
// datatype: "select",
|
|
335
|
+
// required: true,
|
|
336
|
+
// fluid: true,
|
|
337
|
+
// onlyDisplay: true,
|
|
338
|
+
// styling: "semantic",
|
|
339
|
+
// order: 1,
|
|
340
|
+
// style: {
|
|
341
|
+
// border: "none",
|
|
342
|
+
// },
|
|
343
|
+
// customComponent: true,
|
|
344
|
+
// width: 3,
|
|
345
|
+
// offset: 11,
|
|
346
|
+
// supportedEvents: [
|
|
347
|
+
// 'onTagSelect',
|
|
348
|
+
// ],
|
|
349
|
+
// },
|
|
350
|
+
// {
|
|
351
|
+
// id: "insert-image",
|
|
352
|
+
// metaType: "label",
|
|
353
|
+
// type: "div", //Resembles component to be used
|
|
354
|
+
// primitive: true,
|
|
355
|
+
// value: "Insert Image",
|
|
356
|
+
// fluid: true,
|
|
357
|
+
// onlyDisplay: false,
|
|
358
|
+
// styling: "semantic",
|
|
359
|
+
// order: 1,
|
|
360
|
+
// customComponent: false,
|
|
361
|
+
// submitAction: "onImageSelect",
|
|
362
|
+
// style: {
|
|
363
|
+
// color: "#4E92E5",
|
|
364
|
+
// fontSize: "14px",
|
|
365
|
+
// fontFamily: "open-sans",
|
|
366
|
+
// lineHeight: "24px",
|
|
367
|
+
// textAlign: "center",
|
|
368
|
+
// cursor: "pointer",
|
|
369
|
+
// },
|
|
370
|
+
// width: 3,
|
|
371
|
+
// supportedEvents: [
|
|
372
|
+
// "onImageSelect",
|
|
373
|
+
// ],
|
|
374
|
+
// },
|
|
375
|
+
// {
|
|
376
|
+
// id: "mark-final-version-label",
|
|
377
|
+
// metaType: "label",
|
|
378
|
+
// type: "div",
|
|
379
|
+
// primitive: true,
|
|
380
|
+
// value: "Mark as Final",
|
|
381
|
+
// onlyDisplay: true,
|
|
382
|
+
// customComponent: false,
|
|
383
|
+
// order: 3,
|
|
384
|
+
// width: 3,
|
|
385
|
+
// fluid: false,
|
|
386
|
+
// style: {
|
|
387
|
+
// color: "#4E92E5",
|
|
388
|
+
// fontSize: "14px",
|
|
389
|
+
// fontFamily: "open-sans",
|
|
390
|
+
// lineHeight: "24px",
|
|
391
|
+
// textAlign: "center",
|
|
392
|
+
// cursor: "pointer",
|
|
393
|
+
// display: (this.props.location.query.type === 'embedded') ? "none" : "",
|
|
394
|
+
// },
|
|
395
|
+
// submitAction: "markFinalVersion",
|
|
396
|
+
// supportedEvents: [
|
|
397
|
+
// "markFinalVersion",
|
|
398
|
+
// ],
|
|
399
|
+
// },
|
|
400
|
+
// {
|
|
401
|
+
// id: "tab-options-popover",
|
|
402
|
+
// metaType: "display",
|
|
403
|
+
// colStyle: {
|
|
404
|
+
// flex: 0,
|
|
405
|
+
// },
|
|
406
|
+
// type: "popover",
|
|
407
|
+
// customComponent: false,
|
|
408
|
+
// styling: "semantic",
|
|
409
|
+
// order: 3,
|
|
410
|
+
// width: 1,
|
|
411
|
+
// fluid: false,
|
|
412
|
+
// onlyDisplay: true,
|
|
413
|
+
// submitAction: "onTabOptionSelect",
|
|
414
|
+
// supportedEvents: [
|
|
415
|
+
// "onTabOptionSelect",
|
|
416
|
+
// ],
|
|
417
|
+
// content: {
|
|
418
|
+
// sections: [
|
|
419
|
+
// {
|
|
420
|
+
// type: "multicols",
|
|
421
|
+
// inputFields: [
|
|
422
|
+
// {
|
|
423
|
+
// cols: [
|
|
424
|
+
// {
|
|
425
|
+
// id: "duplicate-version-label",
|
|
426
|
+
// metaType: "label",
|
|
427
|
+
// type: "div",
|
|
428
|
+
// primitive: true,
|
|
429
|
+
// value: "Duplicate Version",
|
|
430
|
+
// onlyDisplay: true,
|
|
431
|
+
// customComponent: false,
|
|
432
|
+
// order: 3,
|
|
433
|
+
// fluid: false,
|
|
434
|
+
// colStyle: {
|
|
435
|
+
// display: (this.props.location.query.type === 'embedded') ? "none" : "",
|
|
436
|
+
// },
|
|
437
|
+
// className: "version-popover",
|
|
438
|
+
// submitAction: "duplicateVersion",
|
|
439
|
+
// supportedEvents: [
|
|
440
|
+
// "duplicateVersion",
|
|
441
|
+
// ],
|
|
442
|
+
// },
|
|
443
|
+
// ],
|
|
444
|
+
// },
|
|
445
|
+
// {
|
|
446
|
+
// cols: [
|
|
447
|
+
// {
|
|
448
|
+
// id: "delete-version-label",
|
|
449
|
+
// metaType: "label",
|
|
450
|
+
// type: "div",
|
|
451
|
+
// primitive: true,
|
|
452
|
+
// value: "Delete Version",
|
|
453
|
+
// onlyDisplay: true,
|
|
454
|
+
// customComponent: false,
|
|
455
|
+
// order: 3,
|
|
456
|
+
// fluid: false,
|
|
457
|
+
// colStyle: {
|
|
458
|
+
// display: (this.props.location.query.type === 'embedded') ? "none" : "",
|
|
459
|
+
// },
|
|
460
|
+
// className: "version-popover",
|
|
461
|
+
// submitAction: "deleteVersion",
|
|
462
|
+
// supportedEvents: [
|
|
463
|
+
// "deleteVersion",
|
|
464
|
+
// ],
|
|
465
|
+
// },
|
|
466
|
+
// ],
|
|
467
|
+
// },
|
|
468
|
+
// {
|
|
469
|
+
// cols: [
|
|
470
|
+
// {
|
|
471
|
+
// id: "delete-language-label",
|
|
472
|
+
// metaType: "label",
|
|
473
|
+
// type: "div",
|
|
474
|
+
// primitive: true,
|
|
475
|
+
// value: "Delete Language",
|
|
476
|
+
// onlyDisplay: true,
|
|
477
|
+
// customComponent: false,
|
|
478
|
+
// order: 3,
|
|
479
|
+
// fluid: false,
|
|
480
|
+
// className: "version-popover",
|
|
481
|
+
// submitAction: "deleteLanguage",
|
|
482
|
+
// supportedEvents: [
|
|
483
|
+
// "deleteLanguage",
|
|
484
|
+
// ],
|
|
485
|
+
// },
|
|
486
|
+
// ],
|
|
487
|
+
// },
|
|
488
|
+
// {
|
|
489
|
+
// cols: [
|
|
490
|
+
// {
|
|
491
|
+
// id: "switch-editor-label",
|
|
492
|
+
// metaType: "label",
|
|
493
|
+
// type: "div",
|
|
494
|
+
// primitive: true,
|
|
495
|
+
// value: "Switch Editor",
|
|
496
|
+
// onlyDisplay: true,
|
|
497
|
+
// customComponent: false,
|
|
498
|
+
// order: 4,
|
|
499
|
+
// fluid: false,
|
|
500
|
+
// className: "version-popover",
|
|
501
|
+
// submitAction: "switchEditor",
|
|
502
|
+
// supportedEvents: [
|
|
503
|
+
// "switchEditor",
|
|
504
|
+
// ],
|
|
505
|
+
// style: {
|
|
506
|
+
// display: (!_.isEmpty(this.props.Templates.edmTemplate) && this.props.Templates.edmTemplate.versions.base.drag_drop_id) ? '' : 'none',
|
|
507
|
+
// },
|
|
508
|
+
// },
|
|
509
|
+
// ],
|
|
510
|
+
// },
|
|
511
|
+
// ],
|
|
512
|
+
// actionFields: [],
|
|
513
|
+
// },
|
|
514
|
+
// ],
|
|
515
|
+
// },
|
|
516
|
+
// value: {
|
|
517
|
+
// sections: [
|
|
518
|
+
// {
|
|
519
|
+
// type: "multicols",
|
|
520
|
+
// inputFields: [
|
|
521
|
+
// {
|
|
522
|
+
// cols: [
|
|
523
|
+
// {
|
|
524
|
+
// id: "tab-option-icon",
|
|
525
|
+
// metaType: "display",
|
|
526
|
+
// type: "icon",
|
|
527
|
+
// onlyDisplay: true,
|
|
528
|
+
// primitive: false,
|
|
529
|
+
// value: "",
|
|
530
|
+
// customComponent: false,
|
|
531
|
+
// order: 3,
|
|
532
|
+
// fluid: false,
|
|
533
|
+
// },
|
|
534
|
+
// ],
|
|
535
|
+
// },
|
|
536
|
+
// ],
|
|
537
|
+
// actionFields: [],
|
|
538
|
+
// },
|
|
539
|
+
// ],
|
|
540
|
+
// },
|
|
541
|
+
// trigger: "click",
|
|
542
|
+
// placement: "bottomLeft",
|
|
543
|
+
// },
|
|
544
|
+
// ],
|
|
545
|
+
// },
|
|
546
|
+
// ],
|
|
547
|
+
// },
|
|
548
|
+
// ],
|
|
549
|
+
// },
|
|
550
|
+
// tabContent: {
|
|
551
|
+
// sections: [
|
|
552
|
+
// {
|
|
553
|
+
// type: "multicols",
|
|
554
|
+
// inputFields: [
|
|
555
|
+
// {
|
|
556
|
+
// rowStyle: {
|
|
557
|
+
// display: "flex",
|
|
558
|
+
// flex: 1,
|
|
559
|
+
// },
|
|
560
|
+
// cols: [
|
|
561
|
+
// {
|
|
562
|
+
// id: "tab-header",
|
|
563
|
+
// metaType: "label",
|
|
564
|
+
// value: "English",
|
|
565
|
+
// primitive: true,
|
|
566
|
+
// dynamicTab: false,
|
|
567
|
+
// type: "div",
|
|
568
|
+
// width: 5,
|
|
569
|
+
// offset: 0,
|
|
570
|
+
// onlyDisplay: true,
|
|
571
|
+
// colStyle: {
|
|
572
|
+
// flex: 1,
|
|
573
|
+
// },
|
|
574
|
+
// supportedEvents: [
|
|
575
|
+
// "onChange",
|
|
576
|
+
// ],
|
|
577
|
+
// },
|
|
578
|
+
// ],
|
|
579
|
+
// },
|
|
580
|
+
// ],
|
|
581
|
+
// actionFields: [],
|
|
582
|
+
// },
|
|
583
|
+
// ],
|
|
584
|
+
// },
|
|
585
|
+
// label: "Version",
|
|
586
|
+
// onlyDisplay: true,
|
|
587
|
+
// supportedEvents: [
|
|
588
|
+
// "onTabChange",
|
|
589
|
+
// ],
|
|
590
|
+
// isActive: true,
|
|
591
|
+
// },
|
|
592
|
+
// ],
|
|
593
|
+
// channel: "EMAIL",
|
|
594
|
+
// },
|
|
595
|
+
loading: false,
|
|
596
|
+
isFormValid: true,
|
|
597
|
+
injectedTags: {},
|
|
598
|
+
checkValidation: false,
|
|
599
|
+
saveEdmDataMode: 'save',
|
|
600
|
+
tabKey: '',
|
|
601
|
+
showEmailPreview: false,
|
|
602
|
+
device: "desktop",
|
|
603
|
+
editorInstanse: undefined,
|
|
604
|
+
showImageSelectionBox: false,
|
|
605
|
+
isDragDrop: false,
|
|
606
|
+
showConfirmationModal: false,
|
|
607
|
+
modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation), type: 'confirm', id: 'email-language-delete-modal'},
|
|
608
|
+
showModal: false,
|
|
609
|
+
page: 1,
|
|
610
|
+
perPageLimit: 25,
|
|
611
|
+
totalCount: 0,
|
|
612
|
+
searchText: '',
|
|
613
|
+
saveCount: 0,
|
|
614
|
+
cmsDataCount: 0,
|
|
615
|
+
targetSaveCount: 0,
|
|
616
|
+
saveObj: {},
|
|
617
|
+
showEdmEmailTemplates: false,
|
|
618
|
+
editDataSet: false,
|
|
619
|
+
languageDataSet: false,
|
|
620
|
+
addLanguageType: '',
|
|
621
|
+
startValidation: false,
|
|
622
|
+
saveForm: false,
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
this.isTagLoaded = false;
|
|
626
|
+
this.edmEvent = undefined;
|
|
627
|
+
this.supportedLanguages = this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details.supported_languages ? this.props.Global.currentOrgDetails.basic_details.supported_languages : [];
|
|
628
|
+
this.map = {
|
|
629
|
+
"template-name": {
|
|
630
|
+
onChange: this.onTemplateNameChange,
|
|
631
|
+
},
|
|
632
|
+
"template-version": {
|
|
633
|
+
onSelect: this.handleVersionSelect,
|
|
634
|
+
addVersion: this.addVersion,
|
|
635
|
+
},
|
|
636
|
+
"preview-button": {
|
|
637
|
+
previewTemplate: this.toggleEmailPreview,
|
|
638
|
+
},
|
|
639
|
+
"cancel-button": {
|
|
640
|
+
cancelTemplate: this.cancelTemplate,
|
|
641
|
+
},
|
|
642
|
+
"save-button": {
|
|
643
|
+
saveFormData: this.saveFormData,
|
|
644
|
+
},
|
|
645
|
+
"sms-editor": {
|
|
646
|
+
onChange: this.onTemplateContentChange,
|
|
647
|
+
},
|
|
648
|
+
"tagList": {
|
|
649
|
+
onTagSelect: this.onTagSelect,
|
|
650
|
+
},
|
|
651
|
+
"unicode-validity": {
|
|
652
|
+
onChange: this.onTemplateNameChange,
|
|
653
|
+
},
|
|
654
|
+
"add-language-button": {
|
|
655
|
+
addLanguage: this.addLanguage,
|
|
656
|
+
},
|
|
657
|
+
"tab-header": {
|
|
658
|
+
onChange: this.onVersionNameChange,
|
|
659
|
+
},
|
|
660
|
+
"tab-options-popover": {
|
|
661
|
+
onTabOptionSelect: this.onTabOptionSelect,
|
|
662
|
+
},
|
|
663
|
+
"mark-final-version-label": {
|
|
664
|
+
markFinalVersion: this.markFinalVersion,
|
|
665
|
+
},
|
|
666
|
+
"duplicate-version-label": {
|
|
667
|
+
duplicateVersion: this.duplicateVersion,
|
|
668
|
+
},
|
|
669
|
+
"rename-version-label": {
|
|
670
|
+
renameVersion: this.renameVersion,
|
|
671
|
+
},
|
|
672
|
+
"delete-version-label": {
|
|
673
|
+
deleteVersion: this.deleteVersion,
|
|
674
|
+
},
|
|
675
|
+
"switch-editor-label": {
|
|
676
|
+
switchEditor: this.switchEditor,
|
|
677
|
+
},
|
|
678
|
+
"pane": {
|
|
679
|
+
onTabChange: this.onTabChange,
|
|
680
|
+
},
|
|
681
|
+
"insert-image": {
|
|
682
|
+
onImageSelect: this.onImageSelect,
|
|
683
|
+
},
|
|
684
|
+
"template-content": {
|
|
685
|
+
onContentChange: this.onChange,
|
|
686
|
+
getEditorInstanse: this.getEditorInstanse,
|
|
687
|
+
},
|
|
688
|
+
"delete-language-label": {
|
|
689
|
+
deleteLanguage: this.deleteLanguage,
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
componentWillMount() {
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
const formData = this.initFormData(this.props, true); //_.cloneDeep(this.state.formData);
|
|
698
|
+
const isEmpty = _.isEmpty(formData);
|
|
699
|
+
if (!isEmpty) {
|
|
700
|
+
formData['template-version-options'] = [
|
|
701
|
+
{
|
|
702
|
+
key: 'version 1',
|
|
703
|
+
label: this.props.intl.formatMessage(messages.versionOneMessage),
|
|
704
|
+
value: 'version 1',
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
key: 'New Version',
|
|
708
|
+
label: this.props.intl.formatMessage(messages.newVersion),
|
|
709
|
+
value: 'New Version',
|
|
710
|
+
},
|
|
711
|
+
];
|
|
712
|
+
// console.log('New Form Data Preparing ', this.initFormData());
|
|
713
|
+
formData['template-version'] = "version 1";
|
|
714
|
+
}
|
|
715
|
+
// const formData = _.cloneDeep(this.state.formData);
|
|
716
|
+
if (this.props.params.id || (this.props.location.query.module === "library" && this.props.templateData && !_.isEmpty(this.props.templateData))) {
|
|
717
|
+
this.setState({isEdit: true}, () => {
|
|
718
|
+
if (this.props.params.id) {
|
|
719
|
+
this.props.actions.getTemplateDetails(this.props.params.id, 'email');
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
// formData[0] = {
|
|
724
|
+
// "template-content": (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''),
|
|
725
|
+
// };
|
|
726
|
+
// if (this.props.Templates.CmsSettings) {}
|
|
727
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
728
|
+
if (this.props.location.query.module === "library" && this.props.templateData) {
|
|
729
|
+
this.props.templatesActions.resetTemplateData();
|
|
730
|
+
}
|
|
731
|
+
if (!_.isEmpty(this.props.Templates.edmTemplate)) {
|
|
732
|
+
if (this.props.Templates.edmTemplate.versions.base.is_drag_drop) {
|
|
733
|
+
this.setState({isDragDrop: true});
|
|
734
|
+
}
|
|
735
|
+
if (this.props.params.id) {
|
|
736
|
+
this.props.actions.getCmsSetting('edm', this.props.Templates.edmTemplate.versions.base.drag_drop_id, 'open', undefined, isEdmSupport);
|
|
737
|
+
} else if (this.props.location.query.module !== "library" || (this.props.location.query.module === "library" && !this.props.templateData)) {
|
|
738
|
+
this.props.actions.getCmsSetting('edm', this.props.Templates.edmTemplate.versions.base.drag_drop_id, 'create', undefined, isEdmSupport);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
this.setState({ content: (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''), formData}, () => {
|
|
743
|
+
// this.injectEvents(this.state.schema);
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
// setTimeout(() => {
|
|
747
|
+
// // this.getFormData();
|
|
748
|
+
// this.startTemplateCreation();
|
|
749
|
+
// }, 15000);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
componentDidMount() {
|
|
753
|
+
|
|
754
|
+
const query = {
|
|
755
|
+
layout: 'EMAIL',
|
|
756
|
+
type: 'LAYOUT',
|
|
757
|
+
};
|
|
758
|
+
this.props.globalActions.fetchSchemaForEntity(query);
|
|
759
|
+
window.addEventListener("message", this.handleFrameTasks);
|
|
760
|
+
if (this.props.location.query.type === 'embedded') {
|
|
761
|
+
this.showNext();
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
componentWillReceiveProps(nextProps) {
|
|
766
|
+
|
|
767
|
+
// if (this.props.location.query.type === 'embedded') {
|
|
768
|
+
// this.showNext();
|
|
769
|
+
// }
|
|
770
|
+
|
|
771
|
+
if (this.state.languageDataSet && nextProps.Templates.selectedEmailLayout && nextProps.Templates.selectedEmailLayout !== '' && !_.isEqual(this.props.Templates.selectedEmailLayout, nextProps.Templates.selectedEmailLayout )) {
|
|
772
|
+
|
|
773
|
+
this.setNewLanguageContent(nextProps.Templates.selectedEmailLayout);
|
|
774
|
+
}
|
|
775
|
+
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
|
|
776
|
+
const newSchema = this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
777
|
+
|
|
778
|
+
this.setState({schema: newSchema});
|
|
779
|
+
if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
|
|
780
|
+
const query = {
|
|
781
|
+
layout: 'EMAIL',
|
|
782
|
+
type: 'TAG',
|
|
783
|
+
context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
|
|
784
|
+
embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
|
|
785
|
+
};
|
|
786
|
+
if (this.props.getDefaultTags) {
|
|
787
|
+
query.context = this.props.getDefaultTags;
|
|
788
|
+
}
|
|
789
|
+
if (_.isEmpty(this.props.metaEntities.tags)) {
|
|
790
|
+
this.props.globalActions.fetchSchemaForEntity(query);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
setTimeout(() => {
|
|
794
|
+
this.showSubject();
|
|
795
|
+
}, 0);
|
|
796
|
+
}
|
|
797
|
+
if (nextProps.Global.currentOrgDetails && nextProps.Global.currentOrgDetails.basic_details && !_.isEmpty(nextProps.Global.currentOrgDetails.basic_details) && _.isEmpty(this.state.formData)) {
|
|
798
|
+
const formData = this.initFormData(nextProps);
|
|
799
|
+
formData['template-version-options'] = [
|
|
800
|
+
{
|
|
801
|
+
key: 'version 1',
|
|
802
|
+
label: this.props.intl.formatMessage(messages.versionOneMessage),
|
|
803
|
+
value: 'version 1',
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
key: 'New Version',
|
|
807
|
+
label: this.props.intl.formatMessage(messages.newVersion),
|
|
808
|
+
value: 'New Version',
|
|
809
|
+
},
|
|
810
|
+
];
|
|
811
|
+
// console.log('New Form Data Preparing ', this.initFormData());
|
|
812
|
+
formData['template-version'] = "version 1";
|
|
813
|
+
//const that = this;
|
|
814
|
+
this.setState({formData}, () => {
|
|
815
|
+
// setTimeout(() => {
|
|
816
|
+
// this.getFormData();
|
|
817
|
+
// that.startTemplateCreation();
|
|
818
|
+
// }, 15000);
|
|
819
|
+
});
|
|
820
|
+
} else if (nextProps.Global.currentOrgDetails && nextProps.Global.currentOrgDetails.basic_details) {
|
|
821
|
+
// this.injectEvents(this.state.schema);
|
|
822
|
+
const baseLanguage = nextProps.Global.currentOrgDetails.basic_details.base_language;
|
|
823
|
+
if (this.state.formData[`${this.state.currentTab - 1}`] && _.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages)) {
|
|
824
|
+
|
|
825
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
826
|
+
formData[`${this.state.currentTab - 1}`].selectedLanguages = [];
|
|
827
|
+
formData[`${this.state.currentTab - 1}`].selectedLanguages.push(baseLanguage);
|
|
828
|
+
formData.base.selectedLanguages = [];
|
|
829
|
+
formData.base.selectedLanguages.push(baseLanguage);
|
|
830
|
+
this.setState({formData});
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
if (!_.isEmpty(this.state.schema)) {
|
|
834
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
835
|
+
|
|
836
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
837
|
+
const container = schema.containers[0];
|
|
838
|
+
// const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
839
|
+
if (baseLanguage === formData[0].activeTab) {
|
|
840
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
|
|
841
|
+
} else {
|
|
842
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
|
|
843
|
+
}
|
|
844
|
+
this.setState({schema});
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
//
|
|
848
|
+
// if (!this.isTagLoaded) {
|
|
849
|
+
// this.isTagLoaded = true;
|
|
850
|
+
// const query = {
|
|
851
|
+
// layout: 'EMAIL',
|
|
852
|
+
// type: 'TAG',
|
|
853
|
+
// context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
|
|
854
|
+
// embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
|
|
855
|
+
// };
|
|
856
|
+
// this.props.globalActions.fetchSchemaForEntity(query);
|
|
857
|
+
// }
|
|
858
|
+
|
|
859
|
+
if (this.state.isEdit && !this.state.editDataSet && !_.isEmpty(nextProps.Email.templateDetails) && !_.isEmpty(this.state.schema)) {
|
|
860
|
+
|
|
861
|
+
this.setState({editDataSet: true}, () => {
|
|
862
|
+
this.setEditData(nextProps.Email.templateDetails);
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) && !this.props.params.id && !nextProps.isGetFormData) {
|
|
866
|
+
this.startTemplateCreation(nextProps.templateData);
|
|
867
|
+
}
|
|
868
|
+
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
|
|
869
|
+
this.getFormData();
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (!_.isEmpty(nextProps.Email.CmsSettings) && !_.isEqual(this.props.Email.CmsSettings, nextProps.Email.CmsSettings)) {
|
|
873
|
+
const apiLangId = nextProps.Email.CmsSettings.langId;
|
|
874
|
+
const langId = nextProps.Email.CmsSettings.langId !== "undefined" ? nextProps.Email.CmsSettings.langId : nextProps.Global.currentOrgDetails.basic_details.base_language;
|
|
875
|
+
|
|
876
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
877
|
+
|
|
878
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
879
|
+
const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
|
|
880
|
+
|
|
881
|
+
const temp = (schema.containers || {})[this.state.currentTab - 1];
|
|
882
|
+
const isStyleExists= temp?.tabBarExtraContent?.sections?.[0]?.inputFields?.[0]?.cols?.[4]?.content?.sections?.[0]?.inputFields?.[2]?.cols?.[0]?.style;
|
|
883
|
+
if (baseLanguage === langId && (apiLangId === "undefined" || apiLangId === formData[this.state.currentTab - 1].activeTab)) {
|
|
884
|
+
if(isStyleExists){
|
|
885
|
+
temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
|
|
886
|
+
}
|
|
887
|
+
} else if (apiLangId === "undefined" || apiLangId === formData[this.state.currentTab - 1].activeTab) {
|
|
888
|
+
if(isStyleExists){
|
|
889
|
+
temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (nextProps.Email.CmsSettings.isDragDrop) {
|
|
894
|
+
formData[`${this.state.currentTab - 1}`][langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
|
|
895
|
+
formData[`${this.state.currentTab - 1}`][langId][`drag_drop_id`] = this.getParameterByName("projectId", nextProps.Email.CmsSettings.url);
|
|
896
|
+
formData[`${this.state.currentTab - 1}`][langId][`is_drag_drop`] = true;
|
|
897
|
+
if (formData[`${this.state.currentTab - 1}`].base) {
|
|
898
|
+
formData.base[langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
|
|
899
|
+
formData.base[langId][`drag_drop_id`] = this.getParameterByName("projectId", nextProps.Email.CmsSettings.url);
|
|
900
|
+
formData.base[langId][`is_drag_drop`] = true;
|
|
901
|
+
}
|
|
902
|
+
_.forEach(temp.panes, (pane, index) => {
|
|
903
|
+
const tempPane = pane;
|
|
904
|
+
//
|
|
905
|
+
if (parseInt(index, 10) === parseInt(langIndex, 10)) {
|
|
906
|
+
//
|
|
907
|
+
tempPane.sections[0].inputFields[0].cols[1].colStyle = {display: ""};
|
|
908
|
+
tempPane.sections[0].inputFields[0].cols[0].colStyle = {display: "none"};
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
this.setState({schema, isSchemaChanged: true});
|
|
913
|
+
} else {
|
|
914
|
+
_.forEach(temp.panes, (pane, index) => {
|
|
915
|
+
const tempPane = pane;
|
|
916
|
+
if (parseInt(index, 10) === parseInt(langIndex, 10) ) {
|
|
917
|
+
tempPane.sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
|
|
918
|
+
tempPane.sections[0].inputFields[0].cols[0].colStyle = {display: ""};
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
this.setState({schema, isSchemaChanged: true});
|
|
923
|
+
let html = decodeURIComponent(nextProps.Email.CmsSettings.htmlContent);
|
|
924
|
+
|
|
925
|
+
html = html.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\\"/g, '"');
|
|
926
|
+
|
|
927
|
+
formData[this.state.currentTab - 1][langId]["template-content"] = html;
|
|
928
|
+
if (window.CKEDITOR && apiLangId !== "undefined") {
|
|
929
|
+
const instanceName = `template-content${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`;
|
|
930
|
+
|
|
931
|
+
_.forEach(window.CKEDITOR.instances, (winInstance) => {
|
|
932
|
+
const tempInstance = winInstance;
|
|
933
|
+
|
|
934
|
+
if (winInstance.name === instanceName) {
|
|
935
|
+
|
|
936
|
+
tempInstance.setData(html);
|
|
937
|
+
} else if (winInstance.name.indexOf('editor') !== -1) {
|
|
938
|
+
tempInstance.setData(html);
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
this.setState({ formData }, () => {
|
|
945
|
+
this.hideEdmOptions(nextProps.Email.CmsSettings.isDragDrop);
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
if (nextProps.Email.createResponse && nextProps.Email.createResponse.templateId) {
|
|
950
|
+
// this.resetSchema();
|
|
951
|
+
let message;
|
|
952
|
+
if (this.state.isEdit) {
|
|
953
|
+
message = getMessageObject('success', this.props.intl.formatMessage(messages.emailEditSuccess), true);
|
|
954
|
+
} else {
|
|
955
|
+
message = getMessageObject('success', this.props.intl.formatMessage(messages.emailCreateSuccess), true);
|
|
956
|
+
}
|
|
957
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
958
|
+
this.props.actions.clearCRUDResponse();
|
|
959
|
+
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
960
|
+
const type = this.props.location.query.type;
|
|
961
|
+
const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
|
|
962
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
963
|
+
this.props.router.push({
|
|
964
|
+
pathname: `/email`,
|
|
965
|
+
search : createQueryString(type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport})
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
if (nextProps.Email.createTemplateError && !_.isEqual(nextProps.Email.createTemplateError, this.props.Email.createTemplateError)) {
|
|
969
|
+
const message = getMessageObject('error', (nextProps.Email.createTemplateErrorMessage && nextProps.Email.createTemplateErrorMessage !== '') ? nextProps.Email.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
|
|
970
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
971
|
+
}
|
|
972
|
+
if (!nextProps.Email.fetchingCmsData && !_.isEqual(nextProps.Email.cmsData, this.props.Email.cmsData)) {
|
|
973
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
974
|
+
if (nextProps.Email.langId && nextProps.Email.langId !== 'undefined') {
|
|
975
|
+
console.log('setting template content', nextProps.Email.cmsData, decodeURIComponent(nextProps.Email.cmsData));
|
|
976
|
+
const langId = nextProps.Email.langId;
|
|
977
|
+
formData[`${this.state.currentTab - 1}`][langId]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
|
|
978
|
+
if (formData[`${this.state.currentTab - 1}`].base) {
|
|
979
|
+
formData.base[langId]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
|
|
980
|
+
}
|
|
981
|
+
} else if (this.state.gettingPreviewData) {
|
|
982
|
+
this.setState({gettingPreviewData: false});
|
|
983
|
+
formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
|
|
984
|
+
if (formData[`${this.state.currentTab - 1}`].base) {
|
|
985
|
+
formData.base[formData.base.activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
|
|
986
|
+
}
|
|
987
|
+
} else {
|
|
988
|
+
|
|
989
|
+
const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(formData[this.state.currentTab - 1].activeTab);
|
|
990
|
+
const instanceName = `template-content${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`;
|
|
991
|
+
|
|
992
|
+
_.forEach(window.CKEDITOR.instances, (winInstance) => {
|
|
993
|
+
const temp = winInstance;
|
|
994
|
+
|
|
995
|
+
if (winInstance.name === instanceName) {
|
|
996
|
+
|
|
997
|
+
temp.setData(decodeURIComponent(nextProps.Email.cmsData));
|
|
998
|
+
} else if (winInstance.name.indexOf('editor') !== -1) {
|
|
999
|
+
temp.setData(decodeURIComponent(nextProps.Email.cmsData));
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
|
|
1003
|
+
formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop = false;
|
|
1004
|
+
formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id = "";
|
|
1005
|
+
delete formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].edmeditorsrc;
|
|
1006
|
+
if (formData[`${this.state.currentTab - 1}`].base) {
|
|
1007
|
+
formData.base[formData.base.activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
|
|
1008
|
+
formData.base[formData.base.activeTab].is_drag_drop = false;
|
|
1009
|
+
formData.base[formData.base.activeTab].drag_drop_id = "";
|
|
1010
|
+
delete formData.base[formData.base.activeTab].edmeditorsrc;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
this.setState({ formData }, () => {
|
|
1016
|
+
if (nextProps.Email.langId) {
|
|
1017
|
+
this.shouldStartValidation();
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
if ( !_.isEqual(nextProps.Email.uploadAssetSuccess, this.props.Email.uploadAssetSuccess) && nextProps.Email.uploadAssetSuccess) {
|
|
1023
|
+
|
|
1024
|
+
const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
|
|
1025
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
1026
|
+
if (isDragDrop && isEdmSupport) {
|
|
1027
|
+
console.log('Handle EDM ', this.edmEvent, JSON.parse(this.edmEvent.data)._dynId, nextProps.Email.uploadedAssetData.metaInfo.secure_file_path);
|
|
1028
|
+
const evtData = JSON.parse(this.edmEvent.data);
|
|
1029
|
+
if (evtData.action === 'editBackground') {
|
|
1030
|
+
this.edmEvent.source.postMessage(JSON.stringify({
|
|
1031
|
+
_dynId: JSON.parse(this.edmEvent.data)._dynId,
|
|
1032
|
+
action: "setProps",
|
|
1033
|
+
props: {
|
|
1034
|
+
background: {
|
|
1035
|
+
image: {
|
|
1036
|
+
src: nextProps.Email.uploadedAssetData.metaInfo.secure_file_path,
|
|
1037
|
+
},
|
|
1038
|
+
},
|
|
1039
|
+
},
|
|
1040
|
+
}), "*");
|
|
1041
|
+
} else if (evtData.action === 'edit') {
|
|
1042
|
+
this.edmEvent.source.postMessage(JSON.stringify({
|
|
1043
|
+
_dynId: JSON.parse(this.edmEvent.data)._dynId,
|
|
1044
|
+
action: "setProps",
|
|
1045
|
+
props: {
|
|
1046
|
+
src: nextProps.Email.uploadedAssetData.metaInfo.secure_file_path,
|
|
1047
|
+
},
|
|
1048
|
+
}), "*");
|
|
1049
|
+
}
|
|
1050
|
+
this.edmEvent = undefined;
|
|
1051
|
+
} else if (this.state.editorInstanse) {
|
|
1052
|
+
this.state.editorInstanse.insertHtml(`<img src='${nextProps.Email.uploadedAssetData.metaInfo.secure_file_path}' alt='Image'>`);
|
|
1053
|
+
//this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, nextProps.Email.uploadedAssetData, true);
|
|
1054
|
+
}
|
|
1055
|
+
this.setState({showImageSelectionBox: false});
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if ( !_.isEqual(nextProps.Email.assetUploading, this.props.Email.assetUploading) && !nextProps.Email.assetUploading && !nextProps.Email.uploadAssetSuccess) {
|
|
1059
|
+
const message = getMessageObject('error', this.props.intl.formatMessage(messages.assetUploadFailed), true);
|
|
1060
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
if (!_.isEqual(nextProps.Global.currentOrgDetails.basic_details.supported_languages, this.props.Global.currentOrgDetails.basic_details.supported_languages)) {
|
|
1064
|
+
this.supportedLanguages = nextProps.Global.currentOrgDetails.basic_details.supported_languages;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (!nextProps.Email.fetchingAllAssets && !_.isEqual(nextProps.Email.fetchingAllAssets, this.props.Email.fetchingAllAssets) && !_.isEmpty(nextProps.Email.assetList) && nextProps.Email.assetList[0] && nextProps.Email.assetList[0].totalCount && this.state.totalCount === 0) {
|
|
1068
|
+
this.setState({totalCount: nextProps.Email.assetList[0].totalCount});
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
componentWillUnmount() {
|
|
1074
|
+
|
|
1075
|
+
this.resetStateValue();
|
|
1076
|
+
window.removeEventListener("message", this.handleFrameTasks);
|
|
1077
|
+
this.props.actions.clearStoreValues();
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
onFormDataChange = (formData, tabCount, currentTab) => {
|
|
1081
|
+
|
|
1082
|
+
// this.transformFormData(formData);
|
|
1083
|
+
this.setState({formData, tabCount, isSchemaChanged: false});
|
|
1084
|
+
if (currentTab) {
|
|
1085
|
+
this.setState({currentTab});
|
|
1086
|
+
}
|
|
1087
|
+
//this.resetCkEditorInstance(currentTab, formData);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
onChange = (evt) => {
|
|
1091
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1092
|
+
console.log('oncontentchange onChange ', evt, evt.editor.getData());
|
|
1093
|
+
//if (evt.editor.name.indexOf('editor') === -1) {
|
|
1094
|
+
// _.forEach(window.CKEDITOR.instances, (winInstance) => {
|
|
1095
|
+
// const temp = winInstance;
|
|
1096
|
+
// if (winInstance.name === evt.editor.name) {
|
|
1097
|
+
//
|
|
1098
|
+
// setTimeout(() => {
|
|
1099
|
+
// //temp.name = id;
|
|
1100
|
+
// }, 1000);
|
|
1101
|
+
// //temp.name = id;
|
|
1102
|
+
//
|
|
1103
|
+
// }
|
|
1104
|
+
// });
|
|
1105
|
+
//}
|
|
1106
|
+
if (!formData[this.state.currentTab - 1][formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop) {
|
|
1107
|
+
formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab][`template-content`] = _.cloneDeep(evt.editor.getData());
|
|
1108
|
+
if (formData[`${this.state.currentTab - 1}`].tabKey === formData.base.tabKey) {
|
|
1109
|
+
formData.base[formData[`${this.state.currentTab - 1}`].activeTab][`template-content`] = _.cloneDeep(evt.editor.getData());
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
this.setState({formData, content: evt.editor.getData()}, () => {
|
|
1113
|
+
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
onBlur = (evt) => {
|
|
1119
|
+
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
onTabChange(data, formData) {
|
|
1123
|
+
|
|
1124
|
+
//this.resetCkEditorInstance(data, formData);
|
|
1125
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
1126
|
+
const container = schema.containers[`${data - 1}`];
|
|
1127
|
+
if (formData[`${data - 1}`][formData[`${data - 1}`].activeTab].is_drag_drop) {
|
|
1128
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: ""};
|
|
1129
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[2].style.display = "none";
|
|
1130
|
+
} else {
|
|
1131
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
|
|
1132
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[2].style.display = "";
|
|
1133
|
+
}
|
|
1134
|
+
const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
1135
|
+
if (baseLanguage === formData[`${data - 1}`].activeTab) {
|
|
1136
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
|
|
1137
|
+
} else {
|
|
1138
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
|
|
1139
|
+
}
|
|
1140
|
+
this.setState({currentTab: data, formData, schema});
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
onTemplateNameChange = (name) => {
|
|
1144
|
+
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
onTagSelect = (data, currentTab, value) => {
|
|
1148
|
+
|
|
1149
|
+
const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
|
|
1150
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1151
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
1152
|
+
|
|
1153
|
+
if (isDragDrop && isEdmSupport) {
|
|
1154
|
+
let msg = {};
|
|
1155
|
+
if (data === "unsubscribe") {
|
|
1156
|
+
const anchor = `<a href='{{${data}}}'>${data}</a>`;
|
|
1157
|
+
msg = {
|
|
1158
|
+
action: "InsertToCursor",
|
|
1159
|
+
content: `${anchor}`,
|
|
1160
|
+
};
|
|
1161
|
+
} else {
|
|
1162
|
+
msg = {
|
|
1163
|
+
action: "InsertToCursor",
|
|
1164
|
+
content: `{{${data}}}`,
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
const msgString = JSON.stringify(msg);
|
|
1168
|
+
const langId = formData[this.state.currentTab - 1].activeTab;
|
|
1169
|
+
const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
|
|
1170
|
+
const elementToSelect = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
|
|
1171
|
+
if (elementToSelect) {
|
|
1172
|
+
const win = elementToSelect.contentWindow;
|
|
1173
|
+
win.postMessage(msgString, '*');
|
|
1174
|
+
}
|
|
1175
|
+
} else {
|
|
1176
|
+
|
|
1177
|
+
if (this.state.editorInstanse) {
|
|
1178
|
+
if (data === "unsubscribe") {
|
|
1179
|
+
const anchor = `<a href='{{${data}}}'>${data}</a>`;
|
|
1180
|
+
this.state.editorInstanse.insertHtml(`${anchor}`);
|
|
1181
|
+
} else {
|
|
1182
|
+
this.state.editorInstanse.insertHtml(`{{${data}}}`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
//this.resetCkEditorInstance(currentTab, formData, true, data);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
onImageSelect = (data) => {
|
|
1190
|
+
|
|
1191
|
+
this.setState({ showImageSelectionBox: true }, () => {
|
|
1192
|
+
const params = {
|
|
1193
|
+
name: this.state.searchText,
|
|
1194
|
+
sortBy: 'Most Recent',
|
|
1195
|
+
};
|
|
1196
|
+
this.fetchAllAssets({params, resetPage: true});
|
|
1197
|
+
// this.props.actions.getAllAssets("image", params);
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
getValidationData = () => {
|
|
1202
|
+
const that = this;
|
|
1203
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1204
|
+
_.forEach(formData, (val, index) => {
|
|
1205
|
+
if (!isNaN(index)) {
|
|
1206
|
+
_.forEach(val.selectedLanguages, (language) => {
|
|
1207
|
+
if (val[language].is_drag_drop) {
|
|
1208
|
+
that.props.actions.getCmsData('edm', val[language].drag_drop_id, language);
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
setNewLanguageContent = (data) => {
|
|
1216
|
+
const content = _.cloneDeep(data);
|
|
1217
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1218
|
+
const currentTab = this.state.currentTab - 1;
|
|
1219
|
+
// const schema = _.cloneDeep(this.state.schema);
|
|
1220
|
+
|
|
1221
|
+
const currentTabData = formData[currentTab][this.state.settingLanguage.iso_code];
|
|
1222
|
+
currentTabData.is_drag_drop = false;
|
|
1223
|
+
currentTabData.drag_drop_id = "";
|
|
1224
|
+
const newActiveTab = this.state.settingLanguage.iso_code;
|
|
1225
|
+
currentTabData["template-content"] = content;
|
|
1226
|
+
formData[currentTab].activeTab = newActiveTab;
|
|
1227
|
+
if (currentTabData.edmeditorsrc) {
|
|
1228
|
+
delete currentTabData.edmeditorsrc;
|
|
1229
|
+
}
|
|
1230
|
+
formData[currentTab].selectedLanguages.push(newActiveTab);
|
|
1231
|
+
|
|
1232
|
+
// this.setState({formData});
|
|
1233
|
+
// const container = schema.containers[this.state.currentTab - 1];
|
|
1234
|
+
// const temp = container;
|
|
1235
|
+
// const langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(newActiveTab);
|
|
1236
|
+
//
|
|
1237
|
+
// temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
|
|
1238
|
+
// temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
|
|
1239
|
+
// temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
|
|
1240
|
+
this.props.templatesActions.resetUploadData();
|
|
1241
|
+
this.setState({formData, languageDataSet: false, addLanguageType: ''});
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
getParameterByName = (name, url) => {
|
|
1245
|
+
const match = RegExp(`[?&]${name}=([^&]*)`).exec(url);
|
|
1246
|
+
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
getFormData = (e, value) => {
|
|
1250
|
+
this.setState({getFormDataValue: value, gettingFormData: true}, () => {
|
|
1251
|
+
this.saveValidationData();
|
|
1252
|
+
});
|
|
1253
|
+
//
|
|
1254
|
+
// const response = {
|
|
1255
|
+
// action: "getFormData",
|
|
1256
|
+
// postAction: value || 'next',
|
|
1257
|
+
// value: this.transformFormData(this.state.formData),
|
|
1258
|
+
// validity: this.state.isFormValid,
|
|
1259
|
+
// };
|
|
1260
|
+
//
|
|
1261
|
+
// this.setState({checkValidation: true});
|
|
1262
|
+
// if (e) {
|
|
1263
|
+
// e.source.postMessage(JSON.stringify(response), e.origin);
|
|
1264
|
+
// }
|
|
1265
|
+
// return response;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
setFormValidity = (isFormValid) => {
|
|
1269
|
+
this.setState({isFormValid});
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
setEditData(editData) {
|
|
1273
|
+
|
|
1274
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
1275
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1276
|
+
|
|
1277
|
+
const tabIndex = this.state.currentTab + 1;
|
|
1278
|
+
const schema = (this.props.location.query.type === 'embedded') ? this.removeStandAlone(this.state.schema) : _.cloneDeep(this.state.schema);
|
|
1279
|
+
const containers = _.cloneDeep(schema.containers.slice());
|
|
1280
|
+
let tabKey = "";
|
|
1281
|
+
let currentTab = _.cloneDeep(this.state.currentTab);
|
|
1282
|
+
const isLanguageSupport = this.props.location.query.isLanguageSupport;
|
|
1283
|
+
const type = this.props.location.query.type;
|
|
1284
|
+
|
|
1285
|
+
formData['template-name'] = editData.name;
|
|
1286
|
+
formData.base = editData.versions.base;
|
|
1287
|
+
|
|
1288
|
+
_.forEach(editData.versions.history, (data1, index) => {
|
|
1289
|
+
const data = _.cloneDeep(data1);
|
|
1290
|
+
if (data !== null) {
|
|
1291
|
+
if (index > 0 && (isLanguageSupport || this.props.location.query.type !== 'embedded')) {
|
|
1292
|
+
const firstPane = _.cloneDeep(containers[0].panes[0]);
|
|
1293
|
+
// schema.containers[this.state.currentTab - 1].isActive = false;
|
|
1294
|
+
const sections = [];
|
|
1295
|
+
// containers[0].isActive = true;
|
|
1296
|
+
_.forEach(firstPane.sections, (section) => {
|
|
1297
|
+
let sect = _.cloneDeep(section);
|
|
1298
|
+
console.log('trying to clone in add version', JSON.stringify(sect), index);
|
|
1299
|
+
if (sect.type === 'col-label') {
|
|
1300
|
+
sect = this.cloneColLabel(sect, index, true);
|
|
1301
|
+
} else if (sect.type === 'multicols') {
|
|
1302
|
+
sect = this.cloneMultiCol(sect, index, true);
|
|
1303
|
+
} else if (sect.type === 'parent') {
|
|
1304
|
+
sect = this.cloneParent(sect, index, true);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
sections.push(sect);
|
|
1308
|
+
return true;
|
|
1309
|
+
});
|
|
1310
|
+
firstPane.sections = sections;
|
|
1311
|
+
containers[0].panes = [];
|
|
1312
|
+
containers[0].panes.push(firstPane);
|
|
1313
|
+
schema.containers.push(containers[0]);
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
// _.forEach(sections[0].inputFields[0].cols, (inputField) => {
|
|
1317
|
+
// if (this.map[inputField.id] === undefined) {
|
|
1318
|
+
// if (inputField.id.indexOf('template-content') > -1) {
|
|
1319
|
+
// this.map[inputField.id] = this.map['template-content'];
|
|
1320
|
+
// } else if (inputField.id.indexOf('edmeditor2') > -1) {
|
|
1321
|
+
// this.map[inputField.id] = this.map.edmeditor2;
|
|
1322
|
+
// }
|
|
1323
|
+
// }
|
|
1324
|
+
// });
|
|
1325
|
+
|
|
1326
|
+
const newVersionOption = formData['template-version-options'].pop();
|
|
1327
|
+
formData['template-version-options'].push({
|
|
1328
|
+
key: `version ${index + 1}`,
|
|
1329
|
+
label: `${this.props.intl.formatMessage(messages.versionMessage)} ${index + 1}`,
|
|
1330
|
+
value: `version ${index + 1}`,
|
|
1331
|
+
});
|
|
1332
|
+
formData['template-version-options'].push(newVersionOption);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// data.activeTab = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
1336
|
+
_.forEach((data.selectedLanguages), (language) => {
|
|
1337
|
+
if (data.tabKey === data[language].tabKey) {
|
|
1338
|
+
data.activeTab = language;
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
if (data.constructor === Object) {
|
|
1342
|
+
|
|
1343
|
+
if (data.tabKey === editData.versions.base.tabKey) {
|
|
1344
|
+
tabKey = data.tabKey;
|
|
1345
|
+
schema.containers[index].isActive = true;
|
|
1346
|
+
formData['template-version'] = formData['template-version-options'][index].key;
|
|
1347
|
+
currentTab = index + 1;
|
|
1348
|
+
|
|
1349
|
+
} else {
|
|
1350
|
+
schema.containers[index].isActive = false;
|
|
1351
|
+
|
|
1352
|
+
}
|
|
1353
|
+
// const isLanguageSupport = this.props.location.query.isLanguageSupport;
|
|
1354
|
+
|
|
1355
|
+
_.forEach(data.selectedLanguages, (lang, langIndex) => {
|
|
1356
|
+
|
|
1357
|
+
if ((type !== 'embedded' || (type === 'embedded' && isLanguageSupport === 'true')) && lang !== this.props.Global.currentOrgDetails.basic_details.base_language) {
|
|
1358
|
+
const tabContent = _.cloneDeep(containers[0].tabContent.sections[0]);
|
|
1359
|
+
const tabContentSection = tabContent.inputFields[0].cols[0];
|
|
1360
|
+
const panes = containers[0].panes.slice();
|
|
1361
|
+
const firstPane = _.cloneDeep(panes[0]);
|
|
1362
|
+
const sections = [];
|
|
1363
|
+
_.forEach(firstPane.sections, (section) => {
|
|
1364
|
+
let sect = _.cloneDeep(section);
|
|
1365
|
+
console.log('trying to clone in add version', JSON.stringify(sect), tabIndex);
|
|
1366
|
+
if (sect.type === 'col-label') {
|
|
1367
|
+
sect = this.cloneColLabel(sect, (langIndex + 1));
|
|
1368
|
+
} else if (sect.type === 'multicols') {
|
|
1369
|
+
sect = this.cloneMultiCol(sect, (langIndex + 1));
|
|
1370
|
+
} else if (sect.type === 'parent') {
|
|
1371
|
+
sect = this.cloneParent(sect, (langIndex + 1));
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
sections.push(sect);
|
|
1375
|
+
return true;
|
|
1376
|
+
});
|
|
1377
|
+
//
|
|
1378
|
+
|
|
1379
|
+
this.map[`template-content${data.selectedLanguages.indexOf(lang) + 1}`] = this.map['template-content'];
|
|
1380
|
+
tabContentSection.id = `${tabContentSection.id}${index + 1}`;
|
|
1381
|
+
tabContentSection.value = `${data[lang].language}`;
|
|
1382
|
+
|
|
1383
|
+
firstPane.sections = sections;
|
|
1384
|
+
firstPane.sectionsHeaders = [tabContent];
|
|
1385
|
+
console.log('firstPane final version', JSON.stringify(firstPane));
|
|
1386
|
+
// panes.push(firstPane);
|
|
1387
|
+
console.log('initial panes', JSON.stringify(this.state.schema.containers));
|
|
1388
|
+
schema.containers[index].panes.push(firstPane);
|
|
1389
|
+
} else if (lang !== this.props.Global.currentOrgDetails.basic_details.base_language) {
|
|
1390
|
+
delete data[lang];
|
|
1391
|
+
data.selectedLanguages.splice(langIndex, 1);
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
if (data.base) {
|
|
1396
|
+
formData.base = data;
|
|
1397
|
+
}
|
|
1398
|
+
formData[index] = data;
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
|
|
1402
|
+
_.forEach(formData.base.selectedLanguages, (language) => {
|
|
1403
|
+
if (formData.base.tabKey === formData.base[language].tabKey) {
|
|
1404
|
+
formData.base.activeTab = language;
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
this.setState({ formData, schema, tabKey, currentTab, tabCount: editData.versions.history.length }, () => {
|
|
1410
|
+
|
|
1411
|
+
_.forEach((editData.versions.base.selectedLanguages), (language) => {
|
|
1412
|
+
// if (formData[this.state.currentTab - 1].tabKey === formData[this.state.currentTab - 1][language].tabKey) {
|
|
1413
|
+
// formData[this.state.currentTab - 1].activeTab = language;
|
|
1414
|
+
// }
|
|
1415
|
+
// if (formData.base.tabKey === formData.base[language].tabKey) {
|
|
1416
|
+
// formData.base.activeTab = language;
|
|
1417
|
+
// }
|
|
1418
|
+
if (language && editData.versions.base[language].is_drag_drop) {
|
|
1419
|
+
|
|
1420
|
+
this.props.actions.getCmsSetting('edm', editData.versions.base[language].drag_drop_id, 'open', language, isEdmSupport);
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
|
|
1424
|
+
// this.resetCkEditorInstance(this.state.currentTab - 1, formData);
|
|
1425
|
+
// this.setState({formData});
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
getMappedEvent = (id, event) => {
|
|
1430
|
+
|
|
1431
|
+
const mapIdObject = this.map[id];
|
|
1432
|
+
return mapIdObject && mapIdObject[event] ? mapIdObject[event] : () => {};
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
getCurrentWindow = (e) => {
|
|
1436
|
+
|
|
1437
|
+
const response = {
|
|
1438
|
+
action: e.action,
|
|
1439
|
+
value: 'edit',
|
|
1440
|
+
direction: e.value,
|
|
1441
|
+
};
|
|
1442
|
+
parent.postMessage(JSON.stringify(response), '*');
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
getEditorInstanse = (instance, id) => {
|
|
1446
|
+
|
|
1447
|
+
window.CKEDITOR.on( 'instanceReady', ( event ) => {
|
|
1448
|
+
this.setState({editorInstanse: event.editor});
|
|
1449
|
+
event.editor.on( 'focus', () => {
|
|
1450
|
+
|
|
1451
|
+
this.setState({editorInstanse: event.editor});
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1454
|
+
//this.setState({editorInstanse: instance});
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
setModalContent = (type, data) => {
|
|
1458
|
+
let modalContent = {};
|
|
1459
|
+
if (type === 'delete-version') {
|
|
1460
|
+
modalContent = {
|
|
1461
|
+
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
1462
|
+
body: this.props.intl.formatMessage(messages.deleteVersionConfirm),
|
|
1463
|
+
type: 'confirm',
|
|
1464
|
+
id: 'email-version-delete-modal',
|
|
1465
|
+
};
|
|
1466
|
+
} else if (type === 'delete-language') {
|
|
1467
|
+
modalContent = {
|
|
1468
|
+
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
1469
|
+
body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation),
|
|
1470
|
+
type: 'confirm',
|
|
1471
|
+
id: 'email-language-delete-modal',
|
|
1472
|
+
};
|
|
1473
|
+
} else if (type === 'add-language') {
|
|
1474
|
+
const jsx = (
|
|
1475
|
+
<div>
|
|
1476
|
+
<div><CapButton type="secondary" style={{width: "100%", marginBottom: "8px"}} onClick={this.uploadFile}><FormattedMessage {...messages.uploadFile} /></CapButton>
|
|
1477
|
+
<input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
|
|
1478
|
+
</div>
|
|
1479
|
+
<div><CapButton type="secondary" style={{width: "100%", marginBottom: "8px"}} onClick={this.useEditor}><FormattedMessage {...messages.useEditor} /></CapButton></div>
|
|
1480
|
+
<div><CapButton type="secondary" style={{width: "100%", marginBottom: "8px"}} onClick={this.copyPrimaryLanguage}><FormattedMessage {...messages.copyPrimaryLanguage} /></CapButton></div>
|
|
1481
|
+
</div>);
|
|
1482
|
+
modalContent = {
|
|
1483
|
+
title: "New Language",
|
|
1484
|
+
type: "action",
|
|
1485
|
+
jsx,
|
|
1486
|
+
id: 'email-add-language-options',
|
|
1487
|
+
};
|
|
1488
|
+
this.setState({settingLanguage: data});
|
|
1489
|
+
}
|
|
1490
|
+
this.setState({ modalContent, showModal: true});
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
shouldStartValidation = () => {
|
|
1494
|
+
this.setState((prevState) => ({ cmsDataCount: prevState.cmsDataCount + 1}), () => {
|
|
1495
|
+
|
|
1496
|
+
if (this.state.targetSaveCount === this.state.cmsDataCount) {
|
|
1497
|
+
|
|
1498
|
+
this.setState({startValidation: true});
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
stopValidation = () => {
|
|
1504
|
+
this.setState({startValidation: false});
|
|
1505
|
+
}
|
|
1506
|
+
saveValidationData = () => {
|
|
1507
|
+
let saveCount = 0;
|
|
1508
|
+
this.setState({saveEdmDataMode: 'validation', saveCount: 0, cmsDataCount: 0}, () => {
|
|
1509
|
+
_.forEach(this.state.formData, (newdata, index) => {
|
|
1510
|
+
if (!isNaN(index)) {
|
|
1511
|
+
_.forEach(newdata.selectedLanguages, (language) => {
|
|
1512
|
+
if (newdata[language].is_drag_drop && ((parseInt(index, 10) + 1) === this.state.currentTab)) {
|
|
1513
|
+
|
|
1514
|
+
saveCount += 1;
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
if (saveCount === 0) {
|
|
1520
|
+
this.setState({startValidation: true});
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
this.setState({targetSaveCount: saveCount, mode: "save", saveCount: 0, cmsDataCount: 0}, () => {
|
|
1524
|
+
const data = this.state.formData[this.state.currentTab - 1];
|
|
1525
|
+
_.forEach(data.selectedLanguages, (language, langIndex) => {
|
|
1526
|
+
if (data[language].is_drag_drop) {
|
|
1527
|
+
console.log('saving edm template', document.getElementById("edmeditor"), `edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
|
|
1528
|
+
const elementToSelect = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
|
|
1529
|
+
if (elementToSelect) {
|
|
1530
|
+
const win = elementToSelect.contentWindow;
|
|
1531
|
+
win.postMessage("saveProject", '*');
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
});
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
resetStateValue = () => {
|
|
1540
|
+
this.setState({
|
|
1541
|
+
formData: {},
|
|
1542
|
+
tabCount: 1,
|
|
1543
|
+
currentTab: 1,
|
|
1544
|
+
isEdit: false,
|
|
1545
|
+
schema: {},
|
|
1546
|
+
loading: false,
|
|
1547
|
+
isFormValid: true,
|
|
1548
|
+
injectedTags: {},
|
|
1549
|
+
checkValidation: false,
|
|
1550
|
+
tabKey: '',
|
|
1551
|
+
showEmailPreview: false,
|
|
1552
|
+
device: "desktop",
|
|
1553
|
+
editorInstanse: undefined,
|
|
1554
|
+
showImageSelectionBox: false,
|
|
1555
|
+
isDragDrop: false,
|
|
1556
|
+
showConfirmationModal: false,
|
|
1557
|
+
modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.deleteVersionConfirm), type: 'confirm', id: 'email-language-delete-modal'},
|
|
1558
|
+
showModal: false,
|
|
1559
|
+
page: 1,
|
|
1560
|
+
perPageLimit: 25,
|
|
1561
|
+
totalCount: 0,
|
|
1562
|
+
searchText: '',
|
|
1563
|
+
saveCount: 0,
|
|
1564
|
+
targetSaveCount: 0,
|
|
1565
|
+
saveObj: {},
|
|
1566
|
+
showEdmEmailTemplates: false,
|
|
1567
|
+
editDataSet: false,
|
|
1568
|
+
}, () => {
|
|
1569
|
+
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
resetCkEditorInstance = (data, formData, onInsert, value, isImage) => {
|
|
1574
|
+
const currentLang = formData[`${data - 1}`].selectedLanguages.indexOf(formData[`${data - 1}`].activeTab);
|
|
1575
|
+
const langIndex = formData[`${data - 1}`].selectedLanguages.indexOf(formData[`${data - 1}`].activeTab);
|
|
1576
|
+
let instance1 = window.CKEDITOR.instances[`editor${currentLang + 1}`];
|
|
1577
|
+
const instanceCount = 0;
|
|
1578
|
+
const instanceArray = [];
|
|
1579
|
+
_.forEach(window.CKEDITOR.instances, (instance, index) => {
|
|
1580
|
+
|
|
1581
|
+
const name = instance.name;
|
|
1582
|
+
if (instance.status === "destroyed") {
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
let instanceIdx = 0;
|
|
1586
|
+
if (name.indexOf('template-content') > -1 && name !== 'template-content') {
|
|
1587
|
+
instanceIdx = parseInt(name.replace('template-content', ''), 10) - 1;
|
|
1588
|
+
const obj = {
|
|
1589
|
+
idx: instanceIdx,
|
|
1590
|
+
instance,
|
|
1591
|
+
};
|
|
1592
|
+
instanceArray.push(obj);
|
|
1593
|
+
} else {
|
|
1594
|
+
const obj = {
|
|
1595
|
+
idx: 0,
|
|
1596
|
+
instance,
|
|
1597
|
+
};
|
|
1598
|
+
instanceArray.push(obj);
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
instanceArray.sort( (a, b) => {
|
|
1603
|
+
const idxA = a.idx;
|
|
1604
|
+
const idxB = b.idx;
|
|
1605
|
+
if (idxA < idxB) {
|
|
1606
|
+
return -1;
|
|
1607
|
+
} else if (idxA > idxB) {
|
|
1608
|
+
return 1;
|
|
1609
|
+
}
|
|
1610
|
+
return 0;
|
|
1611
|
+
});
|
|
1612
|
+
|
|
1613
|
+
//instanceCount += 1;
|
|
1614
|
+
// if (instanceIdx === langIndex) {
|
|
1615
|
+
const instance = instanceArray[langIndex].instance;
|
|
1616
|
+
|
|
1617
|
+
instance1 = instance;
|
|
1618
|
+
this.setState({editorInstanse: instance1}, () => {
|
|
1619
|
+
if (this.state.editorInstanse) {
|
|
1620
|
+
if (onInsert && !isImage) {
|
|
1621
|
+
this.state.editorInstanse.insertHtml(`{{${value}}}`);
|
|
1622
|
+
} else if (onInsert) {
|
|
1623
|
+
this.state.editorInstanse.insertHtml(`<img src='${value.metaInfo.secure_file_path}' alt='Image'>`);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
uploadFile = () => {
|
|
1630
|
+
|
|
1631
|
+
document.getElementById('filename').click();
|
|
1632
|
+
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
useEditor = () => {
|
|
1636
|
+
|
|
1637
|
+
//this.toggleEdmEmailTemplateSelection();
|
|
1638
|
+
this.setState({addLanguageType: "useEditor"}, () => {
|
|
1639
|
+
this.setState({showModal: false}, () => {
|
|
1640
|
+
this.toggleEdmEmailTemplateSelection();
|
|
1641
|
+
});
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
copyPrimaryLanguage = () => {
|
|
1646
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
1647
|
+
|
|
1648
|
+
this.setState({addLanguageType: "copyPrimaryLanguage"}, () => {
|
|
1649
|
+
this.setState({showModal: false});
|
|
1650
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1651
|
+
const currentTab = this.state.currentTab - 1;
|
|
1652
|
+
const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language ? this.props.Global.currentOrgDetails.basic_details.base_language : 'en';
|
|
1653
|
+
if (formData[currentTab][baseLanguage].is_drag_drop) {
|
|
1654
|
+
this.props.actions.getCmsSetting('edm', formData[currentTab][baseLanguage].drag_drop_id, 'duplicate', baseLanguage, isEdmSupport);
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
handleFileUpload = (e, {files}) => {
|
|
1660
|
+
if (files.length === 0) {
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
const fileExtension = files[0].name.split('.').pop();
|
|
1664
|
+
const supportedZipFormats = ['zip'];
|
|
1665
|
+
|
|
1666
|
+
if (supportedZipFormats.indexOf(fileExtension.toLowerCase()) !== -1) {
|
|
1667
|
+
this.setState({ addLanguageType: "upload"}, () => {
|
|
1668
|
+
|
|
1669
|
+
this.props.templatesActions.handleZipUpload(files[0]);
|
|
1670
|
+
document.getElementById("filename").value = "";
|
|
1671
|
+
this.setState({showModal: false});
|
|
1672
|
+
});
|
|
1673
|
+
} else if (fileExtension === 'html' || fileExtension === 'htm') {
|
|
1674
|
+
|
|
1675
|
+
const reader = new FileReader();
|
|
1676
|
+
reader.onload = () => {
|
|
1677
|
+
this.setState({ addLanguageType: "upload"}, () => {
|
|
1678
|
+
const text = reader.result;
|
|
1679
|
+
this.props.templatesActions.handleHtmlUpload(text);
|
|
1680
|
+
document.getElementById("filename").value = "";
|
|
1681
|
+
this.setState({showModal: false});
|
|
1682
|
+
});
|
|
1683
|
+
};
|
|
1684
|
+
reader.readAsText(files[0]);
|
|
1685
|
+
} else {
|
|
1686
|
+
alert(this.props.intl.formatMessage(messages.invalidFileMessage));
|
|
1687
|
+
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
uploadImages(e, {files}) {
|
|
1692
|
+
e.preventDefault();
|
|
1693
|
+
const _URL = window.URL || window.webkitURL;
|
|
1694
|
+
const file = files[0];
|
|
1695
|
+
const fileSize = file && (file.size / ( 1024 * 1024 ));
|
|
1696
|
+
if (fileSize > 5) {
|
|
1697
|
+
const message = getMessageObject('error', this.props.intl.formatMessage(messages.uploadSizeError), true);
|
|
1698
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
1699
|
+
document.getElementById("fileName").value = "";
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
const img = new Image();
|
|
1703
|
+
const that = this;
|
|
1704
|
+
img.src = _URL.createObjectURL(file);
|
|
1705
|
+
img.onload = function () {
|
|
1706
|
+
const fileParams = {
|
|
1707
|
+
width: this.width,
|
|
1708
|
+
height: this.height,
|
|
1709
|
+
};
|
|
1710
|
+
that.props.actions.uploadAsset(file, 'image', fileParams);
|
|
1711
|
+
that.handleImagePreviewClose();
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
fetchAllAssets = ({params, getNextPage, resetPage}) => {
|
|
1716
|
+
let queryParams = params;
|
|
1717
|
+
let page = this.state.page;
|
|
1718
|
+
if (!this.props.Email.fetchingAllAssets && (resetPage || (page === 1 && this.state.totalCount === 0) || page <= (this.state.totalCount / this.state.perPageLimit))) {
|
|
1719
|
+
if (getNextPage) {
|
|
1720
|
+
page += 1;
|
|
1721
|
+
}
|
|
1722
|
+
let totalCount = this.state.totalCount;
|
|
1723
|
+
if (resetPage) {
|
|
1724
|
+
page = 1;
|
|
1725
|
+
totalCount = 0;
|
|
1726
|
+
}
|
|
1727
|
+
if ((!params || _.isEmpty(params))) {
|
|
1728
|
+
queryParams = {
|
|
1729
|
+
sortBy: this.state.sortBy,
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
if (this.state.searchText !== "") {
|
|
1733
|
+
queryParams = {...queryParams, name: this.state.searchText};
|
|
1734
|
+
}
|
|
1735
|
+
this.setState({page, totalCount}, () => {
|
|
1736
|
+
queryParams.page = page;
|
|
1737
|
+
queryParams.perPage = this.state.perPageLimit;
|
|
1738
|
+
this.props.actions.getAllAssets('image', queryParams);
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
searchAsset = (value) => {
|
|
1744
|
+
this.setState({searchText: value}, () => {
|
|
1745
|
+
this.delay(() => {
|
|
1746
|
+
const params = {
|
|
1747
|
+
name: this.state.searchText,
|
|
1748
|
+
};
|
|
1749
|
+
if (this.state.sortBy) {
|
|
1750
|
+
params.sortBy = this.state.sortBy;
|
|
1751
|
+
}
|
|
1752
|
+
this.fetchAllAssets({params, resetPage: true});
|
|
1753
|
+
}, 1000);
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
delay = (callback, ms) => {
|
|
1758
|
+
clearTimeout(this.delayTimer);
|
|
1759
|
+
this.delayTimer = setTimeout(callback, ms);
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
deleteLanguage = (passedData, val) => {
|
|
1763
|
+
const formData = _.cloneDeep(passedData);
|
|
1764
|
+
|
|
1765
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
1766
|
+
schema.containers[this.state.currentTab - 1].panes.splice(val, 1);
|
|
1767
|
+
schema.containers[this.state.currentTab - 1].tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
|
|
1768
|
+
//this.resetCkEditorInstance(this.state.currentTab, formData);
|
|
1769
|
+
this.setState({schema, formData, showModal: false});
|
|
1770
|
+
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
initFormData(props, fromMount) {
|
|
1774
|
+
|
|
1775
|
+
let newFormData = {};
|
|
1776
|
+
if (props.Global.currentOrgDetails && props.Global.currentOrgDetails.basic_details) {
|
|
1777
|
+
|
|
1778
|
+
newFormData = {
|
|
1779
|
+
"0": {},
|
|
1780
|
+
"template-name": "",
|
|
1781
|
+
"base": {},
|
|
1782
|
+
};
|
|
1783
|
+
const baseData = {};
|
|
1784
|
+
const baseLanguage = props.Global.currentOrgDetails.basic_details.base_language || 'en';
|
|
1785
|
+
this.supportedLanguages = props.Global.currentOrgDetails.basic_details.supported_languages;
|
|
1786
|
+
const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})] || {iso_code: baseLanguage || 'en', lang_id: -1, language: baseLanguage || "English"};
|
|
1787
|
+
baseData.activeTab = baseLanguage;
|
|
1788
|
+
baseData[languageObject.iso_code] = {};
|
|
1789
|
+
baseData[languageObject.iso_code].is_drag_drop = false;
|
|
1790
|
+
baseData[languageObject.iso_code].lang_id = languageObject.lang_id;
|
|
1791
|
+
baseData[languageObject.iso_code].iso_code = languageObject.iso_code;
|
|
1792
|
+
baseData[languageObject.iso_code].language = languageObject.language;
|
|
1793
|
+
baseData[languageObject.iso_code]["template-content"] = (props.Templates.selectedEmailLayout ? props.Templates.selectedEmailLayout : '');
|
|
1794
|
+
// if (this.state.isDragDrop) {
|
|
1795
|
+
baseData[languageObject.iso_code].drag_drop_id = "";//props.Templates.edmTemplate.versions.base.drag_drop_id;
|
|
1796
|
+
//}
|
|
1797
|
+
baseData.selectedLanguages = [baseLanguage];
|
|
1798
|
+
newFormData.base = baseData;
|
|
1799
|
+
newFormData[0] = baseData;
|
|
1800
|
+
newFormData[0].base = true;
|
|
1801
|
+
}
|
|
1802
|
+
this.props.templatesActions.resetUploadData();
|
|
1803
|
+
return newFormData;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
transformFormData = (formData) => {
|
|
1807
|
+
|
|
1808
|
+
const newFormData = {
|
|
1809
|
+
base: {},
|
|
1810
|
+
secondary_templates: [],
|
|
1811
|
+
};
|
|
1812
|
+
// const baseData = {};
|
|
1813
|
+
_.forEach(formData.base, (content, index) => {
|
|
1814
|
+
if (content && content.constructor === Object) {
|
|
1815
|
+
const tmpData = {};
|
|
1816
|
+
if (_.isEmpty(content)) {
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
tmpData.html_content = content['template-content'];
|
|
1820
|
+
tmpData.is_drag_drop = content.is_drag_drop;
|
|
1821
|
+
tmpData.lang_id = content.lang_id;
|
|
1822
|
+
tmpData.iso_code = content.iso_code;
|
|
1823
|
+
tmpData.language = content.language;
|
|
1824
|
+
if (content.is_drag_drop) {
|
|
1825
|
+
tmpData.drag_drop_id = (content.drag_drop_id ? content.drag_drop_id : "");
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
if (index === this.props.Global.currentOrgDetails.basic_details.base_language) {
|
|
1829
|
+
newFormData.base = _.cloneDeep(tmpData);
|
|
1830
|
+
}
|
|
1831
|
+
newFormData.secondary_templates.push({template_data: tmpData});
|
|
1832
|
+
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
if (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs" || this.props.location.query.module === "coupon_expiry" || this.props.location.query.module === "timeline" || this.props.location.query.module === "library")) {
|
|
1836
|
+
newFormData.base.subject = formData['template-subject'];
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
return newFormData;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
handleFrameTasks = (e) => {
|
|
1844
|
+
|
|
1845
|
+
const type = this.isValidJson(e.data) ? JSON.parse(e.data) : e.data;
|
|
1846
|
+
|
|
1847
|
+
if (typeof type === 'object') {
|
|
1848
|
+
|
|
1849
|
+
const action = type.action;
|
|
1850
|
+
switch (action) {
|
|
1851
|
+
case "startTemplateCreation":
|
|
1852
|
+
this.startTemplateCreation(type.value);
|
|
1853
|
+
break;
|
|
1854
|
+
case "edit":
|
|
1855
|
+
this.edmEvent = e;
|
|
1856
|
+
if (type.elementJson.type === "IMAGE") {
|
|
1857
|
+
|
|
1858
|
+
this.onImageSelect();
|
|
1859
|
+
}
|
|
1860
|
+
break;
|
|
1861
|
+
case "editBackground":
|
|
1862
|
+
this.edmEvent = e;
|
|
1863
|
+
if (type.elementJson.type === "BOX" || type.elementJson.type === "BUTTON" || type.elementJson.type === "GENERAL") {
|
|
1864
|
+
|
|
1865
|
+
this.onImageSelect();
|
|
1866
|
+
}
|
|
1867
|
+
break;
|
|
1868
|
+
case "create":
|
|
1869
|
+
this.edmEvent = e;
|
|
1870
|
+
break;
|
|
1871
|
+
case "select":
|
|
1872
|
+
//this.edmEvent = e;
|
|
1873
|
+
break;
|
|
1874
|
+
case "startLoading":
|
|
1875
|
+
this.startLoading(type.edit);
|
|
1876
|
+
break;
|
|
1877
|
+
case "getCurrentWindow":
|
|
1878
|
+
this.getCurrentWindow(type);
|
|
1879
|
+
break;
|
|
1880
|
+
case "getFormData":
|
|
1881
|
+
this.getFormData(e, type.value);
|
|
1882
|
+
break;
|
|
1883
|
+
default:
|
|
1884
|
+
break;
|
|
1885
|
+
}
|
|
1886
|
+
} else {
|
|
1887
|
+
|
|
1888
|
+
switch (type) {
|
|
1889
|
+
case "getFormData":
|
|
1890
|
+
this.getFormData(e);
|
|
1891
|
+
break;
|
|
1892
|
+
case "startTemplateCreation":
|
|
1893
|
+
|
|
1894
|
+
//this.getFormData(e);
|
|
1895
|
+
break;
|
|
1896
|
+
case "moveToTemplates":
|
|
1897
|
+
|
|
1898
|
+
this.moveToTemplates();
|
|
1899
|
+
break;
|
|
1900
|
+
case "validateContent":
|
|
1901
|
+
|
|
1902
|
+
this.validateContent(e);
|
|
1903
|
+
break;
|
|
1904
|
+
case "Save result: success":
|
|
1905
|
+
this.handleEdmSave();
|
|
1906
|
+
break;
|
|
1907
|
+
case "JsonChanged":
|
|
1908
|
+
this.edmEvent = e;
|
|
1909
|
+
break;
|
|
1910
|
+
default:
|
|
1911
|
+
break;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
isValidJson = (str) => {
|
|
1917
|
+
try {
|
|
1918
|
+
JSON.parse(str);
|
|
1919
|
+
} catch (e) {
|
|
1920
|
+
return false;
|
|
1921
|
+
}
|
|
1922
|
+
return true;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
handleEdmSave = () => {
|
|
1926
|
+
|
|
1927
|
+
if (this.state.mode === "save") {
|
|
1928
|
+
this.setState((prevState) => ({ saveCount: prevState.saveCount + 1}), () => {
|
|
1929
|
+
|
|
1930
|
+
if (this.state.targetSaveCount === this.state.saveCount) {
|
|
1931
|
+
if (this.state.saveEdmDataMode === 'validation') {
|
|
1932
|
+
this.getValidationData();
|
|
1933
|
+
} else if (this.state.saveEdmDataMode === 'save') {
|
|
1934
|
+
this.props.actions.createTemplate(this.state.saveObj);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
} else if (this.state.mode === 'preview' || this.state.mode === 'switchEditor') {
|
|
1939
|
+
this.props.actions.getCmsData('edm', this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id);
|
|
1940
|
+
if (this.state.mode === 'switchEditor') {
|
|
1941
|
+
let schema = _.cloneDeep(this.state.schema);
|
|
1942
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1943
|
+
_.forEach(schema.containers, (container, index) => {
|
|
1944
|
+
if (parseInt(index, 10) === (this.state.currentTab - 1)) {
|
|
1945
|
+
const temp = container;
|
|
1946
|
+
const langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(formData[`${this.state.currentTab - 1}`].activeTab);
|
|
1947
|
+
|
|
1948
|
+
temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
|
|
1949
|
+
temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
|
|
1950
|
+
temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
schema = this.showInsertImageButton(schema);
|
|
1954
|
+
|
|
1955
|
+
this.setState({ schema, showConfirmationModal: false, isSchemaChanged: true }, () => {
|
|
1956
|
+
this.injectEvents(schema);
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
handleImagePreviewClose = () => {
|
|
1963
|
+
this.setState({ showImageSelectionBox: false });
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
handleContentChange = (data) => {
|
|
1967
|
+
|
|
1968
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
1969
|
+
formData[this.state.currentTab][formData[this.state.currentTab - 1].activeTab]["template-content"] = data;
|
|
1970
|
+
this.setState({formData});
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
handleOnHoverItem = (isHovering, id) => {
|
|
1974
|
+
|
|
1975
|
+
if (!isHovering) {
|
|
1976
|
+
// const data = _.find(this.props.Email.assetList, {_id: id});
|
|
1977
|
+
//
|
|
1978
|
+
// if (data) {
|
|
1979
|
+
// if (this.state.isDragDrop) {
|
|
1980
|
+
//
|
|
1981
|
+
// } else {
|
|
1982
|
+
// this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.public_url}' alt='Image'>`);
|
|
1983
|
+
// }
|
|
1984
|
+
// }
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
hideEdmOptions = (isDragDrop) => {
|
|
1989
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
1990
|
+
_.forEach(schema.containers, (container) => {
|
|
1991
|
+
if (container.isActive) {
|
|
1992
|
+
_.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
|
|
1993
|
+
if (containerInputFieldCol.id === 'insert-image') {
|
|
1994
|
+
const newContainerInputFieldCol = containerInputFieldCol;
|
|
1995
|
+
newContainerInputFieldCol.style.display = isDragDrop ? "none" : '';
|
|
1996
|
+
}
|
|
1997
|
+
if (containerInputFieldCol.id === 'tab-options-popover') {
|
|
1998
|
+
_.forEach(containerInputFieldCol.content.sections[0].inputFields, (tabPopoverSection) => {
|
|
1999
|
+
if (tabPopoverSection.cols[0].id === 'switch-editor-label') {
|
|
2000
|
+
const newTabPopoverSection = tabPopoverSection;
|
|
2001
|
+
newTabPopoverSection.cols[0].style.display = isDragDrop ? "" : 'none';
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
console.log('HandleEdmOption ', JSON.stringify(schema));
|
|
2009
|
+
this.setState({schema, isSchemaChanged: true});
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
showInsertImageButton = (passedSchema) => {
|
|
2013
|
+
const schema = passedSchema || _.cloneDeep(this.state.schema);
|
|
2014
|
+
_.forEach(schema.containers, (container) => {
|
|
2015
|
+
if (container.isActive) {
|
|
2016
|
+
_.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
|
|
2017
|
+
if (containerInputFieldCol.id === 'insert-image') {
|
|
2018
|
+
const newContainerInputFieldCol = containerInputFieldCol;
|
|
2019
|
+
newContainerInputFieldCol.style.display = "";
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
console.log('HandleHideMarkAsFinal ', JSON.stringify(schema));
|
|
2025
|
+
this.setState({schema, isSchemaChanged: true});
|
|
2026
|
+
return schema;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
showSubject = () => {
|
|
2030
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
2031
|
+
if (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs" || this.props.location.query.module === "timeline" || this.props.location.query.module === "coupon_expiry" ||
|
|
2032
|
+
this.props.location.query.module === "library")) {
|
|
2033
|
+
schema.standalone.sections[0].inputFields[0].style.display = "";
|
|
2034
|
+
schema.standalone.sections[0].inputFields[0].labelStyle.display = "";
|
|
2035
|
+
}
|
|
2036
|
+
this.setState({schema});
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
handleOnItemClick = (isSelected, id) => {
|
|
2040
|
+
|
|
2041
|
+
const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
|
|
2042
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
2043
|
+
if (isSelected) {
|
|
2044
|
+
const data = _.find(this.props.Email.assetList, {_id: id});
|
|
2045
|
+
|
|
2046
|
+
if (data) {
|
|
2047
|
+
if (isDragDrop && isEdmSupport) {
|
|
2048
|
+
console.log('Handle EDM ', isSelected, id, this.edmEvent, JSON.parse(this.edmEvent.data)._dynId, data.metaInfo.secure_file_path);
|
|
2049
|
+
const evtData = JSON.parse(this.edmEvent.data);
|
|
2050
|
+
if (evtData.action === 'editBackground') {
|
|
2051
|
+
this.edmEvent.source.postMessage(JSON.stringify({
|
|
2052
|
+
_dynId: JSON.parse(this.edmEvent.data)._dynId,
|
|
2053
|
+
action: "setProps",
|
|
2054
|
+
props: {
|
|
2055
|
+
background: {
|
|
2056
|
+
image: {
|
|
2057
|
+
src: data.metaInfo.secure_file_path,
|
|
2058
|
+
},
|
|
2059
|
+
},
|
|
2060
|
+
},
|
|
2061
|
+
}), "*");
|
|
2062
|
+
} else if (evtData.action === 'edit') {
|
|
2063
|
+
this.edmEvent.source.postMessage(JSON.stringify({
|
|
2064
|
+
_dynId: JSON.parse(this.edmEvent.data)._dynId,
|
|
2065
|
+
action: "setProps",
|
|
2066
|
+
props: {
|
|
2067
|
+
src: data.metaInfo.secure_file_path,
|
|
2068
|
+
},
|
|
2069
|
+
}), "*");
|
|
2070
|
+
}
|
|
2071
|
+
this.edmEvent = undefined;
|
|
2072
|
+
} else if (this.state.editorInstanse) {
|
|
2073
|
+
this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.secure_file_path}' alt='Image'>`);
|
|
2074
|
+
//this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, data, true);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
this.setState({ showImageSelectionBox: false });
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
toggleEmailPreview = () => {
|
|
2082
|
+
const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
|
|
2083
|
+
if (isDragDrop && !this.state.showEmailPreview) {
|
|
2084
|
+
const activeLangTab = this.state.formData[`${this.state.currentTab - 1}`].activeTab;
|
|
2085
|
+
const langIndex = this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
|
|
2086
|
+
const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
|
|
2087
|
+
win.postMessage("saveProject", '*');
|
|
2088
|
+
this.setState({mode: "preview", gettingPreviewData: true});
|
|
2089
|
+
// this.setState({gettingPreviewData: true}, () => {
|
|
2090
|
+
// this.props.actions.getCmsData('edm', this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id);
|
|
2091
|
+
// });
|
|
2092
|
+
} else if (this.state.showEmailPreview) {
|
|
2093
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
2094
|
+
formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = "";
|
|
2095
|
+
if (formData[`${this.state.currentTab - 1}`].base) {
|
|
2096
|
+
formData.base[formData.base.activeTab]['template-content'] = "";
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
this.setState( (prevState) => ({ showEmailPreview: !prevState.showEmailPreview }));
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
changePreviewDevice = (device) => {
|
|
2103
|
+
this.setState({ device });
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
handleVersionSelect = (status, formData, val) => {
|
|
2107
|
+
|
|
2108
|
+
const newFormData = _.cloneDeep(this.state.formData);
|
|
2109
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
2110
|
+
const versionIndex = _.findIndex(formData['template-version-options'], {key: status});
|
|
2111
|
+
newFormData['template-version'] = formData['template-version-options'][versionIndex].key;
|
|
2112
|
+
|
|
2113
|
+
const newContainers = [];
|
|
2114
|
+
_.forEach(schema.containers, (container, index) => {
|
|
2115
|
+
|
|
2116
|
+
const tmpContainer = _.cloneDeep(container);
|
|
2117
|
+
if (index === versionIndex) {
|
|
2118
|
+
tmpContainer.isActive = true;
|
|
2119
|
+
} else {
|
|
2120
|
+
tmpContainer.isActive = false;
|
|
2121
|
+
}
|
|
2122
|
+
newContainers.push(tmpContainer);
|
|
2123
|
+
});
|
|
2124
|
+
schema.containers = _.cloneDeep(newContainers);
|
|
2125
|
+
this.setState({formData: newFormData, schema, currentTab: (versionIndex + 1), isSchemaChanged: true});
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
afterPaste = (evt) => {
|
|
2129
|
+
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
deleteVersion = (data, currentTab) => {
|
|
2133
|
+
|
|
2134
|
+
if (this.state.tabCount === 1 || currentTab === 1) {
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
2138
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
2139
|
+
schema.containers.splice(`${currentTab - 1}`, 1);
|
|
2140
|
+
schema.containers[0].isActive = true;
|
|
2141
|
+
delete formData[`${currentTab - 1}`];
|
|
2142
|
+
formData['template-version-options'].splice(`${currentTab - 1}`, 1);
|
|
2143
|
+
formData['template-version'] = formData['template-version-options'][0].value;
|
|
2144
|
+
|
|
2145
|
+
this.setState({schema, tabCount: (this.state.tabCount - 1), currentTab: 1, isSchemaChanged: true, showModal: false});
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
switchEditor = () => {
|
|
2149
|
+
|
|
2150
|
+
this.setState({showConfirmationModal: true});
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
renameVersion = (data, currentTab) => {
|
|
2154
|
+
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
markFinalVersion = (data, currentTab) => {
|
|
2158
|
+
const message = getMessageObject('success', this.props.intl.formatMessage(messages["Template Marked as Final Successfully"]), true);
|
|
2159
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
2160
|
+
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
duplicateVersion = (formData, currentTab) => {
|
|
2164
|
+
|
|
2165
|
+
this.setState({formData}, () => {
|
|
2166
|
+
this.addVersion(this.state.tabCount);
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
addVersion = (data) => {
|
|
2171
|
+
if (this.state.schema.containers.length === 5) {
|
|
2172
|
+
alert(this.props.intl.formatMessage(messages.moreThanFiveVersionNotAllowed));
|
|
2173
|
+
return;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
2177
|
+
const tabIndex = schema.containers.length + 1; //data + 1;
|
|
2178
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
2179
|
+
const containers = _.cloneDeep(schema.containers.slice());
|
|
2180
|
+
const firstPane = _.cloneDeep(containers[0].panes[0]);
|
|
2181
|
+
const sections = [];
|
|
2182
|
+
containers[0].isActive = true;
|
|
2183
|
+
_.forEach(firstPane.sections, (section) => {
|
|
2184
|
+
let sect = _.cloneDeep(section);
|
|
2185
|
+
console.log('trying to clone in add version', JSON.stringify(sect), tabIndex);
|
|
2186
|
+
if (sect.type === 'col-label') {
|
|
2187
|
+
sect = this.cloneColLabel(sect, tabIndex);
|
|
2188
|
+
} else if (sect.type === 'multicols') {
|
|
2189
|
+
sect = this.cloneMultiCol(sect, tabIndex);
|
|
2190
|
+
} else if (sect.type === 'parent') {
|
|
2191
|
+
sect = this.cloneParent(sect, tabIndex);
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
sections.push(sect);
|
|
2195
|
+
return true;
|
|
2196
|
+
});
|
|
2197
|
+
firstPane.sections = sections;
|
|
2198
|
+
containers[0].panes = [];
|
|
2199
|
+
containers[0].panes.push(firstPane);
|
|
2200
|
+
schema.containers.push(containers[0]);
|
|
2201
|
+
|
|
2202
|
+
_.forEach(schema.containers, (container, index) => {
|
|
2203
|
+
schema.containers[index].isActive = ((index + 1) === this.state.currentTab);
|
|
2204
|
+
});
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
_.forEach(sections[0].inputFields[0].cols, (inputField) => {
|
|
2208
|
+
if (this.map[inputField.id] === undefined) {
|
|
2209
|
+
if (inputField.id.indexOf('template-content') > -1) {
|
|
2210
|
+
this.map[inputField.id] = this.map['template-content'];
|
|
2211
|
+
} else if (inputField.id.indexOf('edmeditor2') > -1) {
|
|
2212
|
+
this.map[inputField.id] = this.map.edmeditor2;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
});
|
|
2216
|
+
|
|
2217
|
+
const newVersionOption = formData['template-version-options'].pop();
|
|
2218
|
+
|
|
2219
|
+
formData['template-version-options'].push({
|
|
2220
|
+
key: `version ${tabIndex}`,
|
|
2221
|
+
label: `${this.props.intl.formatMessage(messages.versionMessage)} ${tabIndex}`,
|
|
2222
|
+
value: `version ${tabIndex}`,
|
|
2223
|
+
});
|
|
2224
|
+
formData['template-version-options'].push(newVersionOption);
|
|
2225
|
+
formData['template-version'] = `version ${tabIndex}`;
|
|
2226
|
+
|
|
2227
|
+
if (schema) {
|
|
2228
|
+
this.setState({schema, formData, currentTab: (tabIndex), isSchemaChanged: true});
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
addLanguage = (tempLang, passedData, val, asyncLanguages) => {
|
|
2233
|
+
if (this.state.addLanguageType === "upload") {
|
|
2234
|
+
this.setState({languageDataSet: true}, () => {
|
|
2235
|
+
|
|
2236
|
+
if (this.props.Templates.selectedEmailLayout && this.props.Templates.selectedEmailLayout !== '') {
|
|
2237
|
+
|
|
2238
|
+
this.setNewLanguageContent(this.props.Templates.selectedEmailLayout);
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
let addLanguageLength = 1;
|
|
2243
|
+
if (asyncLanguages) {
|
|
2244
|
+
addLanguageLength = asyncLanguages.length;
|
|
2245
|
+
}
|
|
2246
|
+
let data = tempLang;
|
|
2247
|
+
let tabKey = '';
|
|
2248
|
+
let langTab = 0;
|
|
2249
|
+
const schema = _.cloneDeep(this.state.schema);
|
|
2250
|
+
const formData = _.cloneDeep(passedData);
|
|
2251
|
+
for (let idx = 0; idx < addLanguageLength; idx += 1) {
|
|
2252
|
+
let newActiveTab = this.state.settingLanguage ? this.state.settingLanguage.iso_code : 'en';
|
|
2253
|
+
if (asyncLanguages) {
|
|
2254
|
+
newActiveTab = asyncLanguages[idx].iso_code;
|
|
2255
|
+
data = asyncLanguages[idx];
|
|
2256
|
+
}
|
|
2257
|
+
langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(newActiveTab);
|
|
2258
|
+
if (langTab === -1) {
|
|
2259
|
+
formData[`${this.state.currentTab - 1}`].selectedLanguages.push(newActiveTab);
|
|
2260
|
+
langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(newActiveTab);
|
|
2261
|
+
}
|
|
2262
|
+
const selectedLanguage = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(data.iso_code);
|
|
2263
|
+
tabKey = formData[`${this.state.currentTab - 1}`][data.iso_code].tabKey;
|
|
2264
|
+
|
|
2265
|
+
const tabIndex = (selectedLanguage) + 1;
|
|
2266
|
+
const containers = schema.containers.slice();
|
|
2267
|
+
const tabContent = _.cloneDeep(containers[0].tabContent.sections[0]);
|
|
2268
|
+
const tabContentSection = tabContent.inputFields[0].cols[0];
|
|
2269
|
+
const panes = containers[`${this.state.currentTab - 1}`].panes.slice();
|
|
2270
|
+
const firstPane = _.cloneDeep(panes[0]);
|
|
2271
|
+
const sections = [];
|
|
2272
|
+
_.forEach(firstPane.sections, (section) => {
|
|
2273
|
+
let sect = _.cloneDeep(section);
|
|
2274
|
+
console.log('trying to clone in add version', JSON.stringify(sect), tabIndex);
|
|
2275
|
+
if (sect.type === 'col-label') {
|
|
2276
|
+
sect = this.cloneColLabel(sect, tabIndex);
|
|
2277
|
+
} else if (sect.type === 'multicols') {
|
|
2278
|
+
sect = this.cloneMultiCol(sect, tabIndex);
|
|
2279
|
+
} else if (sect.type === 'parent') {
|
|
2280
|
+
sect = this.cloneParent(sect, tabIndex);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
sections.push(sect);
|
|
2284
|
+
return true;
|
|
2285
|
+
});
|
|
2286
|
+
|
|
2287
|
+
tabContentSection.id = `${tabContentSection.id}${tabIndex}`;
|
|
2288
|
+
tabContentSection.value = `${data.language}`;
|
|
2289
|
+
|
|
2290
|
+
_.forEach(sections[0].inputFields[0].cols, (inputField) => {
|
|
2291
|
+
if (this.map[inputField.id] === undefined) {
|
|
2292
|
+
if (inputField.id.indexOf('template-content') > -1) {
|
|
2293
|
+
this.map[inputField.id] = this.map['template-content'];
|
|
2294
|
+
} else if (inputField.id.indexOf('edmeditor2') > -1) {
|
|
2295
|
+
this.map[inputField.id] = this.map.edmeditor2;
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
firstPane.sections = sections;
|
|
2300
|
+
firstPane.sectionsHeaders = [tabContent];
|
|
2301
|
+
console.log('firstPane final version', JSON.stringify(firstPane));
|
|
2302
|
+
// panes.push(firstPane);
|
|
2303
|
+
console.log('initial panes', JSON.stringify(this.state.schema.containers));
|
|
2304
|
+
schema.containers[`${this.state.currentTab - 1}`].panes.push(firstPane);
|
|
2305
|
+
// schema.containers[0].tabContent.sections.push(tabContent);
|
|
2306
|
+
|
|
2307
|
+
}
|
|
2308
|
+
//this.props.templatesActions.getEdmDefaultTemplates();
|
|
2309
|
+
const container = schema.containers[this.state.currentTab - 1];
|
|
2310
|
+
const temp = container;
|
|
2311
|
+
|
|
2312
|
+
if (this.state.addLanguageType === "upload") {
|
|
2313
|
+
temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
|
|
2314
|
+
temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
|
|
2315
|
+
temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
|
|
2316
|
+
}
|
|
2317
|
+
temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
|
|
2318
|
+
if (schema) {
|
|
2319
|
+
this.setState({schema, isSchemaChanged: true, tabKey});
|
|
2320
|
+
if (this.state.addLanguageType !== "upload") {
|
|
2321
|
+
this.setState({addLanguageType: ''});
|
|
2322
|
+
}
|
|
2323
|
+
//this.toggleEdmEmailTemplateSelection();
|
|
2324
|
+
}
|
|
2325
|
+
// const mode = this.state.addLanguageMode;
|
|
2326
|
+
// switch (mode) {
|
|
2327
|
+
// case "upload":
|
|
2328
|
+
//
|
|
2329
|
+
// default:
|
|
2330
|
+
// break;
|
|
2331
|
+
// }
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
openPreviewMode = (selectedAsset) => {
|
|
2335
|
+
|
|
2336
|
+
const asset = selectedAsset;
|
|
2337
|
+
asset.showButtons = asset.showButtons ? !asset.showButtons : true;
|
|
2338
|
+
this.setState({selectedAsset: asset});
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
cloneParent = (section, tabIndex, noSuffix) => {
|
|
2342
|
+
console.log('trying to clone', JSON.stringify(section), tabIndex);
|
|
2343
|
+
const parentsect = section;
|
|
2344
|
+
const childSectionsBeforeCloning = parentsect.childSections.slice();
|
|
2345
|
+
const childSections = [];
|
|
2346
|
+
_.forEach(childSectionsBeforeCloning, (childSection) => {
|
|
2347
|
+
let sect = {};
|
|
2348
|
+
if (childSection.type === 'col-label') {
|
|
2349
|
+
sect = this.cloneColLabel(childSection, tabIndex, noSuffix);
|
|
2350
|
+
} else if (childSection.type === 'multicols') {
|
|
2351
|
+
sect = this.cloneMultiCol(childSection, tabIndex, noSuffix);
|
|
2352
|
+
} else if (childSection.type === 'parent') {
|
|
2353
|
+
sect = this.cloneParent(childSection, tabIndex, noSuffix);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
childSections.push(sect);
|
|
2357
|
+
return true;
|
|
2358
|
+
});
|
|
2359
|
+
console.log('returning cloned parent section final 1', JSON.stringify(childSections));
|
|
2360
|
+
parentsect.childSections = childSections;
|
|
2361
|
+
|
|
2362
|
+
return _.cloneDeep(parentsect);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
cloneColLabel = (sectionObj, tabIndex, noSuffix) => {
|
|
2366
|
+
|
|
2367
|
+
const section = _.cloneDeep(sectionObj);
|
|
2368
|
+
const inputFields = _.forEach(section.inputFields, (inputField) => {
|
|
2369
|
+
const inputF = inputField;
|
|
2370
|
+
inputF.id = noSuffix ? `${inputField.id}` : `${inputField.id}${tabIndex}`;
|
|
2371
|
+
inputF.paneIndex = tabIndex;
|
|
2372
|
+
return inputF;
|
|
2373
|
+
});
|
|
2374
|
+
section.inputFields = inputFields;
|
|
2375
|
+
|
|
2376
|
+
return section;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
cloneMultiCol = (sectionObj, tabIndex, noSuffix) => {
|
|
2380
|
+
|
|
2381
|
+
const section = _.cloneDeep(sectionObj);
|
|
2382
|
+
const inputFields = _.forEach(section.inputFields, (inputField) => {
|
|
2383
|
+
const inputF = inputField;
|
|
2384
|
+
const cols = _.forEach(inputF.cols, (col) => {
|
|
2385
|
+
const colTemp = col;
|
|
2386
|
+
colTemp.id = noSuffix ? `${col.id}` : `${col.id}${tabIndex}`;
|
|
2387
|
+
colTemp.paneIndex = tabIndex;
|
|
2388
|
+
return colTemp;
|
|
2389
|
+
});
|
|
2390
|
+
inputF.cols = cols;
|
|
2391
|
+
return inputF;
|
|
2392
|
+
});
|
|
2393
|
+
section.inputFields = inputFields;
|
|
2394
|
+
|
|
2395
|
+
return section;
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
injectMessages = (elem) => {
|
|
2399
|
+
const temp = elem;
|
|
2400
|
+
if (temp.value && messages[temp.value]) {
|
|
2401
|
+
temp.value = this.props.intl.formatMessage(messages[temp.value]);
|
|
2402
|
+
}
|
|
2403
|
+
if (temp.label && messages[temp.label]) {
|
|
2404
|
+
temp.label = this.props.intl.formatMessage(messages[temp.label]);
|
|
2405
|
+
}
|
|
2406
|
+
if (temp.errorMessage && messages[temp.errorMessage]) {
|
|
2407
|
+
temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
|
|
2408
|
+
}
|
|
2409
|
+
if (temp.placeholder && messages[temp.placeholder]) {
|
|
2410
|
+
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
2411
|
+
}
|
|
2412
|
+
return temp;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
showNext = () => {
|
|
2416
|
+
|
|
2417
|
+
const response = {
|
|
2418
|
+
action: "showNext",
|
|
2419
|
+
value: true,
|
|
2420
|
+
};
|
|
2421
|
+
parent.postMessage(JSON.stringify(response), '*');
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
moveToTemplates = () => {
|
|
2425
|
+
|
|
2426
|
+
const modalContent = {
|
|
2427
|
+
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
2428
|
+
body: this.props.intl.formatMessage(messages.goBackConfirmation),
|
|
2429
|
+
type: 'confirm',
|
|
2430
|
+
id: 'template-back-confirm-modal',
|
|
2431
|
+
show: true,
|
|
2432
|
+
};
|
|
2433
|
+
this.setState({modalContent, showModal: true});
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
cancelTemplate = () => {
|
|
2437
|
+
const type = this.props.location.query.type;
|
|
2438
|
+
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
2439
|
+
const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
|
|
2440
|
+
const isEdmSupport = this.props.location.query.isEdmSupport !== false || false;
|
|
2441
|
+
this.props.router.push({
|
|
2442
|
+
pathname: `/email/`,
|
|
2443
|
+
search : createQueryString(type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport})
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
selectAsset = (asset) => {
|
|
2448
|
+
if (this.state.editorInstanse) {
|
|
2449
|
+
this.state.editorInstanse.insertHtml(`<img src='${asset}' alt='Image'>`);
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
prepareImageData() {
|
|
2454
|
+
|
|
2455
|
+
const data = [];
|
|
2456
|
+
const assetList = this.props.Email.assetList;
|
|
2457
|
+
_.forEach(assetList, (asset) => {
|
|
2458
|
+
const tmpData = {};
|
|
2459
|
+
tmpData.id = asset._id;
|
|
2460
|
+
const updateDateTime = (moment().format('DD-MM-YYYY') === moment(asset.updatedAt).format('DD-MM-YYYY')) ? moment(asset.updatedAt).format('hh:mma') : moment(asset.updatedAt).format('DD-MM-YYYY');
|
|
2461
|
+
tmpData.content = (
|
|
2462
|
+
<div className="image-container">
|
|
2463
|
+
<img style={{width: '100%'}} src={asset.metaInfo.secure_file_path ? asset.metaInfo.secure_file_path : asset.metaInfo.public_url} alt={asset.name} />
|
|
2464
|
+
<div className={asset.showButtons ? 'overlay show-overlay' : 'overlay hide'}>
|
|
2465
|
+
<div>
|
|
2466
|
+
<CapButton type="secondary" className="select-button" onClick={(e) => this.selectAsset(e)}>
|
|
2467
|
+
<FormattedMessage {...messages.select} />
|
|
2468
|
+
</CapButton>
|
|
2469
|
+
</div>
|
|
2470
|
+
<div>
|
|
2471
|
+
{/* <CapButton type="cancel" className="preview-button" onClick={() => this.openEmbeddedPreviewMode(asset)}>
|
|
2472
|
+
<FormattedMessage {...messages.preview} />
|
|
2473
|
+
</CapButton> */}
|
|
2474
|
+
</div>
|
|
2475
|
+
</div>
|
|
2476
|
+
</div>
|
|
2477
|
+
);
|
|
2478
|
+
tmpData.footer = (
|
|
2479
|
+
<div className="card-footer-wrapper">
|
|
2480
|
+
<div className="card-title-container">
|
|
2481
|
+
<div className="card-title-wrapper">
|
|
2482
|
+
<p className="card-title" onClick={() => this.openPreviewMode(asset)}>{asset.name}</p>
|
|
2483
|
+
</div>
|
|
2484
|
+
<div className="more-icon-wrapper">
|
|
2485
|
+
<Popover
|
|
2486
|
+
placement="leftTop"
|
|
2487
|
+
content={<div style={{ cursor: 'pointer'}}>
|
|
2488
|
+
<p>
|
|
2489
|
+
<FormattedMessage {...messages.delete} />
|
|
2490
|
+
</p></div>} trigger="click">
|
|
2491
|
+
<i className="material-icons creative-icons">more_vert</i>
|
|
2492
|
+
</Popover>
|
|
2493
|
+
</div>
|
|
2494
|
+
</div>
|
|
2495
|
+
<p className="card-detail"><FormattedMessage {...messages.uploadedAt} />: {updateDateTime}</p>
|
|
2496
|
+
</div>
|
|
2497
|
+
);
|
|
2498
|
+
data.push(tmpData);
|
|
2499
|
+
});
|
|
2500
|
+
return data;
|
|
2501
|
+
}
|
|
2502
|
+
injectEvents = (schema) => {
|
|
2503
|
+
const type = this.props.location.query.type;
|
|
2504
|
+
let temp = _.cloneDeep(schema);
|
|
2505
|
+
temp.standalone.sections = this.injectSections(temp.standalone.sections);
|
|
2506
|
+
_.forEach(temp.containers, (container) => {
|
|
2507
|
+
let tempContainer = container;
|
|
2508
|
+
tempContainer = this.injectContainer(tempContainer);
|
|
2509
|
+
return tempContainer;
|
|
2510
|
+
});
|
|
2511
|
+
|
|
2512
|
+
// if (type !== "embedded" || (type === "embedded" && (this.props.location.query.isLanguageSupport === "false" || (this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === "true")))) {
|
|
2513
|
+
const ifLangSupported = this.props.location.query.isLanguageSupport === "true" || type !== "embedded";
|
|
2514
|
+
_.forEach(temp.containers, (container) => {
|
|
2515
|
+
if (container.isActive) {
|
|
2516
|
+
let hideLang = false;
|
|
2517
|
+
_.forEach(container.tabContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
|
|
2518
|
+
const tempEl = containerInputFieldCol;
|
|
2519
|
+
if (containerInputFieldCol.id === "tab-header") {
|
|
2520
|
+
const baseLanguage = this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details && this.props.Global.currentOrgDetails.basic_details.base_language && this.props.Global.currentOrgDetails.basic_details.base_language !== "" ? this.props.Global.currentOrgDetails.basic_details.base_language : 'en';
|
|
2521
|
+
const supportedLanguages = this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details && this.props.Global.currentOrgDetails.basic_details.supported_languages;
|
|
2522
|
+
if (!supportedLanguages) {
|
|
2523
|
+
tempEl.value = baseLanguage || 'English';
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
const langObject = supportedLanguages.find( (lang) => lang.iso_code === baseLanguage);
|
|
2527
|
+
if (langObject) {
|
|
2528
|
+
tempEl.value = langObject.language;
|
|
2529
|
+
} else {
|
|
2530
|
+
tempEl.value = baseLanguage || 'English';
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
_.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
|
|
2535
|
+
if (hideLang && !ifLangSupported) {
|
|
2536
|
+
const newContainerInputFieldCol = containerInputFieldCol;
|
|
2537
|
+
hideLang = false;
|
|
2538
|
+
newContainerInputFieldCol.offset = 16;
|
|
2539
|
+
} else if (hideLang) {
|
|
2540
|
+
const newContainerInputFieldCol = containerInputFieldCol;
|
|
2541
|
+
hideLang = false;
|
|
2542
|
+
newContainerInputFieldCol.offset = 13;
|
|
2543
|
+
}
|
|
2544
|
+
if (containerInputFieldCol.id === 'add-language-button' && !ifLangSupported) {
|
|
2545
|
+
const newContainerInputFieldCol = containerInputFieldCol;
|
|
2546
|
+
if (newContainerInputFieldCol.colStyle.display !== "none") {
|
|
2547
|
+
newContainerInputFieldCol.colStyle.display = "none";
|
|
2548
|
+
}
|
|
2549
|
+
hideLang = true;
|
|
2550
|
+
} else if (containerInputFieldCol.id === 'add-language-button') {
|
|
2551
|
+
hideLang = true;
|
|
2552
|
+
}
|
|
2553
|
+
if (containerInputFieldCol.id === "mark-final-version-label") {
|
|
2554
|
+
const newContainerInputFieldCol = containerInputFieldCol;
|
|
2555
|
+
if (newContainerInputFieldCol.colStyle.display !== "none") {
|
|
2556
|
+
newContainerInputFieldCol.colStyle.display = "none";
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
// if (containerInputFieldCol.id === "tab-options-popover") {
|
|
2560
|
+
// const newContainerInputFieldCol = containerInputFieldCol;
|
|
2561
|
+
// newContainerInputFieldCol.colStyle.display = "none";
|
|
2562
|
+
// }
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
if (temp.standalone.sections && temp.standalone.sections.length > 0) {
|
|
2567
|
+
_.forEach(temp.standalone.sections[1].inputFields[0].cols, (inputField) => {
|
|
2568
|
+
if (inputField.id === "template-version") {
|
|
2569
|
+
const iF = inputField;
|
|
2570
|
+
iF.colStyle = {};
|
|
2571
|
+
iF.colStyle.display = "none";
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
//}
|
|
2576
|
+
temp = type === 'embedded' ? this.removeStandAlone(temp) : temp;
|
|
2577
|
+
this.setState({schema: temp, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1}, () => {
|
|
2578
|
+
if (type === 'embedded' && (this.props.route.name === 'EmailView' || (this.props.location.query.module && (this.props.location.query.module.toLowerCase() === 'loyalty' || this.props.location.query.module.toLowerCase() === 'dvs' || this.props.location.query.module.toLowerCase() === 'coupon_expiry' || this.props.location.query.module.toLowerCase() === 'timeline')))) {
|
|
2579
|
+
if ((this.props.route.name === "EmailEdit" || this.props.route.name === "EmailCreate") && (this.props.location.query.module === "dvs" || this.props.location.query.module.toLowerCase() === 'coupon_expiry')) {
|
|
2580
|
+
return;
|
|
2581
|
+
}
|
|
2582
|
+
const response = {
|
|
2583
|
+
action: 'startTemplateCreation',
|
|
2584
|
+
};
|
|
2585
|
+
parent.postMessage(JSON.stringify(response), '*');
|
|
2586
|
+
}
|
|
2587
|
+
});
|
|
2588
|
+
return temp;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
handleOnTagsContextChange = (data) => {
|
|
2592
|
+
|
|
2593
|
+
const query = {
|
|
2594
|
+
layout: 'EMAIL',
|
|
2595
|
+
type: 'TAG',
|
|
2596
|
+
context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
|
|
2597
|
+
embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
|
|
2598
|
+
};
|
|
2599
|
+
this.props.globalActions.fetchSchemaForEntity(query);
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
removeStandAlone(schema) {
|
|
2603
|
+
const newSchema = _.cloneDeep(schema);
|
|
2604
|
+
delete newSchema.standalone;
|
|
2605
|
+
newSchema.standalone = {};
|
|
2606
|
+
newSchema.standalone.sections = [];
|
|
2607
|
+
if (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs" || this.props.location.query.module === "coupon_expiry" || this.props.location.query.module === "timeline" ||
|
|
2608
|
+
this.props.location.query.module === "library")) {
|
|
2609
|
+
newSchema.standalone.sections.push(_.cloneDeep(schema.standalone.sections[0]));
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
_.forEach(newSchema.containers, (container) => {
|
|
2613
|
+
const temp = container;
|
|
2614
|
+
if (temp.type === 'tabs') {
|
|
2615
|
+
// temp.tabBarExtraContent = {};
|
|
2616
|
+
// temp.tabBarExtraContent.sections = [];
|
|
2617
|
+
const basePane = _.cloneDeep(temp.panes[0]);
|
|
2618
|
+
_.forEach(temp.tabContent.sections, (section) => {
|
|
2619
|
+
_.forEach(section.inputFields, (inputField) => {
|
|
2620
|
+
if (section.type === 'multicols') {
|
|
2621
|
+
_.forEach(inputField.cols, (col, key) => {
|
|
2622
|
+
if (col.id === 'tab-options-popover') {
|
|
2623
|
+
inputField.cols.splice(key, 1);
|
|
2624
|
+
} else if (col.id === 'tab-header') {
|
|
2625
|
+
const tempCol = col;
|
|
2626
|
+
tempCol.style = {padding: '8px 0'};
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
});
|
|
2632
|
+
_.forEach(temp.tabBarExtraContent.sections, (section) => {
|
|
2633
|
+
_.forEach(section.inputFields, (inputFields) => {
|
|
2634
|
+
if (section.type === "multicols") {
|
|
2635
|
+
_.forEach(inputFields.cols, (col) => {
|
|
2636
|
+
if ((col.id === "tab-options-popover" || col.id === "add-language-button") && this.props.location.query.type === 'embedded' && (this.props.location.query.module === "library")) {
|
|
2637
|
+
const colStyle = col.colStyle;
|
|
2638
|
+
colStyle.display = "none";
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
});
|
|
2643
|
+
});
|
|
2644
|
+
temp.panes = [];
|
|
2645
|
+
temp.panes.push(basePane);
|
|
2646
|
+
}
|
|
2647
|
+
});
|
|
2648
|
+
return newSchema;
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
startTemplateCreation(data) {
|
|
2652
|
+
|
|
2653
|
+
if (_.isEmpty(data)) {
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
2657
|
+
|
|
2658
|
+
//const data = {"base":{"subject":"deded","html_content":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> \t<title>Scheduled Report</title> \t<meta http-equiv=\"Content-Type\" content=\"text/html charset=UTF-8\"/> \t<style type=\"text/css\">.container-main p{line-height: 1.6;}@media screen and (max-width: 480px){a.brand{font-size: 35px;}}@media screen and (max-width: 480px){.container-main a{text-align: center;}a.brand{text-align: center;}}a.brand img{vertical-align: middle; padding: 0 8px 0 0; width: 250px;}@media screen and (max-width: 480px){a.brand img{width: 220px !important;}}@media screen and (max-width: 480px){.container-content{padding: 15px 20px; font-size: 12px !important;} .email-footer{font-size: 12px !important;}}.container-content table{border-collapse: collapse;}.container-content table tr td p{margin: 5px;}.container-content table tr td p span{font-weight: bold; padding: 0 3px 0 0;}@media screen and (max-width: 480px){a.btn-view-reports{margin: 25px auto 10px;}}a.btn-view-reports:hover{background: grey; color: #fff;}.email-footer p{text-align: center; font-size: 12px; color: grey;}.email-footer p a{color: blue; cursor: pointer;}.email-footer p a:hover{color: grey;} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table class=\"container-main\" style=\"background:#eeeeee; color:#000000; font-family:'Open Sans',sans-serif; font-size:16px; font-weight:400; margin:0 auto; max-width:978px; padding:15px; width:100%\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table class=\"email-header\" style=\"background:#ffffff; margin:0 0 5px; padding:17px 0; width:100%\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td style=\"width:100%\"><a class=\"brand\" href=\"#\" style=\"display: table; margin: 0 auto; text-decoration: none; font-size: 37px; color: grey;\"><img alt=\"Capillary Technologies\" src=\"https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/60221e2020ba572f6787.png\" /> </a></td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<div class=\"container-content\" style=\"background:#ffffff; padding:20px 35px\"> \t\t\t<p>Hi Ashish Karan,</p> \t\t\t<p>You've received a new scheduled report. {{unsubscribe}}</p> \t\t\t<table> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Org Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>autotest1</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Scheduled Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>Schedule Test</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Time Period: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>1st Jan, 2017 to 24th Sep, 2017</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Report Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>redDart Report</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<p style=\"font-size:15px; margin-top:25px\">By clicking "View Report" you will be redirected to Capillary Analytics to view the automated report.</p> \t\t\t<a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91?snapshot=59c8bce750f4e75ec8b0d24c\" style=\"background: #009e0f; text-align: center; color: #fff; font-size: 16px; padding: 10px 25px; cursor: pointer; text-decoration: none; display: block; width: 120px; margin: 25px auto 15px;\" target=\"_blank\">View Report</a></div> \t\t\t<div class=\"email-footer\"> \t\t\t<p style=\"color:grey; font-size:12px; text-align:center\">You've received this mail because you subscribed to Schedule Test schedule of redDart Report. <a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91/schedule/59c8bce750f4e75ec8b0d24c/unsubscribeSchedule\" style=\"color: blue; cursor: pointer;\" target=\"_blank\">Unsubscribe</a></p> \t\t\t<p><a href=\"http://capillarytech.com/privacy-policy/\" target=\"_blank\">Privacy Policy</a> | <a href=\"http://capillarytech.com/about-us/\" target=\"_blank\">About Capillary</a></p> \t\t\t</div> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","is_drag_drop":false,"drag_drop_id":null},"secondary_templates":[{"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":false,"drag_drop_id":null,"scope":null,"tag":null,"is_default":null,"html_content":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> \t<title>Scheduled Report</title> \t<meta http-equiv=\"Content-Type\" content=\"text/html charset=UTF-8\"/> \t<style type=\"text/css\">.container-main p{line-height: 1.6;}@media screen and (max-width: 480px){a.brand{font-size: 35px;}}@media screen and (max-width: 480px){.container-main a{text-align: center;}a.brand{text-align: center;}}a.brand img{vertical-align: middle; padding: 0 8px 0 0; width: 250px;}@media screen and (max-width: 480px){a.brand img{width: 220px !important;}}@media screen and (max-width: 480px){.container-content{padding: 15px 20px; font-size: 12px !important;} .email-footer{font-size: 12px !important;}}.container-content table{border-collapse: collapse;}.container-content table tr td p{margin: 5px;}.container-content table tr td p span{font-weight: bold; padding: 0 3px 0 0;}@media screen and (max-width: 480px){a.btn-view-reports{margin: 25px auto 10px;}}a.btn-view-reports:hover{background: grey; color: #fff;}.email-footer p{text-align: center; font-size: 12px; color: grey;}.email-footer p a{color: blue; cursor: pointer;}.email-footer p a:hover{color: grey;} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table class=\"container-main\" style=\"background:#eeeeee; color:#000000; font-family:'Open Sans',sans-serif; font-size:16px; font-weight:400; margin:0 auto; max-width:978px; padding:15px; width:100%\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table class=\"email-header\" style=\"background:#ffffff; margin:0 0 5px; padding:17px 0; width:100%\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td style=\"width:100%\"><a class=\"brand\" href=\"#\" style=\"display: table; margin: 0 auto; text-decoration: none; font-size: 37px; color: grey;\"><img alt=\"Capillary Technologies\" src=\"https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/60221e2020ba572f6787.png\" /> </a></td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<div class=\"container-content\" style=\"background:#ffffff; padding:20px 35px\"> \t\t\t<p>Hi Ashish Karan,</p> \t\t\t<p>You've received a new scheduled report. {{unsubscribe}}</p> \t\t\t<table> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Org Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>autotest1</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Scheduled Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>Schedule Test</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Time Period: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>1st Jan, 2017 to 24th Sep, 2017</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Report Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>redDart Report</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<p style=\"font-size:15px; margin-top:25px\">By clicking "View Report" you will be redirected to Capillary Analytics to view the automated report.</p> \t\t\t<a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91?snapshot=59c8bce750f4e75ec8b0d24c\" style=\"background: #009e0f; text-align: center; color: #fff; font-size: 16px; padding: 10px 25px; cursor: pointer; text-decoration: none; display: block; width: 120px; margin: 25px auto 15px;\" target=\"_blank\">View Report</a></div> \t\t\t<div class=\"email-footer\"> \t\t\t<p style=\"color:grey; font-size:12px; text-align:center\">You've received this mail because you subscribed to Schedule Test schedule of redDart Report. <a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91/schedule/59c8bce750f4e75ec8b0d24c/unsubscribeSchedule\" style=\"color: blue; cursor: pointer;\" target=\"_blank\">Unsubscribe</a></p> \t\t\t<p><a href=\"http://capillarytech.com/privacy-policy/\" target=\"_blank\">Privacy Policy</a> | <a href=\"http://capillarytech.com/about-us/\" target=\"_blank\">About Capillary</a></p> \t\t\t</div> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","secondary_template_id":"9500","is_base_template":1,"language_name":"English","language":"English","lang_id":"69"}],"edit":true,"tags":[]};
|
|
2659
|
+
// const data = {edit: true, "base":{"subject":"testsubject","html_content":"<html> <head> \t<meta charset=\"utf-8\" /> \t<title>Aster Secure</title> \t<style type=\"text/css\">#outlook a { padding: 0; } body { width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0;} .ExternalClass { width: 100%; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } #backgroundTable { margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; border: none; -ms-interpolation-mode: bicubic; } a img { border: none; } .image_fix { display: block; } p { margin: 0px 0px !important; } table td { border-collapse: collapse; } table { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; } table[class=full] { width: 100%; clear: both; } table[class=spacetable] { height: 176px; } table[class=spacetable1] { height: 431px; } table[class=spacetable2] { height: 50px; } table[class=spacetable3] { height: 55px; } \t @media only screen and (min-width: 320px) and (max-width: 540px) { a[href^=\"tel\"], a[href^=\"sms\"] { text-decoration: none; color: #ffffff; pointer-events: none; cursor: default; } .mobile_link a[href^=\"tel\"], .mobile_link a[href^=\"sms\"] { text-decoration: default; color: #ffffff !important; pointer-events: auto; cursor: default; } img[class=logo] { width: 132px!important; } img[class=shop] { width:53px!important; text-align: center!important; } table[class=innerlayer] { width: 300px !important; text-align: center; } img[class=spot] { width: 65px!important; } img[class=banner] { width: 290px !important; text-align: center; } img[class=banner1] { width: 229px!important; } img[class=click] { width:55px!important; } img[class=border] { width: 290px!important; } td[class=txtfont] { font-size:11px!important; height:50px!important; line-height: 15px!important; } \t span[class=txtfont] { font-size:9px!important; height:98px!important; line-height:23px!important; } \t td[class=txtfont1] { font-size:11px!important; height:40px!important; line-height: 14px!important; } img[class=left] { width:195px!important; } img[class=right] { width:46px!important; } \t \t td[class=txtfont3] { font-size:8px!important;} \ttd[class=txtfont2] { font-size:6px!important; line-height:9px!important; } td[class=txtbold] { font-size: 21px!important; } img[class=gap] { width:92px!important; } img[class=gap1] { width: 20px!important; } table[class=social] { width: 99% !important; } img[class=fb] { width:20px!important; } img[class=in] { width:21px!important; } img[class=tw] { width:20px!important; } img[class=pin] { width:41px!important; } \t img[class=and] { width:81px!important; } img[class=my] { width: 44px!important; } \t img[class=you] { width:21px!important; } img[class=store] { width:65px!important; } \t \t img[class=snap] { width:24px!important; } td[class=textlen] { height:52px!important; } \ttd[class=tdlen] \t{ \theight:35px!important;font-size: 10px !important; \t} \t\t\timg[class=a] { width: 42px!important; } \t\t\timg[class=b] { width: 22px!important; } \t\t\timg[class=c] { width: 72px!important; } \t\t\timg[class=d] { width: 50px!important; } \t\t\timg[class=e] { width: 56px!important; } \t\t\timg[class=f] { width: 56px!important; } \t\t\t} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table align=\"center\" bgcolor=\"#fff\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">Shop at Aster Pharmacy this month and You could be the next lucky winner!</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><a href=\"#\" style=\"pointer-events:none;\"><img class=\"banner\" src=\"https://s3-eu-west-1.amazonaws.com/fs.capillary.eu/intouch_creative_assets/890bdffee3b2322d8ec7.jpg\" style=\"border:none; display:block\" /></a></td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">To remove your email address from our mailing list , please click on {{unsubscribe}}</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","is_drag_drop":0,"drag_drop_id":null},"secondary_templates":[{"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":false,"drag_drop_id":null,"scope":null,"tag":null,"is_default":null,"html_content":"<html>\r\n<head>\r\n\t<meta charset=\"utf-8\" />\r\n\t<title>Aster Secure</title>\r\n\t<style type=\"text/css\">#outlook a { padding: 0; } body { width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0;} .ExternalClass { width: 100%; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } #backgroundTable { margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; border: none; -ms-interpolation-mode: bicubic; } a img { border: none; } .image_fix { display: block; } p { margin: 0px 0px !important; } table td { border-collapse: collapse; } table { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; } table[class=full] { width: 100%; clear: both; } table[class=spacetable] { height: 176px; } table[class=spacetable1] { height: 431px; } table[class=spacetable2] { height: 50px; } table[class=spacetable3] { height: 55px; } \t @media only screen and (min-width: 320px) and (max-width: 540px) { a[href^=\"tel\"], a[href^=\"sms\"] { text-decoration: none; color: #ffffff; pointer-events: none; cursor: default; } .mobile_link a[href^=\"tel\"], .mobile_link a[href^=\"sms\"] { text-decoration: default; color: #ffffff !important; pointer-events: auto; cursor: default; } img[class=logo] { width: 132px!important; } img[class=shop] { width:53px!important; text-align: center!important; } table[class=innerlayer] { width: 300px !important; text-align: center; } img[class=spot] { width: 65px!important; } img[class=banner] { width: 290px !important; text-align: center; } img[class=banner1] { width: 229px!important; } img[class=click] { width:55px!important; } img[class=border] { width: 290px!important; } td[class=txtfont] { font-size:11px!important; height:50px!important; line-height: 15px!important; } \t span[class=txtfont] { font-size:9px!important; height:98px!important; line-height:23px!important; } \t td[class=txtfont1] { font-size:11px!important; height:40px!important; line-height: 14px!important; } img[class=left] { width:195px!important; } img[class=right] { width:46px!important; } \t \t td[class=txtfont3] { font-size:8px!important;} \ttd[class=txtfont2] { font-size:6px!important; line-height:9px!important; } td[class=txtbold] { font-size: 21px!important; } img[class=gap] { width:92px!important; } img[class=gap1] { width: 20px!important; } table[class=social] { width: 99% !important; } img[class=fb] { width:20px!important; } img[class=in] { width:21px!important; } img[class=tw] { width:20px!important; } img[class=pin] { width:41px!important; } \t img[class=and] { width:81px!important; } img[class=my] { width: 44px!important; } \t img[class=you] { width:21px!important; } img[class=store] { width:65px!important; } \t \t img[class=snap] { width:24px!important; } td[class=textlen] { height:52px!important; } \ttd[class=tdlen] \t{ \theight:35px!important;font-size: 10px !important; \t} \t\t\timg[class=a] { width: 42px!important; } \t\t\timg[class=b] { width: 22px!important; } \t\t\timg[class=c] { width: 72px!important; } \t\t\timg[class=d] { width: 50px!important; } \t\t\timg[class=e] { width: 56px!important; } \t\t\timg[class=f] { width: 56px!important; } \t\t\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\">\r\n\t<tbody>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t<table align=\"center\" bgcolor=\"#fff\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">Shop at Aster Pharmacy this month and You could be the next lucky winner!</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td><a href=\"#\" style=\"pointer-events:none;\"><img class=\"banner\" src=\"https://s3-eu-west-1.amazonaws.com/fs.capillary.eu/intouch_creative_assets/890bdffee3b2322d8ec7.jpg\" style=\"border:none; display:block\" /></a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">To remove your email address from our mailing list , please click on {{unsubscribe}}</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</tbody>\r\n</table>\r\n</body>\r\n</html>\r\n","secondary_template_id":"9584","is_base_template":1,"language_name":"English","language":"English","lang_id":"69"}, {"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":false,"drag_drop_id":null,"scope":null,"tag":null,"is_default":null,"html_content":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> \t<title>Scheduled Report</title> \t<meta http-equiv=\"Content-Type\" content=\"text/html charset=UTF-8\"/> \t<style type=\"text/css\">.container-main p{line-height: 1.6;}@media screen and (max-width: 480px){a.brand{font-size: 35px;}}@media screen and (max-width: 480px){.container-main a{text-align: center;}a.brand{text-align: center;}}a.brand img{vertical-align: middle; padding: 0 8px 0 0; width: 250px;}@media screen and (max-width: 480px){a.brand img{width: 220px !important;}}@media screen and (max-width: 480px){.container-content{padding: 15px 20px; font-size: 12px !important;} .email-footer{font-size: 12px !important;}}.container-content table{border-collapse: collapse;}.container-content table tr td p{margin: 5px;}.container-content table tr td p span{font-weight: bold; padding: 0 3px 0 0;}@media screen and (max-width: 480px){a.btn-view-reports{margin: 25px auto 10px;}}a.btn-view-reports:hover{background: grey; color: #fff;}.email-footer p{text-align: center; font-size: 12px; color: grey;}.email-footer p a{color: blue; cursor: pointer;}.email-footer p a:hover{color: grey;} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table class=\"container-main\" style=\"background:#eeeeee; color:#000000; font-family:'Open Sans',sans-serif; font-size:16px; font-weight:400; margin:0 auto; max-width:978px; padding:15px; width:100%\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table class=\"email-header\" style=\"background:#ffffff; margin:0 0 5px; padding:17px 0; width:100%\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td style=\"width:100%\"><a class=\"brand\" href=\"#\" style=\"display: table; margin: 0 auto; text-decoration: none; font-size: 37px; color: grey;\"><img alt=\"Capillary Technologies\" src=\"https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/60221e2020ba572f6787.png\" /> </a></td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<div class=\"container-content\" style=\"background:#ffffff; padding:20px 35px\"> \t\t\t<p>Hi Ashish Karan,</p> \t\t\t<p>You've received a new scheduled report. {{unsubscribe}}</p> \t\t\t<table> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Org Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>autotest1</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Scheduled Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>Schedule Test</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Time Period: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>1st Jan, 2017 to 24th Sep, 2017</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Report Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>redDart Report</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<p style=\"font-size:15px; margin-top:25px\">By clicking "View Report" you will be redirected to Capillary Analytics to view the automated report.</p> \t\t\t<a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91?snapshot=59c8bce750f4e75ec8b0d24c\" style=\"background: #009e0f; text-align: center; color: #fff; font-size: 16px; padding: 10px 25px; cursor: pointer; text-decoration: none; display: block; width: 120px; margin: 25px auto 15px;\" target=\"_blank\">View Report</a></div> \t\t\t<div class=\"email-footer\"> \t\t\t<p style=\"color:grey; font-size:12px; text-align:center\">You've received this mail because you subscribed to Schedule Test schedule of redDart Report. <a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91/schedule/59c8bce750f4e75ec8b0d24c/unsubscribeSchedule\" style=\"color: blue; cursor: pointer;\" target=\"_blank\">Unsubscribe</a></p> \t\t\t<p><a href=\"http://capillarytech.com/privacy-policy/\" target=\"_blank\">Privacy Policy</a> | <a href=\"http://capillarytech.com/about-us/\" target=\"_blank\">About Capillary</a></p> \t\t\t</div> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","secondary_template_id":"9500","is_base_template":false,"language_name":"Hindi","language":"Hindi","lang_id":"151"},{"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":1,"drag_drop_id":"55acf47048a85bbf7681a35a","scope":null,"tag":null,"is_default":null,"html_content":"","secondary_template_id":"9500","is_base_template":0,"language_name":"Japanese","language":"Japanese","lang_id":"100"}]};
|
|
2660
|
+
|
|
2661
|
+
if (data && data.edit) {
|
|
2662
|
+
|
|
2663
|
+
// const formData = {'0': {}};
|
|
2664
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
2665
|
+
formData[0].selectedLanguages = [];
|
|
2666
|
+
let tabKey;
|
|
2667
|
+
if (this.props.location.query.type === 'embedded' && (this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === 'false')) {
|
|
2668
|
+
formData['template-subject'] = (data.base && data.base.subject) ? data.base.subject : '';
|
|
2669
|
+
const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
2670
|
+
let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
|
|
2671
|
+
|
|
2672
|
+
if (languageIndex === -1) {
|
|
2673
|
+
languageIndex = 0;
|
|
2674
|
+
}
|
|
2675
|
+
const dataBase = data.base;
|
|
2676
|
+
const tempData = {
|
|
2677
|
+
"is_drag_drop": dataBase && dataBase.is_drag_drop,
|
|
2678
|
+
"lang_id": this.supportedLanguages[languageIndex].lang_id,
|
|
2679
|
+
"iso_code": this.supportedLanguages[languageIndex].iso_code,
|
|
2680
|
+
"language": this.supportedLanguages[languageIndex].language,
|
|
2681
|
+
"template-content": dataBase && !dataBase.is_drag_drop && dataBase.is_drag_drop !== 1 ? dataBase.html_content : "",
|
|
2682
|
+
};
|
|
2683
|
+
formData[0].base = true;
|
|
2684
|
+
formData[0].selectedLanguages.push(this.supportedLanguages[languageIndex].iso_code);
|
|
2685
|
+
formData[0][this.supportedLanguages[languageIndex].iso_code] = tempData;
|
|
2686
|
+
formData[0].activeTab = this.supportedLanguages[languageIndex].iso_code;
|
|
2687
|
+
tabKey = "2";
|
|
2688
|
+
|
|
2689
|
+
} else {
|
|
2690
|
+
const additionalLanguages = [];
|
|
2691
|
+
_.forEach(data.secondary_templates, (templates) => {
|
|
2692
|
+
|
|
2693
|
+
const id = "1";
|
|
2694
|
+
tabKey = id;
|
|
2695
|
+
let languageIndex = _.findIndex(this.supportedLanguages, {language: templates.language});
|
|
2696
|
+
if (languageIndex === -1) {
|
|
2697
|
+
languageIndex = 0;
|
|
2698
|
+
}
|
|
2699
|
+
const tempData = {
|
|
2700
|
+
"is_drag_drop": templates.is_drag_drop === "1" || false,
|
|
2701
|
+
"lang_id": this.supportedLanguages[languageIndex].lang_id,
|
|
2702
|
+
"iso_code": this.supportedLanguages[languageIndex].iso_code,
|
|
2703
|
+
"language": this.supportedLanguages[languageIndex].language,
|
|
2704
|
+
"template-content": templates.html_content,
|
|
2705
|
+
};
|
|
2706
|
+
if (templates.drag_drop_id) {
|
|
2707
|
+
tempData.drag_drop_id = templates.drag_drop_id;
|
|
2708
|
+
this.props.actions.getCmsSetting('edm', tempData.drag_drop_id, 'open', tempData.iso_code, isEdmSupport);
|
|
2709
|
+
}
|
|
2710
|
+
// formData.usingTabContainer = true;
|
|
2711
|
+
// formData.tabCount = 1;
|
|
2712
|
+
|
|
2713
|
+
// formData[0].tabkey = "1";
|
|
2714
|
+
// formData[0] = {};
|
|
2715
|
+
// formData[0].activeTab = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
2716
|
+
formData[0].base = true;
|
|
2717
|
+
formData[0].selectedLanguages.push(this.supportedLanguages[languageIndex].iso_code);
|
|
2718
|
+
formData[0][this.supportedLanguages[languageIndex].iso_code] = tempData;
|
|
2719
|
+
if (templates.is_base_template === 1) {
|
|
2720
|
+
formData[0].activeTab = this.supportedLanguages[languageIndex].iso_code;
|
|
2721
|
+
// formData.base = tempData;
|
|
2722
|
+
} else {
|
|
2723
|
+
additionalLanguages.push(this.supportedLanguages[languageIndex]);
|
|
2724
|
+
}
|
|
2725
|
+
});
|
|
2726
|
+
this.addLanguage(false, formData, false, additionalLanguages);
|
|
2727
|
+
}
|
|
2728
|
+
formData.base = _.cloneDeep(formData[0]);
|
|
2729
|
+
|
|
2730
|
+
this.setState({formData, loading: false, injectedTags: data.tags, tabKey, isDragDrop: (data?.base?.is_drag_drop !== 0 )}, () => {
|
|
2731
|
+
// this.setState({tabKey: ''});
|
|
2732
|
+
_.forEach(formData[0].selectedLanguages, (language) => {
|
|
2733
|
+
if (formData[0][language].is_drag_drop) {
|
|
2734
|
+
this.props.actions.getCmsSetting('edm', formData[0][language].drag_drop_id, 'open', language, isEdmSupport);
|
|
2735
|
+
}
|
|
2736
|
+
});
|
|
2737
|
+
});
|
|
2738
|
+
} else {
|
|
2739
|
+
this.setState({injectedTags: data.tags});
|
|
2740
|
+
}
|
|
2741
|
+
if (data.tags) {
|
|
2742
|
+
this.props.globalActions.setInjectedTags(data.tags);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
startLoading = (ifEdit) => {
|
|
2747
|
+
if (ifEdit) {
|
|
2748
|
+
this.setState({loading: true});
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
injectContainer = (container) => {
|
|
2753
|
+
const temp = container;
|
|
2754
|
+
if (temp.type === 'tabs') {
|
|
2755
|
+
temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
|
|
2756
|
+
temp.tabBarExtraContent.sections = this.injectSections(temp.tabBarExtraContent.sections);
|
|
2757
|
+
temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
|
|
2758
|
+
temp.injectedEvents = {};
|
|
2759
|
+
_.forEach(temp.supportedEvents, (event) => {
|
|
2760
|
+
temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
|
|
2761
|
+
});
|
|
2762
|
+
_.forEach(temp.panes, (pane) => {
|
|
2763
|
+
const tempPane = pane;
|
|
2764
|
+
tempPane.sections = this.injectSections(tempPane.sections);
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
return temp;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
injectMultiColSection = (section) => {
|
|
2771
|
+
_.forEach(section.inputFields, (inputField) => {
|
|
2772
|
+
_.forEach(inputField.cols, (col) => {
|
|
2773
|
+
const temp = col;
|
|
2774
|
+
if (temp.type === 'popover') {
|
|
2775
|
+
temp.content.sections = this.injectSections(temp.content.sections);
|
|
2776
|
+
temp.value.sections = this.injectSections(temp.value.sections);
|
|
2777
|
+
return true;
|
|
2778
|
+
}
|
|
2779
|
+
temp.injectedEvents = {};
|
|
2780
|
+
_.forEach(col.supportedEvents, (event) => {
|
|
2781
|
+
// console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
|
|
2782
|
+
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
2783
|
+
});
|
|
2784
|
+
//
|
|
2785
|
+
if (temp.type === 'icon') {
|
|
2786
|
+
return true;
|
|
2787
|
+
}
|
|
2788
|
+
if (temp.value && messages[temp.value]) {
|
|
2789
|
+
temp.value = this.props.intl.formatMessage(messages[temp.value]);
|
|
2790
|
+
}
|
|
2791
|
+
if (temp.label && messages[temp.label]) {
|
|
2792
|
+
temp.label = this.props.intl.formatMessage(messages[temp.label]);
|
|
2793
|
+
}
|
|
2794
|
+
if (temp.errorMessage && messages[temp.errorMessage]) {
|
|
2795
|
+
temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
|
|
2796
|
+
}
|
|
2797
|
+
if (temp.placeholder && messages[temp.placeholder]) {
|
|
2798
|
+
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
2799
|
+
}
|
|
2800
|
+
return true;
|
|
2801
|
+
});
|
|
2802
|
+
});
|
|
2803
|
+
_.forEach(section.actionFields, (actionField) => {
|
|
2804
|
+
_.forEach(actionField.cols, (col) => {
|
|
2805
|
+
const temp = col;
|
|
2806
|
+
if (temp.type === 'popover') {
|
|
2807
|
+
temp.content.sections = this.injectSections(temp.content.sections);
|
|
2808
|
+
temp.value.sections = this.injectSections(temp.value.sections);
|
|
2809
|
+
return true;
|
|
2810
|
+
}
|
|
2811
|
+
temp.injectedEvents = {};
|
|
2812
|
+
_.forEach(col.supportedEvents, (event) => {
|
|
2813
|
+
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
2814
|
+
});
|
|
2815
|
+
//
|
|
2816
|
+
if (temp.type === 'icon') {
|
|
2817
|
+
return true;
|
|
2818
|
+
}
|
|
2819
|
+
if (temp.value && messages[temp.value]) {
|
|
2820
|
+
temp.value = this.props.intl.formatMessage(messages[temp.value]);
|
|
2821
|
+
}
|
|
2822
|
+
if (temp.label && messages[temp.label]) {
|
|
2823
|
+
temp.label = this.props.intl.formatMessage(messages[temp.label]);
|
|
2824
|
+
}
|
|
2825
|
+
if (temp.errorMessage && messages[temp.errorMessage]) {
|
|
2826
|
+
temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
|
|
2827
|
+
}
|
|
2828
|
+
if (temp.placeholder && messages[temp.placeholder]) {
|
|
2829
|
+
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
2830
|
+
}
|
|
2831
|
+
return true;
|
|
2832
|
+
});
|
|
2833
|
+
});
|
|
2834
|
+
return section;
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
injectColLabelSection = (section) => {
|
|
2838
|
+
_.forEach(section.inputFields, (inputField) => {
|
|
2839
|
+
const temp = inputField;
|
|
2840
|
+
if (temp.type === 'popover') {
|
|
2841
|
+
temp.content.sections = this.injectSections(temp.content.sections);
|
|
2842
|
+
temp.value.sections = this.injectSections(temp.value.sections);
|
|
2843
|
+
return true;
|
|
2844
|
+
}
|
|
2845
|
+
temp.injectedEvents = {};
|
|
2846
|
+
_.forEach(inputField.supportedEvents, (event) => {
|
|
2847
|
+
temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
|
|
2848
|
+
});
|
|
2849
|
+
//
|
|
2850
|
+
if (temp.type === 'icon') {
|
|
2851
|
+
return true;
|
|
2852
|
+
}
|
|
2853
|
+
if (temp.value && messages[temp.value]) {
|
|
2854
|
+
temp.value = this.props.intl.formatMessage(messages[temp.value]);
|
|
2855
|
+
}
|
|
2856
|
+
if (temp.label && messages[temp.label]) {
|
|
2857
|
+
temp.label = this.props.intl.formatMessage(messages[temp.label]);
|
|
2858
|
+
}
|
|
2859
|
+
if (temp.errorMessage && messages[temp.errorMessage]) {
|
|
2860
|
+
temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
|
|
2861
|
+
}
|
|
2862
|
+
if (temp.placeholder && messages[temp.placeholder]) {
|
|
2863
|
+
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
2864
|
+
}
|
|
2865
|
+
return true;
|
|
2866
|
+
});
|
|
2867
|
+
_.forEach(section.actionFields, (actionField) => {
|
|
2868
|
+
const temp = actionField;
|
|
2869
|
+
if (temp.type === 'popover') {
|
|
2870
|
+
temp.content.sections = this.injectSections(temp.content.sections);
|
|
2871
|
+
temp.value.sections = this.injectSections(temp.value.sections);
|
|
2872
|
+
return true;
|
|
2873
|
+
}
|
|
2874
|
+
temp.injectedEvents = {};
|
|
2875
|
+
_.forEach(actionField.supportedEvents, (event) => {
|
|
2876
|
+
temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
|
|
2877
|
+
});
|
|
2878
|
+
//
|
|
2879
|
+
if (temp.type === 'icon') {
|
|
2880
|
+
return true;
|
|
2881
|
+
}
|
|
2882
|
+
if (temp.value && messages[temp.value]) {
|
|
2883
|
+
temp.value = this.props.intl.formatMessage(messages[temp.value]);
|
|
2884
|
+
}
|
|
2885
|
+
if (temp.label && messages[temp.label]) {
|
|
2886
|
+
temp.label = this.props.intl.formatMessage(messages[temp.label]);
|
|
2887
|
+
}
|
|
2888
|
+
if (temp.errorMessage && messages[temp.errorMessage]) {
|
|
2889
|
+
temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
|
|
2890
|
+
}
|
|
2891
|
+
if (temp.placeholder && messages[temp.placeholder]) {
|
|
2892
|
+
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
2893
|
+
}
|
|
2894
|
+
return true;
|
|
2895
|
+
});
|
|
2896
|
+
return section;
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
injectSections = (sections) => {
|
|
2900
|
+
_.forEach(sections, (section) => {
|
|
2901
|
+
let temp = section;
|
|
2902
|
+
if (temp.type === 'col-label') {
|
|
2903
|
+
temp = this.injectColLabelSection(temp);
|
|
2904
|
+
} else if (section.type === 'multicols') {
|
|
2905
|
+
temp = this.injectMultiColSection(temp);
|
|
2906
|
+
} else if (section.type === 'parent') {
|
|
2907
|
+
temp = this.injectSections(temp.childSections);
|
|
2908
|
+
}
|
|
2909
|
+
});
|
|
2910
|
+
return sections;
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
injectParentSection = (section) => {
|
|
2914
|
+
_.forEach(section.childSections, (childSection) => {
|
|
2915
|
+
let temp = childSection;
|
|
2916
|
+
if (temp.type === 'col-label') {
|
|
2917
|
+
temp = this.injectColLabelSection(temp);
|
|
2918
|
+
} else if (section.type === 'multicols') {
|
|
2919
|
+
temp = this.injectMultiColSection(temp);
|
|
2920
|
+
} else if (section.type === 'parent') {
|
|
2921
|
+
temp = this.injectParentSection(temp);
|
|
2922
|
+
}
|
|
2923
|
+
});
|
|
2924
|
+
return section;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
saveFormData = (passedData) => {
|
|
2928
|
+
//Logic to save in db etc
|
|
2929
|
+
// const isValidated = this.validateFormData(formData);
|
|
2930
|
+
//
|
|
2931
|
+
// if (!isValidated) {
|
|
2932
|
+
// return;
|
|
2933
|
+
// }
|
|
2934
|
+
//if (!this.state.startValidation) {
|
|
2935
|
+
// this.saveValidationData();
|
|
2936
|
+
// return;
|
|
2937
|
+
//}
|
|
2938
|
+
|
|
2939
|
+
if (this.state.gettingFormData) {
|
|
2940
|
+
|
|
2941
|
+
const response = {
|
|
2942
|
+
action: "getFormData",
|
|
2943
|
+
postAction: this.state.getFormDataValue || 'next',
|
|
2944
|
+
value: this.transformFormData(passedData),
|
|
2945
|
+
validity: this.state.isFormValid,
|
|
2946
|
+
};
|
|
2947
|
+
|
|
2948
|
+
this.setState({checkValidation: true});
|
|
2949
|
+
if (this.props.location.query.module === 'library' && this.props.isGetFormData) {
|
|
2950
|
+
this.props.getFormSubscriptionData(response);
|
|
2951
|
+
}
|
|
2952
|
+
parent.postMessage(JSON.stringify(response), "*");
|
|
2953
|
+
this.setState({gettingFormData: false, startValidation: false});
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
const formData = _.cloneDeep(passedData);
|
|
2957
|
+
console.log('Saving form data', JSON.stringify(formData), this.state.tabCount);
|
|
2958
|
+
const obj = {};
|
|
2959
|
+
obj.versions = {
|
|
2960
|
+
base: {},
|
|
2961
|
+
history: [],
|
|
2962
|
+
};
|
|
2963
|
+
if (this.state.isEdit) {
|
|
2964
|
+
obj._id = this.props.Email.templateDetails._id;
|
|
2965
|
+
}
|
|
2966
|
+
obj.type = 'EMAIL';
|
|
2967
|
+
const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
2968
|
+
let baseKey = -1;
|
|
2969
|
+
//let saveCount = 0;
|
|
2970
|
+
|
|
2971
|
+
_.forEach(formData, (data, index) => {
|
|
2972
|
+
const newdata = data;
|
|
2973
|
+
|
|
2974
|
+
if (!isNaN(index) && newdata) {
|
|
2975
|
+
const baseLangTabKey = newdata[baseLanguage].tabKey;
|
|
2976
|
+
newdata.tabKey = baseLangTabKey;
|
|
2977
|
+
newdata.activeTab = baseLanguage;
|
|
2978
|
+
if (newdata.base) {
|
|
2979
|
+
baseKey = baseLangTabKey;
|
|
2980
|
+
}
|
|
2981
|
+
_.forEach(newdata.selectedLanguages, (language) => {
|
|
2982
|
+
// console.log('all data 3', newdata[language], language, this.state.currentTab, index, (index + 1), (index + 1) === this.state.currentTab, newdata[language].is_drag_drop);
|
|
2983
|
+
// if (newdata[language].is_drag_drop && ((parseInt(index, 10) + 1) === this.state.currentTab)) {
|
|
2984
|
+
//
|
|
2985
|
+
// saveCount += 1;
|
|
2986
|
+
// }
|
|
2987
|
+
if (newdata[language].is_drag_drop) {
|
|
2988
|
+
delete newdata[language].edmeditorsrc;
|
|
2989
|
+
}
|
|
2990
|
+
});
|
|
2991
|
+
obj.versions.history.push(newdata);
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
//const data = formData[`${this.state.currentTab - 1}`];
|
|
2995
|
+
obj.name = formData['template-name'];
|
|
2996
|
+
obj.versions.base = formData.base;
|
|
2997
|
+
obj.versions.base.tabKey = baseKey;
|
|
2998
|
+
obj.versions.base.activeTab = baseLanguage;
|
|
2999
|
+
_.forEach(obj.versions.base.selectedLanguages, (language) => {
|
|
3000
|
+
if (obj.versions.base[language].is_drag_drop) {
|
|
3001
|
+
delete obj.versions.base[language].edmeditorsrc;
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
|
|
3005
|
+
// if (saveCount === 0) {
|
|
3006
|
+
this.props.actions.createTemplate(obj);
|
|
3007
|
+
// } else {
|
|
3008
|
+
// this.setState({saveObj: obj, targetSaveCount: saveCount, mode: "save", saveEdmDataMode: 'save'}, () => {
|
|
3009
|
+
// _.forEach(data.selectedLanguages, (language, langIndex) => {
|
|
3010
|
+
// if (data[language].is_drag_drop) {
|
|
3011
|
+
// console.log('saving edm template', document.getElementById("edmeditor"), `edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
|
|
3012
|
+
// const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
|
|
3013
|
+
// win.postMessage("saveProject", '*');
|
|
3014
|
+
// }
|
|
3015
|
+
// });
|
|
3016
|
+
// });
|
|
3017
|
+
// }
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
handleOk = () => {
|
|
3021
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
3022
|
+
const activeLangTab = formData[`${this.state.currentTab - 1}`].activeTab;
|
|
3023
|
+
const langIndex = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
|
|
3024
|
+
|
|
3025
|
+
this.setState({mode: "switchEditor"}, () => {
|
|
3026
|
+
console.log('posting message for switching editor', `edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
|
|
3027
|
+
const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
|
|
3028
|
+
win.postMessage("saveProject", '*');
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
handleCancel = () => {
|
|
3033
|
+
this.setState({ showConfirmationModal: false });
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
handleCancelModal = () => {
|
|
3037
|
+
this.setState({showModal: false});
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
openFileDialog() {
|
|
3041
|
+
document.getElementById("fileName").click();
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
toggleEdmEmailTemplateSelection = () => {
|
|
3045
|
+
|
|
3046
|
+
this.setState( (prevState) => ({
|
|
3047
|
+
showEdmEmailTemplates: !prevState.showEdmEmailTemplates}), () => {
|
|
3048
|
+
if (this.state.showEdmEmailTemplates) {
|
|
3049
|
+
this.props.templatesActions.getEdmDefaultTemplates();
|
|
3050
|
+
}
|
|
3051
|
+
});
|
|
3052
|
+
};
|
|
3053
|
+
|
|
3054
|
+
handleEdmDefaultTemplateSelection = (isSelected, id) => {
|
|
3055
|
+
if (isSelected) {
|
|
3056
|
+
const data = _.find(this.props.Templates.cmsTemplates, {_id: id});
|
|
3057
|
+
// const type = this.props.location.query.type;
|
|
3058
|
+
// const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
3059
|
+
// const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : true;
|
|
3060
|
+
// const isEdmSupport = (this.props.location.query.isEdmSupport) ? this.props.location.query.isEdmSupport : true;
|
|
3061
|
+
// let getQuery = '';
|
|
3062
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
3063
|
+
|
|
3064
|
+
this.props.actions.getCmsSetting('edm', data.versions.base.drag_drop_id, 'create', this.state.formData[this.state.currentTab - 1].activeTab, isEdmSupport);
|
|
3065
|
+
// this.props.templatesActions.setEdmTemplate(data);
|
|
3066
|
+
this.toggleEdmEmailTemplateSelection();
|
|
3067
|
+
// if (type && type.toLowerCase() === 'email') {
|
|
3068
|
+
// getQuery = (type === 'embedded') ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport};
|
|
3069
|
+
// } else {
|
|
3070
|
+
// getQuery = (type === 'embedded') ? {type: 'embedded', module} : {module};
|
|
3071
|
+
// }
|
|
3072
|
+
// this.props.router.push({
|
|
3073
|
+
// pathname: `/${this.state.channel.toLowerCase()}/create`,
|
|
3074
|
+
// query: getQuery,
|
|
3075
|
+
// });
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
|
|
3079
|
+
renderConfirmationModal() {
|
|
3080
|
+
const modal = (
|
|
3081
|
+
<Modal
|
|
3082
|
+
visible={this.state.showConfirmationModal}
|
|
3083
|
+
title={this.props.intl.formatMessage(messages.switchEditor)}
|
|
3084
|
+
onOk={this.handleOk}
|
|
3085
|
+
onCancel={this.handleCancel}
|
|
3086
|
+
footer={[
|
|
3087
|
+
<CapButton key="back" onClick={this.handleCancel}>
|
|
3088
|
+
{this.props.intl.formatMessage(messages.cancel)}
|
|
3089
|
+
</CapButton>,
|
|
3090
|
+
<CapButton key="submit" type="primary" onClick={this.handleOk}>
|
|
3091
|
+
{this.props.intl.formatMessage(messages.yes)}
|
|
3092
|
+
</CapButton>,
|
|
3093
|
+
]}
|
|
3094
|
+
>
|
|
3095
|
+
<p>{this.props.intl.formatMessage(messages.edmSwtichMessage)}</p>
|
|
3096
|
+
<p>{this.props.intl.formatMessage(messages.edmSwitchAcceptText)}</p>
|
|
3097
|
+
</Modal>);
|
|
3098
|
+
return modal;
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
render() {
|
|
3102
|
+
// const pageHeading = (this.state.isEdit) ? this.props.intl.formatMessage(messages.editHeading) : this.props.intl.formatMessage(messages.createHeading);
|
|
3103
|
+
// const actionComponents = '';
|
|
3104
|
+
|
|
3105
|
+
const filterContent = (
|
|
3106
|
+
<div className="action-container" style={{ display: 'inline-flex', width: '100%'}}>
|
|
3107
|
+
<div style={{ marginTop: '8px', width: '50%'}}>
|
|
3108
|
+
<CapInput
|
|
3109
|
+
className="search-text"
|
|
3110
|
+
style={{width: '210px'}}
|
|
3111
|
+
placeholder={this.props.intl.formatMessage(messages.searchText)}
|
|
3112
|
+
prefix={<i className="material-icons" style={{color: '#707070', fontSize: '16px'}}>search</i>}
|
|
3113
|
+
value={this.state.searchText}
|
|
3114
|
+
onChange={(e) => this.searchAsset(e.target.value)}
|
|
3115
|
+
/>
|
|
3116
|
+
</div>
|
|
3117
|
+
<div style={{ textAlign: 'right', marginTop: '16px', width: '50%'}}>
|
|
3118
|
+
<span className="select-font">
|
|
3119
|
+
<FormattedMessage {...messages.sortby} />
|
|
3120
|
+
</span>
|
|
3121
|
+
<Select
|
|
3122
|
+
style={{marginLeft: '8px', width: 120, borderLeft: 'none', borderRight: 'none', borderTop: 'none'}}
|
|
3123
|
+
className="select-font"
|
|
3124
|
+
defaultValue="Most Recent"
|
|
3125
|
+
onChange={this.handleSortingChange}
|
|
3126
|
+
>
|
|
3127
|
+
<Option className="select-font" value="Most Recent">
|
|
3128
|
+
<FormattedMessage {...messages.mostRecent} />
|
|
3129
|
+
</Option>
|
|
3130
|
+
<Option className="select-font" value="Alphabetically">
|
|
3131
|
+
<FormattedMessage {...messages.alphabetically} />
|
|
3132
|
+
</Option>
|
|
3133
|
+
</Select>
|
|
3134
|
+
</div>
|
|
3135
|
+
</div>
|
|
3136
|
+
);
|
|
3137
|
+
const schema = this.state.schema;
|
|
3138
|
+
const spinning = this.state.loading || (this.props.Email && "createTemplateInProgress" in this.props.Email && this.props.Email.createTemplateInProgress) || (this.props.Email.assetUploading !== undefined && this.props.Email.assetUploading);
|
|
3139
|
+
const previewHeader = (<h3>{this.props.intl.formatMessage(messages.h3emailPreview)}</h3>);
|
|
3140
|
+
const imagePreviewHeader = (<h3>{this.props.intl.formatMessage(messages.h3imageSelection)}</h3>);
|
|
3141
|
+
const imagePreviewContent = (
|
|
3142
|
+
<div>
|
|
3143
|
+
<div>
|
|
3144
|
+
<form encType="multipart/form-data" id="myForm">
|
|
3145
|
+
<input style={{ display: 'none'}} id="fileName" type="file" onChange={(e) => this.uploadImages(e, {files: e.target.files})} accept="image/*" />
|
|
3146
|
+
<CapButton type={'secondary'} onClick={(e) => this.openFileDialog(e)} style={{float: 'right', marginRight: '24px'}}>
|
|
3147
|
+
<FormattedMessage {...messages.upload} />
|
|
3148
|
+
</CapButton>
|
|
3149
|
+
</form>
|
|
3150
|
+
</div>
|
|
3151
|
+
<Pagination onPageChange={() => { this.fetchAllAssets({getNextPage: true}); }} paginationSelector="pagination-container">
|
|
3152
|
+
<CardGrid
|
|
3153
|
+
listItem={this.prepareImageData()}
|
|
3154
|
+
filterContent={filterContent}
|
|
3155
|
+
onHoverItem={this.handleOnHoverItem}
|
|
3156
|
+
onItemClick={this.handleOnItemClick}
|
|
3157
|
+
colNumber={2}
|
|
3158
|
+
enablePagination
|
|
3159
|
+
/>
|
|
3160
|
+
</Pagination>
|
|
3161
|
+
</div>
|
|
3162
|
+
);
|
|
3163
|
+
|
|
3164
|
+
if (!this.props.Global.currentOrgDetails || !this.props.Global.currentOrgDetails.basic_details) {
|
|
3165
|
+
return (<div>Loading...</div>);
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
let loaderText = this.props.Email.createTemplateInProgress ? this.props.intl.formatMessage(messages.saveTemplateLoader) : this.props.intl.formatMessage(messages.templateLoader);
|
|
3169
|
+
if (this.props.Email.assetUploading) {
|
|
3170
|
+
loaderText = this.props.intl.formatMessage(messages.uploadingImage);
|
|
3171
|
+
}
|
|
3172
|
+
let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
|
|
3173
|
+
if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
|
|
3174
|
+
tags = this.props.supportedTags;
|
|
3175
|
+
}
|
|
3176
|
+
return (
|
|
3177
|
+
<div className="email-container">
|
|
3178
|
+
<Helmet
|
|
3179
|
+
title={this.props.intl.formatMessage(messages.Email)}
|
|
3180
|
+
meta={[
|
|
3181
|
+
{ name: 'description', content: this.props.intl.formatMessage(messages.descriptionEmail) },
|
|
3182
|
+
]}
|
|
3183
|
+
/>
|
|
3184
|
+
{/* <PageHeader pageHeading={pageHeading} /> */}
|
|
3185
|
+
<Spin tip={loaderText} spinning={spinning}>
|
|
3186
|
+
{this.props.location.query.type !== 'embedded' && <Row>
|
|
3187
|
+
<Col span={24}>
|
|
3188
|
+
{this.props.location.query.type !== "embedded" &&
|
|
3189
|
+
<Breadcrumb>
|
|
3190
|
+
<BreadcrumbItem>{this.props.intl.formatMessage(messages.campaigns)}</BreadcrumbItem>
|
|
3191
|
+
<BreadcrumbItem>{this.props.intl.formatMessage(messages.creatives)}</BreadcrumbItem>
|
|
3192
|
+
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Email)}</BreadcrumbItem>
|
|
3193
|
+
</Breadcrumb>
|
|
3194
|
+
}
|
|
3195
|
+
</Col>
|
|
3196
|
+
</Row>}
|
|
3197
|
+
<Row>
|
|
3198
|
+
<Col>
|
|
3199
|
+
{/* <input type="file" id="filename" style={{ display: 'none'}} accept="text/html" onChange={(event) => this.openFile(event)} /><br/> */}
|
|
3200
|
+
{/* <CKEditor
|
|
3201
|
+
content={this.state.content}
|
|
3202
|
+
config={{}}
|
|
3203
|
+
events={this.state.events}
|
|
3204
|
+
/> */}
|
|
3205
|
+
{/* { (!this.props.Email.fetchingCmsSettings && !this.props.Email.fetchingCmsSettingsError &&
|
|
3206
|
+
!_.isEmpty(this.props.Email.CmsSettings) && this.props.Email.CmsSettings.url) ?
|
|
3207
|
+
<EDMEditor
|
|
3208
|
+
content={'Hello World'}
|
|
3209
|
+
getEditorInstanse={this.getEditorInstanse}
|
|
3210
|
+
edmSrc={this.props.Email.CmsSettings.url}
|
|
3211
|
+
/> : ''
|
|
3212
|
+
} */}
|
|
3213
|
+
{ !_.isEmpty(schema) && (this.state.formData[0] || this.state.formData["0"]) ?
|
|
3214
|
+
<FormBuilder
|
|
3215
|
+
schema={schema}
|
|
3216
|
+
onSubmit={this.saveFormData}
|
|
3217
|
+
onChange={this.onFormDataChange}
|
|
3218
|
+
currentTab={this.state.currentTab}
|
|
3219
|
+
parent={this}
|
|
3220
|
+
formData={_.cloneDeep(this.state.formData)}
|
|
3221
|
+
location={this.props.location}
|
|
3222
|
+
tabKey={this.state.tabKey}
|
|
3223
|
+
tags={tags}
|
|
3224
|
+
tagModule={this.props.getDefaultTags}
|
|
3225
|
+
injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
|
|
3226
|
+
onFormValidityChange={this.setFormValidity}
|
|
3227
|
+
handleCancelModal={this.handleCancelModal}
|
|
3228
|
+
usingTabContainer
|
|
3229
|
+
checkValidation={this.state.checkValidation}
|
|
3230
|
+
onContextChange={this.handleOnTagsContextChange}
|
|
3231
|
+
tabCount={this.state.tabCount}
|
|
3232
|
+
isNewVersionFlow
|
|
3233
|
+
modal={this.state.modalContent}
|
|
3234
|
+
showModal={this.state.showModal}
|
|
3235
|
+
isEdit={this.state.isEdit}
|
|
3236
|
+
iframeParent={parent}
|
|
3237
|
+
router={this.props.router}
|
|
3238
|
+
baseLanguage={this.props.Global.currentOrgDetails.basic_details.base_language}
|
|
3239
|
+
supportedLanguages={this.props.Global.currentOrgDetails.basic_details.supported_languages}
|
|
3240
|
+
isSchemaChanged={this.state.isSchemaChanged}
|
|
3241
|
+
cmsTemplates={this.props.Templates.cmsTemplates}
|
|
3242
|
+
getCmsTemplatesInProgress={this.props.Templates.getCmsTemplatesInProgress}
|
|
3243
|
+
showEdmEmailTemplates={this.state.showEdmEmailTemplates}
|
|
3244
|
+
toggleEdmEmailTemplateSelection={this.toggleEdmEmailTemplateSelection}
|
|
3245
|
+
handleEdmDefaultTemplateSelection={this.handleEdmDefaultTemplateSelection}
|
|
3246
|
+
setModalContent={this.setModalContent}
|
|
3247
|
+
addLanguageType={this.state.addLanguageType}
|
|
3248
|
+
startValidation={this.state.startValidation}
|
|
3249
|
+
getValidationData={this.saveValidationData}
|
|
3250
|
+
saveForm={this.state.saveForm}
|
|
3251
|
+
stopValidation={this.stopValidation}
|
|
3252
|
+
/> : ''}
|
|
3253
|
+
</Col>
|
|
3254
|
+
</Row>
|
|
3255
|
+
</Spin>
|
|
3256
|
+
{!_.isEmpty(this.state.formData[(this.state.currentTab - 1)]) && <EmailPreview
|
|
3257
|
+
header={previewHeader}
|
|
3258
|
+
content={this.state.formData[(this.state.currentTab - 1)][this.state.formData[(this.state.currentTab - 1)].activeTab] ? this.state.formData[(this.state.currentTab - 1)][this.state.formData[(this.state.currentTab - 1)].activeTab][`template-content`] : ''}
|
|
3259
|
+
show={this.state.showEmailPreview}
|
|
3260
|
+
device={this.state.device}
|
|
3261
|
+
handleClose={this.toggleEmailPreview}
|
|
3262
|
+
changePreviewDevice={this.changePreviewDevice}
|
|
3263
|
+
/>}
|
|
3264
|
+
<ImagePreview
|
|
3265
|
+
header={imagePreviewHeader}
|
|
3266
|
+
content={imagePreviewContent}
|
|
3267
|
+
show={this.state.showImageSelectionBox}
|
|
3268
|
+
handleClose={this.handleImagePreviewClose}
|
|
3269
|
+
isLoading={this.props.Email.fetchingAllAssets}
|
|
3270
|
+
/>
|
|
3271
|
+
{this.state.showConfirmationModal && this.renderConfirmationModal()}
|
|
3272
|
+
</div>
|
|
3273
|
+
);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
Email.propTypes = {
|
|
3278
|
+
actions: PropTypes.object.isRequired,
|
|
3279
|
+
Email: PropTypes.object,
|
|
3280
|
+
params: PropTypes.object,
|
|
3281
|
+
router: PropTypes.object,
|
|
3282
|
+
Templates: PropTypes.object,
|
|
3283
|
+
globalActions: PropTypes.object,
|
|
3284
|
+
location: PropTypes.object,
|
|
3285
|
+
intl: intlShape.isRequired,
|
|
3286
|
+
metaEntities: PropTypes.object,
|
|
3287
|
+
Global: PropTypes.object,
|
|
3288
|
+
templatesActions: PropTypes.object,
|
|
3289
|
+
route: PropTypes.object,
|
|
3290
|
+
templateData: PropTypes.object,
|
|
3291
|
+
isGetFormData: PropTypes.bool,
|
|
3292
|
+
getFormSubscriptionData: PropTypes.func,
|
|
3293
|
+
supportedTags: PropTypes.array,
|
|
3294
|
+
getDefaultTags: PropTypes.string,
|
|
3295
|
+
injectedTags: PropTypes.object,
|
|
3296
|
+
};
|
|
3297
|
+
|
|
3298
|
+
const mapStateToProps = createStructuredSelector({
|
|
3299
|
+
Email: makeSelectEmail(),
|
|
3300
|
+
Templates: makeSelectTemplates(),
|
|
3301
|
+
metaEntities: makeSelectMetaEntities(),
|
|
3302
|
+
Global: makeSelectAuthenticated(),
|
|
3303
|
+
injectedTags: setInjectedTags(),
|
|
3304
|
+
});
|
|
3305
|
+
|
|
3306
|
+
function mapDispatchToProps(dispatch) {
|
|
3307
|
+
return {
|
|
3308
|
+
actions: bindActionCreators(actions, dispatch),
|
|
3309
|
+
globalActions: bindActionCreators(globalActions, dispatch),
|
|
3310
|
+
templatesActions: bindActionCreators(templatesActions, dispatch),
|
|
3311
|
+
};
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
|
3315
|
+
const withReducer = injectReducer({ key: 'email', reducer });
|
|
3316
|
+
const withSaga = injectSaga({ key: 'email', saga: emailSaga });
|
|
3317
|
+
const withTemplateSaga = injectSaga({ key: 'templates', saga: templateSaga });
|
|
3318
|
+
|
|
3319
|
+
export default compose(
|
|
3320
|
+
UserIsAuthenticated,
|
|
3321
|
+
withReducer,
|
|
3322
|
+
withSaga,
|
|
3323
|
+
withTemplateSaga,
|
|
3324
|
+
withConnect,
|
|
3325
|
+
)(injectIntl(Email));
|