@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,1071 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Create
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { connect } from 'react-redux';
|
|
11
|
+
import Helmet from 'react-helmet';
|
|
12
|
+
import { bindActionCreators, compose } from 'redux';
|
|
13
|
+
import { createStructuredSelector } from 'reselect';
|
|
14
|
+
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
15
|
+
import _ from 'lodash';
|
|
16
|
+
import { Menu, Dropdown } from 'antd';
|
|
17
|
+
import { CapRow, CapColumn, CapButton, CapCard, CapSpinner } from '@capillarytech/cap-react-ui-library';
|
|
18
|
+
import makeSelectCreate, {makeSelectTemplates, getAssetDetails, getContentAssetDetails} from './selectors';
|
|
19
|
+
import * as actions from './actions';
|
|
20
|
+
import richmediaschema from './richmediaschema';
|
|
21
|
+
import './_createRichmedia.scss';
|
|
22
|
+
import messages from './messages';
|
|
23
|
+
import * as globalActions from '../../../../containers/Cap/actions';
|
|
24
|
+
import {getMessageObject} from '../../../../utils/messageUtils';
|
|
25
|
+
import FormBuilder from '../../../../components/FormBuilder';
|
|
26
|
+
import Header from '../../../../components/Header';
|
|
27
|
+
import WechatRichmediaTemplatePreview from '../../../../components/TemplatePreview/WechatRichmediaTemplatePreview';
|
|
28
|
+
import injectSaga from '../../../../utils/injectSaga';
|
|
29
|
+
import injectReducer from '../../../../utils/injectReducer';
|
|
30
|
+
import reducer from './reducer';
|
|
31
|
+
import { richMediaTemplatesSaga } from './sagas';
|
|
32
|
+
import { UserIsAuthenticated } from '../../../../utils/authWrapper';
|
|
33
|
+
import { createQueryString } from '../../../../utils/common';
|
|
34
|
+
|
|
35
|
+
const MenuItem = Menu.Item;
|
|
36
|
+
export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
37
|
+
constructor(props) {
|
|
38
|
+
super(props);
|
|
39
|
+
let templateData = {};
|
|
40
|
+
let isEdit = false;
|
|
41
|
+
let totalContentBlocks = 0;
|
|
42
|
+
let mediaId = "";
|
|
43
|
+
let templateId = "";
|
|
44
|
+
let templateName = "";
|
|
45
|
+
let isIframe = false;
|
|
46
|
+
if (props.location.query.type === "embedded" && props.location.query.module === "outbound") {
|
|
47
|
+
isIframe = true;
|
|
48
|
+
}
|
|
49
|
+
if (props.mode === 'EDIT') {
|
|
50
|
+
templateData = props.templateData;
|
|
51
|
+
isEdit = true;
|
|
52
|
+
totalContentBlocks = props.totalContentBlocks;
|
|
53
|
+
mediaId = props.mediaId;
|
|
54
|
+
templateId = props.templateId;
|
|
55
|
+
templateName = props.templateName;
|
|
56
|
+
}
|
|
57
|
+
this.state = {
|
|
58
|
+
richmediaSchema: richmediaschema,
|
|
59
|
+
map: {
|
|
60
|
+
"image-value": {
|
|
61
|
+
onUpload: this.uploadImage,
|
|
62
|
+
},
|
|
63
|
+
"title-value": {
|
|
64
|
+
onChange: this.onFormDataChange,
|
|
65
|
+
},
|
|
66
|
+
"author-value": {
|
|
67
|
+
onChange: this.onFormDataChange,
|
|
68
|
+
},
|
|
69
|
+
"cover-abstract-value": {
|
|
70
|
+
onChange: this.onFormDataChange,
|
|
71
|
+
},
|
|
72
|
+
"source-link-value": {
|
|
73
|
+
onChange: this.onFormDataChange,
|
|
74
|
+
},
|
|
75
|
+
"content-value": {
|
|
76
|
+
getEditorInstanse: this.getEditorInstanse,
|
|
77
|
+
onContentChange: this.onContentChange,
|
|
78
|
+
onFocusOut: this.focusOutFromCkEditor,
|
|
79
|
+
onFocusIn: this.focusInFromCkeditor,
|
|
80
|
+
},
|
|
81
|
+
"show-cover-pic-value": {
|
|
82
|
+
onChange: this.onFormDataChange,
|
|
83
|
+
},
|
|
84
|
+
"post-comments-value": {
|
|
85
|
+
onChange: this.onFormDataChange,
|
|
86
|
+
},
|
|
87
|
+
"content-image-value": {
|
|
88
|
+
onUpload: this.uploadImage,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
isEdit,
|
|
92
|
+
isFormValid: true,
|
|
93
|
+
templateData,
|
|
94
|
+
currentContentId: 0,
|
|
95
|
+
totalContentBlocks,
|
|
96
|
+
templateName,
|
|
97
|
+
templateId,
|
|
98
|
+
mediaId,
|
|
99
|
+
isIframe,
|
|
100
|
+
hovered: false,
|
|
101
|
+
loading: false,
|
|
102
|
+
showPreview: false,
|
|
103
|
+
focusOut: true,
|
|
104
|
+
showModal: false,
|
|
105
|
+
modalContent: {
|
|
106
|
+
title: this.props.intl.formatMessage(messages.modalTitle),
|
|
107
|
+
body: this.props.intl.formatMessage(messages.modalBody),
|
|
108
|
+
type: 'confirm',
|
|
109
|
+
id: 'template-back-confirm-modal',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
this.onFormDataChange = this.onFormDataChange.bind(this);
|
|
113
|
+
this.cancelHandler = this.cancelHandler.bind(this);
|
|
114
|
+
this.templateNameHandler = this.templateNameHandler.bind(this);
|
|
115
|
+
this.saveHandler = this.saveHandler.bind(this);
|
|
116
|
+
this.previewHandler = this.previewHandler.bind(this);
|
|
117
|
+
this.setFormValidity = this.setFormValidity.bind(this);
|
|
118
|
+
this.injectEvents = this.injectEvents.bind(this);
|
|
119
|
+
this.injectSections = this.injectSections.bind(this);
|
|
120
|
+
this.injectContainer = this.injectContainer.bind(this);
|
|
121
|
+
this.injectColLabelSection = this.injectColLabelSection.bind(this);
|
|
122
|
+
this.injectMultiColSection = this.injectMultiColSection.bind(this);
|
|
123
|
+
this.getMappedEvent = this.getMappedEvent.bind(this);
|
|
124
|
+
this.updateTotalContentBlocks = this.updateTotalContentBlocks.bind(this);
|
|
125
|
+
this.insertTemplateData = this.insertTemplateData.bind(this);
|
|
126
|
+
this.uploadImage = this.uploadImage.bind(this);
|
|
127
|
+
this.returnCardLayout = this.returnCardLayout.bind(this);
|
|
128
|
+
this.menuOnClickEvent = this.menuOnClickEvent.bind(this);
|
|
129
|
+
this.showErrorMessage = this.showErrorMessage.bind(this);
|
|
130
|
+
this.returnCurrentFormData = this.returnCurrentFormData.bind(this);
|
|
131
|
+
this.returnCurrentSchema = this.returnCurrentSchema.bind(this);
|
|
132
|
+
this.handleFrameTasks = this.handleFrameTasks.bind(this);
|
|
133
|
+
this.getCurrentWindow = this.getCurrentWindow.bind(this);
|
|
134
|
+
// this.startLoading = this.startLoading.bind(this);
|
|
135
|
+
this.moveToTemplates = this.moveToTemplates.bind(this);
|
|
136
|
+
this.showNext = this.showNext.bind(this);
|
|
137
|
+
this.prepareWeChatRichmediaPreviewData = this.prepareWeChatRichmediaPreviewData.bind(this);
|
|
138
|
+
this.injectMessages = this.injectMessages.bind(this);
|
|
139
|
+
}
|
|
140
|
+
componentWillMount = () => {
|
|
141
|
+
if (_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
142
|
+
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
143
|
+
const type = this.props.location.query.type;
|
|
144
|
+
this.props.router.push({
|
|
145
|
+
pathname: `/wechat`,
|
|
146
|
+
search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module}) });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
componentDidMount = () => {
|
|
150
|
+
if (!this.state.isEdit) {
|
|
151
|
+
this.updateTotalContentBlocks();
|
|
152
|
+
}
|
|
153
|
+
if (this.state.isIframe) {
|
|
154
|
+
window.addEventListener("message", this.handleFrameTasks);
|
|
155
|
+
this.showNext();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
componentWillReceiveProps = (nextProps) => {
|
|
159
|
+
if (nextProps.Create.saveTemplateRes && !_.isEmpty(nextProps.Create.saveTemplateRes) && nextProps.Create.saveTemplateSuccess && !_.isEqual(nextProps.Create.saveTemplateRes, this.props.Create.saveTemplateRes)) {
|
|
160
|
+
this.setState({loading: false});
|
|
161
|
+
const message = getMessageObject('success', this.props.intl.formatMessage(messages.saveSuccess), true);
|
|
162
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
163
|
+
const type = nextProps.location.query.type;
|
|
164
|
+
nextProps.router.push({
|
|
165
|
+
pathname: `/wechat`,
|
|
166
|
+
query: type === 'embedded' ? {type: 'embedded'} : {},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (!nextProps.Create.saveTemplateSuccess && nextProps.Create.saveTemplateSuccess !== undefined && nextProps.Create.saveTemplateErrorMessage && nextProps.Create.saveTemplateErrorMessage !== this.props.Create.saveTemplateErrorMessage) {
|
|
170
|
+
this.setState({loading: false});
|
|
171
|
+
this.showErrorMessage(nextProps.Create.saveTemplateErrorMessage);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
componentWillUnmount() {
|
|
175
|
+
if (this.state.isIframe) {
|
|
176
|
+
window.removeEventListener("message", this.handleFrameTasks);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
onHover = (data) => {
|
|
180
|
+
this.setState({hovered: data});
|
|
181
|
+
}
|
|
182
|
+
onHoverRemove = (data) => {
|
|
183
|
+
this.setState({hovered: data});
|
|
184
|
+
}
|
|
185
|
+
onFormDataChange = (currentFormData) => {
|
|
186
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
187
|
+
templateData[this.state.currentContentId].formData = _.cloneDeep(currentFormData);
|
|
188
|
+
this.setState({templateData});
|
|
189
|
+
}
|
|
190
|
+
onContentChange = (evt) => {
|
|
191
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
192
|
+
console.log('oncontentchange onChange ', evt, evt.editor.getData(), templateData);
|
|
193
|
+
templateData[this.state.currentContentId].formData['content-value'] = evt.editor.getData();
|
|
194
|
+
this.setState({templateData});
|
|
195
|
+
}
|
|
196
|
+
getEditorInstanse = (instance, id) => {
|
|
197
|
+
|
|
198
|
+
window.CKEDITOR.on( 'instanceReady', ( event ) => {
|
|
199
|
+
this.setState({editorInstanse: event.editor});
|
|
200
|
+
event.editor.on( 'focus', () => {
|
|
201
|
+
|
|
202
|
+
this.setState({editorInstanse: event.editor});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
//this.setState({editorInstanse: instance});
|
|
206
|
+
}
|
|
207
|
+
getMappedEvent = (id, event) => {
|
|
208
|
+
const map = this.state.map;
|
|
209
|
+
// if (!map[id] || !map[id][event]) {
|
|
210
|
+
// }
|
|
211
|
+
return map[id][event];
|
|
212
|
+
}
|
|
213
|
+
setFormValidity = (isFormValid) => {
|
|
214
|
+
this.setState({isFormValid});
|
|
215
|
+
}
|
|
216
|
+
getCurrentWindow(e) {
|
|
217
|
+
|
|
218
|
+
const response = {
|
|
219
|
+
action: e.action,
|
|
220
|
+
value: 'edit',
|
|
221
|
+
direction: e.value,
|
|
222
|
+
};
|
|
223
|
+
parent.postMessage(JSON.stringify(response), '*');
|
|
224
|
+
}
|
|
225
|
+
getFormData(e) {
|
|
226
|
+
|
|
227
|
+
const message = {
|
|
228
|
+
mediaList: this.props.templateData.templateDetails.versions.base.mediaList,
|
|
229
|
+
media_id: this.props.templateData.templateDetails.versions.base.mediaId,
|
|
230
|
+
definition: {
|
|
231
|
+
msgtype: "MPNEWS",
|
|
232
|
+
msgcontent: "RICH_MEDIA_WECHAT",
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
const data = {
|
|
236
|
+
data: message,
|
|
237
|
+
accountId: this.props.Templates && this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.id,
|
|
238
|
+
template_id: this.props.templateId,
|
|
239
|
+
Title: this.props.templateName,
|
|
240
|
+
OriginalId: this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier,
|
|
241
|
+
TopColor: "#000000",
|
|
242
|
+
touser: "{{wechat_open_id}}",
|
|
243
|
+
creative_template_id: this.props.templateId,
|
|
244
|
+
};
|
|
245
|
+
const response = {
|
|
246
|
+
action: "getFormData",
|
|
247
|
+
value: data,
|
|
248
|
+
validity: this.state.isFormValid,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
252
|
+
}
|
|
253
|
+
injectMessages(elem) {
|
|
254
|
+
const temp = elem;
|
|
255
|
+
if (temp.value && messages[temp.value]) {
|
|
256
|
+
temp.value = this.props.intl.formatMessage(messages[temp.value]);
|
|
257
|
+
}
|
|
258
|
+
if (temp.label && messages[temp.label]) {
|
|
259
|
+
temp.label = this.props.intl.formatMessage(messages[temp.label]);
|
|
260
|
+
}
|
|
261
|
+
if (temp.errorMessage && messages[temp.errorMessage]) {
|
|
262
|
+
temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
|
|
263
|
+
}
|
|
264
|
+
if (temp.placeholder && messages[temp.placeholder]) {
|
|
265
|
+
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
266
|
+
}
|
|
267
|
+
if (temp.options) {
|
|
268
|
+
_.forEach(temp.options, (option, id) => {
|
|
269
|
+
if (messages[option]) {
|
|
270
|
+
temp.options[id] = this.props.intl.formatMessage(messages[option]);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return temp;
|
|
275
|
+
}
|
|
276
|
+
showErrorMessage = (errorMessage) => {
|
|
277
|
+
const message = getMessageObject('error', errorMessage, true);
|
|
278
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
279
|
+
}
|
|
280
|
+
checkFormFieldsCount = () => {
|
|
281
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
282
|
+
let isLimitExceeded = false;
|
|
283
|
+
_.forEach(templateData, (content) => {
|
|
284
|
+
if (_.isEmpty(content)) {
|
|
285
|
+
isLimitExceeded = true;
|
|
286
|
+
}
|
|
287
|
+
if (content.formData['title-value'].length > 64) {
|
|
288
|
+
this.showErrorMessage(`${this.props.intl.formatMessage(messages.titleCharacterCount)} ${content.formData['title-value'].length - 64} characters`);
|
|
289
|
+
isLimitExceeded = true;
|
|
290
|
+
}
|
|
291
|
+
if (content.formData['author-value'].length > 8) {
|
|
292
|
+
this.showErrorMessage(`${this.props.intl.formatMessage(messages.authorCharacterCount)} ${content.formData['author-value'].length - 8} characters`);
|
|
293
|
+
isLimitExceeded = true;
|
|
294
|
+
}
|
|
295
|
+
if (content.formData['cover-abstract-value'].length > 120) {
|
|
296
|
+
this.showErrorMessage(`${this.props.intl.formatMessage(messages.coverAbstractCharacterCount)} ${content.formData['cover-abstract-value'].length - 120} characters`);
|
|
297
|
+
isLimitExceeded = true;
|
|
298
|
+
}
|
|
299
|
+
return isLimitExceeded;
|
|
300
|
+
});
|
|
301
|
+
return isLimitExceeded;
|
|
302
|
+
}
|
|
303
|
+
// startLoading(ifEdit) {
|
|
304
|
+
// if (ifEdit) {
|
|
305
|
+
// this.setState({loading: true});
|
|
306
|
+
// }
|
|
307
|
+
// }
|
|
308
|
+
moveToTemplates() {
|
|
309
|
+
|
|
310
|
+
const modalContent = {
|
|
311
|
+
title: this.props.intl.formatMessage(messages.modalTitle),
|
|
312
|
+
body: this.props.intl.formatMessage(messages.modalBody),
|
|
313
|
+
type: 'confirm',
|
|
314
|
+
id: 'template-back-confirm-modal',
|
|
315
|
+
show: true,
|
|
316
|
+
};
|
|
317
|
+
this.setState({modalContent, showModal: true});
|
|
318
|
+
}
|
|
319
|
+
handleCancelModal = () => {
|
|
320
|
+
this.setState({showModal: false});
|
|
321
|
+
}
|
|
322
|
+
showNext() {
|
|
323
|
+
|
|
324
|
+
const response = {
|
|
325
|
+
action: "showNext",
|
|
326
|
+
value: true,
|
|
327
|
+
};
|
|
328
|
+
parent.postMessage(JSON.stringify(response), '*');
|
|
329
|
+
}
|
|
330
|
+
handleFrameTasks = (e) => {
|
|
331
|
+
|
|
332
|
+
const type = e.data;
|
|
333
|
+
if (typeof type === 'object') {
|
|
334
|
+
const action = type.action;
|
|
335
|
+
switch (action) {
|
|
336
|
+
case "startLoading":
|
|
337
|
+
this.startLoading(type.edit);
|
|
338
|
+
break;
|
|
339
|
+
case "getCurrentWindow":
|
|
340
|
+
this.getCurrentWindow(type);
|
|
341
|
+
break;
|
|
342
|
+
default:
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
switch (type) {
|
|
347
|
+
case "getFormData":
|
|
348
|
+
this.getFormData(e);
|
|
349
|
+
break;
|
|
350
|
+
case "moveToTemplates":
|
|
351
|
+
|
|
352
|
+
this.moveToTemplates();
|
|
353
|
+
break;
|
|
354
|
+
default:
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
injectEvents = (schema) => {
|
|
360
|
+
const temp = schema;
|
|
361
|
+
if (temp.standalone) {
|
|
362
|
+
temp.standalone.sections = this.injectSections(temp.standalone.sections);
|
|
363
|
+
}
|
|
364
|
+
if (temp.containers) {
|
|
365
|
+
_.forEach(temp.containers, (container) => {
|
|
366
|
+
let tempContainer = container;
|
|
367
|
+
tempContainer = this.injectContainer(tempContainer);
|
|
368
|
+
return tempContainer;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return schema;
|
|
372
|
+
}
|
|
373
|
+
injectContainer = (container) => {
|
|
374
|
+
const temp = container;
|
|
375
|
+
if (temp.type === 'tabs') {
|
|
376
|
+
temp.injectedEvents = {};
|
|
377
|
+
_.forEach(temp.supportedEvents, (event) => {
|
|
378
|
+
temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
|
|
379
|
+
});
|
|
380
|
+
_.forEach(temp.panes, (pane) => {
|
|
381
|
+
const tempPane = pane;
|
|
382
|
+
tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
|
|
383
|
+
tempPane.sections = this.injectSections(tempPane.sections);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return temp;
|
|
387
|
+
}
|
|
388
|
+
injectSections = (sections) => {
|
|
389
|
+
_.forEach(sections, (section) => {
|
|
390
|
+
let temp = section;
|
|
391
|
+
if (temp.type === 'col-label') {
|
|
392
|
+
temp = this.injectColLabelSection(temp);
|
|
393
|
+
} else if (section.type === 'multicols') {
|
|
394
|
+
temp = this.injectMultiColSection(temp);
|
|
395
|
+
} else if (section.type === 'parent') {
|
|
396
|
+
temp = this.injectSections(temp.childSections);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return sections;
|
|
400
|
+
}
|
|
401
|
+
injectColLabelSection = (section) => {
|
|
402
|
+
_.forEach(section.inputFields, (inputField) => {
|
|
403
|
+
let temp = inputField;
|
|
404
|
+
temp.injectedEvents = {};
|
|
405
|
+
_.forEach(inputField.supportedEvents, (event) => {
|
|
406
|
+
temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
|
|
407
|
+
});
|
|
408
|
+
temp = this.injectMessages(temp);
|
|
409
|
+
return true;
|
|
410
|
+
});
|
|
411
|
+
_.forEach(section.actionFields, (actionField) => {
|
|
412
|
+
let temp = actionField;
|
|
413
|
+
temp.injectedEvents = {};
|
|
414
|
+
_.forEach(actionField.supportedEvents, (event) => {
|
|
415
|
+
temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
|
|
416
|
+
});
|
|
417
|
+
temp = this.injectMessages(temp);
|
|
418
|
+
return true;
|
|
419
|
+
});
|
|
420
|
+
return section;
|
|
421
|
+
}
|
|
422
|
+
injectMultiColSection = (section) => {
|
|
423
|
+
_.forEach(section.inputFields, (inputField) => {
|
|
424
|
+
_.forEach(inputField.cols, (col) => {
|
|
425
|
+
let temp = col;
|
|
426
|
+
temp.injectedEvents = {};
|
|
427
|
+
_.forEach(col.supportedEvents, (event) => {
|
|
428
|
+
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
429
|
+
});
|
|
430
|
+
temp = this.injectMessages(temp);
|
|
431
|
+
return true;
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
_.forEach(section.actionFields, (actionField) => {
|
|
435
|
+
_.forEach(actionField.cols, (col) => {
|
|
436
|
+
let temp = col;
|
|
437
|
+
temp.injectedEvents = {};
|
|
438
|
+
_.forEach(col.supportedEvents, (event) => {
|
|
439
|
+
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
440
|
+
});
|
|
441
|
+
temp = this.injectMessages(temp);
|
|
442
|
+
return true;
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
return section;
|
|
446
|
+
}
|
|
447
|
+
templateNameHandler = (ev) => {
|
|
448
|
+
const { value } = ev.target;
|
|
449
|
+
this.setState({templateName: value});
|
|
450
|
+
}
|
|
451
|
+
cancelHandler = () => {
|
|
452
|
+
const type = this.props.location.query.type;
|
|
453
|
+
this.props.router.push({
|
|
454
|
+
pathname: `/wechat`,
|
|
455
|
+
search : createQueryString(type === 'embedded' ? {type: 'embedded'} : {})
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
closeSlideBox = () => {
|
|
459
|
+
this.setState({showPreview: false});
|
|
460
|
+
}
|
|
461
|
+
deducePostCommentsData = (data) => {
|
|
462
|
+
let postCommentsData = {};
|
|
463
|
+
if (data && data.toLowerCase() === 'anyone') {
|
|
464
|
+
postCommentsData = {
|
|
465
|
+
need_open_comment: 1,
|
|
466
|
+
only_fans_can_comment: 0,
|
|
467
|
+
};
|
|
468
|
+
} else if (data && data.toLowerCase() === 'only followers') {
|
|
469
|
+
postCommentsData = {
|
|
470
|
+
need_open_comment: 1,
|
|
471
|
+
only_fans_can_comment: 1,
|
|
472
|
+
};
|
|
473
|
+
} else {
|
|
474
|
+
postCommentsData = {
|
|
475
|
+
need_open_comment: 0,
|
|
476
|
+
only_fans_can_comment: 0,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
return postCommentsData;
|
|
480
|
+
}
|
|
481
|
+
prepareMediaList = () => {
|
|
482
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
483
|
+
const mediaList = [];
|
|
484
|
+
_.forEach(templateData, (contentData) => {
|
|
485
|
+
const postCommentsData = this.deducePostCommentsData(contentData.formData['post-comments-value']);
|
|
486
|
+
const filteredContent = {
|
|
487
|
+
title: contentData.formData['title-value'],
|
|
488
|
+
author: contentData.formData['author-value'] ? contentData.formData['author-value'] : '',
|
|
489
|
+
digest: contentData.formData['cover-abstract-value'] ? contentData.formData['cover-abstract-value'] : '',
|
|
490
|
+
content: contentData.formData['content-value'],
|
|
491
|
+
content_source_url: contentData.formData['source-link-value'],
|
|
492
|
+
show_cover_pic: contentData.formData['show-cover-pic-value'] === true ? 1 : 0,
|
|
493
|
+
need_open_comment: postCommentsData.need_open_comment,
|
|
494
|
+
only_fans_can_comment: postCommentsData.only_fans_can_comment,
|
|
495
|
+
thumb_media_id: contentData.mediaId,
|
|
496
|
+
image_url: contentData.imageUrl,
|
|
497
|
+
};
|
|
498
|
+
mediaList.push(filteredContent);
|
|
499
|
+
});
|
|
500
|
+
return mediaList;
|
|
501
|
+
}
|
|
502
|
+
prepareWeChatRichmediaPreviewData = () => {
|
|
503
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
504
|
+
const returnObj = [];
|
|
505
|
+
_.forEach(templateData, (contentData, contentIndex) => {
|
|
506
|
+
const id = parseInt(contentIndex, 10);
|
|
507
|
+
if (id === 0) {
|
|
508
|
+
returnObj.push(
|
|
509
|
+
<div style={{ width: "100%", height: 116, position: "relative" }}>
|
|
510
|
+
<CapRow>
|
|
511
|
+
<img alt="default" width="100%" height="110px" src={contentData.imageUrl} />
|
|
512
|
+
<div style={{ position: "absolute", bottom: "5%", left: "5%" }}>{contentData.formData['title-value'] ? contentData.formData['title-value'] : ""}</div>
|
|
513
|
+
</CapRow>
|
|
514
|
+
{Object.keys(templateData).length === 1 ?
|
|
515
|
+
<CapRow style={{ height: 32 }}>
|
|
516
|
+
{contentData.formData['cover-abstract-value'] ? contentData.formData['cover-abstract-value'] : ""}
|
|
517
|
+
</CapRow>
|
|
518
|
+
:
|
|
519
|
+
""
|
|
520
|
+
}
|
|
521
|
+
</div>
|
|
522
|
+
);
|
|
523
|
+
} else {
|
|
524
|
+
returnObj.push(
|
|
525
|
+
<CapRow style={{ "width": "100%", "height": 64, "border-bottom": "0.5px solid lightgrey" }}>
|
|
526
|
+
<CapColumn style={{ padding: "5% 0% 0% 5%", float: "left" }}>
|
|
527
|
+
{contentData.formData['title-value']}
|
|
528
|
+
</CapColumn>
|
|
529
|
+
<CapColumn style={{ float: "right" }}>
|
|
530
|
+
<img alt="default" width="60px" height="60px" src={contentData.imageUrl} style={{ "padding-right": "10%", "float": "left" }}/>
|
|
531
|
+
</CapColumn>
|
|
532
|
+
</CapRow>
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
return returnObj;
|
|
537
|
+
}
|
|
538
|
+
previewHandler = () => {
|
|
539
|
+
this.setState({showPreview: true});
|
|
540
|
+
}
|
|
541
|
+
saveHandler = () => {
|
|
542
|
+
let isFormValid = this.validateFormFields();
|
|
543
|
+
if (_.isEmpty(this.state.templateName)) {
|
|
544
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.emptyTemplateName));
|
|
545
|
+
isFormValid = false;
|
|
546
|
+
}
|
|
547
|
+
if (isFormValid) {
|
|
548
|
+
const mediaList = this.prepareMediaList();
|
|
549
|
+
const saveObj = {};
|
|
550
|
+
saveObj.name = this.state.templateName.trim();
|
|
551
|
+
saveObj.appId = this.props.Templates.selectedWeChatAccount.configs.wechat_app_id;
|
|
552
|
+
saveObj.appSecret = this.props.Templates.selectedWeChatAccount.configs.wechat_app_secret;
|
|
553
|
+
saveObj.versions = {
|
|
554
|
+
base: {
|
|
555
|
+
OriginalId: this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier,
|
|
556
|
+
mediaList,
|
|
557
|
+
},
|
|
558
|
+
history: [],
|
|
559
|
+
};
|
|
560
|
+
saveObj.definition = {
|
|
561
|
+
msgtype: "MPNEWS",
|
|
562
|
+
msgcontent: "RICH_MEDIA_WECHAT",
|
|
563
|
+
};
|
|
564
|
+
if (this.state.isEdit) {
|
|
565
|
+
saveObj._id = this.props.templateId;
|
|
566
|
+
saveObj.mediaId = this.props.mediaId;
|
|
567
|
+
saveObj.type = "WECHAT";
|
|
568
|
+
}
|
|
569
|
+
this.setState({loading: true});
|
|
570
|
+
this.props.actions.saveTemplate(saveObj);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
uploadImage = (data, uploadId) => {
|
|
574
|
+
if (data.type === "wrong file") {
|
|
575
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.wrongFormatFile));
|
|
576
|
+
} else {
|
|
577
|
+
const wechatParams = {
|
|
578
|
+
appId: this.props.Templates.selectedWeChatAccount.configs.wechat_app_id,
|
|
579
|
+
appSecret: this.props.Templates.selectedWeChatAccount.configs.wechat_app_secret,
|
|
580
|
+
source: 'wechat',
|
|
581
|
+
};
|
|
582
|
+
this.setState({loading: true});
|
|
583
|
+
this.props.actions.uploadAsset(data.file, data.type, data.fileParams, null, wechatParams, this.state.currentContentId, uploadId);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
updateTotalContentBlocks = () => {
|
|
587
|
+
this.setState({
|
|
588
|
+
totalContentBlocks: this.state.totalContentBlocks + 1,
|
|
589
|
+
}, () => {
|
|
590
|
+
this.insertTemplateData();
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
insertTemplateData = () => {
|
|
594
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
595
|
+
templateData[this.state.totalContentBlocks - 1] = {
|
|
596
|
+
formData: {},
|
|
597
|
+
imageUrl: "",
|
|
598
|
+
mediaId: "",
|
|
599
|
+
};
|
|
600
|
+
this.setState({templateData});
|
|
601
|
+
}
|
|
602
|
+
updateImageData = () => {
|
|
603
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
604
|
+
if (this.props.ImageData && !_.isEmpty(this.props.ImageData[this.state.currentContentId]) && this.props.ImageData[this.state.currentContentId].metaInfo && this.props.ImageData[this.state.currentContentId].metaInfo.secure_file_path && this.props.ImageData[this.state.currentContentId].metaInfo.mediaId && templateData[this.state.currentContentId].imageUrl !== this.props.ImageData[this.state.currentContentId].metaInfo.secure_file_path) {
|
|
605
|
+
templateData[this.state.currentContentId].imageUrl = this.props.ImageData[this.state.currentContentId].metaInfo.secure_file_path;
|
|
606
|
+
templateData[this.state.currentContentId].mediaId = this.props.ImageData[this.state.currentContentId].metaInfo.mediaId;
|
|
607
|
+
this.setState({templateData, loading: false});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
viewContent = (e, id) => {
|
|
611
|
+
this.setState({currentContentId: id});
|
|
612
|
+
}
|
|
613
|
+
deleteContent = (e, id) => {
|
|
614
|
+
const modalContent = {
|
|
615
|
+
title: this.props.intl.formatMessage(messages.modalTitle),
|
|
616
|
+
body: this.props.intl.formatMessage(messages.deleteContent),
|
|
617
|
+
type: 'confirm',
|
|
618
|
+
id: 'template-delete-confirm-modal',
|
|
619
|
+
show: true,
|
|
620
|
+
contentId: id,
|
|
621
|
+
};
|
|
622
|
+
this.setState({showModal: true, modalContent});
|
|
623
|
+
}
|
|
624
|
+
handleDelete = (modalContent) => {
|
|
625
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
626
|
+
let totalContentBlocks = this.state.totalContentBlocks;
|
|
627
|
+
let currentContentId = this.state.currentContentId;
|
|
628
|
+
let index = 0;
|
|
629
|
+
for (index = modalContent.contentId; index <= (totalContentBlocks - 2); index += 1) {
|
|
630
|
+
templateData[index] = templateData[index + 1];
|
|
631
|
+
}
|
|
632
|
+
delete templateData[index];
|
|
633
|
+
currentContentId = (totalContentBlocks - 1) === modalContent.contentId ? modalContent.contentId - 1 : modalContent.contentId;
|
|
634
|
+
totalContentBlocks -= 1;
|
|
635
|
+
this.setState({templateData, totalContentBlocks, currentContentId, showModal: false});
|
|
636
|
+
}
|
|
637
|
+
moveContentDownward = (e, id) => {
|
|
638
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
639
|
+
let currentContentId = this.state.currentContentId;
|
|
640
|
+
const temp = templateData[id];
|
|
641
|
+
templateData[id] = templateData[id + 1];
|
|
642
|
+
templateData[id + 1] = temp;
|
|
643
|
+
currentContentId = id + 1;
|
|
644
|
+
this.setState({templateData, currentContentId});
|
|
645
|
+
}
|
|
646
|
+
moveContentUpward = (e, id) => {
|
|
647
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
648
|
+
let currentContentId = this.state.currentContentId;
|
|
649
|
+
const temp = templateData[id];
|
|
650
|
+
templateData[id] = templateData[id - 1];
|
|
651
|
+
templateData[id - 1] = temp;
|
|
652
|
+
currentContentId = id - 1;
|
|
653
|
+
this.setState({templateData, currentContentId});
|
|
654
|
+
}
|
|
655
|
+
returnCardLayout = () => {
|
|
656
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
657
|
+
const returnObj = [];
|
|
658
|
+
if (this.state.isIframe) {
|
|
659
|
+
_.forEach(templateData, (contentData, contentId) => {
|
|
660
|
+
const id = parseInt(contentId, 10);
|
|
661
|
+
const imageUrl = contentData.imageUrl;
|
|
662
|
+
if (id === 0) {
|
|
663
|
+
returnObj[id] = (
|
|
664
|
+
<div className="hover-container">
|
|
665
|
+
<CapCard
|
|
666
|
+
id={id}
|
|
667
|
+
style={{ width: 244, height: 221 }}
|
|
668
|
+
bodyStyle={{ "padding": 0, "background-color": "#707070", "height": 139 }}
|
|
669
|
+
onClick={(e) => this.viewContent(e, id)}
|
|
670
|
+
className={id === this.state.currentContentId ? "richmedia-card richmedia-card-clicked" : "richmedia-card"}
|
|
671
|
+
>
|
|
672
|
+
<div>
|
|
673
|
+
<div className="custom-image">
|
|
674
|
+
<img alt="" width="100%" height="139px" src={imageUrl} />
|
|
675
|
+
</div>
|
|
676
|
+
<div className="custom-card overflow-wrap-fields">
|
|
677
|
+
<p style={{ padding: "0px 8px" }}>{contentData && contentData.formData ? contentData.formData['cover-abstract-value'] : ""}</p>
|
|
678
|
+
</div>
|
|
679
|
+
</div>
|
|
680
|
+
</CapCard>
|
|
681
|
+
</div>
|
|
682
|
+
);
|
|
683
|
+
} else {
|
|
684
|
+
returnObj[id] = (
|
|
685
|
+
<div
|
|
686
|
+
id={id}
|
|
687
|
+
style={{ "margin-top": 10 }}
|
|
688
|
+
className="hover-container"
|
|
689
|
+
onClick={(e) => this.viewContent(e, id)}
|
|
690
|
+
>
|
|
691
|
+
<CapRow style={{ width: 244, height: 53 }} className={id === this.state.currentContentId ? "richmedia-card-rectangle richmedia-card-rectangle-clicked" : "richmedia-card-rectangle"}>
|
|
692
|
+
<CapColumn span={19} style={{ padding: "10px 8px 0px 8px" }} className="overflow-wrap-fields" >
|
|
693
|
+
{contentData && contentData.formData ? contentData.formData['title-value'] : ""}
|
|
694
|
+
</CapColumn>
|
|
695
|
+
<CapColumn span={5} style={{ "height": "100%", "background-color": "#707070" }}>
|
|
696
|
+
<img alt="" width="50px" height="100%" src={imageUrl} />
|
|
697
|
+
</CapColumn>
|
|
698
|
+
</CapRow>
|
|
699
|
+
</div>
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
} else {
|
|
704
|
+
_.forEach(templateData, (contentData, contentId) => {
|
|
705
|
+
const id = parseInt(contentId, 10);
|
|
706
|
+
const imageUrl = contentData.imageUrl;
|
|
707
|
+
if (id === 0) {
|
|
708
|
+
returnObj[id] = (
|
|
709
|
+
<div className="hover-container">
|
|
710
|
+
<CapCard
|
|
711
|
+
id={id}
|
|
712
|
+
style={{ width: 244, height: 221 }}
|
|
713
|
+
bodyStyle={{ "padding": 0, "background-color": "#707070", "height": 139 }}
|
|
714
|
+
className={id === this.state.currentContentId ? "richmedia-card richmedia-card-clicked" : "richmedia-card"}
|
|
715
|
+
>
|
|
716
|
+
<div>
|
|
717
|
+
<div className="custom-image">
|
|
718
|
+
<img alt="" width="100%" height="139px" src={imageUrl} />
|
|
719
|
+
</div>
|
|
720
|
+
<div className="custom-card overflow-wrap-fields">
|
|
721
|
+
<p style={{ padding: "0px 8px" }}>{contentData && contentData.formData ? contentData.formData['cover-abstract-value'] : ""}</p>
|
|
722
|
+
</div>
|
|
723
|
+
</div>
|
|
724
|
+
</CapCard>
|
|
725
|
+
|
|
726
|
+
{this.state.totalContentBlocks !== 1 ?
|
|
727
|
+
<div className="richmedia-icons">
|
|
728
|
+
<div id={id} onClick={(e) => this.moveContentDownward(e, id)}>
|
|
729
|
+
<i className="material-icons hover-icons">arrow_downward</i>
|
|
730
|
+
</div>
|
|
731
|
+
<div id={id} onClick={(e) => this.viewContent(e, id)} style={{ 'padding-left': '190px' }}>
|
|
732
|
+
<i className="material-icons hover-icons">visibility</i>
|
|
733
|
+
</div>
|
|
734
|
+
</div>
|
|
735
|
+
:
|
|
736
|
+
<div className="richmedia-icons">
|
|
737
|
+
<div id={id} onClick={(e) => this.viewContent(e, id)} style={{ 'padding-left': '214px' }}>
|
|
738
|
+
<i className="material-icons hover-icons">visibility</i>
|
|
739
|
+
</div>
|
|
740
|
+
</div>
|
|
741
|
+
}
|
|
742
|
+
</div>
|
|
743
|
+
);
|
|
744
|
+
} else {
|
|
745
|
+
returnObj[id] = (
|
|
746
|
+
<div
|
|
747
|
+
id={id}
|
|
748
|
+
style={{ "margin-top": 10 }}
|
|
749
|
+
className="hover-container"
|
|
750
|
+
>
|
|
751
|
+
<CapRow style={{ width: 244, height: 53 }} className={id === this.state.currentContentId ? "richmedia-card-rectangle richmedia-card-rectangle-clicked" : "richmedia-card-rectangle"}>
|
|
752
|
+
<CapColumn span={19} style={{ padding: "10px 8px 0px 8px" }} className="overflow-wrap-fields" >
|
|
753
|
+
{contentData && contentData.formData ? contentData.formData['title-value'] : ""}
|
|
754
|
+
</CapColumn>
|
|
755
|
+
<CapColumn span={5} style={{ "height": "100%", "background-color": "#707070" }}>
|
|
756
|
+
<img alt="" width="50px" height="100%" src={imageUrl} />
|
|
757
|
+
</CapColumn>
|
|
758
|
+
</CapRow>
|
|
759
|
+
<div className="richmedia-icons">
|
|
760
|
+
<div style={{display: 'inline-flex'}}>
|
|
761
|
+
<div id={id} onClick={(e) => this.moveContentUpward(e, id)}>
|
|
762
|
+
<i className="material-icons hover-icons">arrow_upward</i>
|
|
763
|
+
</div>
|
|
764
|
+
{id !== (this.state.totalContentBlocks - 1 ) ?
|
|
765
|
+
<div id={id} onClick={(e) => this.moveContentDownward(e, id)}>
|
|
766
|
+
<i className="material-icons hover-icons">arrow_downward</i>
|
|
767
|
+
</div>
|
|
768
|
+
:
|
|
769
|
+
""
|
|
770
|
+
}
|
|
771
|
+
</div>
|
|
772
|
+
{id !== (this.state.totalContentBlocks - 1 ) ?
|
|
773
|
+
<div style={{'display': 'inline-flex', 'padding-left': '142px'}}>
|
|
774
|
+
<div id={id} onClick={(e) => this.viewContent(e, id)}>
|
|
775
|
+
<i className="material-icons hover-icons">visibility</i>
|
|
776
|
+
</div>
|
|
777
|
+
<div id={id} onClick={(e) => this.deleteContent(e, id)} >
|
|
778
|
+
<i className="material-icons hover-icons">delete</i>
|
|
779
|
+
</div>
|
|
780
|
+
</div>
|
|
781
|
+
:
|
|
782
|
+
<div style={{'display': 'inline-flex', 'padding-left': '166px'}}>
|
|
783
|
+
<div id={id} onClick={(e) => this.viewContent(e, id)}>
|
|
784
|
+
<i className="material-icons hover-icons">visibility</i>
|
|
785
|
+
</div>
|
|
786
|
+
<div id={id} onClick={(e) => this.deleteContent(e, id)} >
|
|
787
|
+
<i className="material-icons hover-icons">delete</i>
|
|
788
|
+
</div>
|
|
789
|
+
</div>
|
|
790
|
+
}
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
return (
|
|
798
|
+
<div>{returnObj}</div>
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
isTitleRepeated = () => {
|
|
802
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
803
|
+
const titleSet = new Set();
|
|
804
|
+
let isRepeated = false;
|
|
805
|
+
_.forEach(templateData, (content = '') => {
|
|
806
|
+
const setSizeBefore = titleSet.size;
|
|
807
|
+
titleSet.add((content.formData['title-value'] || '').toLowerCase());
|
|
808
|
+
const setSizeAfter = titleSet.size;
|
|
809
|
+
if (setSizeAfter === setSizeBefore) {
|
|
810
|
+
isRepeated = true;
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
return isRepeated;
|
|
814
|
+
}
|
|
815
|
+
isFormEmpty = () => {
|
|
816
|
+
const templateData = _.cloneDeep(this.state.templateData);
|
|
817
|
+
let isEmpty = false;
|
|
818
|
+
_.forEach(templateData, (content) => {
|
|
819
|
+
if (_.isEmpty(content.formData)) {
|
|
820
|
+
isEmpty = true;
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
return isEmpty;
|
|
824
|
+
}
|
|
825
|
+
validateFormFields = () => {
|
|
826
|
+
let isValid = true;
|
|
827
|
+
const currentContent = this.state.templateData[this.state.currentContentId];
|
|
828
|
+
if (this.isFormEmpty()) {
|
|
829
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.formEmpty));
|
|
830
|
+
isValid = false;
|
|
831
|
+
return isValid;
|
|
832
|
+
}
|
|
833
|
+
if (_.isEmpty(currentContent.formData['title-value'])) {
|
|
834
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.titleEmpty));
|
|
835
|
+
isValid = false;
|
|
836
|
+
return isValid;
|
|
837
|
+
}
|
|
838
|
+
if (_.isEmpty(currentContent.imageUrl) || _.isEmpty(currentContent.mediaId)) {
|
|
839
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.noImage));
|
|
840
|
+
isValid = false;
|
|
841
|
+
return isValid;
|
|
842
|
+
}
|
|
843
|
+
if (_.isEmpty(currentContent.formData['source-link-value'])) {
|
|
844
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.sourceLinkEmpty));
|
|
845
|
+
isValid = false;
|
|
846
|
+
return isValid;
|
|
847
|
+
}
|
|
848
|
+
if (_.isEmpty(currentContent.formData['content-value'])) {
|
|
849
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.contentEmpty));
|
|
850
|
+
isValid = false;
|
|
851
|
+
return isValid;
|
|
852
|
+
}
|
|
853
|
+
if (this.checkFormFieldsCount(currentContent.formData)) {
|
|
854
|
+
isValid = false;
|
|
855
|
+
return isValid;
|
|
856
|
+
}
|
|
857
|
+
if (this.isTitleRepeated()) {
|
|
858
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.titleNameRepeated));
|
|
859
|
+
isValid = false;
|
|
860
|
+
return isValid;
|
|
861
|
+
}
|
|
862
|
+
if (!_.isEmpty(currentContent.formData['source-link-value'])) {
|
|
863
|
+
isValid = currentContent.formData['source-link-value'].match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g);
|
|
864
|
+
if (!isValid) {
|
|
865
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.wrongUrl));
|
|
866
|
+
return isValid;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return isValid;
|
|
870
|
+
}
|
|
871
|
+
menuOnClickEvent(ev) {
|
|
872
|
+
const isFormValid = this.validateFormFields();
|
|
873
|
+
if (!isFormValid) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
switch (ev.key) {
|
|
877
|
+
case "new_richmedia_content":
|
|
878
|
+
if (this.state.totalContentBlocks < 8) {
|
|
879
|
+
this.setState({
|
|
880
|
+
currentContentId: this.state.totalContentBlocks,
|
|
881
|
+
}, () => {
|
|
882
|
+
this.updateTotalContentBlocks();
|
|
883
|
+
});
|
|
884
|
+
} else {
|
|
885
|
+
this.showErrorMessage(this.props.intl.formatMessage(messages.maxContentCount));
|
|
886
|
+
}
|
|
887
|
+
break;
|
|
888
|
+
case "old_richmedia_content":
|
|
889
|
+
this.setState({
|
|
890
|
+
currentContentId: this.state.currentContentId + 1,
|
|
891
|
+
}, () => {
|
|
892
|
+
this.updateTotalContentBlocks();
|
|
893
|
+
});
|
|
894
|
+
break;
|
|
895
|
+
default:
|
|
896
|
+
this.setState({
|
|
897
|
+
currentContentId: this.state.totalContentBlocks + 1,
|
|
898
|
+
}, () => {
|
|
899
|
+
this.updateTotalContentBlocks();
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
904
|
+
updateContentData = () => {
|
|
905
|
+
if (this.state.editorInstanse) {
|
|
906
|
+
this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Image'>`);
|
|
907
|
+
}
|
|
908
|
+
this.props.actions.clearContentImageStore();
|
|
909
|
+
this.setState({loading: false});
|
|
910
|
+
}
|
|
911
|
+
returnContentMenu = () => {
|
|
912
|
+
let actionButton = '';
|
|
913
|
+
const createPushMenu = (
|
|
914
|
+
<Menu onClick={this.menuOnClickEvent}>
|
|
915
|
+
{/* <MenuItem key="old_richmedia_content">
|
|
916
|
+
Add existing Richmedia content
|
|
917
|
+
</MenuItem> */}
|
|
918
|
+
<MenuItem key="new_richmedia_content">
|
|
919
|
+
<FormattedMessage {...messages.addNewRichmedia} />
|
|
920
|
+
</MenuItem>
|
|
921
|
+
</Menu>
|
|
922
|
+
);
|
|
923
|
+
actionButton = (<Dropdown overlay={createPushMenu} trigger={['click']}>
|
|
924
|
+
<CapButton style={{width: '244', height: '53', marginTop: '16'}} type="secondary">
|
|
925
|
+
<div style={{display: 'inline-flex'}}>
|
|
926
|
+
<p>
|
|
927
|
+
<i style={{ color: '#2e89df'}} className="material-icons">+</i>
|
|
928
|
+
</p>
|
|
929
|
+
</div>
|
|
930
|
+
</CapButton>
|
|
931
|
+
</Dropdown>);
|
|
932
|
+
return actionButton;
|
|
933
|
+
}
|
|
934
|
+
focusOutFromCkEditor = () => {
|
|
935
|
+
this.setState({focusOut: true});
|
|
936
|
+
}
|
|
937
|
+
focusInFromCkeditor = () => {
|
|
938
|
+
this.setState({focusOut: false});
|
|
939
|
+
}
|
|
940
|
+
returnCurrentSchema = () => {
|
|
941
|
+
let schema = _.cloneDeep(this.state.richmediaSchema);
|
|
942
|
+
if (this.state.isIframe) {
|
|
943
|
+
const disabledFormSchema = _.cloneDeep(this.state.richmediaSchema);
|
|
944
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[0].cols[1].disabled = true;
|
|
945
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[1].cols[1].disabled = true;
|
|
946
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[2].cols[1].disabled = true;
|
|
947
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[3].cols[1].disabled = true;
|
|
948
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[4].cols[0].disabled = true;
|
|
949
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[5].cols[1].disabled = true;
|
|
950
|
+
disabledFormSchema.standalone.sections[0].childSections[2].inputFields[0].cols[1].disabled = true;
|
|
951
|
+
disabledFormSchema.standalone.sections[0].childSections[1].childSections[1].childSections[0].inputFields[0].cols[1].disabled = true;
|
|
952
|
+
if (this.state.editorInstanse) {
|
|
953
|
+
this.state.editorInstanse.setReadOnly(true);
|
|
954
|
+
}
|
|
955
|
+
schema = this.injectEvents(disabledFormSchema);
|
|
956
|
+
return schema;
|
|
957
|
+
}
|
|
958
|
+
if (this.state.editorInstanse && this.state.focusOut) {
|
|
959
|
+
schema.standalone.sections[0].childSections[1].childSections[1].childSections[0].inputFields[0].cols[1].disabled = true;
|
|
960
|
+
} else if (this.state.editorInstanse && !this.state.focusOut) {
|
|
961
|
+
schema.standalone.sections[0].childSections[1].childSections[1].childSections[0].inputFields[0].cols[1].disabled = false;
|
|
962
|
+
}
|
|
963
|
+
schema = this.injectEvents(schema);
|
|
964
|
+
return schema;
|
|
965
|
+
}
|
|
966
|
+
returnCurrentFormData = () => {
|
|
967
|
+
const formData = this.state.templateData && !_.isEmpty(this.state.templateData[this.state.currentContentId]) && this.state.templateData[this.state.currentContentId].formData ? _.cloneDeep(this.state.templateData[this.state.currentContentId].formData) : {};
|
|
968
|
+
return formData;
|
|
969
|
+
}
|
|
970
|
+
render() {
|
|
971
|
+
const cardLayout = this.returnCardLayout();
|
|
972
|
+
const contentMenu = this.returnContentMenu();
|
|
973
|
+
const schema = this.returnCurrentSchema();
|
|
974
|
+
const formData = this.returnCurrentFormData();
|
|
975
|
+
this.updateImageData();
|
|
976
|
+
if (this.props.ContentImageData && this.props.ContentImageData.metaInfo && this.props.ContentImageData.metaInfo.wechatUrl) {
|
|
977
|
+
this.updateContentData();
|
|
978
|
+
}
|
|
979
|
+
return (
|
|
980
|
+
<div className="richmedia-container">
|
|
981
|
+
<CapSpinner spinning={this.state.loading}>
|
|
982
|
+
{this.state.showPreview && <WechatRichmediaTemplatePreview
|
|
983
|
+
show={this.state.showPreview}
|
|
984
|
+
closeSlideBox={this.closeSlideBox}
|
|
985
|
+
header={this.state.templateName}
|
|
986
|
+
width={50}
|
|
987
|
+
showSlidebox
|
|
988
|
+
const type={this.props.location && this.props.location.query.type ? this.props.location.query.type : ''}
|
|
989
|
+
content={this.prepareMediaList()}
|
|
990
|
+
/>}
|
|
991
|
+
<div>
|
|
992
|
+
<Helmet
|
|
993
|
+
title="Wechat Richmedia"
|
|
994
|
+
/>
|
|
995
|
+
<div className="wechat-container">
|
|
996
|
+
{!this.state.isIframe && <Header templateName={this.state.templateName} templateNameHandler={this.templateNameHandler} previewHandler={this.previewHandler} cancelHandler={this.cancelHandler} saveHandler={this.saveHandler} />}
|
|
997
|
+
<CapRow className="wechat-form-container">
|
|
998
|
+
<CapColumn span={6}>
|
|
999
|
+
{cardLayout}
|
|
1000
|
+
{!this.state.isIframe && contentMenu}
|
|
1001
|
+
</CapColumn>
|
|
1002
|
+
<CapColumn span={18}>
|
|
1003
|
+
<FormBuilder
|
|
1004
|
+
key={this.state.currentContentId}
|
|
1005
|
+
schema={schema}
|
|
1006
|
+
onChange={this.onFormDataChange}
|
|
1007
|
+
parent={this}
|
|
1008
|
+
formData={formData}
|
|
1009
|
+
onFormValidityChange={this.setFormValidity}
|
|
1010
|
+
location={this.props.location}
|
|
1011
|
+
usingTabContainer={false}
|
|
1012
|
+
router={this.props.router}
|
|
1013
|
+
modal={this.state.modalContent}
|
|
1014
|
+
showModal={this.state.showModal}
|
|
1015
|
+
handleCancelModal={this.handleCancelModal}
|
|
1016
|
+
iframeParent={parent}
|
|
1017
|
+
handleDelete={this.handleDelete}
|
|
1018
|
+
/>
|
|
1019
|
+
</CapColumn>
|
|
1020
|
+
</CapRow>
|
|
1021
|
+
</div>
|
|
1022
|
+
</div>
|
|
1023
|
+
</CapSpinner>
|
|
1024
|
+
</div>
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
Create.propTypes = {
|
|
1030
|
+
location: PropTypes.object,
|
|
1031
|
+
router: PropTypes.object,
|
|
1032
|
+
mode: PropTypes.string,
|
|
1033
|
+
templateData: PropTypes.object,
|
|
1034
|
+
totalContentBlocks: PropTypes.integer,
|
|
1035
|
+
templateName: PropTypes.string,
|
|
1036
|
+
templateId: PropTypes.string,
|
|
1037
|
+
mediaId: PropTypes.string,
|
|
1038
|
+
Templates: PropTypes.object,
|
|
1039
|
+
ImageData: PropTypes.object,
|
|
1040
|
+
actions: PropTypes.object,
|
|
1041
|
+
globalActions: PropTypes.object,
|
|
1042
|
+
Create: PropTypes.object,
|
|
1043
|
+
intl: intlShape.isRequired,
|
|
1044
|
+
ContentImageData: PropTypes.object,
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
const mapStateToProps = createStructuredSelector({
|
|
1048
|
+
Create: makeSelectCreate(),
|
|
1049
|
+
Templates: makeSelectTemplates(),
|
|
1050
|
+
ImageData: getAssetDetails(),
|
|
1051
|
+
ContentImageData: getContentAssetDetails(),
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
function mapDispatchToProps(dispatch) {
|
|
1055
|
+
return {
|
|
1056
|
+
actions: bindActionCreators(actions, dispatch),
|
|
1057
|
+
globalActions: bindActionCreators(globalActions, dispatch),
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
|
1062
|
+
const withSaga = injectSaga({ key: 'create', saga: richMediaTemplatesSaga });
|
|
1063
|
+
const withReducer = injectReducer({ key: 'create', reducer });
|
|
1064
|
+
|
|
1065
|
+
export default compose(
|
|
1066
|
+
UserIsAuthenticated,
|
|
1067
|
+
withReducer,
|
|
1068
|
+
withSaga,
|
|
1069
|
+
withConnect,
|
|
1070
|
+
)(injectIntl(Create));
|
|
1071
|
+
|