@capillarytech/creatives-library 3.0.35 → 3.1.0
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/assets/noImage.png +0 -0
- package/components/BreadCrumbs/messages.js +1 -1
- package/components/CapTagList/index.js +3 -3
- package/components/CapTagList/messages.js +4 -16
- package/components/Ckeditor/messages.js +1 -1
- package/components/CustomPopOver/index.js +4 -3
- package/components/CustomPopOver/messages.js +1 -5
- package/components/DateFilter/index.js +12 -12
- package/components/DateFilter/messages.js +0 -40
- package/components/DateRange/index.js +4 -5
- package/components/DateRange/messages.js +1 -13
- package/components/Edmeditor/messages.js +1 -1
- package/components/EmailPreview/index.js +4 -4
- package/components/EmailPreview/messages.js +2 -18
- package/components/Footer/messages.js +1 -1
- package/components/FormBuilder/index.js +19 -15
- package/components/FormBuilder/messages.js +1 -33
- package/components/Header/messages.js +4 -4
- package/components/ImagePreview/index.js +1 -1
- package/components/ImagePreview/messages.js +1 -5
- package/components/PageHeader/messages.js +1 -1
- package/components/PreviewSideBar/index.js +2 -2
- package/components/PreviewSideBar/messages.js +6 -14
- package/components/Sidebar/messages.js +3 -3
- package/components/SmsTest/index.js +4 -6
- package/components/SmsTest/messages.js +1 -9
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +3 -3
- package/components/TemplatePreview/index.js +10 -11
- package/components/TemplatePreview/messages.js +7 -23
- package/components/Toastr/messages.js +1 -1
- package/components/ToastrMessage/index.js +1 -4
- package/components/ToastrMessage/messages.js +1 -5
- package/components/TopBar/messages.js +1 -1
- package/config/app.js +0 -2
- package/containers/Assets/Gallery/messages.js +20 -20
- package/containers/Cap/index.js +5 -5
- package/containers/Dashboard/index.js +2 -2
- package/containers/Dashboard/messages.js +1 -1
- package/containers/Ebill/index.js +1 -1
- package/containers/Ebill/messages.js +16 -20
- package/containers/Email/index.js +24 -24
- package/containers/Email/messages.js +59 -107
- package/containers/Line/Create/index.js +7 -7
- package/containers/Line/Create/messages.js +42 -58
- package/containers/Line/Edit/index.js +14 -14
- package/containers/Line/Edit/messages.js +38 -58
- package/containers/Login/components/LoginForm/index.js +7 -10
- package/containers/Login/components/LoginForm/messages.js +3 -15
- package/containers/Login/index.js +1 -1
- package/containers/Login/messages.js +3 -7
- package/containers/MobilePush/Create/index.js +45 -45
- package/containers/MobilePush/Create/messages.js +75 -111
- package/containers/MobilePush/Edit/index.js +45 -45
- package/containers/MobilePush/Edit/messages.js +83 -100
- package/containers/NotFoundPage/messages.js +1 -1
- package/containers/Sms/Create/index.js +8 -7
- package/containers/Sms/Create/messages.js +19 -43
- package/containers/Sms/Edit/index.js +4 -4
- package/containers/Sms/Edit/messages.js +20 -36
- package/containers/TagList/messages.js +1 -1
- package/containers/Templates/index.js +19 -20
- package/containers/Templates/messages.js +64 -136
- package/containers/TestPage/messages.js +1 -1
- package/containers/Testv2/index.js +2 -2
- package/containers/Testv2/messages.js +1 -9
- package/containers/WeChat/MapTemplates/index.js +10 -10
- package/containers/WeChat/MapTemplates/messages.js +17 -49
- package/containers/WeChat/RichmediaTemplates/Create/messages.js +33 -33
- package/containers/WeChat/RichmediaTemplates/Edit/messages.js +1 -1
- package/containers/WeChat/RichmediaTemplates/View/index.js +2 -2
- package/containers/WeChat/RichmediaTemplates/View/messages.js +1 -9
- package/index.js +20 -8
- package/package.json +4 -1
- package/routes.js +16 -2
- package/services/api.js +2 -17
- package/services/getSchema.js +4 -1
- package/translations/en.json +360 -1396
- package/translations/zh.json +381 -1417
- package/utils/smsCharCountV2.js +10 -26
- package/v2Components/BreadCrumbs/messages.js +1 -1
- package/v2Components/CallTaskPreview/messages.js +1 -1
- package/v2Components/CapTagList/index.js +5 -6
- package/v2Components/CapTagList/messages.js +4 -24
- package/v2Components/Ckeditor/index.js +0 -1
- package/v2Components/Ckeditor/messages.js +1 -1
- package/v2Components/CmsTemplatesComponent/messages.js +2 -2
- package/v2Components/CustomPopOver/index.js +2 -4
- package/v2Components/CustomPopOver/messages.js +1 -5
- package/v2Components/DateFilter/index.js +349 -0
- package/v2Components/DateFilter/messages.js +17 -0
- package/v2Components/DateFilter/tests/index.test.js +15 -0
- package/v2Components/DateRange/index.js +113 -0
- package/v2Components/DateRange/messages.js +13 -0
- package/v2Components/DateRange/tests/index.test.js +10 -0
- package/v2Components/Edmeditor/messages.js +1 -1
- package/v2Components/EmailPreview/index.js +2 -2
- package/v2Components/EmailPreview/messages.js +3 -11
- package/v2Components/EmailPreviewV2/index.js +1 -1
- package/v2Components/EmailPreviewV2/messages.js +9 -13
- package/v2Components/Footer/messages.js +1 -1
- package/v2Components/FormBuilder/_formBuilder.scss +19 -0
- package/v2Components/FormBuilder/index.js +58 -27
- package/v2Components/FormBuilder/messages.js +1 -49
- package/v2Components/Header/index.js +2 -2
- package/v2Components/Header/messages.js +4 -4
- package/v2Components/ImagePreview/index.js +2 -3
- package/v2Components/ImagePreview/messages.js +1 -5
- package/v2Components/MobilePushPreviewV2/index.js +5 -2
- package/v2Components/MobilePushPreviewV2/messages.js +1 -9
- package/v2Components/NavigationBar/messages.js +1 -1
- package/v2Components/NewCallTask/messages.js +5 -5
- package/v2Components/PageHeader/_pageHeader.scss +22 -0
- package/v2Components/PageHeader/index.js +37 -0
- package/v2Components/PageHeader/messages.js +13 -0
- package/v2Components/PageHeader/tests/index.test.js +10 -0
- package/v2Components/PreviewSideBar/messages.js +6 -6
- package/v2Components/Sidebar/_sidebar.scss +115 -0
- package/v2Components/Sidebar/index.js +208 -0
- package/v2Components/Sidebar/messages.js +21 -0
- package/v2Components/Sidebar/tests/index.test.js +10 -0
- package/v2Components/SmsEditor/index.js +55 -0
- package/v2Components/SmsEditor/tests/index.test.js +10 -0
- package/v2Components/SmsTest/index.js +4 -6
- package/v2Components/SmsTest/messages.js +1 -9
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +2 -0
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +18 -28
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +3 -3
- package/v2Components/TemplatePreview/_templatePreview.scss +0 -9
- package/v2Components/TemplatePreview/index.js +16 -35
- package/v2Components/TemplatePreview/messages.js +7 -23
- package/v2Components/Toastr/messages.js +1 -1
- package/v2Components/ToastrMessage/index.js +2 -3
- package/v2Components/ToastrMessage/messages.js +1 -5
- package/v2Components/TopBar/_topbar.scss +46 -0
- package/v2Components/TopBar/messages.js +7 -7
- package/v2Containers/App/constants.js +0 -11
- package/v2Containers/Assets/Gallery/messages.js +24 -24
- package/v2Containers/CallTask/messages.js +6 -6
- package/v2Containers/Cap/actions.js +0 -1
- package/v2Containers/Cap/index.js +9 -6
- package/v2Containers/Cap/messsages.js +15 -19
- package/v2Containers/Cap/sagas.js +8 -1
- package/v2Containers/ChannelTemplates/messages.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +39 -1
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +7 -1
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +21 -3
- package/v2Containers/CreativesContainer/index.js +95 -50
- package/v2Containers/CreativesContainer/index.scss +15 -0
- package/v2Containers/CreativesContainer/messages.js +12 -16
- package/v2Containers/Dashboard/index.js +1 -2
- package/v2Containers/Dashboard/messages.js +1 -1
- package/v2Containers/Ebill/index.js +1 -1
- package/v2Containers/Ebill/messages.js +16 -20
- package/v2Containers/Email/index.js +20 -20
- package/v2Containers/Email/messages.js +61 -101
- package/v2Containers/EmailWrapper/index.js +44 -64
- package/v2Containers/EmailWrapper/messages.js +12 -12
- package/v2Containers/Line/Create/index.js +3 -3
- package/v2Containers/Line/Create/messages.js +41 -53
- package/v2Containers/Line/Edit/index.js +10 -10
- package/v2Containers/Line/Edit/messages.js +39 -55
- package/v2Containers/Login/components/LoginForm/index.js +6 -9
- package/v2Containers/Login/components/LoginForm/messages.js +3 -15
- package/v2Containers/Login/index.js +1 -1
- package/v2Containers/Login/messages.js +3 -7
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +3 -0
- package/v2Containers/MobilePush/Create/index.js +33 -33
- package/v2Containers/MobilePush/Create/messages.js +81 -109
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +3 -0
- package/v2Containers/MobilePush/Edit/index.js +22 -22
- package/v2Containers/MobilePush/Edit/messages.js +79 -95
- package/v2Containers/MobilePush/initialSchema.js +1 -2
- package/v2Containers/MobilepushWrapper/messages.js +5 -5
- package/v2Containers/NotFoundPage/messages.js +1 -1
- package/v2Containers/Sms/Create/index.js +6 -6
- package/v2Containers/Sms/Create/messages.js +21 -41
- package/v2Containers/Sms/Edit/index.js +6 -6
- package/v2Containers/Sms/Edit/messages.js +20 -36
- package/v2Containers/TagList/messages.js +1 -1
- package/v2Containers/Templates/_templates.scss +31 -5
- package/v2Containers/Templates/index.js +243 -248
- package/v2Containers/Templates/messages.js +7 -15
- package/v2Containers/Templates/sagas.js +0 -1
- package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
- package/v2Containers/TemplatesV2/index.js +4 -1
- package/v2Containers/TemplatesV2/messages.js +5 -29
- package/v2Containers/TestPage/messages.js +1 -1
- package/v2Containers/Testv2/index.js +2 -2
- package/v2Containers/Testv2/messages.js +1 -9
- package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +16 -0
- package/v2Containers/WeChat/MapTemplates/actions.js +4 -2
- package/v2Containers/WeChat/MapTemplates/index.js +800 -872
- package/v2Containers/WeChat/MapTemplates/initialSchema.js +184 -0
- package/v2Containers/WeChat/MapTemplates/messages.js +19 -43
- package/v2Containers/WeChat/MapTemplates/sagas.js +6 -2
- package/v2Containers/WeChat/MapTemplates/selectors.js +1 -1
- package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +118 -28
- package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +3 -1
- package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +262 -306
- package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +43 -95
- package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +2 -1
- package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +113 -246
- package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +5 -2
- package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +1 -1
- package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +2 -2
- package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +11 -10
- package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +1 -1
- package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +1 -0
- package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +4 -2
- package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +1 -1
- package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +1 -9
- package/v2Containers/WeChat/Wrapper/_wrapper.scss +0 -0
- package/v2Containers/WeChat/Wrapper/constants.js +5 -0
- package/v2Containers/WeChat/Wrapper/index.js +194 -0
- package/v2Containers/WeChat/Wrapper/messages.js +21 -0
- package/v2Containers/WeChat/helper.js +12 -0
- package/containers/Cap/messages.js +0 -75
- package/v2Containers/Cap/messages.js +0 -75
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
1
2
|
/*
|
|
2
3
|
*
|
|
3
4
|
* Create
|
|
@@ -11,10 +12,15 @@ import { connect } from 'react-redux';
|
|
|
11
12
|
import Helmet from 'react-helmet';
|
|
12
13
|
import { bindActionCreators } from 'redux';
|
|
13
14
|
import { createStructuredSelector } from 'reselect';
|
|
14
|
-
import { injectIntl, intlShape
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
15
|
+
import { injectIntl, intlShape } from 'react-intl';
|
|
16
|
+
import isEmpty from 'lodash/isEmpty';
|
|
17
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
18
|
+
import forEach from 'lodash/forEach';
|
|
19
|
+
import isEqual from 'lodash/isEqual';
|
|
20
|
+
import get from 'lodash/get';
|
|
21
|
+
|
|
22
|
+
import { Menu } from 'antd';
|
|
23
|
+
import { CapRow, CapColumn, CapButton, CapCard, CapSpin, CapInput, CapHeading, CapDivider, CapIcon, CapLink } from '@capillarytech/cap-ui-library';
|
|
18
24
|
import makeSelectCreate, {makeSelectTemplates, getAssetDetails, getContentAssetDetails} from './selectors';
|
|
19
25
|
import * as actions from './actions';
|
|
20
26
|
import richmediaschema from './richmediaschema';
|
|
@@ -23,9 +29,9 @@ import messages from './messages';
|
|
|
23
29
|
import * as globalActions from '../../../Cap/actions';
|
|
24
30
|
import {getMessageObject} from '../../../../utils/messageUtils';
|
|
25
31
|
import FormBuilder from '../../../../v2Components/FormBuilder';
|
|
26
|
-
import Header from '../../../../v2Components/Header';
|
|
27
32
|
import WechatRichmediaTemplatePreview from '../../../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
|
|
28
|
-
|
|
33
|
+
import noImage from '../../../../assets/noImage.png';
|
|
34
|
+
|
|
29
35
|
export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
30
36
|
constructor(props) {
|
|
31
37
|
super(props);
|
|
@@ -36,7 +42,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
36
42
|
let templateId = "";
|
|
37
43
|
let templateName = "";
|
|
38
44
|
let isIframe = false;
|
|
39
|
-
if (props.location.query.type === "embedded" && props.location.query.module === "
|
|
45
|
+
if (props.location.query.type === "embedded" && props.location.query.module === "library") {
|
|
40
46
|
isIframe = true;
|
|
41
47
|
}
|
|
42
48
|
if (props.mode === 'EDIT') {
|
|
@@ -122,7 +128,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
122
128
|
this.showErrorMessage = this.showErrorMessage.bind(this);
|
|
123
129
|
this.returnCurrentFormData = this.returnCurrentFormData.bind(this);
|
|
124
130
|
this.returnCurrentSchema = this.returnCurrentSchema.bind(this);
|
|
125
|
-
this.handleFrameTasks = this.handleFrameTasks.bind(this);
|
|
131
|
+
// this.handleFrameTasks = this.handleFrameTasks.bind(this);
|
|
126
132
|
this.getCurrentWindow = this.getCurrentWindow.bind(this);
|
|
127
133
|
// this.startLoading = this.startLoading.bind(this);
|
|
128
134
|
this.moveToTemplates = this.moveToTemplates.bind(this);
|
|
@@ -131,7 +137,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
131
137
|
this.injectMessages = this.injectMessages.bind(this);
|
|
132
138
|
}
|
|
133
139
|
componentWillMount = () => {
|
|
134
|
-
if (
|
|
140
|
+
if (isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
135
141
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
136
142
|
const type = this.props.location.query.type;
|
|
137
143
|
this.props.router.push({
|
|
@@ -144,31 +150,28 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
144
150
|
if (!this.state.isEdit) {
|
|
145
151
|
this.updateTotalContentBlocks();
|
|
146
152
|
}
|
|
147
|
-
if (this.state.isIframe) {
|
|
148
|
-
window.addEventListener("message", this.handleFrameTasks);
|
|
149
|
-
this.showNext();
|
|
150
|
-
}
|
|
151
153
|
}
|
|
152
154
|
componentWillReceiveProps = (nextProps) => {
|
|
153
|
-
if (nextProps.
|
|
155
|
+
if (nextProps.isGetFormData && !this.props.isFullMode && this.state.isEdit) {
|
|
156
|
+
nextProps.getFormData(this.getFormData());
|
|
157
|
+
} else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && (this.props.isFullMode || !this.state.isEdit)) {
|
|
158
|
+
this.saveHandler();
|
|
159
|
+
}
|
|
160
|
+
if (nextProps.Create.saveTemplateRes && !isEmpty(nextProps.Create.saveTemplateRes) && nextProps.Create.saveTemplateSuccess && !isEqual(nextProps.Create.saveTemplateRes, this.props.Create.saveTemplateRes)) {
|
|
154
161
|
this.setState({loading: false});
|
|
155
162
|
const message = getMessageObject('success', this.props.intl.formatMessage(messages.saveSuccess), true);
|
|
156
163
|
this.props.globalActions.addMessageToQueue(message);
|
|
157
|
-
const type = nextProps.location.query.type;
|
|
158
|
-
nextProps.router.push({
|
|
159
|
-
pathname: `/wechat`,
|
|
160
|
-
query: type === 'embedded' ? {type: 'embedded'} : {},
|
|
161
|
-
});
|
|
162
164
|
}
|
|
163
165
|
if (!nextProps.Create.saveTemplateSuccess && nextProps.Create.saveTemplateSuccess !== undefined && nextProps.Create.saveTemplateErrorMessage && nextProps.Create.saveTemplateErrorMessage !== this.props.Create.saveTemplateErrorMessage) {
|
|
164
166
|
this.setState({loading: false});
|
|
165
167
|
this.showErrorMessage(nextProps.Create.saveTemplateErrorMessage);
|
|
166
168
|
}
|
|
169
|
+
if (!isEqual(nextProps.templateName, this.props.templateName)) {
|
|
170
|
+
this.setState({templateName: nextProps.templateName});
|
|
171
|
+
}
|
|
167
172
|
}
|
|
168
173
|
componentWillUnmount() {
|
|
169
|
-
|
|
170
|
-
window.removeEventListener("message", this.handleFrameTasks);
|
|
171
|
-
}
|
|
174
|
+
this.props.actions.clearContentImageStore();
|
|
172
175
|
}
|
|
173
176
|
onHover = (data) => {
|
|
174
177
|
this.setState({hovered: data});
|
|
@@ -177,12 +180,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
177
180
|
this.setState({hovered: data});
|
|
178
181
|
}
|
|
179
182
|
onFormDataChange = (currentFormData) => {
|
|
180
|
-
const templateData =
|
|
181
|
-
templateData[this.state.currentContentId].formData =
|
|
183
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
184
|
+
templateData[this.state.currentContentId].formData = cloneDeep(currentFormData);
|
|
182
185
|
this.setState({templateData});
|
|
183
186
|
}
|
|
184
187
|
onContentChange = (evt) => {
|
|
185
|
-
const templateData =
|
|
188
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
186
189
|
console.log('oncontentchange onChange ', evt, evt.editor.getData(), templateData);
|
|
187
190
|
templateData[this.state.currentContentId].formData['content-value'] = evt.editor.getData();
|
|
188
191
|
this.setState({templateData});
|
|
@@ -216,33 +219,50 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
216
219
|
};
|
|
217
220
|
parent.postMessage(JSON.stringify(response), '*');
|
|
218
221
|
}
|
|
219
|
-
getFormData(
|
|
220
|
-
|
|
222
|
+
getFormData(templateParams) {
|
|
223
|
+
/**
|
|
224
|
+
* This method would be called in two scenario
|
|
225
|
+
*
|
|
226
|
+
* Scenario 1:
|
|
227
|
+
* ===========
|
|
228
|
+
* When a user selects a template. Edit container would be loaded with read only value. On click of done, This method would be invoked.
|
|
229
|
+
* In this scenario we depend up on props to parse this data
|
|
230
|
+
*
|
|
231
|
+
* Scenario 2:
|
|
232
|
+
* ===========
|
|
233
|
+
* When a user creates a new richmedia template.
|
|
234
|
+
* In this scenario we depend up on state and function param to parse this data.
|
|
235
|
+
*
|
|
236
|
+
* Considering the above scenarios, Parsing based on Props is considered as the default approach and fallback will be based on state.
|
|
237
|
+
*/
|
|
238
|
+
const { templateData, Templates: templates, templateId: templateIdFromProp, templateName: templateNameFromProp} = this.props;
|
|
239
|
+
const { mediaId, mediaList, templateId, templateName } = templateParams || {};
|
|
221
240
|
const message = {
|
|
222
|
-
mediaList:
|
|
223
|
-
media_id:
|
|
241
|
+
mediaList: get(templateData, 'templateDetails.versions.base.mediaList', mediaList),
|
|
242
|
+
media_id: get(templateData, 'templateDetails.versions.base.mediaId', mediaId),
|
|
224
243
|
definition: {
|
|
225
244
|
msgtype: "MPNEWS",
|
|
226
245
|
msgcontent: "RICH_MEDIA_WECHAT",
|
|
227
246
|
},
|
|
228
247
|
};
|
|
229
248
|
const data = {
|
|
230
|
-
|
|
231
|
-
accountId:
|
|
232
|
-
template_id:
|
|
233
|
-
Title:
|
|
234
|
-
OriginalId:
|
|
249
|
+
content: message,
|
|
250
|
+
accountId: get(templates, 'selectedWeChatAccount.id'),
|
|
251
|
+
template_id: templateIdFromProp || templateId,
|
|
252
|
+
Title: templateNameFromProp || templateName,
|
|
253
|
+
OriginalId: get(templates, 'selectedWeChatAccount.sourceAccountIdentifier'),
|
|
235
254
|
TopColor: "#000000",
|
|
236
255
|
touser: "{{wechat_open_id}}",
|
|
237
|
-
creative_template_id:
|
|
256
|
+
creative_template_id: templateIdFromProp || templateId,
|
|
257
|
+
previewContent: message.mediaList,
|
|
238
258
|
};
|
|
239
259
|
const response = {
|
|
240
260
|
action: "getFormData",
|
|
241
261
|
value: data,
|
|
242
262
|
validity: this.state.isFormValid,
|
|
263
|
+
type: "WECHAT",
|
|
243
264
|
};
|
|
244
|
-
|
|
245
|
-
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
265
|
+
return response;
|
|
246
266
|
}
|
|
247
267
|
injectMessages(elem) {
|
|
248
268
|
const temp = elem;
|
|
@@ -259,7 +279,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
259
279
|
temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
|
|
260
280
|
}
|
|
261
281
|
if (temp.options) {
|
|
262
|
-
|
|
282
|
+
forEach(temp.options, (option, id) => {
|
|
263
283
|
if (messages[option]) {
|
|
264
284
|
temp.options[id] = this.props.intl.formatMessage(messages[option]);
|
|
265
285
|
}
|
|
@@ -272,10 +292,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
272
292
|
this.props.globalActions.addMessageToQueue(message);
|
|
273
293
|
}
|
|
274
294
|
checkFormFieldsCount = () => {
|
|
275
|
-
const templateData =
|
|
295
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
276
296
|
let isLimitExceeded = false;
|
|
277
|
-
|
|
278
|
-
if (
|
|
297
|
+
forEach(templateData, (content) => {
|
|
298
|
+
if (isEmpty(content)) {
|
|
279
299
|
isLimitExceeded = true;
|
|
280
300
|
}
|
|
281
301
|
if (content.formData['title-value'].length > 64) {
|
|
@@ -300,7 +320,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
300
320
|
// }
|
|
301
321
|
// }
|
|
302
322
|
moveToTemplates() {
|
|
303
|
-
console.log("moveToTemplates richmedia");
|
|
304
323
|
const modalContent = {
|
|
305
324
|
title: this.props.intl.formatMessage(messages.modalTitle),
|
|
306
325
|
body: this.props.intl.formatMessage(messages.modalBody),
|
|
@@ -314,49 +333,19 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
314
333
|
this.setState({showModal: false});
|
|
315
334
|
}
|
|
316
335
|
showNext() {
|
|
317
|
-
console.log("richmedia shownext");
|
|
318
336
|
const response = {
|
|
319
337
|
action: "showNext",
|
|
320
338
|
value: true,
|
|
321
339
|
};
|
|
322
340
|
parent.postMessage(JSON.stringify(response), '*');
|
|
323
341
|
}
|
|
324
|
-
handleFrameTasks = (e) => {
|
|
325
|
-
console.log("richmedia handleFrameTasks: ", e.data);
|
|
326
|
-
const type = e.data;
|
|
327
|
-
if (typeof type === 'object') {
|
|
328
|
-
const action = type.action;
|
|
329
|
-
switch (action) {
|
|
330
|
-
case "startLoading":
|
|
331
|
-
this.startLoading(type.edit);
|
|
332
|
-
break;
|
|
333
|
-
case "getCurrentWindow":
|
|
334
|
-
this.getCurrentWindow(type);
|
|
335
|
-
break;
|
|
336
|
-
default:
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
} else {
|
|
340
|
-
switch (type) {
|
|
341
|
-
case "getFormData":
|
|
342
|
-
this.getFormData(e);
|
|
343
|
-
break;
|
|
344
|
-
case "moveToTemplates":
|
|
345
|
-
console.log("moveToTemplates richmedia case");
|
|
346
|
-
this.moveToTemplates();
|
|
347
|
-
break;
|
|
348
|
-
default:
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
342
|
injectEvents = (schema) => {
|
|
354
343
|
const temp = schema;
|
|
355
344
|
if (temp.standalone) {
|
|
356
345
|
temp.standalone.sections = this.injectSections(temp.standalone.sections);
|
|
357
346
|
}
|
|
358
347
|
if (temp.containers) {
|
|
359
|
-
|
|
348
|
+
forEach(temp.containers, (container) => {
|
|
360
349
|
let tempContainer = container;
|
|
361
350
|
tempContainer = this.injectContainer(tempContainer);
|
|
362
351
|
return tempContainer;
|
|
@@ -368,10 +357,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
368
357
|
const temp = container;
|
|
369
358
|
if (temp.type === 'tabs') {
|
|
370
359
|
temp.injectedEvents = {};
|
|
371
|
-
|
|
360
|
+
forEach(temp.supportedEvents, (event) => {
|
|
372
361
|
temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
|
|
373
362
|
});
|
|
374
|
-
|
|
363
|
+
forEach(temp.panes, (pane) => {
|
|
375
364
|
const tempPane = pane;
|
|
376
365
|
tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
|
|
377
366
|
tempPane.sections = this.injectSections(tempPane.sections);
|
|
@@ -380,7 +369,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
380
369
|
return temp;
|
|
381
370
|
}
|
|
382
371
|
injectSections = (sections) => {
|
|
383
|
-
|
|
372
|
+
forEach(sections, (section) => {
|
|
384
373
|
let temp = section;
|
|
385
374
|
if (temp.type === 'col-label') {
|
|
386
375
|
temp = this.injectColLabelSection(temp);
|
|
@@ -393,19 +382,19 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
393
382
|
return sections;
|
|
394
383
|
}
|
|
395
384
|
injectColLabelSection = (section) => {
|
|
396
|
-
|
|
385
|
+
forEach(section.inputFields, (inputField) => {
|
|
397
386
|
let temp = inputField;
|
|
398
387
|
temp.injectedEvents = {};
|
|
399
|
-
|
|
388
|
+
forEach(inputField.supportedEvents, (event) => {
|
|
400
389
|
temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
|
|
401
390
|
});
|
|
402
391
|
temp = this.injectMessages(temp);
|
|
403
392
|
return true;
|
|
404
393
|
});
|
|
405
|
-
|
|
394
|
+
forEach(section.actionFields, (actionField) => {
|
|
406
395
|
let temp = actionField;
|
|
407
396
|
temp.injectedEvents = {};
|
|
408
|
-
|
|
397
|
+
forEach(actionField.supportedEvents, (event) => {
|
|
409
398
|
temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
|
|
410
399
|
});
|
|
411
400
|
temp = this.injectMessages(temp);
|
|
@@ -414,22 +403,22 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
414
403
|
return section;
|
|
415
404
|
}
|
|
416
405
|
injectMultiColSection = (section) => {
|
|
417
|
-
|
|
418
|
-
|
|
406
|
+
forEach(section.inputFields, (inputField) => {
|
|
407
|
+
forEach(inputField.cols, (col) => {
|
|
419
408
|
let temp = col;
|
|
420
409
|
temp.injectedEvents = {};
|
|
421
|
-
|
|
410
|
+
forEach(col.supportedEvents, (event) => {
|
|
422
411
|
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
423
412
|
});
|
|
424
413
|
temp = this.injectMessages(temp);
|
|
425
414
|
return true;
|
|
426
415
|
});
|
|
427
416
|
});
|
|
428
|
-
|
|
429
|
-
|
|
417
|
+
forEach(section.actionFields, (actionField) => {
|
|
418
|
+
forEach(actionField.cols, (col) => {
|
|
430
419
|
let temp = col;
|
|
431
420
|
temp.injectedEvents = {};
|
|
432
|
-
|
|
421
|
+
forEach(col.supportedEvents, (event) => {
|
|
433
422
|
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
434
423
|
});
|
|
435
424
|
temp = this.injectMessages(temp);
|
|
@@ -473,9 +462,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
473
462
|
return postCommentsData;
|
|
474
463
|
}
|
|
475
464
|
prepareMediaList = () => {
|
|
476
|
-
const templateData =
|
|
465
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
477
466
|
const mediaList = [];
|
|
478
|
-
|
|
467
|
+
forEach(templateData, (contentData) => {
|
|
479
468
|
const postCommentsData = this.deducePostCommentsData(contentData.formData['post-comments-value']);
|
|
480
469
|
const filteredContent = {
|
|
481
470
|
title: contentData.formData['title-value'],
|
|
@@ -494,9 +483,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
494
483
|
return mediaList;
|
|
495
484
|
}
|
|
496
485
|
prepareWeChatRichmediaPreviewData = () => {
|
|
497
|
-
const templateData =
|
|
486
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
498
487
|
const returnObj = [];
|
|
499
|
-
|
|
488
|
+
forEach(templateData, (contentData, contentIndex) => {
|
|
500
489
|
const id = parseInt(contentIndex, 10);
|
|
501
490
|
if (id === 0) {
|
|
502
491
|
returnObj.push(
|
|
@@ -534,7 +523,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
534
523
|
}
|
|
535
524
|
saveHandler = () => {
|
|
536
525
|
let isFormValid = this.validateFormFields();
|
|
537
|
-
|
|
526
|
+
const { getFormData, onValidationFail } = this.props;
|
|
527
|
+
if (isEmpty(this.state.templateName)) {
|
|
538
528
|
this.showErrorMessage(this.props.intl.formatMessage(messages.emptyTemplateName));
|
|
539
529
|
isFormValid = false;
|
|
540
530
|
}
|
|
@@ -561,10 +551,23 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
561
551
|
saveObj.type = "WECHAT";
|
|
562
552
|
}
|
|
563
553
|
this.setState({loading: true});
|
|
564
|
-
this.props.actions.saveTemplate(saveObj)
|
|
554
|
+
this.props.actions.saveTemplate(saveObj, (response) => {
|
|
555
|
+
console.log("inside save template callback", response);
|
|
556
|
+
if (getFormData) {
|
|
557
|
+
getFormData(this.getFormData({
|
|
558
|
+
mediaId: response.mediaId,
|
|
559
|
+
templateId: response.templateId,
|
|
560
|
+
mediaList,
|
|
561
|
+
templateName: saveObj.name,
|
|
562
|
+
}));
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
} else {
|
|
566
|
+
onValidationFail();
|
|
565
567
|
}
|
|
566
568
|
}
|
|
567
569
|
uploadImage = (data, uploadId) => {
|
|
570
|
+
console.log("uploadImage", data, uploadId);
|
|
568
571
|
if (data.type === "wrong file") {
|
|
569
572
|
this.showErrorMessage(this.props.intl.formatMessage(messages.wrongFormatFile));
|
|
570
573
|
} else {
|
|
@@ -585,7 +588,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
585
588
|
});
|
|
586
589
|
}
|
|
587
590
|
insertTemplateData = () => {
|
|
588
|
-
const templateData =
|
|
591
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
589
592
|
templateData[this.state.totalContentBlocks - 1] = {
|
|
590
593
|
formData: {},
|
|
591
594
|
imageUrl: "",
|
|
@@ -594,17 +597,21 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
594
597
|
this.setState({templateData});
|
|
595
598
|
}
|
|
596
599
|
updateImageData = () => {
|
|
597
|
-
const templateData =
|
|
598
|
-
if (this.props.ImageData && !
|
|
600
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
601
|
+
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) {
|
|
599
602
|
templateData[this.state.currentContentId].imageUrl = this.props.ImageData[this.state.currentContentId].metaInfo.secure_file_path;
|
|
600
603
|
templateData[this.state.currentContentId].mediaId = this.props.ImageData[this.state.currentContentId].metaInfo.mediaId;
|
|
601
604
|
this.setState({templateData, loading: false});
|
|
602
605
|
}
|
|
603
606
|
}
|
|
604
|
-
viewContent = (
|
|
607
|
+
viewContent = (id, e) => {
|
|
608
|
+
e.stopPropagation();
|
|
609
|
+
console.log("moveContentUpward viewContent", id);
|
|
605
610
|
this.setState({currentContentId: id});
|
|
606
611
|
}
|
|
607
|
-
deleteContent = (
|
|
612
|
+
deleteContent = (id, e) => {
|
|
613
|
+
e.stopPropagation();
|
|
614
|
+
console.log("clicked delete", id);
|
|
608
615
|
const modalContent = {
|
|
609
616
|
title: this.props.intl.formatMessage(messages.modalTitle),
|
|
610
617
|
body: this.props.intl.formatMessage(messages.deleteContent),
|
|
@@ -616,7 +623,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
616
623
|
this.setState({showModal: true, modalContent});
|
|
617
624
|
}
|
|
618
625
|
handleDelete = (modalContent) => {
|
|
619
|
-
const templateData =
|
|
626
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
620
627
|
let totalContentBlocks = this.state.totalContentBlocks;
|
|
621
628
|
let currentContentId = this.state.currentContentId;
|
|
622
629
|
let index = 0;
|
|
@@ -628,175 +635,142 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
628
635
|
totalContentBlocks -= 1;
|
|
629
636
|
this.setState({templateData, totalContentBlocks, currentContentId, showModal: false});
|
|
630
637
|
}
|
|
631
|
-
moveContentDownward = (
|
|
632
|
-
|
|
638
|
+
moveContentDownward = (id, e) => {
|
|
639
|
+
e.stopPropagation();
|
|
640
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
633
641
|
let currentContentId = this.state.currentContentId;
|
|
634
|
-
const temp = templateData[id];
|
|
635
|
-
templateData[id] = templateData[id + 1];
|
|
642
|
+
const temp = cloneDeep(templateData[id]);
|
|
643
|
+
templateData[id] = cloneDeep(templateData[id + 1]);
|
|
636
644
|
templateData[id + 1] = temp;
|
|
637
645
|
currentContentId = id + 1;
|
|
638
646
|
this.setState({templateData, currentContentId});
|
|
639
647
|
}
|
|
640
|
-
moveContentUpward = (
|
|
641
|
-
|
|
648
|
+
moveContentUpward = (id, e) => {
|
|
649
|
+
e.stopPropagation();
|
|
650
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
642
651
|
let currentContentId = this.state.currentContentId;
|
|
643
|
-
const temp = templateData[id];
|
|
644
|
-
templateData[id] = templateData[id - 1];
|
|
652
|
+
const temp = cloneDeep(templateData[id]);
|
|
653
|
+
templateData[id] = cloneDeep(templateData[id - 1]);
|
|
645
654
|
templateData[id - 1] = temp;
|
|
646
655
|
currentContentId = id - 1;
|
|
656
|
+
console.log("moveContentUpward", id, this.state.currentContentId, currentContentId);
|
|
647
657
|
this.setState({templateData, currentContentId});
|
|
648
658
|
}
|
|
659
|
+
getCardActionBar = (contentBlocks, id) => (
|
|
660
|
+
<div className="card-nav-container">
|
|
661
|
+
<CapLink
|
|
662
|
+
onClick={(e) => this.deleteContent(id, e)}
|
|
663
|
+
title={
|
|
664
|
+
<CapIcon
|
|
665
|
+
size="s"
|
|
666
|
+
type="close"
|
|
667
|
+
/>
|
|
668
|
+
}
|
|
669
|
+
/>
|
|
670
|
+
<CapLink
|
|
671
|
+
{...(id > 0 && {onClick: (e) => this.moveContentUpward(id, e)})}
|
|
672
|
+
className={id < 1 ? 'disabled-action' : ''}
|
|
673
|
+
title={<CapIcon
|
|
674
|
+
size="s"
|
|
675
|
+
type="arrow-up"
|
|
676
|
+
style={{
|
|
677
|
+
paddingLeft: '2px',
|
|
678
|
+
paddingBottom: '6px',
|
|
679
|
+
}}
|
|
680
|
+
/>}
|
|
681
|
+
/>
|
|
682
|
+
<CapLink
|
|
683
|
+
{...(id < contentBlocks - 1 && {onClick: (e) => this.moveContentDownward(id, e)})}
|
|
684
|
+
className={contentBlocks - 1 === id ? 'disabled-action' : ''}
|
|
685
|
+
title={<CapIcon
|
|
686
|
+
size="s"
|
|
687
|
+
type="arrow-down"
|
|
688
|
+
style={{
|
|
689
|
+
paddingLeft: '2px',
|
|
690
|
+
}}
|
|
691
|
+
/>}
|
|
692
|
+
/>
|
|
693
|
+
</div>
|
|
694
|
+
)
|
|
649
695
|
returnCardLayout = () => {
|
|
650
|
-
const templateData =
|
|
696
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
697
|
+
const { isIframe, totalContentBlocks } = this.state;
|
|
651
698
|
const returnObj = [];
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
>
|
|
666
|
-
<div>
|
|
667
|
-
<div className="custom-image">
|
|
668
|
-
<img alt="" width="100%" height="139px" src={imageUrl} />
|
|
669
|
-
</div>
|
|
670
|
-
<div className="custom-card overflow-wrap-fields">
|
|
671
|
-
<p style={{ padding: "0px 8px" }}>{contentData && contentData.formData ? contentData.formData['cover-abstract-value'] : ""}</p>
|
|
672
|
-
</div>
|
|
673
|
-
</div>
|
|
674
|
-
</CapCard>
|
|
675
|
-
</div>
|
|
676
|
-
);
|
|
677
|
-
} else {
|
|
678
|
-
returnObj[id] = (
|
|
679
|
-
<div
|
|
680
|
-
id={id}
|
|
681
|
-
style={{ "margin-top": 10 }}
|
|
682
|
-
className="hover-container"
|
|
683
|
-
onClick={(e) => this.viewContent(e, id)}
|
|
699
|
+
forEach(templateData, (contentData, contentId) => {
|
|
700
|
+
const id = parseInt(contentId, 10);
|
|
701
|
+
const imageUrl = contentData.imageUrl || noImage;
|
|
702
|
+
const { formData = {} } = contentData;
|
|
703
|
+
if (id === 0) {
|
|
704
|
+
returnObj[id] = (
|
|
705
|
+
<div>
|
|
706
|
+
<CapRow
|
|
707
|
+
style={{ width: `${totalContentBlocks === 1 ? '260px' : '292px'}`,
|
|
708
|
+
height: `${totalContentBlocks === 1 ? '252px' : '156px'}`,
|
|
709
|
+
display: 'flex',
|
|
710
|
+
}}
|
|
711
|
+
className={id === this.state.currentContentId ? "richmedia-card richmedia-card-clicked" : "richmedia-card"}
|
|
684
712
|
>
|
|
685
|
-
<CapRow style={{ width: 244, height: 53 }} className={id === this.state.currentContentId ? "richmedia-card-rectangle richmedia-card-rectangle-clicked" : "richmedia-card-rectangle"}>
|
|
686
|
-
<CapColumn span={19} style={{ padding: "10px 8px 0px 8px" }} className="overflow-wrap-fields" >
|
|
687
|
-
{contentData && contentData.formData ? contentData.formData['title-value'] : ""}
|
|
688
|
-
</CapColumn>
|
|
689
|
-
<CapColumn span={5} style={{ "height": "100%", "background-color": "#707070" }}>
|
|
690
|
-
<img alt="" width="50px" height="100%" src={imageUrl} />
|
|
691
|
-
</CapColumn>
|
|
692
|
-
</CapRow>
|
|
693
|
-
</div>
|
|
694
|
-
);
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
} else {
|
|
698
|
-
_.forEach(templateData, (contentData, contentId) => {
|
|
699
|
-
const id = parseInt(contentId, 10);
|
|
700
|
-
const imageUrl = contentData.imageUrl;
|
|
701
|
-
if (id === 0) {
|
|
702
|
-
returnObj[id] = (
|
|
703
|
-
<div className="hover-container">
|
|
704
713
|
<CapCard
|
|
705
714
|
id={id}
|
|
706
|
-
|
|
707
|
-
bodyStyle={{
|
|
708
|
-
|
|
715
|
+
bordered={false}
|
|
716
|
+
bodyStyle={{
|
|
717
|
+
padding: 0,
|
|
718
|
+
borderRadius: '4px',
|
|
719
|
+
width: '244px',
|
|
720
|
+
border: '1px solid #e8e8e8',
|
|
721
|
+
}}
|
|
722
|
+
onClick={(e) => this.viewContent(id, e)}
|
|
709
723
|
>
|
|
710
724
|
<div>
|
|
711
|
-
<div className="custom-image">
|
|
712
|
-
<img alt="" width="100%" height="
|
|
725
|
+
<div className={`custom-image ${totalContentBlocks !== 1 && "custom-image-border-bottom"}`}>
|
|
726
|
+
<img alt="" width="100%" height="136px" src={imageUrl} />
|
|
727
|
+
{totalContentBlocks !== 1 && <div className="name-container">
|
|
728
|
+
<CapHeading type="h4">{formData['title-value'] || "Title"}</CapHeading>
|
|
729
|
+
</div>}
|
|
713
730
|
</div>
|
|
714
|
-
|
|
715
|
-
|
|
731
|
+
{totalContentBlocks === 1 &&
|
|
732
|
+
<div className="custom-card">
|
|
733
|
+
<CapHeading type="h4" className="overflow-wrap-fields">{formData['title-value'] || "Title"}</CapHeading>
|
|
734
|
+
<CapHeading type="label7" className="overflow-wrap-fields">{formData['cover-abstract-value'] || "Cover abstract"}</CapHeading>
|
|
716
735
|
</div>
|
|
736
|
+
}
|
|
717
737
|
</div>
|
|
718
738
|
</CapCard>
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
<i className="material-icons hover-icons">arrow_downward</i>
|
|
724
|
-
</div>
|
|
725
|
-
<div id={id} onClick={(e) => this.viewContent(e, id)} style={{ 'padding-left': '190px' }}>
|
|
726
|
-
<i className="material-icons hover-icons">{this.props.intl.formatMessage(messages.visibility)}</i>
|
|
727
|
-
</div>
|
|
728
|
-
</div>
|
|
729
|
-
:
|
|
730
|
-
<div className="richmedia-icons">
|
|
731
|
-
<div id={id} onClick={(e) => this.viewContent(e, id)} style={{ 'padding-left': '214px' }}>
|
|
732
|
-
<i className="material-icons hover-icons">{this.props.intl.formatMessage(messages.visibility)}</i>
|
|
733
|
-
</div>
|
|
734
|
-
</div>
|
|
735
|
-
}
|
|
736
|
-
</div>
|
|
739
|
+
{!isIframe && totalContentBlocks !== 1 &&
|
|
740
|
+
this.getCardActionBar(totalContentBlocks, id)}
|
|
741
|
+
</CapRow>
|
|
742
|
+
</div>
|
|
737
743
|
);
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
style={{ "
|
|
743
|
-
|
|
744
|
+
} else {
|
|
745
|
+
returnObj[id] = (
|
|
746
|
+
<div>
|
|
747
|
+
<CapRow
|
|
748
|
+
style={{ width: 296, height: 72 }} className={id === this.state.currentContentId ? "richmedia-card-rectangle richmedia-card-rectangle-clicked" : "richmedia-card-rectangle"}
|
|
749
|
+
onClick={(e) => this.viewContent(id, e)}
|
|
744
750
|
>
|
|
745
|
-
<
|
|
746
|
-
<CapColumn span={
|
|
747
|
-
{
|
|
751
|
+
<div className="richmedia-card-container">
|
|
752
|
+
<CapColumn span={18} className="overflow-wrap-fields title" >
|
|
753
|
+
<CapHeading type="label7">{formData['title-value'] || "Title"}</CapHeading>
|
|
748
754
|
</CapColumn>
|
|
749
|
-
<CapColumn span={
|
|
750
|
-
<img alt="" width="
|
|
755
|
+
<CapColumn span={6} className="image">
|
|
756
|
+
<img alt="" width="40px" height="40px" src={imageUrl} />
|
|
751
757
|
</CapColumn>
|
|
752
|
-
|
|
753
|
-
<div className="richmedia-icons">
|
|
754
|
-
<div style={{display: 'inline-flex'}}>
|
|
755
|
-
<div id={id} onClick={(e) => this.moveContentUpward(e, id)}>
|
|
756
|
-
<i className="material-icons hover-icons">arrow_upward</i>
|
|
757
|
-
</div>
|
|
758
|
-
{id !== (this.state.totalContentBlocks - 1 ) ?
|
|
759
|
-
<div id={id} onClick={(e) => this.moveContentDownward(e, id)}>
|
|
760
|
-
<i className="material-icons hover-icons">arrow_downward</i>
|
|
761
|
-
</div>
|
|
762
|
-
:
|
|
763
|
-
""
|
|
764
|
-
}
|
|
765
|
-
</div>
|
|
766
|
-
{id !== (this.state.totalContentBlocks - 1 ) ?
|
|
767
|
-
<div style={{'display': 'inline-flex', 'padding-left': '142px'}}>
|
|
768
|
-
<div id={id} onClick={(e) => this.viewContent(e, id)}>
|
|
769
|
-
<i className="material-icons hover-icons">{this.props.intl.formatMessage(messages.visibility)}</i>
|
|
770
|
-
</div>
|
|
771
|
-
<div id={id} onClick={(e) => this.deleteContent(e, id)} >
|
|
772
|
-
<i className="material-icons hover-icons">{this.props.intl.formatMessage(messages.delete)}</i>
|
|
773
|
-
</div>
|
|
774
|
-
</div>
|
|
775
|
-
:
|
|
776
|
-
<div style={{'display': 'inline-flex', 'padding-left': '166px'}}>
|
|
777
|
-
<div id={id} onClick={(e) => this.viewContent(e, id)}>
|
|
778
|
-
<i className="material-icons hover-icons">{this.props.intl.formatMessage(messages.visibility)}</i>
|
|
779
|
-
</div>
|
|
780
|
-
<div id={id} onClick={(e) => this.deleteContent(e, id)} >
|
|
781
|
-
<i className="material-icons hover-icons">{this.props.intl.formatMessage(messages.delete)}</i>
|
|
782
|
-
</div>
|
|
783
|
-
</div>
|
|
784
|
-
}
|
|
758
|
+
{!isIframe && this.getCardActionBar(totalContentBlocks, id)}
|
|
785
759
|
</div>
|
|
786
|
-
</
|
|
760
|
+
</CapRow>
|
|
761
|
+
</div>
|
|
787
762
|
);
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
763
|
+
}
|
|
764
|
+
});
|
|
791
765
|
return (
|
|
792
766
|
<div>{returnObj}</div>
|
|
793
767
|
);
|
|
794
768
|
}
|
|
795
769
|
isTitleRepeated = () => {
|
|
796
|
-
const templateData =
|
|
770
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
797
771
|
const titleSet = new Set();
|
|
798
772
|
let isRepeated = false;
|
|
799
|
-
|
|
773
|
+
forEach(templateData, (content) => {
|
|
800
774
|
const setSizeBefore = titleSet.size;
|
|
801
775
|
titleSet.add(content.formData['title-value'].toLowerCase());
|
|
802
776
|
const setSizeAfter = titleSet.size;
|
|
@@ -807,14 +781,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
807
781
|
return isRepeated;
|
|
808
782
|
}
|
|
809
783
|
isFormEmpty = () => {
|
|
810
|
-
const templateData =
|
|
811
|
-
let
|
|
812
|
-
|
|
813
|
-
if (
|
|
814
|
-
|
|
784
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
785
|
+
let isFormEmpty = false;
|
|
786
|
+
forEach(templateData, (content) => {
|
|
787
|
+
if (isEmpty(content.formData)) {
|
|
788
|
+
isFormEmpty = true;
|
|
815
789
|
}
|
|
816
790
|
});
|
|
817
|
-
return
|
|
791
|
+
return isFormEmpty;
|
|
818
792
|
}
|
|
819
793
|
validateFormFields = () => {
|
|
820
794
|
let isValid = true;
|
|
@@ -824,22 +798,22 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
824
798
|
isValid = false;
|
|
825
799
|
return isValid;
|
|
826
800
|
}
|
|
827
|
-
if (
|
|
801
|
+
if (isEmpty(currentContent.formData['title-value'])) {
|
|
828
802
|
this.showErrorMessage(this.props.intl.formatMessage(messages.titleEmpty));
|
|
829
803
|
isValid = false;
|
|
830
804
|
return isValid;
|
|
831
805
|
}
|
|
832
|
-
if (
|
|
806
|
+
if (isEmpty(currentContent.imageUrl) || isEmpty(currentContent.mediaId)) {
|
|
833
807
|
this.showErrorMessage(this.props.intl.formatMessage(messages.noImage));
|
|
834
808
|
isValid = false;
|
|
835
809
|
return isValid;
|
|
836
810
|
}
|
|
837
|
-
if (
|
|
811
|
+
if (isEmpty(currentContent.formData['source-link-value'])) {
|
|
838
812
|
this.showErrorMessage(this.props.intl.formatMessage(messages.sourceLinkEmpty));
|
|
839
813
|
isValid = false;
|
|
840
814
|
return isValid;
|
|
841
815
|
}
|
|
842
|
-
if (
|
|
816
|
+
if (isEmpty(currentContent.formData['content-value'])) {
|
|
843
817
|
this.showErrorMessage(this.props.intl.formatMessage(messages.contentEmpty));
|
|
844
818
|
isValid = false;
|
|
845
819
|
return isValid;
|
|
@@ -853,7 +827,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
853
827
|
isValid = false;
|
|
854
828
|
return isValid;
|
|
855
829
|
}
|
|
856
|
-
if (!
|
|
830
|
+
if (!isEmpty(currentContent.formData['source-link-value'])) {
|
|
857
831
|
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);
|
|
858
832
|
if (!isValid) {
|
|
859
833
|
this.showErrorMessage(this.props.intl.formatMessage(messages.wrongUrl));
|
|
@@ -862,37 +836,16 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
862
836
|
}
|
|
863
837
|
return isValid;
|
|
864
838
|
}
|
|
865
|
-
menuOnClickEvent(
|
|
839
|
+
menuOnClickEvent() {
|
|
866
840
|
const isFormValid = this.validateFormFields();
|
|
867
841
|
if (!isFormValid) {
|
|
868
842
|
return false;
|
|
869
843
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
}, () => {
|
|
876
|
-
this.updateTotalContentBlocks();
|
|
877
|
-
});
|
|
878
|
-
} else {
|
|
879
|
-
this.showErrorMessage(this.props.intl.formatMessage(messages.maxContentCount));
|
|
880
|
-
}
|
|
881
|
-
break;
|
|
882
|
-
case "old_richmedia_content":
|
|
883
|
-
this.setState({
|
|
884
|
-
currentContentId: this.state.currentContentId + 1,
|
|
885
|
-
}, () => {
|
|
886
|
-
this.updateTotalContentBlocks();
|
|
887
|
-
});
|
|
888
|
-
break;
|
|
889
|
-
default:
|
|
890
|
-
this.setState({
|
|
891
|
-
currentContentId: this.state.totalContentBlocks + 1,
|
|
892
|
-
}, () => {
|
|
893
|
-
this.updateTotalContentBlocks();
|
|
894
|
-
});
|
|
895
|
-
}
|
|
844
|
+
this.setState({
|
|
845
|
+
currentContentId: this.state.totalContentBlocks,
|
|
846
|
+
}, () => {
|
|
847
|
+
this.updateTotalContentBlocks();
|
|
848
|
+
});
|
|
896
849
|
return true;
|
|
897
850
|
}
|
|
898
851
|
updateContentData = () => {
|
|
@@ -901,27 +854,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
901
854
|
this.setState({loading: false});
|
|
902
855
|
}
|
|
903
856
|
returnContentMenu = () => {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
<MenuItem key="new_richmedia_content">
|
|
911
|
-
<FormattedMessage {...messages.addNewRichmedia} />
|
|
912
|
-
</MenuItem>
|
|
913
|
-
</Menu>
|
|
857
|
+
const addRichMediaMenu = (
|
|
858
|
+
<>
|
|
859
|
+
<div style={{width: '292px'}}><CapDivider /></div>
|
|
860
|
+
<CapHeading type="h5" style={{marginBottom: '8px'}}>Add rich media content</CapHeading>
|
|
861
|
+
<CapButton type="dashed" onClick={this.menuOnClickEvent} prefix={<CapIcon size="s" type="add-media" />} style={{backgroundColor: 'white'}}>New media</CapButton>
|
|
862
|
+
</>
|
|
914
863
|
);
|
|
915
|
-
|
|
916
|
-
<CapButton style={{width: '244', height: '53', marginTop: '16'}} type="secondary">
|
|
917
|
-
<div style={{display: 'inline-flex'}}>
|
|
918
|
-
<p>
|
|
919
|
-
<i style={{ color: '#2e89df'}} className="material-icons">+</i>
|
|
920
|
-
</p>
|
|
921
|
-
</div>
|
|
922
|
-
</CapButton>
|
|
923
|
-
</Dropdown>);
|
|
924
|
-
return actionButton;
|
|
864
|
+
return addRichMediaMenu;
|
|
925
865
|
}
|
|
926
866
|
focusOutFromCkEditor = () => {
|
|
927
867
|
this.setState({focusOut: true});
|
|
@@ -930,17 +870,19 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
930
870
|
this.setState({focusOut: false});
|
|
931
871
|
}
|
|
932
872
|
returnCurrentSchema = () => {
|
|
933
|
-
let schema =
|
|
873
|
+
let schema = cloneDeep(this.state.richmediaSchema);
|
|
934
874
|
if (this.state.isIframe) {
|
|
935
|
-
const disabledFormSchema =
|
|
936
|
-
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[0].cols[
|
|
937
|
-
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[1].cols[
|
|
938
|
-
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[2].cols[
|
|
939
|
-
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[3].cols[
|
|
875
|
+
const disabledFormSchema = cloneDeep(this.state.richmediaSchema);
|
|
876
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[0].cols[0].disabled = true;
|
|
877
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[1].cols[0].disabled = true;
|
|
878
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[2].cols[0].disabled = true;
|
|
879
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[3].cols[0].disabled = true;
|
|
940
880
|
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[4].cols[0].disabled = true;
|
|
941
|
-
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[5].cols[
|
|
942
|
-
disabledFormSchema.standalone.sections[0].childSections[2].inputFields[0].cols[
|
|
943
|
-
disabledFormSchema.standalone.sections[0].childSections[
|
|
881
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[5].cols[0].disabled = true;
|
|
882
|
+
disabledFormSchema.standalone.sections[0].childSections[2].inputFields[0].cols[0].disabled = true;
|
|
883
|
+
disabledFormSchema.standalone.sections[0].childSections[0].inputFields[4].cols[0].componentProps.disabled = true;
|
|
884
|
+
disabledFormSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[1].disabled = true;
|
|
885
|
+
disabledFormSchema.standalone.sections[0].childSections[2].inputFields[2].cols[0].disabled = true;
|
|
944
886
|
if (this.state.editorInstanse) {
|
|
945
887
|
this.state.editorInstanse.setReadOnly(true);
|
|
946
888
|
}
|
|
@@ -948,15 +890,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
948
890
|
return schema;
|
|
949
891
|
}
|
|
950
892
|
if (this.state.editorInstanse && this.state.focusOut) {
|
|
951
|
-
schema.standalone.sections[0].childSections[1].childSections[
|
|
893
|
+
schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[1].disabled = true;
|
|
952
894
|
} else if (this.state.editorInstanse && !this.state.focusOut) {
|
|
953
|
-
schema.standalone.sections[0].childSections[1].childSections[
|
|
895
|
+
schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[1].disabled = false;
|
|
954
896
|
}
|
|
955
897
|
schema = this.injectEvents(schema);
|
|
956
898
|
return schema;
|
|
957
899
|
}
|
|
958
900
|
returnCurrentFormData = () => {
|
|
959
|
-
const formData = this.state.templateData && !
|
|
901
|
+
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) : {};
|
|
960
902
|
return formData;
|
|
961
903
|
}
|
|
962
904
|
render() {
|
|
@@ -964,6 +906,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
964
906
|
const contentMenu = this.returnContentMenu();
|
|
965
907
|
const schema = this.returnCurrentSchema();
|
|
966
908
|
const formData = this.returnCurrentFormData();
|
|
909
|
+
const { isIframe } = this.state;
|
|
967
910
|
this.updateImageData();
|
|
968
911
|
if (this.props.ContentImageData && this.props.ContentImageData.metaInfo && this.props.ContentImageData.metaInfo.wechatUrl) {
|
|
969
912
|
this.updateContentData();
|
|
@@ -985,13 +928,22 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
985
928
|
title="Wechat Richmedia"
|
|
986
929
|
/>
|
|
987
930
|
<div className="wechat-container">
|
|
988
|
-
{!this.state.isIframe && <Header templateName={this.state.templateName} templateNameHandler={this.templateNameHandler} previewHandler={this.previewHandler} cancelHandler={this.cancelHandler} saveHandler={this.saveHandler} />}
|
|
989
931
|
<CapRow className="wechat-form-container">
|
|
990
|
-
<CapColumn span={
|
|
932
|
+
<CapColumn span={8}>
|
|
991
933
|
{cardLayout}
|
|
992
934
|
{!this.state.isIframe && contentMenu}
|
|
993
935
|
</CapColumn>
|
|
994
|
-
<CapColumn span={
|
|
936
|
+
<CapColumn span={16}>
|
|
937
|
+
{ !isIframe && <CapInput
|
|
938
|
+
label="Name of the template"
|
|
939
|
+
value={this.state.templateName}
|
|
940
|
+
onChange={this.templateNameHandler}
|
|
941
|
+
size="large"
|
|
942
|
+
style={{
|
|
943
|
+
marginBottom: '24px',
|
|
944
|
+
}}
|
|
945
|
+
className="richmedia-template-name"
|
|
946
|
+
/>}
|
|
995
947
|
<FormBuilder
|
|
996
948
|
key={this.state.currentContentId}
|
|
997
949
|
schema={schema}
|
|
@@ -1034,6 +986,10 @@ Create.propTypes = {
|
|
|
1034
986
|
Create: PropTypes.object,
|
|
1035
987
|
intl: intlShape.isRequired,
|
|
1036
988
|
ContentImageData: PropTypes.object,
|
|
989
|
+
isFullMode: PropTypes.bool,
|
|
990
|
+
isGetFormData: PropTypes.bool,
|
|
991
|
+
getFormData: PropTypes.func,
|
|
992
|
+
onValidationFail: PropTypes.func,
|
|
1037
993
|
};
|
|
1038
994
|
|
|
1039
995
|
const mapStateToProps = createStructuredSelector({
|