@capillarytech/creatives-library 8.0.136 → 8.0.137-alpha.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/constants/unified.js +189 -0
- package/package.json +1 -1
- package/services/getSchema.js +1 -1
- package/services/localStorageApi.js +1 -0
- package/tests/i18n.test.js +1 -1
- package/utils/common.js +2 -2
- 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 +1 -1
- package/v2Components/CapTagList/index.js +9 -14
- 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 +2 -1
- 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 +1 -1
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +0 -1
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +271 -0
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +189 -0
- package/v2Containers/MobilePushNew/index.scss +0 -7
- 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/components/BreadCrumbs/index.js +0 -65
- package/components/BreadCrumbs/messages.js +0 -13
- package/components/CapTagList/index.js +0 -235
- package/components/CapTagList/messages.js +0 -45
- package/components/Card/_customCard.scss +0 -40
- package/components/Card/index.js +0 -78
- package/components/Card/tests/__snapshots__/index.test.js.snap +0 -22
- package/components/Card/tests/index.test.js +0 -20
- package/components/CardGrid/index.js +0 -71
- package/components/Ckeditor/index.js +0 -238
- package/components/Ckeditor/messages.js +0 -13
- package/components/Ckeditor/style.scss +0 -3
- package/components/Component/index.js +0 -29
- package/components/CustomPopOver/index.js +0 -81
- package/components/CustomPopOver/messages.js +0 -17
- package/components/DateFilter/index.js +0 -349
- package/components/DateFilter/messages.js +0 -57
- package/components/DateRange/index.js +0 -114
- package/components/DateRange/messages.js +0 -25
- package/components/Edmeditor/index.js +0 -65
- package/components/Edmeditor/messages.js +0 -13
- package/components/EmailPreview/_emailPreview.scss +0 -119
- package/components/EmailPreview/assets/images/iPad.svg +0 -10
- package/components/EmailPreview/assets/images/mobile.png +0 -0
- package/components/EmailPreview/index.js +0 -107
- package/components/EmailPreview/messages.js +0 -33
- package/components/Footer/index.js +0 -27
- package/components/Footer/messages.js +0 -13
- package/components/FormBuilder/_formBuilder.scss +0 -83
- package/components/FormBuilder/index.js +0 -3279
- package/components/FormBuilder/messages.js +0 -61
- package/components/Header/index.js +0 -44
- package/components/Header/messages.js +0 -29
- package/components/ImagePreview/_imagePreview.scss +0 -63
- package/components/ImagePreview/index.js +0 -52
- package/components/ImagePreview/messages.js +0 -17
- package/components/PageHeader/_pageHeader.scss +0 -22
- package/components/PageHeader/index.js +0 -37
- package/components/PageHeader/messages.js +0 -13
- package/components/Pagination/_pagination.scss +0 -5
- package/components/Pagination/index.js +0 -49
- package/components/PreviewSideBar/_previewsidebar.scss +0 -28
- package/components/PreviewSideBar/index.js +0 -152
- package/components/PreviewSideBar/messages.js +0 -41
- package/components/Sidebar/_sidebar.scss +0 -115
- package/components/Sidebar/index.js +0 -214
- package/components/Sidebar/messages.js +0 -21
- package/components/SlideBox/_slideBox.scss +0 -63
- package/components/SlideBox/index.js +0 -47
- package/components/SlideBox/tests/index.test.js +0 -103
- package/components/SmsEditor/index.js +0 -55
- package/components/SmsTest/index.js +0 -117
- package/components/SmsTest/messages.js +0 -21
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +0 -42
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +0 -141
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +0 -21
- package/components/TemplatePreview/_templatePreview.scss +0 -642
- package/components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
- package/components/TemplatePreview/assets/images/androidPushMessage.svg +0 -45
- package/components/TemplatePreview/assets/images/home-screen-android.svg +0 -21
- package/components/TemplatePreview/assets/images/home-screen-ios.svg +0 -16
- package/components/TemplatePreview/assets/images/iPhonePushMessage.svg +0 -135
- package/components/TemplatePreview/assets/images/mobile.svg +0 -24
- 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 +0 -22
- package/components/TemplatePreview/assets/images/sms_mobile_ios.svg +0 -16
- package/components/TemplatePreview/assets/images/user-icon.svg +0 -19
- package/components/TemplatePreview/assets/images/wechat-mobile.svg +0 -78
- package/components/TemplatePreview/assets/images/wechat_mobile_android.svg +0 -20
- package/components/TemplatePreview/index.js +0 -617
- package/components/TemplatePreview/messages.js +0 -78
- package/components/Toastr/index.js +0 -60
- package/components/Toastr/messages.js +0 -13
- package/components/ToastrMessage/index.js +0 -113
- package/components/ToastrMessage/messages.js +0 -17
- package/components/TopBar/_topbar.scss +0 -46
- 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 +0 -113
- package/components/TopBar/messages.js +0 -29
- package/containers/App/actions.js +0 -7
- package/containers/App/constants.js +0 -114
- package/containers/App/index.js +0 -52
- package/containers/App/reducer.js +0 -19
- package/containers/App/sagas.js +0 -31
- package/containers/App/selectors.js +0 -25
- package/containers/App/test/saga.test.js +0 -11
- package/containers/Assets/Gallery/_gallery.scss +0 -126
- package/containers/Assets/Gallery/actions.js +0 -37
- package/containers/Assets/Gallery/constants.js +0 -23
- package/containers/Assets/Gallery/index.js +0 -473
- package/containers/Assets/Gallery/messages.js +0 -93
- package/containers/Assets/Gallery/reducer.js +0 -81
- package/containers/Assets/Gallery/sagas.js +0 -80
- package/containers/Assets/Gallery/selectors.js +0 -25
- package/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +0 -9
- package/containers/Assets/Gallery/tests/actions.test.js +0 -25
- package/containers/Assets/Gallery/tests/reducer.test.js +0 -96
- package/containers/Assets/Gallery/tests/saga.test.js +0 -157
- package/containers/Cap/actions.js +0 -66
- package/containers/Cap/constants.js +0 -25
- package/containers/Cap/index.js +0 -402
- package/containers/Cap/messages.js +0 -75
- package/containers/Cap/reducer.js +0 -113
- package/containers/Cap/sagas.js +0 -159
- package/containers/Cap/selectors.js +0 -75
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +0 -2269
- package/containers/Cap/tests/index.test.js +0 -22
- package/containers/Cap/tests/saga.test.js +0 -284
- package/containers/Dashboard/actions.js +0 -15
- package/containers/Dashboard/constants.js +0 -7
- package/containers/Dashboard/index.js +0 -76
- package/containers/Dashboard/messages.js +0 -13
- package/containers/Dashboard/reducer.js +0 -21
- package/containers/Dashboard/sagas.js +0 -17
- package/containers/Dashboard/selectors.js +0 -25
- package/containers/Dashboard/test/saga.test.js +0 -9
- package/containers/Ebill/_ebill.scss +0 -5
- package/containers/Ebill/actions.js +0 -43
- package/containers/Ebill/constants.js +0 -20
- package/containers/Ebill/index.js +0 -1278
- package/containers/Ebill/messages.js +0 -77
- package/containers/Ebill/reducer.js +0 -72
- package/containers/Ebill/sagas.js +0 -74
- package/containers/Ebill/selectors.js +0 -25
- package/containers/Ebill/test/saga.test.js +0 -11
- package/containers/Email/_email.scss +0 -141
- package/containers/Email/actions.js +0 -81
- package/containers/Email/constants.js +0 -36
- package/containers/Email/index.js +0 -3325
- package/containers/Email/messages.js +0 -289
- package/containers/Email/reducer.js +0 -142
- package/containers/Email/sagas.js +0 -135
- package/containers/Email/selectors.js +0 -31
- package/containers/Email/test/saga.test.js +0 -671
- package/containers/LanguageProvider/actions.js +0 -17
- package/containers/LanguageProvider/constants.js +0 -8
- package/containers/LanguageProvider/index.js +0 -80
- package/containers/LanguageProvider/reducer.js +0 -30
- package/containers/LanguageProvider/selectors.js +0 -20
- package/containers/LanguageProvider/tests/actions.test.js +0 -19
- package/containers/LanguageProvider/tests/index.test.js +0 -78
- package/containers/LanguageProvider/tests/reducer.test.js +0 -20
- package/containers/LanguageProvider/tests/selectors.test.js +0 -15
- package/containers/Line/Create/_lineCreate.scss +0 -54
- package/containers/Line/Create/actions.js +0 -90
- package/containers/Line/Create/constants.js +0 -39
- package/containers/Line/Create/index.js +0 -836
- package/containers/Line/Create/messages.js +0 -189
- package/containers/Line/Create/reducer.js +0 -99
- package/containers/Line/Create/sagas.js +0 -121
- package/containers/Line/Create/selectors.js +0 -36
- package/containers/Line/Create/tests/saga.test.js +0 -202
- package/containers/Line/Edit/_lineEdit.scss +0 -35
- package/containers/Line/Edit/actions.js +0 -79
- package/containers/Line/Edit/constants.js +0 -27
- package/containers/Line/Edit/index.js +0 -1050
- package/containers/Line/Edit/messages.js +0 -177
- package/containers/Line/Edit/reducer.js +0 -83
- package/containers/Line/Edit/sagas.js +0 -80
- package/containers/Line/Edit/selectors.js +0 -29
- package/containers/Line/Edit/test/saga.test.js +0 -160
- package/containers/Login/assets/images/capillary_logo.png +0 -0
- package/containers/Login/components/LoginForm/index.js +0 -62
- package/containers/Login/components/LoginForm/messages.js +0 -33
- package/containers/Login/index.js +0 -130
- package/containers/Login/messages.js +0 -25
- package/containers/Login/selectors.js +0 -25
- package/containers/MobilePush/Create/_mobilePushCreate.scss +0 -39
- package/containers/MobilePush/Create/actions.js +0 -46
- package/containers/MobilePush/Create/constants.js +0 -23
- package/containers/MobilePush/Create/index.js +0 -2303
- package/containers/MobilePush/Create/messages.js +0 -269
- package/containers/MobilePush/Create/reducer.js +0 -70
- package/containers/MobilePush/Create/sagas.js +0 -74
- package/containers/MobilePush/Create/selectors.js +0 -28
- package/containers/MobilePush/Create/test/saga.test.js +0 -19
- package/containers/MobilePush/Edit/_mobilePushCreate.scss +0 -39
- package/containers/MobilePush/Edit/actions.js +0 -91
- package/containers/MobilePush/Edit/constants.js +0 -35
- package/containers/MobilePush/Edit/index.js +0 -2601
- package/containers/MobilePush/Edit/messages.js +0 -266
- package/containers/MobilePush/Edit/reducer.js +0 -112
- package/containers/MobilePush/Edit/sagas.js +0 -126
- package/containers/MobilePush/Edit/selectors.js +0 -29
- package/containers/MobilePush/Edit/tests/saga.test.js +0 -255
- package/containers/NotFoundPage/index.js +0 -25
- package/containers/NotFoundPage/messages.js +0 -13
- package/containers/NotFoundPage/tests/index.test.js +0 -17
- package/containers/Sms/Create/_smsCreate.scss +0 -42
- package/containers/Sms/Create/actions.js +0 -27
- package/containers/Sms/Create/constants.js +0 -16
- package/containers/Sms/Create/index.js +0 -1488
- package/containers/Sms/Create/messages.js +0 -109
- package/containers/Sms/Create/reducer.js +0 -41
- package/containers/Sms/Create/sagas.js +0 -40
- package/containers/Sms/Create/selectors.js +0 -28
- package/containers/Sms/Create/test/saga.test.js +0 -11
- package/containers/Sms/Edit/actions.js +0 -40
- package/containers/Sms/Edit/constants.js +0 -17
- package/containers/Sms/Edit/index.js +0 -1472
- package/containers/Sms/Edit/messages.js +0 -105
- package/containers/Sms/Edit/reducer.js +0 -50
- package/containers/Sms/Edit/sagas.js +0 -60
- package/containers/Sms/Edit/selectors.js +0 -32
- package/containers/Sms/Edit/test/saga.test.js +0 -13
- package/containers/TagList/_tagList.scss +0 -8
- package/containers/TagList/actions.js +0 -15
- package/containers/TagList/constants.js +0 -32
- package/containers/TagList/index.js +0 -236
- package/containers/TagList/messages.js +0 -13
- package/containers/TagList/reducer.js +0 -23
- package/containers/TagList/sagas.js +0 -11
- package/containers/TagList/selectors.js +0 -25
- package/containers/Templates/_templates.scss +0 -333
- package/containers/Templates/actions.js +0 -103
- package/containers/Templates/constants.js +0 -60
- package/containers/Templates/index.js +0 -1756
- package/containers/Templates/messages.js +0 -337
- package/containers/Templates/reducer.js +0 -142
- package/containers/Templates/sagas.js +0 -163
- package/containers/Templates/selectors.js +0 -28
- package/containers/Templates/test/saga.test.js +0 -241
- package/containers/WeChat/MapTemplates/_mapTemplates.scss +0 -8
- package/containers/WeChat/MapTemplates/actions.js +0 -52
- package/containers/WeChat/MapTemplates/constants.js +0 -28
- package/containers/WeChat/MapTemplates/index.js +0 -1610
- package/containers/WeChat/MapTemplates/messages.js +0 -157
- package/containers/WeChat/MapTemplates/reducer.js +0 -74
- package/containers/WeChat/MapTemplates/sagas.js +0 -84
- package/containers/WeChat/MapTemplates/selectors.js +0 -25
- package/containers/WeChat/MapTemplates/test/saga.test.js +0 -155
- package/containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +0 -57
- package/containers/WeChat/RichmediaTemplates/Create/actions.js +0 -36
- package/containers/WeChat/RichmediaTemplates/Create/constants.js +0 -15
- package/containers/WeChat/RichmediaTemplates/Create/index.js +0 -1071
- package/containers/WeChat/RichmediaTemplates/Create/messages.js +0 -165
- package/containers/WeChat/RichmediaTemplates/Create/reducer.js +0 -60
- package/containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +0 -497
- package/containers/WeChat/RichmediaTemplates/Create/sagas.js +0 -51
- package/containers/WeChat/RichmediaTemplates/Create/selectors.js +0 -37
- package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +0 -13
- package/containers/WeChat/RichmediaTemplates/Edit/actions.js +0 -20
- package/containers/WeChat/RichmediaTemplates/Edit/constants.js +0 -10
- package/containers/WeChat/RichmediaTemplates/Edit/index.js +0 -136
- package/containers/WeChat/RichmediaTemplates/Edit/messages.js +0 -13
- package/containers/WeChat/RichmediaTemplates/Edit/reducer.js +0 -28
- package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +0 -36
- package/containers/WeChat/RichmediaTemplates/Edit/selectors.js +0 -30
- package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +0 -12
- package/containers/WeChat/RichmediaTemplates/View/actions.js +0 -15
- package/containers/WeChat/RichmediaTemplates/View/constants.js +0 -7
- package/containers/WeChat/RichmediaTemplates/View/index.js +0 -47
- package/containers/WeChat/RichmediaTemplates/View/messages.js +0 -21
- package/containers/WeChat/RichmediaTemplates/View/reducer.js +0 -23
- package/containers/WeChat/RichmediaTemplates/View/sagas.js +0 -11
- package/containers/WeChat/RichmediaTemplates/View/selectors.js +0 -25
- package/utils/asyncInjectors.js +0 -78
- package/utils/callNativeEvent.js +0 -16
- package/utils/checkStore.js +0 -21
- package/utils/customAuthWrapper.js +0 -62
- package/utils/customConnectedAuthWrapper.js +0 -26
- package/utils/jed.js +0 -1497
- package/utils/smsCharCount.js +0 -351
|
@@ -1,836 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React, { Component } from 'react';
|
|
3
|
-
import {connect} from 'react-redux';
|
|
4
|
-
import { bindActionCreators, compose } from 'redux';
|
|
5
|
-
import { injectIntl, intlShape } from 'react-intl';
|
|
6
|
-
import { createStructuredSelector } from 'reselect';
|
|
7
|
-
import { Row, Col, Spin, Breadcrumb } from 'antd';
|
|
8
|
-
import _ from 'lodash';
|
|
9
|
-
import messages from './messages';
|
|
10
|
-
import * as actions from './actions';
|
|
11
|
-
import FormBuilder from '../../../components/FormBuilder';
|
|
12
|
-
import { UserIsAuthenticated } from '../../../utils/authWrapper';
|
|
13
|
-
import * as globalActions from '../../../containers/Cap/actions';
|
|
14
|
-
//import { makeSelectCreate, makeSelectCreateResponse, makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse } from './selectors';
|
|
15
|
-
import {makeSelectCreateLine} from './selectors';
|
|
16
|
-
import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
|
|
17
|
-
import {getMessageObject} from '../../../utils/messageUtils';
|
|
18
|
-
import { makeSelectTemplates } from '../../Templates/selectors';
|
|
19
|
-
import './_lineCreate.scss';
|
|
20
|
-
import injectSaga from '../../../utils/injectSaga';
|
|
21
|
-
import injectReducer from '../../../utils/injectReducer';
|
|
22
|
-
import reducer from './reducer';
|
|
23
|
-
import { lineCreateSaga } from './sagas';
|
|
24
|
-
import { createQueryString } from '../../../utils/common';
|
|
25
|
-
|
|
26
|
-
const BreadcrumbItem = Breadcrumb.Item;
|
|
27
|
-
|
|
28
|
-
export class Line extends Component {
|
|
29
|
-
|
|
30
|
-
constructor(props) {
|
|
31
|
-
super(props);
|
|
32
|
-
const map = {
|
|
33
|
-
"save-button": {
|
|
34
|
-
saveFormData: this.saveFormData,
|
|
35
|
-
},
|
|
36
|
-
"template-name": {
|
|
37
|
-
onChange: this.onTemplateNameChange,
|
|
38
|
-
},
|
|
39
|
-
"discard-button": {
|
|
40
|
-
discardValues: this.discardValues,
|
|
41
|
-
},
|
|
42
|
-
"cancel-button": {
|
|
43
|
-
cancelTemplate: this.cancelTemplate,
|
|
44
|
-
},
|
|
45
|
-
"message-editor": {
|
|
46
|
-
onChange: this.onTemplateContentChange,
|
|
47
|
-
},
|
|
48
|
-
"message-editor2": {
|
|
49
|
-
onChange: this.onTemplateContentChange,
|
|
50
|
-
},
|
|
51
|
-
"message-tagList": {
|
|
52
|
-
onTagSelect: this.onTagSelect,
|
|
53
|
-
},
|
|
54
|
-
"title-tagList": {
|
|
55
|
-
onTagSelect: this.onTagSelectTitle,
|
|
56
|
-
},
|
|
57
|
-
"pane": {
|
|
58
|
-
onTabChange: this.onTabChange,
|
|
59
|
-
},
|
|
60
|
-
"line-template": {
|
|
61
|
-
onSelect: this.onTemplateChange,
|
|
62
|
-
},
|
|
63
|
-
"image-upload-line": {
|
|
64
|
-
onUpload: this.uploadImage,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
this.state = {
|
|
68
|
-
schema: {},
|
|
69
|
-
isSchemaChanged: false,
|
|
70
|
-
formData: {0: {}},
|
|
71
|
-
tabCount: 1,
|
|
72
|
-
currentTab: 1,
|
|
73
|
-
loading: false,
|
|
74
|
-
isFormValid: true,
|
|
75
|
-
tabKey: '',
|
|
76
|
-
checkValidation: false,
|
|
77
|
-
eventsMap: map,
|
|
78
|
-
errorData: {},
|
|
79
|
-
displayProps: {},
|
|
80
|
-
modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.templateNotConfigured), type: 'confirm'},
|
|
81
|
-
injectedTags: {},
|
|
82
|
-
isEdit: false,
|
|
83
|
-
isEdited: false,
|
|
84
|
-
editTemplateData: {},
|
|
85
|
-
isReady: false,
|
|
86
|
-
modeType: null,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
componentWillMount() {
|
|
91
|
-
if (this.props.params.id) {
|
|
92
|
-
const editTemplateId = this.props.params.id;
|
|
93
|
-
this.props.actions.getTemplateDetails(editTemplateId, 'LINE');
|
|
94
|
-
this.setState({isEdit: true});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
componentDidMount() {
|
|
99
|
-
const getSchemaQuery = {
|
|
100
|
-
layout: 'LINE',
|
|
101
|
-
type: 'LAYOUT',
|
|
102
|
-
};
|
|
103
|
-
this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
|
|
104
|
-
const type = this.props.location.query.type;
|
|
105
|
-
const name = this.props.route.name;
|
|
106
|
-
window.addEventListener("message", this.handleFrameTasks);
|
|
107
|
-
if (type === 'embedded') {
|
|
108
|
-
const response = {
|
|
109
|
-
action: 'startTemplateCreation',
|
|
110
|
-
window: name === 'view' ? 'view' : '',
|
|
111
|
-
};
|
|
112
|
-
parent.postMessage(JSON.stringify(response), '*');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
componentWillReceiveProps(nextProps) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//// Create template logic ////
|
|
120
|
-
|
|
121
|
-
let modeType;
|
|
122
|
-
const {layouts, tags} = nextProps.metaEntities;
|
|
123
|
-
const isSchemaReady = (layouts !== undefined && layouts.length > 0);
|
|
124
|
-
const editModeType = nextProps.route.name;
|
|
125
|
-
if (nextProps.params.mode === 'text' || nextProps.route.name === 'edit_text') {
|
|
126
|
-
modeType = 'text';
|
|
127
|
-
} else {
|
|
128
|
-
modeType = 'image';
|
|
129
|
-
}
|
|
130
|
-
if (modeType) {
|
|
131
|
-
this.setState({modeType, schema: {}});
|
|
132
|
-
//
|
|
133
|
-
}
|
|
134
|
-
if (nextProps.isGetFormData) {
|
|
135
|
-
nextProps.getFormLibraryData(this.getFormData());
|
|
136
|
-
}
|
|
137
|
-
if (isSchemaReady) {
|
|
138
|
-
// set schema value as per mode type. Supported mode (text & image)
|
|
139
|
-
|
|
140
|
-
const {textSchema, imageSchema} = layouts[0].definition;
|
|
141
|
-
const schema = (modeType === "text" || editModeType === 'edit_text') ? textSchema : imageSchema;
|
|
142
|
-
this.setState({schema}, () => {
|
|
143
|
-
// Once schema is ready and set, then inject the available events from the schema
|
|
144
|
-
if (!_.isEmpty(this.state.schema)) {
|
|
145
|
-
this.injectEvents(this.state.schema);
|
|
146
|
-
}
|
|
147
|
-
// Once schema is ready, then only get the tags.
|
|
148
|
-
const getTagsQuery = {
|
|
149
|
-
layout: 'LINE',
|
|
150
|
-
type: 'TAG',
|
|
151
|
-
context: 'outbound',
|
|
152
|
-
embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
|
|
153
|
-
};
|
|
154
|
-
if (this.props.getDefaultTags) {
|
|
155
|
-
getTagsQuery.context = this.props.getDefaultTags;
|
|
156
|
-
}
|
|
157
|
-
if (tags === undefined && modeType !== 'image') {
|
|
158
|
-
this.props.globalActions.fetchSchemaForEntity(getTagsQuery);
|
|
159
|
-
} else {
|
|
160
|
-
this.setState({isReady: true});
|
|
161
|
-
}
|
|
162
|
-
if (this.props.location.query.type === 'embedded') {
|
|
163
|
-
this.showNext();
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if ( nextProps.Line && (nextProps.Line.response && nextProps.Line.response.templateId) ) {
|
|
169
|
-
|
|
170
|
-
this.discardValues();
|
|
171
|
-
const message = getMessageObject('success', this.props.intl.formatMessage(messages["Line Template Created Successfully"]), true);
|
|
172
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
173
|
-
this.props.actions.clearCreateResponse();
|
|
174
|
-
const type = this.props.location.query.type;
|
|
175
|
-
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
176
|
-
this.props.router.push({
|
|
177
|
-
pathname: `/line/`,
|
|
178
|
-
search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (nextProps.Line.createTemplateError && !_.isEqual(nextProps.Line.createTemplateError, this.props.Line.createTemplateError)) {
|
|
183
|
-
const message = getMessageObject('error', (nextProps.Line.createTemplateErrorMessage && nextProps.Line.createTemplateErrorMessage !== '') ? nextProps.Line.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
|
|
184
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
//// Edit Template Logic ////
|
|
188
|
-
|
|
189
|
-
const isEdit = this.state.isEdit && this.props.params.id && (this.props.route.name === 'edit_text' || this.props.route.name === 'edit_image') && this.props.Line.templateDetails && this.props.Line.templateDetails.versions;
|
|
190
|
-
if (isEdit) {
|
|
191
|
-
const formData = this.getEditTransformedData(this.props.Line.templateDetails);
|
|
192
|
-
this.setState({formData, editTemplateData: this.props.Line.templateDetails});
|
|
193
|
-
this.props.actions.clearData();
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const isEditSucceed = (this.state.isEdit && nextProps.Line && nextProps.Line.editResponse && nextProps.Line.editResponse.templateId);
|
|
197
|
-
if (isEditSucceed) {
|
|
198
|
-
this.setState({formData: {} });
|
|
199
|
-
const message = getMessageObject('success', this.props.intl.formatMessage(messages['Line Template Edited Successfully']), true);
|
|
200
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
201
|
-
this.props.actions.clearEditResponse();
|
|
202
|
-
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
203
|
-
const type = this.props.location.query.type;
|
|
204
|
-
this.props.router.push({
|
|
205
|
-
pathname: `/line/`,
|
|
206
|
-
search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (nextProps.Line.editTemplateError && !_.isEqual(nextProps.Line.editTemplateError, this.props.Line.editTemplateError)) {
|
|
211
|
-
const message = getMessageObject('error', (nextProps.Line.editTemplateErrorMessage && nextProps.Line.editTemplateErrorMessage !== '') ? nextProps.Line.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
|
|
212
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (nextProps.Line.uploadAssetSuccess && nextProps.Line.uploadedAssetData) {
|
|
216
|
-
const formData = _.cloneDeep(this.state.formData);
|
|
217
|
-
// TODO: if multiple image upload supports, change below accordingly.
|
|
218
|
-
formData[this.state.currentTab - 1].image = nextProps.Line.uploadedAssetData.metaInfo.secure_file_path;
|
|
219
|
-
formData[this.state.currentTab - 1].imagePreview = nextProps.Line.uploadedAssetData.metaInfo.secure_file_path_preview;
|
|
220
|
-
|
|
221
|
-
this.setState({formData});
|
|
222
|
-
|
|
223
|
-
this.props.actions.clearAsset();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
componentWillUnmount() {
|
|
228
|
-
|
|
229
|
-
window.removeEventListener("message", this.handleFrameTasks);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
onTagSelect(data, currentTab) {
|
|
233
|
-
|
|
234
|
-
const editorId = 'message-editor';
|
|
235
|
-
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
|
|
236
|
-
document.getElementById(editorId).focus();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
onTagSelectTitle(data, currentTab) {
|
|
240
|
-
|
|
241
|
-
const editorId = 'message-title';
|
|
242
|
-
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
|
|
243
|
-
document.getElementById(editorId).focus();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
onFormDataChange = (formData, tabCount, currentTab) => {
|
|
247
|
-
|
|
248
|
-
this.setState({formData, tabCount});
|
|
249
|
-
if (currentTab) {
|
|
250
|
-
this.setState({currentTab});
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
getTransformedData = (formData) => {
|
|
255
|
-
|
|
256
|
-
const modeType = this.state.modeType;
|
|
257
|
-
const obj = {};
|
|
258
|
-
const msgData = {};
|
|
259
|
-
obj.versions = {
|
|
260
|
-
base: {
|
|
261
|
-
content: {
|
|
262
|
-
to: "{{line_id}}",
|
|
263
|
-
messages: [],
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
obj.type = 'LINE';
|
|
268
|
-
obj.name = formData['template-name'];
|
|
269
|
-
obj.definition = {
|
|
270
|
-
mode: modeType,
|
|
271
|
-
};
|
|
272
|
-
if ( modeType && modeType !== undefined) {
|
|
273
|
-
msgData.type = modeType;
|
|
274
|
-
}
|
|
275
|
-
if (modeType === 'text') {
|
|
276
|
-
if (this.state.isEdit) {
|
|
277
|
-
const editTemplateId = this.state.editTemplateData._id;
|
|
278
|
-
if (editTemplateId && editTemplateId !== undefined) {
|
|
279
|
-
obj._id = this.state.editTemplateData._id;
|
|
280
|
-
msgData.text = formData['0']['message-editor'];
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
msgData.text = formData.base['message-editor'];
|
|
284
|
-
}
|
|
285
|
-
} else if (modeType === 'image') {
|
|
286
|
-
if (formData['0'].image.length < 1) {
|
|
287
|
-
return 'IMAGE_ERROR';
|
|
288
|
-
}
|
|
289
|
-
if (this.state.isEdit) {
|
|
290
|
-
const editTemplateId = this.state.editTemplateData._id;
|
|
291
|
-
if (editTemplateId && editTemplateId !== undefined) {
|
|
292
|
-
obj._id = editTemplateId;
|
|
293
|
-
msgData.originalContentUrl = formData['0'].image;
|
|
294
|
-
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
295
|
-
}
|
|
296
|
-
} else {
|
|
297
|
-
// const img = new Image();
|
|
298
|
-
// img.src = formData['0'].image;
|
|
299
|
-
// img.onload = () => {
|
|
300
|
-
//
|
|
301
|
-
// };
|
|
302
|
-
// // Preview Image set to 240px max
|
|
303
|
-
// const prevImgSet = new Image(240, 240);
|
|
304
|
-
// prevImgSet.src = formData['0'].image;
|
|
305
|
-
|
|
306
|
-
msgData.originalContentUrl = formData['0'].image;
|
|
307
|
-
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
obj.versions.base.content.messages.push(msgData);
|
|
311
|
-
return obj;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
getEditTransformedData = ({name, versions}) => {
|
|
315
|
-
const modeType = this.state.modeType;
|
|
316
|
-
const obj = {};
|
|
317
|
-
obj['0'] = {};
|
|
318
|
-
obj.base = {
|
|
319
|
-
base: true,
|
|
320
|
-
};
|
|
321
|
-
obj['template-name'] = name;
|
|
322
|
-
if (modeType === 'text') {
|
|
323
|
-
obj.base['message-editor'] = versions.base.content.messages[0].text;
|
|
324
|
-
obj['0']['message-editor'] = versions.base.content.messages[0].text;
|
|
325
|
-
} else if (modeType === 'image') {
|
|
326
|
-
obj.base.image = versions.base.content.messages[0].originalContentUrl;
|
|
327
|
-
obj['0'].image = versions.base.content.messages[0].originalContentUrl;
|
|
328
|
-
obj['0'].imagePreview = versions.base.content.messages[0].previewImageUrl;
|
|
329
|
-
obj.base.imagePreview = versions.base.content.messages[0].previewImageUrl;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return obj;
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
setFormValidity = (isFormValid) => {
|
|
337
|
-
this.setState({isFormValid});
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
getMappedEvent = (id, event) => {
|
|
341
|
-
const map = this.state.eventsMap;
|
|
342
|
-
if (!map[id] || !map[id][event]) {
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
return map[id][event];
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
getCurrentWindow(e) {
|
|
349
|
-
|
|
350
|
-
const response = {
|
|
351
|
-
action: e.action,
|
|
352
|
-
value: 'edit',
|
|
353
|
-
direction: e.value,
|
|
354
|
-
};
|
|
355
|
-
parent.postMessage(JSON.stringify(response), '*');
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
getFormData = (e) => {
|
|
359
|
-
|
|
360
|
-
const response = {
|
|
361
|
-
action: "getFormData",
|
|
362
|
-
value: this.getTransformedData(this.state.formData),
|
|
363
|
-
validity: this.state.isFormValid,
|
|
364
|
-
};
|
|
365
|
-
this.setState({checkValidation: true});
|
|
366
|
-
if (e) {
|
|
367
|
-
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
368
|
-
}
|
|
369
|
-
return response;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
injectEvents = (schema) => {
|
|
373
|
-
const temp = schema;
|
|
374
|
-
if (temp.standalone) {
|
|
375
|
-
temp.standalone.sections = this.injectSections(temp.standalone.sections);
|
|
376
|
-
}
|
|
377
|
-
_.forEach(temp.containers, (container) => {
|
|
378
|
-
let tempContainer = container;
|
|
379
|
-
tempContainer = this.injectContainer(tempContainer);
|
|
380
|
-
return tempContainer;
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
this.setState({schema, isSchemaChanged: true}, () => {
|
|
384
|
-
this.removeStandAlone();
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
return schema;
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
saveFormData = (formData) => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const obj = this.getTransformedData(formData);
|
|
394
|
-
|
|
395
|
-
if (obj === 'IMAGE_ERROR') {
|
|
396
|
-
const message = getMessageObject('error', this.props.intl.formatMessage(messages['Please upload an image to proceed']), true);
|
|
397
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
if (obj !== 'IMAGE_ERROR' && obj.versions.base.content.messages[0].type === 'text') {
|
|
401
|
-
const charCount = obj.versions.base.content.messages[0].text.length;
|
|
402
|
-
if (charCount > 1600) {
|
|
403
|
-
const message = getMessageObject('error', this.props.intl.formatMessage(messages['Maximum characters length exceeds']), true);
|
|
404
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
if (this.state.isEdit) {
|
|
409
|
-
|
|
410
|
-
this.props.actions.editTemplate(obj);
|
|
411
|
-
} else {
|
|
412
|
-
this.props.actions.createTemplate(obj);
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
cancelTemplate = () => {
|
|
417
|
-
const type = this.props.location.query.type;
|
|
418
|
-
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
419
|
-
this.props.router.push({
|
|
420
|
-
pathname: `/LINE/`,
|
|
421
|
-
search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
|
|
422
|
-
});
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
injectSections = (sections) => {
|
|
426
|
-
_.forEach(sections, (section) => {
|
|
427
|
-
let temp = section;
|
|
428
|
-
if (temp.type === 'col-label') {
|
|
429
|
-
temp = this.injectColLabelSection(temp);
|
|
430
|
-
} else if (section.type === 'multicols') {
|
|
431
|
-
temp = this.injectMultiColSection(temp);
|
|
432
|
-
} else if (section.type === 'parent') {
|
|
433
|
-
temp = this.injectSections(temp.childSections);
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
return sections;
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
injectMultiColSection = (section) => {
|
|
440
|
-
_.forEach(section.inputFields, (inputField) => {
|
|
441
|
-
_.forEach(inputField.cols, (col) => {
|
|
442
|
-
const temp = col;
|
|
443
|
-
if (temp.type === 'popover') {
|
|
444
|
-
temp.content.sections = this.injectSections(temp.content.sections);
|
|
445
|
-
temp.value.sections = this.injectSections(temp.value.sections);
|
|
446
|
-
return true;
|
|
447
|
-
}
|
|
448
|
-
if (temp.id === "discard-button") {
|
|
449
|
-
temp.colStyle = {...temp.colStyle, display: 'none'};
|
|
450
|
-
}
|
|
451
|
-
if (temp.id === "cancel-button") {
|
|
452
|
-
temp.offset = 11;
|
|
453
|
-
}
|
|
454
|
-
if (temp.id === "line-push-preview") {
|
|
455
|
-
temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
|
|
456
|
-
}
|
|
457
|
-
temp.injectedEvents = {};
|
|
458
|
-
|
|
459
|
-
_.forEach(col.supportedEvents, (event) => {
|
|
460
|
-
console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
|
|
461
|
-
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
462
|
-
});
|
|
463
|
-
return true;
|
|
464
|
-
});
|
|
465
|
-
});
|
|
466
|
-
_.forEach(section.actionFields, (actionField) => {
|
|
467
|
-
_.forEach(actionField.cols, (col) => {
|
|
468
|
-
const temp = col;
|
|
469
|
-
if (temp.type === 'popover') {
|
|
470
|
-
temp.content.sections = this.injectSections(temp.content.sections);
|
|
471
|
-
temp.value.sections = this.injectSections(temp.value.sections);
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
temp.injectedEvents = {};
|
|
475
|
-
_.forEach(col.supportedEvents, (event) => {
|
|
476
|
-
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
477
|
-
});
|
|
478
|
-
return true;
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
return section;
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
injectColLabelSection = (section) => {
|
|
485
|
-
_.forEach(section.inputFields, (inputField) => {
|
|
486
|
-
const temp = inputField;
|
|
487
|
-
if (temp.type === 'popover') {
|
|
488
|
-
temp.content.sections = this.injectSections(temp.content.sections);
|
|
489
|
-
temp.value.sections = this.injectSections(temp.value.sections);
|
|
490
|
-
return true;
|
|
491
|
-
}
|
|
492
|
-
temp.injectedEvents = {};
|
|
493
|
-
_.forEach(inputField.supportedEvents, (event) => {
|
|
494
|
-
temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
|
|
495
|
-
});
|
|
496
|
-
return true;
|
|
497
|
-
});
|
|
498
|
-
_.forEach(section.actionFields, (actionField) => {
|
|
499
|
-
const temp = actionField;
|
|
500
|
-
if (temp.type === 'popover') {
|
|
501
|
-
temp.content.sections = this.injectSections(temp.content.sections);
|
|
502
|
-
temp.value.sections = this.injectSections(temp.value.sections);
|
|
503
|
-
return true;
|
|
504
|
-
}
|
|
505
|
-
temp.injectedEvents = {};
|
|
506
|
-
_.forEach(actionField.supportedEvents, (event) => {
|
|
507
|
-
temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
|
|
508
|
-
});
|
|
509
|
-
return true;
|
|
510
|
-
});
|
|
511
|
-
return section;
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
injectParentSection = (section) => {
|
|
515
|
-
_.forEach(section.childSections, (childSection) => {
|
|
516
|
-
let temp = childSection;
|
|
517
|
-
if (temp.type === 'col-label') {
|
|
518
|
-
temp = this.injectColLabelSection(temp);
|
|
519
|
-
} else if (section.type === 'multicols') {
|
|
520
|
-
temp = this.injectMultiColSection(temp);
|
|
521
|
-
} else if (section.type === 'parent') {
|
|
522
|
-
temp = this.injectParentSection(temp);
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
return section;
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
insertAtCursor = (field, myValue, currentTab) => {
|
|
529
|
-
//IE support
|
|
530
|
-
const myField = field;
|
|
531
|
-
if (document.selection) {
|
|
532
|
-
myField.focus();
|
|
533
|
-
const sel = document.selection.createRange();
|
|
534
|
-
sel.text = myValue;
|
|
535
|
-
} else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
|
|
536
|
-
const startPos = myField.selectionStart;
|
|
537
|
-
const endPos = myField.selectionEnd;
|
|
538
|
-
myField.value = myField.value.substring(0, startPos)
|
|
539
|
-
+ myValue
|
|
540
|
-
+ myField.value.substring(endPos, myField.value.length);
|
|
541
|
-
myField.selectionStart = startPos + myValue.length;
|
|
542
|
-
myField.selectionEnd = startPos + myValue.length;
|
|
543
|
-
} else {
|
|
544
|
-
myField.value += myValue;
|
|
545
|
-
}
|
|
546
|
-
const formData = _.cloneDeep(this.state.formData);
|
|
547
|
-
formData[currentTab - 1][field.id] = myField.value;
|
|
548
|
-
this.setState({formData});
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
startTemplateCreation = (data) => {
|
|
552
|
-
const getSchemaQuery = {
|
|
553
|
-
layout: 'LINE',
|
|
554
|
-
type: 'LAYOUT',
|
|
555
|
-
};
|
|
556
|
-
this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
|
|
557
|
-
|
|
558
|
-
const content = data.content;
|
|
559
|
-
const obj = {};
|
|
560
|
-
obj['0'] = {};
|
|
561
|
-
obj.base = {
|
|
562
|
-
base: true,
|
|
563
|
-
};
|
|
564
|
-
if (data.type === 'text') {
|
|
565
|
-
obj.base['message-editor'] = content;
|
|
566
|
-
obj['0']['message-editor'] = content;
|
|
567
|
-
} else {
|
|
568
|
-
obj.base.image = content;
|
|
569
|
-
obj['0'].image = content;
|
|
570
|
-
}
|
|
571
|
-
this.setState({formData: obj, loading: false, injectedTags: data.tags});
|
|
572
|
-
this.props.globalActions.setInjectedTags(data.tags);
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
startLoading = (ifEdit) => {
|
|
576
|
-
|
|
577
|
-
if (ifEdit) {
|
|
578
|
-
this.setState({loading: true});
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
injectContainer = (container) => {
|
|
583
|
-
const temp = container;
|
|
584
|
-
if (temp.type === 'tabs') {
|
|
585
|
-
temp.injectedEvents = {};
|
|
586
|
-
_.forEach(temp.supportedEvents, (event) => {
|
|
587
|
-
temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
|
|
588
|
-
});
|
|
589
|
-
_.forEach(temp.panes, (pane) => {
|
|
590
|
-
const tempPane = pane;
|
|
591
|
-
tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
|
|
592
|
-
tempPane.sections = this.injectSections(tempPane.sections);
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
return temp;
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
resetSchema = () => {
|
|
599
|
-
this.setState({ schema: this.state.initialState ? this.state.initialState : this.state.schema});
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
resetState = () => {
|
|
603
|
-
this.setState({
|
|
604
|
-
formData: {},
|
|
605
|
-
tabCount: 1,
|
|
606
|
-
currentTab: 1,
|
|
607
|
-
});
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
discardValues = () => {
|
|
611
|
-
this.resetSchema();
|
|
612
|
-
this.resetState();
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
moveToTemplates() {
|
|
616
|
-
|
|
617
|
-
const modalContent = {
|
|
618
|
-
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
619
|
-
body: this.props.intl.formatMessage(messages.goBackConfirmation),
|
|
620
|
-
type: 'confirm',
|
|
621
|
-
id: 'template-back-confirm-modal',
|
|
622
|
-
show: true,
|
|
623
|
-
};
|
|
624
|
-
this.setState({modalContent, showModal: true});
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
showNext() {
|
|
628
|
-
const response = {
|
|
629
|
-
action: "showNext",
|
|
630
|
-
value: true,
|
|
631
|
-
};
|
|
632
|
-
parent.postMessage(JSON.stringify(response), '*');
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
discardValues = () => {
|
|
636
|
-
this.resetSchema();
|
|
637
|
-
this.resetState();
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
handleFrameTasks = (e) => {
|
|
641
|
-
|
|
642
|
-
const type = e.data;
|
|
643
|
-
|
|
644
|
-
if (typeof type === 'object') {
|
|
645
|
-
|
|
646
|
-
const action = type.action;
|
|
647
|
-
switch (action) {
|
|
648
|
-
case "startTemplateCreation":
|
|
649
|
-
this.startTemplateCreation(type.value);
|
|
650
|
-
break;
|
|
651
|
-
case "startLoading":
|
|
652
|
-
this.startLoading(type.edit);
|
|
653
|
-
break;
|
|
654
|
-
case "getCurrentWindow":
|
|
655
|
-
this.getCurrentWindow(type);
|
|
656
|
-
break;
|
|
657
|
-
default:
|
|
658
|
-
break;
|
|
659
|
-
}
|
|
660
|
-
} else {
|
|
661
|
-
switch (type) {
|
|
662
|
-
case "getFormData":
|
|
663
|
-
this.getFormData(e);
|
|
664
|
-
break;
|
|
665
|
-
case "startTemplateCreation":
|
|
666
|
-
|
|
667
|
-
//this.getFormData(e);
|
|
668
|
-
break;
|
|
669
|
-
case "moveToTemplates":
|
|
670
|
-
|
|
671
|
-
this.moveToTemplates();
|
|
672
|
-
break;
|
|
673
|
-
case "validateContent":
|
|
674
|
-
|
|
675
|
-
this.validateContent(e);
|
|
676
|
-
break;
|
|
677
|
-
default:
|
|
678
|
-
break;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
removeStandAlone = () => {
|
|
684
|
-
const schema = _.cloneDeep(this.state.schema);
|
|
685
|
-
|
|
686
|
-
if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
|
|
687
|
-
schema.standalone.sections.splice(0, 1);
|
|
688
|
-
} else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') {
|
|
689
|
-
delete schema.standalone;
|
|
690
|
-
} else {
|
|
691
|
-
schema.standalone.sections.splice(1, 1);
|
|
692
|
-
}
|
|
693
|
-
this.setState({ schema });
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
validateContent = (e) => {
|
|
697
|
-
|
|
698
|
-
const response = {
|
|
699
|
-
action: "validateContent",
|
|
700
|
-
value: this.state.isFormValid,
|
|
701
|
-
};
|
|
702
|
-
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
handleOnTagsContextChange = (data) => {
|
|
706
|
-
|
|
707
|
-
const query = {
|
|
708
|
-
layout: 'LINE',
|
|
709
|
-
type: 'TAG',
|
|
710
|
-
context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
|
|
711
|
-
embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
|
|
712
|
-
};
|
|
713
|
-
this.props.globalActions.fetchSchemaForEntity(query);
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
uploadImage = (pearmData) => {
|
|
717
|
-
|
|
718
|
-
const data = pearmData;
|
|
719
|
-
if (data.file && data.file.size > 1000000) {
|
|
720
|
-
const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 1mb']), true);
|
|
721
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
722
|
-
} else {
|
|
723
|
-
data.fileParams.isGeneratePreview = true;
|
|
724
|
-
const name = data.file.name.split('.');
|
|
725
|
-
// const blob = data.file.slice(0, -1, 'image');
|
|
726
|
-
const newFile = new File([data.file], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image/jpeg'});
|
|
727
|
-
this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
render() {
|
|
732
|
-
if (this.state.formData && this.state.formData["0"] && this.state.formData["0"].image) {
|
|
733
|
-
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
let tipText = this.props.Line.createTemplateInProgress ? this.props.intl.formatMessage(messages.savingTemplate) : "";
|
|
737
|
-
let loading = this.props.Line.createTemplateInProgress ? this.props.Line.createTemplateInProgress : false;
|
|
738
|
-
if (this.props.Line.assetUploading) {
|
|
739
|
-
tipText = this.props.intl.formatMessage(messages.uploadingImage);
|
|
740
|
-
loading = true;
|
|
741
|
-
}
|
|
742
|
-
// if (!this.state.isReady) {
|
|
743
|
-
// tipText = "Please wait..";
|
|
744
|
-
// loading = true;
|
|
745
|
-
// }
|
|
746
|
-
let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
|
|
747
|
-
if (this.props.supportedTags) {
|
|
748
|
-
tags = this.props.supportedTags;
|
|
749
|
-
}
|
|
750
|
-
return (
|
|
751
|
-
<Spin tip={tipText} spinning={loading}>
|
|
752
|
-
<Row style={{marginLeft: '-48px'}}>
|
|
753
|
-
<Col offset={1}>
|
|
754
|
-
{this.props.location.query.type !== "embedded" &&
|
|
755
|
-
<Breadcrumb>
|
|
756
|
-
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Campaigns)}</BreadcrumbItem>
|
|
757
|
-
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Creatives)}</BreadcrumbItem>
|
|
758
|
-
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Line)}</BreadcrumbItem>
|
|
759
|
-
</Breadcrumb>
|
|
760
|
-
}
|
|
761
|
-
</Col>
|
|
762
|
-
</Row>
|
|
763
|
-
<Row>
|
|
764
|
-
<Col>
|
|
765
|
-
{!_.isEmpty(this.state.schema) && <FormBuilder
|
|
766
|
-
key={"form builder"}
|
|
767
|
-
schema={this.state.schema}
|
|
768
|
-
onSubmit={this.saveFormData}
|
|
769
|
-
onChange={this.onFormDataChange}
|
|
770
|
-
currentTab={this.state.currentTab}
|
|
771
|
-
parent={this}
|
|
772
|
-
formData={_.cloneDeep(this.state.formData)}
|
|
773
|
-
location={this.props.location}
|
|
774
|
-
tags={tags}
|
|
775
|
-
injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
|
|
776
|
-
onFormValidityChange={this.setFormValidity}
|
|
777
|
-
usingTabContainer
|
|
778
|
-
checkValidation={this.state.checkValidation}
|
|
779
|
-
tabKey={this.state.tabKey}
|
|
780
|
-
tabCount={2}
|
|
781
|
-
showModal={this.state.showModal}
|
|
782
|
-
isSchemaChanged={this.state.isSchemaChanged}
|
|
783
|
-
modal={this.state.modalContent}
|
|
784
|
-
handleCancelModal={this.handleCancelModal}
|
|
785
|
-
iframeParent={parent}
|
|
786
|
-
router={this.props.router}
|
|
787
|
-
onContextChange={this.handleOnTagsContextChange}
|
|
788
|
-
setModalContent={this.setModalContent}
|
|
789
|
-
/> }
|
|
790
|
-
</Col>
|
|
791
|
-
</Row>
|
|
792
|
-
</Spin>
|
|
793
|
-
);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
Line.propTypes = {
|
|
798
|
-
actions: PropTypes.object.isRequired,
|
|
799
|
-
globalActions: PropTypes.object,
|
|
800
|
-
Templates: PropTypes.object,
|
|
801
|
-
location: PropTypes.object,
|
|
802
|
-
router: PropTypes.object,
|
|
803
|
-
params: PropTypes.object,
|
|
804
|
-
metaEntities: PropTypes.object,
|
|
805
|
-
intl: intlShape.isRequired,
|
|
806
|
-
route: PropTypes.object,
|
|
807
|
-
Line: PropTypes.object,
|
|
808
|
-
supportedTags: PropTypes.any,
|
|
809
|
-
getDefaultTags: PropTypes.string,
|
|
810
|
-
injectedTags: PropTypes.object,
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
const mapStateToProps = createStructuredSelector({
|
|
814
|
-
Line: makeSelectCreateLine(),
|
|
815
|
-
Templates: makeSelectTemplates(),
|
|
816
|
-
metaEntities: makeSelectMetaEntities(),
|
|
817
|
-
injectedTags: setInjectedTags(),
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
function mapDispatchToProps(dispatch) {
|
|
821
|
-
return {
|
|
822
|
-
actions: bindActionCreators(actions, dispatch),
|
|
823
|
-
globalActions: bindActionCreators(globalActions, dispatch),
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
|
828
|
-
const withReducer = injectReducer({ key: 'line', reducer });
|
|
829
|
-
const withSaga = injectSaga({ key: 'line', saga: lineCreateSaga});
|
|
830
|
-
|
|
831
|
-
export default compose(
|
|
832
|
-
UserIsAuthenticated,
|
|
833
|
-
withReducer,
|
|
834
|
-
withSaga,
|
|
835
|
-
withConnect,
|
|
836
|
-
)(injectIntl(Line));
|