@capillarytech/creatives-library 3.10.0 → 3.11.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/lineImageTemplate.png +0 -0
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +7 -7
- package/components/TemplatePreview/_templatePreview.scss +287 -20
- package/components/TemplatePreview/assets/images/home-screen-android.svg +21 -0
- package/components/TemplatePreview/assets/images/home-screen-ios.svg +16 -0
- package/components/TemplatePreview/assets/images/sms_mobile_android.svg +22 -0
- package/components/TemplatePreview/assets/images/sms_mobile_ios.svg +16 -0
- package/components/TemplatePreview/assets/images/wechat_mobile_android.svg +20 -0
- package/components/TemplatePreview/index.js +203 -31
- package/components/TemplatePreview/messages.js +21 -0
- package/containers/Assets/Gallery/index.js +53 -59
- package/containers/Cap/index.js +1 -0
- package/index.js +6 -0
- package/package.json +1 -1
- package/routes.js +5 -0
- package/services/getSchema.js +4 -1
- package/translations/en.json +40 -4
- package/translations/zh.json +39 -3
- package/v2Components/FormBuilder/index.js +188 -37
- package/v2Components/FormBuilder/messages.js +16 -0
- package/v2Components/MobilePushPreviewV2/index.js +44 -36
- package/v2Components/MobilePushPreviewV2/messages.js +0 -8
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +64 -0
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +100 -18
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +12 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +24 -4
- package/v2Components/TemplatePreview/assets/images/home-screen-android.svg +21 -0
- package/v2Components/TemplatePreview/assets/images/home-screen-ios.svg +16 -0
- package/v2Components/TemplatePreview/assets/images/sms_mobile_android.svg +22 -0
- package/v2Components/TemplatePreview/assets/images/wechat-home-screen-android.svg +21 -0
- package/v2Components/TemplatePreview/assets/images/wechat_mobile_android.svg +20 -0
- package/v2Components/TemplatePreview/index.js +162 -23
- package/v2Components/TemplatePreview/messages.js +8 -0
- package/v2Containers/Assets/Gallery/index.js +54 -48
- package/v2Containers/CreativesContainer/SlideBoxContent.js +87 -4
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -1
- package/v2Containers/CreativesContainer/index.js +58 -2
- package/v2Containers/CreativesContainer/messages.js +2 -2
- package/v2Containers/Email/_email.scss +7 -1
- package/v2Containers/Email/index.js +40 -14
- package/v2Containers/Email/messages.js +4 -0
- package/v2Containers/Email/reducer.js +1 -0
- package/v2Containers/EmailWrapper/index.js +7 -5
- package/v2Containers/Line/Create/_lineCreate.scss +40 -19
- package/v2Containers/Line/Create/actions.js +13 -9
- package/v2Containers/Line/Create/index.js +498 -237
- package/v2Containers/Line/Create/initialSchema.js +378 -0
- package/v2Containers/Line/Create/messages.js +42 -2
- package/v2Containers/Line/Create/sagas.js +10 -4
- package/v2Containers/Line/Create/selectors.js +3 -9
- package/v2Containers/Line/CreateWrapper/constants.js +2 -0
- package/v2Containers/Line/CreateWrapper/index.js +117 -0
- package/v2Containers/Line/CreateWrapper/messages.js +55 -0
- package/v2Containers/MobilePush/Create/index.js +5 -0
- package/v2Containers/MobilePush/Edit/index.js +5 -0
- package/v2Containers/MobilepushWrapper/index.js +4 -1
- package/v2Containers/Sms/Create/index.js +2 -1
- package/v2Containers/Sms/Edit/index.js +2 -0
- package/v2Containers/Templates/_templates.scss +24 -1
- package/v2Containers/Templates/actions.js +7 -0
- package/v2Containers/Templates/constants.js +2 -0
- package/v2Containers/Templates/index.js +118 -15
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/Templates/reducer.js +2 -0
- package/v2Containers/TemplatesV2/index.js +5 -4
- package/v2Containers/TemplatesV2/messages.js +4 -0
|
@@ -1,62 +1,66 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import set from 'lodash/set';
|
|
3
5
|
import { bindActionCreators } from 'redux';
|
|
4
6
|
import { intlShape } from 'react-intl';
|
|
5
7
|
import { createStructuredSelector } from 'reselect';
|
|
6
|
-
import { Row, Col, Spin, Breadcrumb } from 'antd';
|
|
7
8
|
import _ from 'lodash';
|
|
9
|
+
import { CapSpin, CapHeading, CapRow, CapColumn } from '@capillarytech/cap-ui-library';
|
|
8
10
|
import messages from './messages';
|
|
9
11
|
import * as actions from './actions';
|
|
12
|
+
import Gallery from '../../Assets/Gallery';
|
|
10
13
|
import FormBuilder from '../../../v2Components/FormBuilder';
|
|
11
14
|
//import { makeSelectCreate, makeSelectCreateResponse, makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse } from './selectors';
|
|
12
|
-
import {makeSelectCreateLine} from './selectors';
|
|
15
|
+
import {makeSelectCreateLine, makeSelectLine} from './selectors';
|
|
13
16
|
import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
|
|
14
17
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
15
18
|
import { makeSelectTemplates } from '../../Templates/selectors';
|
|
16
19
|
import './_lineCreate.scss';
|
|
17
20
|
import withCreatives from '../../../hoc/withCreatives';
|
|
18
21
|
|
|
19
|
-
const BreadcrumbItem = Breadcrumb.Item;
|
|
20
|
-
|
|
21
22
|
export class Line extends Component {
|
|
22
|
-
|
|
23
23
|
constructor(props) {
|
|
24
24
|
super(props);
|
|
25
25
|
const map = {
|
|
26
|
-
|
|
26
|
+
'save-button': {
|
|
27
27
|
saveFormData: this.saveFormData,
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
'template-name': {
|
|
30
30
|
onChange: this.onTemplateNameChange,
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
'discard-button': {
|
|
33
33
|
discardValues: this.discardValues,
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
cancelTemplate: this.cancelTemplate,
|
|
37
|
-
},
|
|
38
|
-
"message-editor": {
|
|
35
|
+
'message-editor': {
|
|
39
36
|
onChange: this.onTemplateContentChange,
|
|
40
37
|
},
|
|
41
|
-
|
|
38
|
+
'message-editor2': {
|
|
42
39
|
onChange: this.onTemplateContentChange,
|
|
43
40
|
},
|
|
44
|
-
|
|
41
|
+
'message-tagList': {
|
|
45
42
|
onTagSelect: this.onTagSelect,
|
|
46
43
|
},
|
|
47
|
-
|
|
44
|
+
'title-tagList': {
|
|
48
45
|
onTagSelect: this.onTagSelectTitle,
|
|
49
46
|
},
|
|
50
|
-
|
|
47
|
+
'pane': {
|
|
51
48
|
onTabChange: this.onTabChange,
|
|
52
49
|
},
|
|
53
|
-
|
|
50
|
+
'line-template': {
|
|
54
51
|
onSelect: this.onTemplateChange,
|
|
55
52
|
},
|
|
56
|
-
|
|
53
|
+
'image-upload-line': {
|
|
57
54
|
onUpload: this.uploadImage,
|
|
58
55
|
},
|
|
56
|
+
'tagList': {
|
|
57
|
+
onTagSelect: this.onTagSelect,
|
|
58
|
+
},
|
|
59
|
+
'line-editor': {
|
|
60
|
+
onChange: this.onTemplateContentChange,
|
|
61
|
+
},
|
|
59
62
|
};
|
|
63
|
+
|
|
60
64
|
this.state = {
|
|
61
65
|
schema: {},
|
|
62
66
|
isSchemaChanged: false,
|
|
@@ -70,13 +74,21 @@ export class Line extends Component {
|
|
|
70
74
|
eventsMap: map,
|
|
71
75
|
errorData: {},
|
|
72
76
|
displayProps: {},
|
|
73
|
-
modalContent: {
|
|
77
|
+
modalContent: {
|
|
78
|
+
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
79
|
+
body: this.props.intl.formatMessage(
|
|
80
|
+
messages.templateNotConfigured
|
|
81
|
+
),
|
|
82
|
+
type: 'confirm',
|
|
83
|
+
},
|
|
74
84
|
injectedTags: {},
|
|
75
85
|
isEdit: false,
|
|
76
86
|
isEdited: false,
|
|
77
87
|
editTemplateData: {},
|
|
78
88
|
isReady: false,
|
|
79
89
|
modeType: null,
|
|
90
|
+
isDrawerRequired: false,
|
|
91
|
+
startValidation: false,
|
|
80
92
|
};
|
|
81
93
|
}
|
|
82
94
|
|
|
@@ -84,7 +96,7 @@ export class Line extends Component {
|
|
|
84
96
|
if (this.props.params.id) {
|
|
85
97
|
const editTemplateId = this.props.params.id;
|
|
86
98
|
this.props.actions.getTemplateDetails(editTemplateId, 'LINE');
|
|
87
|
-
this.setState({isEdit: true});
|
|
99
|
+
this.setState({ isEdit: true });
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
|
|
@@ -92,47 +104,60 @@ export class Line extends Component {
|
|
|
92
104
|
const getSchemaQuery = {
|
|
93
105
|
layout: 'LINE',
|
|
94
106
|
type: 'LAYOUT',
|
|
107
|
+
version: 'v2',
|
|
95
108
|
};
|
|
96
109
|
this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
|
|
97
|
-
const type = this.props.location.query.type;
|
|
98
|
-
const name = this.props.route.name;
|
|
99
|
-
window.addEventListener("message", this.handleFrameTasks);
|
|
100
|
-
if (type === 'embedded') {
|
|
101
|
-
const response = {
|
|
102
|
-
action: 'startTemplateCreation',
|
|
103
|
-
window: name === 'view' ? 'view' : '',
|
|
104
|
-
};
|
|
105
|
-
parent.postMessage(JSON.stringify(response), '*');
|
|
106
|
-
}
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
componentWillReceiveProps(nextProps) {
|
|
110
|
-
console.log("nextProps line @@@", nextProps);
|
|
111
|
-
|
|
112
113
|
//// Create template logic ////
|
|
113
114
|
|
|
114
115
|
let modeType;
|
|
115
|
-
const {layouts, tags} = nextProps.metaEntities;
|
|
116
|
-
const isSchemaReady =
|
|
116
|
+
const { layouts, tags } = nextProps.metaEntities;
|
|
117
|
+
const isSchemaReady = layouts !== undefined && layouts.length > 0;
|
|
117
118
|
const editModeType = nextProps.route.name;
|
|
118
|
-
if (
|
|
119
|
+
if (
|
|
120
|
+
nextProps.params.mode === 'text' ||
|
|
121
|
+
nextProps.route.name === 'edit_text'
|
|
122
|
+
) {
|
|
119
123
|
modeType = 'text';
|
|
120
124
|
} else {
|
|
121
125
|
modeType = 'image';
|
|
122
126
|
}
|
|
123
127
|
if (modeType) {
|
|
124
|
-
this.setState({modeType, schema: {}});
|
|
125
|
-
|
|
128
|
+
this.setState({ modeType, schema: {} });
|
|
129
|
+
}
|
|
130
|
+
const {
|
|
131
|
+
isGetFormData,
|
|
132
|
+
templateData,
|
|
133
|
+
} = nextProps;
|
|
134
|
+
if (isGetFormData) {
|
|
135
|
+
const {
|
|
136
|
+
lineData,
|
|
137
|
+
getFormSubscriptionData,
|
|
138
|
+
} = nextProps;
|
|
139
|
+
let selectedAccount = {};
|
|
140
|
+
if (lineData) {
|
|
141
|
+
const {
|
|
142
|
+
weCrmAccounts = [],
|
|
143
|
+
} = lineData;
|
|
144
|
+
selectedAccount = weCrmAccounts.filter((account) => account === selectedAccount);
|
|
145
|
+
}
|
|
146
|
+
getFormSubscriptionData({ ...this.getFormData(), accountDetails: selectedAccount, type: 'LINE' });
|
|
126
147
|
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
148
|
+
if (templateData && templateData.edit) {
|
|
149
|
+
this.setEditState(templateData);
|
|
129
150
|
}
|
|
130
151
|
if (isSchemaReady) {
|
|
131
152
|
// set schema value as per mode type. Supported mode (text & image)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
const { textSchema, imageSchema } = this.updateSchemaWithLabels(
|
|
154
|
+
layouts[0].definition
|
|
155
|
+
);
|
|
156
|
+
const schema =
|
|
157
|
+
modeType === 'text' || editModeType === 'edit_text'
|
|
158
|
+
? textSchema
|
|
159
|
+
: imageSchema;
|
|
160
|
+
this.setState({ schema }, () => {
|
|
136
161
|
// Once schema is ready and set, then inject the available events from the schema
|
|
137
162
|
if (!_.isEmpty(this.state.schema)) {
|
|
138
163
|
this.injectEvents(this.state.schema);
|
|
@@ -141,118 +166,188 @@ export class Line extends Component {
|
|
|
141
166
|
const getTagsQuery = {
|
|
142
167
|
layout: 'LINE',
|
|
143
168
|
type: 'TAG',
|
|
144
|
-
context:
|
|
145
|
-
|
|
169
|
+
context:
|
|
170
|
+
this.props.location.query.type === 'embedded'
|
|
171
|
+
? 'outbound'
|
|
172
|
+
: 'default',
|
|
173
|
+
embedded:
|
|
174
|
+
this.props.location.query.type === 'embedded'
|
|
175
|
+
? this.props.location.query.type
|
|
176
|
+
: 'full',
|
|
146
177
|
};
|
|
147
178
|
if (this.props.getDefaultTags) {
|
|
148
179
|
getTagsQuery.context = this.props.getDefaultTags;
|
|
149
180
|
}
|
|
150
|
-
if (tags
|
|
181
|
+
if (!Object.keys(tags || {}).length && modeType !== 'image') {
|
|
151
182
|
this.props.globalActions.fetchSchemaForEntity(getTagsQuery);
|
|
152
183
|
} else {
|
|
153
|
-
this.setState({isReady: true});
|
|
154
|
-
}
|
|
155
|
-
if (this.props.location.query.type === 'embedded') {
|
|
156
|
-
this.showNext();
|
|
184
|
+
this.setState({ isReady: true });
|
|
157
185
|
}
|
|
158
186
|
});
|
|
159
187
|
}
|
|
160
188
|
|
|
161
|
-
|
|
162
|
-
|
|
189
|
+
const lineTemplateId = get(nextProps, 'Line.response.templateId', '');
|
|
190
|
+
if (lineTemplateId) {
|
|
163
191
|
this.discardValues();
|
|
164
|
-
const message = getMessageObject(
|
|
192
|
+
const message = getMessageObject(
|
|
193
|
+
'success',
|
|
194
|
+
this.props.intl.formatMessage(
|
|
195
|
+
messages.lineTemplateCreatedSuccessfully
|
|
196
|
+
),
|
|
197
|
+
true
|
|
198
|
+
);
|
|
165
199
|
this.props.globalActions.addMessageToQueue(message);
|
|
166
200
|
this.props.actions.clearCreateResponse();
|
|
167
|
-
const type = this.props.location.query.type;
|
|
168
|
-
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
169
|
-
this.props.router.push({
|
|
170
|
-
pathname: `/line/`,
|
|
171
|
-
query: type === 'embedded' ? {type: 'embedded', module} : {module},
|
|
172
|
-
});
|
|
173
201
|
}
|
|
174
202
|
|
|
175
|
-
if (
|
|
176
|
-
|
|
203
|
+
if (
|
|
204
|
+
nextProps.Line.createTemplateError &&
|
|
205
|
+
!_.isEqual(
|
|
206
|
+
nextProps.Line.createTemplateError,
|
|
207
|
+
this.props.Line.createTemplateError
|
|
208
|
+
)
|
|
209
|
+
) {
|
|
210
|
+
const {
|
|
211
|
+
Line: {
|
|
212
|
+
createTemplateErrorMessage,
|
|
213
|
+
},
|
|
214
|
+
} = nextProps;
|
|
215
|
+
const message = getMessageObject(
|
|
216
|
+
'error',
|
|
217
|
+
createTemplateErrorMessage || this.props.intl.formatMessage(messages.somethingWentWrong),
|
|
218
|
+
true
|
|
219
|
+
);
|
|
177
220
|
this.props.globalActions.addMessageToQueue(message);
|
|
178
221
|
}
|
|
179
222
|
|
|
180
223
|
//// Edit Template Logic ////
|
|
181
|
-
|
|
182
|
-
|
|
224
|
+
const isEdit =
|
|
225
|
+
this.state.isEdit &&
|
|
226
|
+
this.props.params.id &&
|
|
227
|
+
(this.props.route.name === 'edit_text' ||
|
|
228
|
+
this.props.route.name === 'edit_image') &&
|
|
229
|
+
this.props.Line.templateDetails &&
|
|
230
|
+
this.props.Line.templateDetails.versions;
|
|
183
231
|
if (isEdit) {
|
|
184
|
-
const formData = this.getEditTransformedData(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (isEditSucceed) {
|
|
191
|
-
this.setState({formData: {} });
|
|
192
|
-
const message = getMessageObject('success', this.props.intl.formatMessage(messages['Line Template Edited Successfully']), true);
|
|
193
|
-
this.props.globalActions.addMessageToQueue(message);
|
|
194
|
-
this.props.actions.clearEditResponse();
|
|
195
|
-
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
196
|
-
const type = this.props.location.query.type;
|
|
197
|
-
this.props.router.push({
|
|
198
|
-
pathname: `/line/`,
|
|
199
|
-
query: type === 'embedded' ? {type: 'embedded', module} : {module},
|
|
232
|
+
const formData = this.getEditTransformedData(
|
|
233
|
+
this.props.Line.templateDetails
|
|
234
|
+
);
|
|
235
|
+
this.setState({
|
|
236
|
+
formData,
|
|
237
|
+
editTemplateData: this.props.Line.templateDetails,
|
|
200
238
|
});
|
|
239
|
+
this.props.actions.clearData();
|
|
201
240
|
}
|
|
202
241
|
|
|
203
|
-
if (
|
|
204
|
-
|
|
242
|
+
if (
|
|
243
|
+
nextProps.Line.editTemplateError &&
|
|
244
|
+
!_.isEqual(
|
|
245
|
+
nextProps.Line.editTemplateError,
|
|
246
|
+
this.props.Line.editTemplateError
|
|
247
|
+
)
|
|
248
|
+
) {
|
|
249
|
+
const message = getMessageObject(
|
|
250
|
+
'error',
|
|
251
|
+
nextProps.Line.editTemplateErrorMessage &&
|
|
252
|
+
nextProps.Line.editTemplateErrorMessage !== ''
|
|
253
|
+
? nextProps.Line.editTemplateErrorMessage
|
|
254
|
+
: this.props.intl.formatMessage(messages.somethingWentWrong),
|
|
255
|
+
true
|
|
256
|
+
);
|
|
205
257
|
this.props.globalActions.addMessageToQueue(message);
|
|
206
258
|
}
|
|
207
259
|
|
|
208
|
-
if (
|
|
260
|
+
if (
|
|
261
|
+
nextProps.Line.uploadAssetSuccess &&
|
|
262
|
+
nextProps.Line.uploadedAssetData
|
|
263
|
+
) {
|
|
209
264
|
const formData = _.cloneDeep(this.state.formData);
|
|
210
265
|
// TODO: if multiple image upload supports, change below accordingly.
|
|
211
|
-
formData[this.state.currentTab - 1].image =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
266
|
+
formData[this.state.currentTab - 1].image =
|
|
267
|
+
nextProps.Line.uploadedAssetData.metaInfo.secure_file_path;
|
|
268
|
+
formData[this.state.currentTab - 1].imagePreview =
|
|
269
|
+
nextProps.Line.uploadedAssetData.metaInfo.secure_file_path_preview;
|
|
270
|
+
this.setState({ formData });
|
|
216
271
|
this.props.actions.clearAsset();
|
|
217
272
|
}
|
|
218
273
|
}
|
|
219
274
|
|
|
275
|
+
setEditSuccessMessage = () => {
|
|
276
|
+
this.setState({ formData: {} });
|
|
277
|
+
const message = getMessageObject(
|
|
278
|
+
'success',
|
|
279
|
+
this.props.intl.formatMessage(
|
|
280
|
+
messages['Line Template Edited Successfully']
|
|
281
|
+
),
|
|
282
|
+
true
|
|
283
|
+
);
|
|
284
|
+
this.props.globalActions.addMessageToQueue(message);
|
|
285
|
+
this.props.actions.clearEditResponse();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
setEditState = (data) => {
|
|
289
|
+
const { formData: previousFormData } = this.state;
|
|
290
|
+
const { text, originalContentUrl, imagePreview, image } = get(data, "versions.base.content.messages[0]", {});
|
|
291
|
+
const retrievedData = {
|
|
292
|
+
...previousFormData[0],
|
|
293
|
+
};
|
|
294
|
+
if (text) {
|
|
295
|
+
retrievedData["message-editor"] = text;
|
|
296
|
+
}
|
|
297
|
+
const lineImage = originalContentUrl || image;
|
|
298
|
+
if (lineImage) {
|
|
299
|
+
retrievedData.image = lineImage;
|
|
300
|
+
retrievedData.imagePreview = imagePreview;
|
|
301
|
+
}
|
|
302
|
+
const formData = {
|
|
303
|
+
0: retrievedData,
|
|
304
|
+
base: retrievedData,
|
|
305
|
+
};
|
|
306
|
+
this.setState({ formData });
|
|
307
|
+
}
|
|
308
|
+
|
|
220
309
|
componentWillUnmount() {
|
|
221
|
-
|
|
222
|
-
window.removeEventListener("message", this.handleFrameTasks);
|
|
310
|
+
window.removeEventListener('message', this.handleFrameTasks);
|
|
223
311
|
}
|
|
224
312
|
|
|
225
313
|
onTagSelect(data, currentTab) {
|
|
226
|
-
console.log('parent data tag', data, currentTab);
|
|
227
314
|
const editorId = 'message-editor';
|
|
228
|
-
this.insertAtCursor(
|
|
315
|
+
this.insertAtCursor(
|
|
316
|
+
document.getElementById(editorId),
|
|
317
|
+
`{{${data}}}`,
|
|
318
|
+
currentTab
|
|
319
|
+
);
|
|
229
320
|
document.getElementById(editorId).focus();
|
|
230
321
|
}
|
|
231
322
|
|
|
232
323
|
onTagSelectTitle(data, currentTab) {
|
|
233
|
-
console.log('parent data tag', data, currentTab);
|
|
234
324
|
const editorId = 'message-title';
|
|
235
|
-
this.insertAtCursor(
|
|
325
|
+
this.insertAtCursor(
|
|
326
|
+
document.getElementById(editorId),
|
|
327
|
+
`{{${data}}}`,
|
|
328
|
+
currentTab
|
|
329
|
+
);
|
|
236
330
|
document.getElementById(editorId).focus();
|
|
237
331
|
}
|
|
238
332
|
|
|
239
333
|
onFormDataChange = (formData, tabCount, currentTab) => {
|
|
240
|
-
|
|
241
|
-
|
|
334
|
+
this.setState({ formData: { ...formData } });
|
|
335
|
+
if (tabCount) {
|
|
336
|
+
this.setState({ tabCount });
|
|
337
|
+
}
|
|
242
338
|
if (currentTab) {
|
|
243
|
-
this.setState({currentTab});
|
|
339
|
+
this.setState({ currentTab });
|
|
244
340
|
}
|
|
245
341
|
};
|
|
246
342
|
|
|
247
343
|
getTransformedData = (formData) => {
|
|
248
|
-
console.log("formData before transform@@@", formData);
|
|
249
344
|
const modeType = this.state.modeType;
|
|
250
345
|
const obj = {};
|
|
251
346
|
const msgData = {};
|
|
252
347
|
obj.versions = {
|
|
253
348
|
base: {
|
|
254
349
|
content: {
|
|
255
|
-
to:
|
|
350
|
+
to: '{{line_id}}',
|
|
256
351
|
messages: [],
|
|
257
352
|
},
|
|
258
353
|
},
|
|
@@ -262,7 +357,7 @@ export class Line extends Component {
|
|
|
262
357
|
obj.definition = {
|
|
263
358
|
mode: modeType,
|
|
264
359
|
};
|
|
265
|
-
if (
|
|
360
|
+
if (modeType && modeType !== undefined) {
|
|
266
361
|
msgData.type = modeType;
|
|
267
362
|
}
|
|
268
363
|
if (modeType === 'text') {
|
|
@@ -287,15 +382,6 @@ export class Line extends Component {
|
|
|
287
382
|
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
288
383
|
}
|
|
289
384
|
} else {
|
|
290
|
-
// const img = new Image();
|
|
291
|
-
// img.src = formData['0'].image;
|
|
292
|
-
// img.onload = () => {
|
|
293
|
-
// console.log(`Image aspect ratio details line@@@${img.width} and ${img.height}`);
|
|
294
|
-
// };
|
|
295
|
-
// // Preview Image set to 240px max
|
|
296
|
-
// const prevImgSet = new Image(240, 240);
|
|
297
|
-
// prevImgSet.src = formData['0'].image;
|
|
298
|
-
|
|
299
385
|
msgData.originalContentUrl = formData['0'].image;
|
|
300
386
|
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
301
387
|
}
|
|
@@ -304,7 +390,7 @@ export class Line extends Component {
|
|
|
304
390
|
return obj;
|
|
305
391
|
};
|
|
306
392
|
|
|
307
|
-
getEditTransformedData = ({name, versions}) => {
|
|
393
|
+
getEditTransformedData = ({ name, versions }) => {
|
|
308
394
|
const modeType = this.state.modeType;
|
|
309
395
|
const obj = {};
|
|
310
396
|
obj['0'] = {};
|
|
@@ -313,33 +399,39 @@ export class Line extends Component {
|
|
|
313
399
|
};
|
|
314
400
|
obj['template-name'] = name;
|
|
315
401
|
if (modeType === 'text') {
|
|
316
|
-
obj.base['message-editor'] =
|
|
317
|
-
|
|
402
|
+
obj.base['message-editor'] =
|
|
403
|
+
versions.base.content.messages[0].text;
|
|
404
|
+
obj['0']['message-editor'] =
|
|
405
|
+
versions.base.content.messages[0].text;
|
|
318
406
|
} else if (modeType === 'image') {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
407
|
+
const {
|
|
408
|
+
base: {
|
|
409
|
+
content: {
|
|
410
|
+
messages: [{
|
|
411
|
+
originalContentUrl,
|
|
412
|
+
previewImageUrl,
|
|
413
|
+
}],
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
} = versions;
|
|
417
|
+
obj.base.image = originalContentUrl;
|
|
418
|
+
obj['0'].image = originalContentUrl;
|
|
419
|
+
obj['0'].imagePreview = previewImageUrl;
|
|
420
|
+
obj.base.imagePreview = previewImageUrl;
|
|
323
421
|
}
|
|
324
|
-
|
|
325
|
-
console.log("getEditTransformedData", obj);
|
|
326
422
|
return obj;
|
|
327
423
|
};
|
|
328
424
|
|
|
329
425
|
setFormValidity = (isFormValid) => {
|
|
330
|
-
this.setState({isFormValid});
|
|
426
|
+
this.setState({ isFormValid });
|
|
331
427
|
};
|
|
332
428
|
|
|
333
429
|
getMappedEvent = (id, event) => {
|
|
334
430
|
const map = this.state.eventsMap;
|
|
335
|
-
if (!map[id] || !map[id][event]) {
|
|
336
|
-
console.log(`error map[id] ${map[id]}` );
|
|
337
|
-
}
|
|
338
431
|
return map[id][event];
|
|
339
432
|
};
|
|
340
433
|
|
|
341
434
|
getCurrentWindow(e) {
|
|
342
|
-
console.log('in Line create@@@', e);
|
|
343
435
|
const response = {
|
|
344
436
|
action: e.action,
|
|
345
437
|
value: 'edit',
|
|
@@ -349,13 +441,12 @@ export class Line extends Component {
|
|
|
349
441
|
}
|
|
350
442
|
|
|
351
443
|
getFormData = (e) => {
|
|
352
|
-
console.log('posting final result', this.state.formData);
|
|
353
444
|
const response = {
|
|
354
|
-
action:
|
|
445
|
+
action: 'getFormData',
|
|
355
446
|
value: this.getTransformedData(this.state.formData),
|
|
356
447
|
validity: this.state.isFormValid,
|
|
357
448
|
};
|
|
358
|
-
this.setState({checkValidation: true});
|
|
449
|
+
this.setState({ checkValidation: true });
|
|
359
450
|
if (e) {
|
|
360
451
|
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
361
452
|
}
|
|
@@ -365,56 +456,79 @@ export class Line extends Component {
|
|
|
365
456
|
injectEvents = (schema) => {
|
|
366
457
|
const temp = schema;
|
|
367
458
|
if (temp.standalone) {
|
|
368
|
-
temp.standalone.sections = this.injectSections(
|
|
459
|
+
temp.standalone.sections = this.injectSections(
|
|
460
|
+
temp.standalone.sections
|
|
461
|
+
);
|
|
369
462
|
}
|
|
370
463
|
_.forEach(temp.containers, (container) => {
|
|
371
464
|
let tempContainer = container;
|
|
372
465
|
tempContainer = this.injectContainer(tempContainer);
|
|
373
466
|
return tempContainer;
|
|
374
467
|
});
|
|
375
|
-
|
|
376
|
-
this.setState({schema, isSchemaChanged: true}, () => {
|
|
468
|
+
this.setState({ schema, isSchemaChanged: true }, () => {
|
|
377
469
|
this.removeStandAlone();
|
|
378
470
|
});
|
|
379
|
-
console.log('final returned schema', this.state.schema);
|
|
380
471
|
return schema;
|
|
381
472
|
};
|
|
382
473
|
|
|
383
474
|
saveFormData = (formData) => {
|
|
384
|
-
console.log("ccc", this.props);
|
|
385
|
-
console.log('Saving form data of LINE @@@', formData, this.state.tabCount);
|
|
386
475
|
const obj = this.getTransformedData(formData);
|
|
387
|
-
console.log('obj final@@@', obj);
|
|
388
476
|
if (obj === 'IMAGE_ERROR') {
|
|
389
|
-
const message = getMessageObject(
|
|
477
|
+
const message = getMessageObject(
|
|
478
|
+
'error',
|
|
479
|
+
this.props.intl.formatMessage(
|
|
480
|
+
messages['Please upload an image to proceed']
|
|
481
|
+
),
|
|
482
|
+
true
|
|
483
|
+
);
|
|
390
484
|
this.props.globalActions.addMessageToQueue(message);
|
|
391
485
|
return;
|
|
392
486
|
}
|
|
393
|
-
if (
|
|
394
|
-
|
|
487
|
+
if (
|
|
488
|
+
obj !== 'IMAGE_ERROR' &&
|
|
489
|
+
obj.versions.base.content.messages[0].type === 'text'
|
|
490
|
+
) {
|
|
491
|
+
const text = obj.versions.base.content.messages[0].text;
|
|
492
|
+
const charCount = text ? text.length : 0;
|
|
395
493
|
if (charCount > 1600) {
|
|
396
|
-
const message = getMessageObject(
|
|
494
|
+
const message = getMessageObject(
|
|
495
|
+
'error',
|
|
496
|
+
this.props.intl.formatMessage(
|
|
497
|
+
messages['Maximum characters length exceeds']
|
|
498
|
+
),
|
|
499
|
+
true
|
|
500
|
+
);
|
|
397
501
|
this.props.globalActions.addMessageToQueue(message);
|
|
398
502
|
return;
|
|
399
503
|
}
|
|
400
504
|
}
|
|
401
|
-
if (this.state.
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
505
|
+
if (!this.state.startValidation) {
|
|
506
|
+
this.setState({
|
|
507
|
+
startValidation: true,
|
|
508
|
+
}, () => {
|
|
509
|
+
const {
|
|
510
|
+
isFullMode,
|
|
511
|
+
saveMessage,
|
|
512
|
+
actions,
|
|
513
|
+
onCreateComplete,
|
|
514
|
+
} = this.props;
|
|
515
|
+
if (!isFullMode) {
|
|
516
|
+
saveMessage();
|
|
517
|
+
} else if (this.state.isEdit) {
|
|
518
|
+
actions.editTemplate(obj, () => {
|
|
519
|
+
this.setEditSuccessMessage();
|
|
520
|
+
onCreateComplete();
|
|
521
|
+
});
|
|
522
|
+
} else {
|
|
523
|
+
actions.createTemplate(
|
|
524
|
+
obj,
|
|
525
|
+
onCreateComplete
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
406
529
|
}
|
|
407
530
|
};
|
|
408
531
|
|
|
409
|
-
cancelTemplate = () => {
|
|
410
|
-
const type = this.props.location.query.type;
|
|
411
|
-
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
412
|
-
this.props.router.push({
|
|
413
|
-
pathname: `/LINE/`,
|
|
414
|
-
query: type === 'embedded' ? {type: 'embedded', module} : {module},
|
|
415
|
-
});
|
|
416
|
-
};
|
|
417
|
-
|
|
418
532
|
injectSections = (sections) => {
|
|
419
533
|
_.forEach(sections, (section) => {
|
|
420
534
|
let temp = section;
|
|
@@ -434,24 +548,28 @@ export class Line extends Component {
|
|
|
434
548
|
_.forEach(inputField.cols, (col) => {
|
|
435
549
|
const temp = col;
|
|
436
550
|
if (temp.type === 'popover') {
|
|
437
|
-
temp.content.sections = this.injectSections(
|
|
551
|
+
temp.content.sections = this.injectSections(
|
|
552
|
+
temp.content.sections
|
|
553
|
+
);
|
|
438
554
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
439
555
|
return true;
|
|
440
556
|
}
|
|
441
|
-
if (temp.id ===
|
|
442
|
-
temp.colStyle = {...temp.colStyle, display: 'none'};
|
|
557
|
+
if (temp.id === 'discard-button') {
|
|
558
|
+
temp.colStyle = { ...temp.colStyle, display: 'none' };
|
|
443
559
|
}
|
|
444
|
-
if (temp.id ===
|
|
560
|
+
if (temp.id === 'cancel-button') {
|
|
445
561
|
temp.offset = 11;
|
|
446
562
|
}
|
|
447
|
-
if (temp.id ===
|
|
563
|
+
if (temp.id === 'line-push-preview') {
|
|
448
564
|
temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
|
|
449
565
|
}
|
|
450
566
|
temp.injectedEvents = {};
|
|
451
567
|
|
|
452
568
|
_.forEach(col.supportedEvents, (event) => {
|
|
453
|
-
|
|
454
|
-
|
|
569
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
570
|
+
col.id,
|
|
571
|
+
event
|
|
572
|
+
);
|
|
455
573
|
});
|
|
456
574
|
return true;
|
|
457
575
|
});
|
|
@@ -460,13 +578,18 @@ export class Line extends Component {
|
|
|
460
578
|
_.forEach(actionField.cols, (col) => {
|
|
461
579
|
const temp = col;
|
|
462
580
|
if (temp.type === 'popover') {
|
|
463
|
-
temp.content.sections = this.injectSections(
|
|
581
|
+
temp.content.sections = this.injectSections(
|
|
582
|
+
temp.content.sections
|
|
583
|
+
);
|
|
464
584
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
465
585
|
return true;
|
|
466
586
|
}
|
|
467
587
|
temp.injectedEvents = {};
|
|
468
588
|
_.forEach(col.supportedEvents, (event) => {
|
|
469
|
-
temp.injectedEvents[event] = this.getMappedEvent(
|
|
589
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
590
|
+
col.id,
|
|
591
|
+
event
|
|
592
|
+
);
|
|
470
593
|
});
|
|
471
594
|
return true;
|
|
472
595
|
});
|
|
@@ -478,26 +601,36 @@ export class Line extends Component {
|
|
|
478
601
|
_.forEach(section.inputFields, (inputField) => {
|
|
479
602
|
const temp = inputField;
|
|
480
603
|
if (temp.type === 'popover') {
|
|
481
|
-
temp.content.sections = this.injectSections(
|
|
604
|
+
temp.content.sections = this.injectSections(
|
|
605
|
+
temp.content.sections
|
|
606
|
+
);
|
|
482
607
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
483
608
|
return true;
|
|
484
609
|
}
|
|
485
610
|
temp.injectedEvents = {};
|
|
486
611
|
_.forEach(inputField.supportedEvents, (event) => {
|
|
487
|
-
temp.injectedEvents[event] = this.getMappedEvent(
|
|
612
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
613
|
+
inputField.id,
|
|
614
|
+
event
|
|
615
|
+
);
|
|
488
616
|
});
|
|
489
617
|
return true;
|
|
490
618
|
});
|
|
491
619
|
_.forEach(section.actionFields, (actionField) => {
|
|
492
620
|
const temp = actionField;
|
|
493
621
|
if (temp.type === 'popover') {
|
|
494
|
-
temp.content.sections = this.injectSections(
|
|
622
|
+
temp.content.sections = this.injectSections(
|
|
623
|
+
temp.content.sections
|
|
624
|
+
);
|
|
495
625
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
496
626
|
return true;
|
|
497
627
|
}
|
|
498
628
|
temp.injectedEvents = {};
|
|
499
629
|
_.forEach(actionField.supportedEvents, (event) => {
|
|
500
|
-
temp.injectedEvents[event] = this.getMappedEvent(
|
|
630
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
631
|
+
actionField.id,
|
|
632
|
+
event
|
|
633
|
+
);
|
|
501
634
|
});
|
|
502
635
|
return true;
|
|
503
636
|
});
|
|
@@ -525,12 +658,17 @@ export class Line extends Component {
|
|
|
525
658
|
myField.focus();
|
|
526
659
|
const sel = document.selection.createRange();
|
|
527
660
|
sel.text = myValue;
|
|
528
|
-
} else if (
|
|
661
|
+
} else if (
|
|
662
|
+
myField.selectionStart ||
|
|
663
|
+
myField.selectionStart === '0'
|
|
664
|
+
) {
|
|
665
|
+
//MOZILLA and others
|
|
529
666
|
const startPos = myField.selectionStart;
|
|
530
667
|
const endPos = myField.selectionEnd;
|
|
531
|
-
myField.value =
|
|
532
|
-
+
|
|
533
|
-
+
|
|
668
|
+
myField.value =
|
|
669
|
+
myField.value.substring(0, startPos) +
|
|
670
|
+
myValue +
|
|
671
|
+
myField.value.substring(endPos, myField.value.length);
|
|
534
672
|
myField.selectionStart = startPos + myValue.length;
|
|
535
673
|
myField.selectionEnd = startPos + myValue.length;
|
|
536
674
|
} else {
|
|
@@ -538,7 +676,7 @@ export class Line extends Component {
|
|
|
538
676
|
}
|
|
539
677
|
const formData = _.cloneDeep(this.state.formData);
|
|
540
678
|
formData[currentTab - 1][field.id] = myField.value;
|
|
541
|
-
this.setState({formData});
|
|
679
|
+
this.setState({ formData });
|
|
542
680
|
};
|
|
543
681
|
|
|
544
682
|
startTemplateCreation = (data) => {
|
|
@@ -547,7 +685,6 @@ export class Line extends Component {
|
|
|
547
685
|
type: 'LAYOUT',
|
|
548
686
|
};
|
|
549
687
|
this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
|
|
550
|
-
console.log('startTemplateCreation');
|
|
551
688
|
const content = data.content;
|
|
552
689
|
const obj = {};
|
|
553
690
|
obj['0'] = {};
|
|
@@ -561,14 +698,17 @@ export class Line extends Component {
|
|
|
561
698
|
obj.base.image = content;
|
|
562
699
|
obj['0'].image = content;
|
|
563
700
|
}
|
|
564
|
-
this.setState({
|
|
701
|
+
this.setState({
|
|
702
|
+
formData: obj,
|
|
703
|
+
loading: false,
|
|
704
|
+
injectedTags: data.tags,
|
|
705
|
+
});
|
|
565
706
|
this.props.globalActions.setInjectedTags(data.tags);
|
|
566
707
|
};
|
|
567
708
|
|
|
568
709
|
startLoading = (ifEdit) => {
|
|
569
|
-
console.log('startLoading', ifEdit);
|
|
570
710
|
if (ifEdit) {
|
|
571
|
-
this.setState({loading: true});
|
|
711
|
+
this.setState({ loading: true });
|
|
572
712
|
}
|
|
573
713
|
};
|
|
574
714
|
|
|
@@ -581,7 +721,9 @@ export class Line extends Component {
|
|
|
581
721
|
});
|
|
582
722
|
_.forEach(temp.panes, (pane) => {
|
|
583
723
|
const tempPane = pane;
|
|
584
|
-
tempPane.sectionsHeaders = this.injectSections(
|
|
724
|
+
tempPane.sectionsHeaders = this.injectSections(
|
|
725
|
+
tempPane.sectionsHeaders
|
|
726
|
+
);
|
|
585
727
|
tempPane.sections = this.injectSections(tempPane.sections);
|
|
586
728
|
});
|
|
587
729
|
}
|
|
@@ -589,7 +731,11 @@ export class Line extends Component {
|
|
|
589
731
|
};
|
|
590
732
|
|
|
591
733
|
resetSchema = () => {
|
|
592
|
-
this.setState({
|
|
734
|
+
this.setState({
|
|
735
|
+
schema: this.state.initialState
|
|
736
|
+
? this.state.initialState
|
|
737
|
+
: this.state.schema,
|
|
738
|
+
});
|
|
593
739
|
};
|
|
594
740
|
|
|
595
741
|
resetState = () => {
|
|
@@ -606,7 +752,6 @@ export class Line extends Component {
|
|
|
606
752
|
};
|
|
607
753
|
|
|
608
754
|
moveToTemplates() {
|
|
609
|
-
console.log('in move to Templates');
|
|
610
755
|
const modalContent = {
|
|
611
756
|
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
612
757
|
body: this.props.intl.formatMessage(messages.goBackTemporaryLost),
|
|
@@ -614,12 +759,12 @@ export class Line extends Component {
|
|
|
614
759
|
id: 'template-back-confirm-modal',
|
|
615
760
|
show: true,
|
|
616
761
|
};
|
|
617
|
-
this.setState({modalContent, showModal: true});
|
|
762
|
+
this.setState({ modalContent, showModal: true });
|
|
618
763
|
}
|
|
619
764
|
|
|
620
765
|
showNext() {
|
|
621
766
|
const response = {
|
|
622
|
-
action:
|
|
767
|
+
action: 'showNext',
|
|
623
768
|
value: true,
|
|
624
769
|
};
|
|
625
770
|
parent.postMessage(JSON.stringify(response), '*');
|
|
@@ -631,20 +776,17 @@ export class Line extends Component {
|
|
|
631
776
|
};
|
|
632
777
|
|
|
633
778
|
handleFrameTasks = (e) => {
|
|
634
|
-
console.log('listened from cheetah@@@', e.data);
|
|
635
779
|
const type = e.data;
|
|
636
|
-
console.log('data type', typeof type);
|
|
637
780
|
if (typeof type === 'object') {
|
|
638
|
-
console.log('received something', type);
|
|
639
781
|
const action = type.action;
|
|
640
782
|
switch (action) {
|
|
641
|
-
case
|
|
783
|
+
case 'startTemplateCreation':
|
|
642
784
|
this.startTemplateCreation(type.value);
|
|
643
785
|
break;
|
|
644
|
-
case
|
|
786
|
+
case 'startLoading':
|
|
645
787
|
this.startLoading(type.edit);
|
|
646
788
|
break;
|
|
647
|
-
case
|
|
789
|
+
case 'getCurrentWindow':
|
|
648
790
|
this.getCurrentWindow(type);
|
|
649
791
|
break;
|
|
650
792
|
default:
|
|
@@ -652,19 +794,16 @@ export class Line extends Component {
|
|
|
652
794
|
}
|
|
653
795
|
} else {
|
|
654
796
|
switch (type) {
|
|
655
|
-
case
|
|
797
|
+
case 'getFormData':
|
|
656
798
|
this.getFormData(e);
|
|
657
799
|
break;
|
|
658
|
-
case
|
|
659
|
-
console.log('Starting to create template');
|
|
800
|
+
case 'startTemplateCreation':
|
|
660
801
|
//this.getFormData(e);
|
|
661
802
|
break;
|
|
662
|
-
case
|
|
663
|
-
console.log('moving to templates');
|
|
803
|
+
case 'moveToTemplates':
|
|
664
804
|
this.moveToTemplates();
|
|
665
805
|
break;
|
|
666
|
-
case
|
|
667
|
-
console.log('validating Content');
|
|
806
|
+
case 'validateContent':
|
|
668
807
|
this.validateContent(e);
|
|
669
808
|
break;
|
|
670
809
|
default:
|
|
@@ -675,11 +814,24 @@ export class Line extends Component {
|
|
|
675
814
|
|
|
676
815
|
removeStandAlone = () => {
|
|
677
816
|
const schema = _.cloneDeep(this.state.schema);
|
|
678
|
-
|
|
679
|
-
|
|
817
|
+
const {
|
|
818
|
+
location: {
|
|
819
|
+
query: {
|
|
820
|
+
type,
|
|
821
|
+
mode,
|
|
822
|
+
module,
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
} = this.props;
|
|
826
|
+
if (type === 'embedded' && module === 'loyalty') {
|
|
680
827
|
schema.standalone.sections.splice(0, 1);
|
|
681
|
-
} else if (
|
|
682
|
-
|
|
828
|
+
} else if (type === 'embedded' && typeof mode !== 'undefined') {
|
|
829
|
+
delete schema.standalone;
|
|
830
|
+
} else if (!this.props.isFullMode) {
|
|
831
|
+
const childSections = get(schema, 'standalone.sections[0].childSections');
|
|
832
|
+
const fields = get(childSections, '[1].childSections[0].childSections');//removing template name section
|
|
833
|
+
fields.splice(0, 1);
|
|
834
|
+
set(childSections, '[1].childSections[0].childSections', fields);
|
|
683
835
|
} else {
|
|
684
836
|
schema.standalone.sections.splice(1, 1);
|
|
685
837
|
}
|
|
@@ -687,74 +839,170 @@ export class Line extends Component {
|
|
|
687
839
|
};
|
|
688
840
|
|
|
689
841
|
validateContent = (e) => {
|
|
690
|
-
console.log('posting final validation result', this.state.isFormValid);
|
|
691
842
|
const response = {
|
|
692
|
-
action:
|
|
843
|
+
action: 'validateContent',
|
|
693
844
|
value: this.state.isFormValid,
|
|
694
845
|
};
|
|
695
846
|
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
696
847
|
};
|
|
697
848
|
|
|
698
849
|
handleOnTagsContextChange = (data) => {
|
|
699
|
-
console.log('parent tags context', data);
|
|
700
850
|
const query = {
|
|
701
851
|
layout: 'LINE',
|
|
702
852
|
type: 'TAG',
|
|
703
|
-
context:
|
|
704
|
-
|
|
853
|
+
context:
|
|
854
|
+
data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
|
|
855
|
+
embedded:
|
|
856
|
+
this.props.location.query.type === 'embedded'
|
|
857
|
+
? this.props.location.query.type
|
|
858
|
+
: 'full',
|
|
705
859
|
};
|
|
706
860
|
this.props.globalActions.fetchSchemaForEntity(query);
|
|
707
861
|
};
|
|
708
862
|
|
|
709
863
|
uploadImage = (pearmData) => {
|
|
710
|
-
console.log("image data line@@@", pearmData);
|
|
711
864
|
const data = pearmData;
|
|
712
865
|
if (data.file.size > 1000000) {
|
|
713
|
-
const message = getMessageObject(
|
|
866
|
+
const message = getMessageObject(
|
|
867
|
+
'error',
|
|
868
|
+
this.props.intl.formatMessage(
|
|
869
|
+
messages['File size cannot be more than 1mb']
|
|
870
|
+
),
|
|
871
|
+
true
|
|
872
|
+
);
|
|
714
873
|
this.props.globalActions.addMessageToQueue(message);
|
|
715
874
|
} else {
|
|
716
875
|
data.fileParams.isGeneratePreview = true;
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
876
|
+
this.props.actions.uploadAsset(
|
|
877
|
+
data.file,
|
|
878
|
+
data.type,
|
|
879
|
+
data.fileParams,
|
|
880
|
+
);
|
|
721
881
|
}
|
|
722
882
|
};
|
|
723
883
|
|
|
884
|
+
onGalleryImageSelect = (imageTemplate) => {
|
|
885
|
+
const { formData } = this.state;
|
|
886
|
+
const image = get(imageTemplate, 'metaInfo.secure_file_path');
|
|
887
|
+
const imagePreview = get(imageTemplate, 'metaInfo.secure_file_path_preview');
|
|
888
|
+
this.setState({
|
|
889
|
+
isDrawerRequired: false,
|
|
890
|
+
formData: {
|
|
891
|
+
...formData,
|
|
892
|
+
0: {
|
|
893
|
+
...formData[0],
|
|
894
|
+
image,
|
|
895
|
+
imagePreview,
|
|
896
|
+
},
|
|
897
|
+
base: {
|
|
898
|
+
...formData.base,
|
|
899
|
+
image,
|
|
900
|
+
imagePreview,
|
|
901
|
+
},
|
|
902
|
+
},
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
getGalleryDrawerContent = () => {
|
|
907
|
+
const location = {
|
|
908
|
+
pathname: `/assets`,
|
|
909
|
+
search: '',
|
|
910
|
+
query: !this.props.isFullMode ? {type: 'embedded', module: 'library'} : {},
|
|
911
|
+
};
|
|
912
|
+
const content = (
|
|
913
|
+
<Gallery
|
|
914
|
+
location={location}
|
|
915
|
+
isFullMode={this.props.isFullMode}
|
|
916
|
+
isLineAsset
|
|
917
|
+
onGalleryImageSelect={this.onGalleryImageSelect}
|
|
918
|
+
/>);
|
|
919
|
+
return (
|
|
920
|
+
<>
|
|
921
|
+
<CapHeading type="h3">
|
|
922
|
+
{this.props.intl.formatMessage(messages.imageGallery)}
|
|
923
|
+
</CapHeading>
|
|
924
|
+
{content}
|
|
925
|
+
</>
|
|
926
|
+
);
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
updateSchemaWithLabels = (schema) => {
|
|
930
|
+
/* eslint-disable no-param-reassign */
|
|
931
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].placeholder = this.props.intl.formatMessage(
|
|
932
|
+
messages.templatePlaceholder
|
|
933
|
+
);
|
|
934
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].errorMessage = this.props.intl.formatMessage(
|
|
935
|
+
messages.templateNameErrorPlaceholder
|
|
936
|
+
);
|
|
937
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].label = this.props.intl.formatMessage(
|
|
938
|
+
messages.templateAddTag
|
|
939
|
+
);
|
|
940
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[2].inputFields[0].cols[0].placeholder = this.props.intl.formatMessage(
|
|
941
|
+
messages.templateMessagePlaceholder
|
|
942
|
+
);
|
|
943
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[2].inputFields[0].cols[0].errorMessage = this.props.intl.formatMessage(
|
|
944
|
+
messages.templateMessageError
|
|
945
|
+
);
|
|
946
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].placeholder = this.props.intl.formatMessage(
|
|
947
|
+
messages.templatePlaceholder
|
|
948
|
+
);
|
|
949
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].errorMessage = this.props.intl.formatMessage(
|
|
950
|
+
messages.templateNameErrorPlaceholder
|
|
951
|
+
);
|
|
952
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].previewProps.label = this.props.intl.formatMessage(
|
|
953
|
+
messages.templateMessagePreviewPropsLabel
|
|
954
|
+
);
|
|
955
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].previewProps.inductiveText = this.props.intl.formatMessage(
|
|
956
|
+
messages.templateMessagePreviewPropsInductiveText
|
|
957
|
+
);
|
|
958
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].previewProps.errorMessage = this.props.intl.formatMessage(
|
|
959
|
+
messages.templateMessagePreviewPropsError
|
|
960
|
+
);
|
|
961
|
+
return schema;
|
|
962
|
+
};
|
|
963
|
+
|
|
724
964
|
render() {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
965
|
+
const {
|
|
966
|
+
Line: {
|
|
967
|
+
createTemplateInProgress,
|
|
968
|
+
assetUploading,
|
|
969
|
+
} = {},
|
|
970
|
+
templateData,
|
|
971
|
+
params: {
|
|
972
|
+
id,
|
|
973
|
+
} = {},
|
|
974
|
+
} = this.props;
|
|
975
|
+
const {
|
|
976
|
+
edit,
|
|
977
|
+
mode,
|
|
978
|
+
orgId,
|
|
979
|
+
isDefault,
|
|
980
|
+
} = templateData || {};
|
|
981
|
+
let loading = createTemplateInProgress || false;
|
|
982
|
+
loading = !!assetUploading;
|
|
983
|
+
if (!isDefault && (edit || mode === 'edit' || (orgId && id))) {
|
|
984
|
+
const {
|
|
985
|
+
base: {
|
|
986
|
+
'message-editor': msgEditor,
|
|
987
|
+
image: uploadedAsset,
|
|
988
|
+
} = {},
|
|
989
|
+
reUpload,
|
|
990
|
+
} = this.state.formData;
|
|
991
|
+
loading = typeof reUpload === 'undefined' ? !(msgEditor || uploadedAsset) : !reUpload;
|
|
992
|
+
}
|
|
993
|
+
let tags =
|
|
994
|
+
this.props.metaEntities && this.props.metaEntities.tags
|
|
995
|
+
? this.props.metaEntities.tags.standard
|
|
996
|
+
: [];
|
|
738
997
|
if (this.props.supportedTags) {
|
|
739
998
|
tags = this.props.supportedTags;
|
|
740
999
|
}
|
|
741
1000
|
return (
|
|
742
|
-
<
|
|
743
|
-
<
|
|
744
|
-
<
|
|
745
|
-
{this.props.location.query.type !== "embedded" &&
|
|
746
|
-
<Breadcrumb>
|
|
747
|
-
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Campaigns)}</BreadcrumbItem>
|
|
748
|
-
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Creatives)}</BreadcrumbItem>
|
|
749
|
-
<BreadcrumbItem>{this.props.intl.formatMessage(messages.Line)}</BreadcrumbItem>
|
|
750
|
-
</Breadcrumb>
|
|
751
|
-
}
|
|
752
|
-
</Col>
|
|
753
|
-
</Row>
|
|
754
|
-
<Row>
|
|
755
|
-
<Col>
|
|
1001
|
+
<CapSpin spinning={loading}>
|
|
1002
|
+
<CapRow>
|
|
1003
|
+
<CapColumn>
|
|
756
1004
|
<FormBuilder
|
|
757
|
-
key={
|
|
1005
|
+
key={'form builder'}
|
|
758
1006
|
schema={this.state.schema}
|
|
759
1007
|
onSubmit={this.saveFormData}
|
|
760
1008
|
onChange={this.onFormDataChange}
|
|
@@ -763,7 +1011,9 @@ export class Line extends Component {
|
|
|
763
1011
|
formData={_.cloneDeep(this.state.formData)}
|
|
764
1012
|
location={this.props.location}
|
|
765
1013
|
tags={tags}
|
|
766
|
-
injectedTags={
|
|
1014
|
+
injectedTags={
|
|
1015
|
+
this.props.injectedTags ? this.props.injectedTags : {}
|
|
1016
|
+
}
|
|
767
1017
|
onFormValidityChange={this.setFormValidity}
|
|
768
1018
|
usingTabContainer
|
|
769
1019
|
checkValidation={this.state.checkValidation}
|
|
@@ -777,10 +1027,16 @@ export class Line extends Component {
|
|
|
777
1027
|
router={this.props.router}
|
|
778
1028
|
onContextChange={this.handleOnTagsContextChange}
|
|
779
1029
|
setModalContent={this.setModalContent}
|
|
1030
|
+
capDrawerContent={this.getGalleryDrawerContent()}
|
|
1031
|
+
isDrawerRequired={this.state.isDrawerRequired}
|
|
1032
|
+
setDrawerVisibility={(drawervisibleFlag) =>
|
|
1033
|
+
this.setState({ isDrawerRequired: drawervisibleFlag })
|
|
1034
|
+
}
|
|
1035
|
+
startValidation={this.state.startValidation}
|
|
780
1036
|
/>
|
|
781
|
-
</
|
|
782
|
-
</
|
|
783
|
-
</
|
|
1037
|
+
</CapColumn>
|
|
1038
|
+
</CapRow>
|
|
1039
|
+
</CapSpin>
|
|
784
1040
|
);
|
|
785
1041
|
}
|
|
786
1042
|
}
|
|
@@ -799,10 +1055,15 @@ Line.propTypes = {
|
|
|
799
1055
|
supportedTags: PropTypes.any,
|
|
800
1056
|
getDefaultTags: PropTypes.string,
|
|
801
1057
|
injectedTags: PropTypes.object,
|
|
1058
|
+
onCreateComplete: PropTypes.func,
|
|
1059
|
+
isFullMode: PropTypes.bool,
|
|
1060
|
+
saveMessage: PropTypes.func,
|
|
1061
|
+
templateData: PropTypes.object,
|
|
802
1062
|
};
|
|
803
1063
|
|
|
804
1064
|
const mapStateToProps = createStructuredSelector({
|
|
805
1065
|
Line: makeSelectCreateLine(),
|
|
1066
|
+
lineData: makeSelectLine(),
|
|
806
1067
|
Templates: makeSelectTemplates(),
|
|
807
1068
|
metaEntities: makeSelectMetaEntities(),
|
|
808
1069
|
injectedTags: setInjectedTags(),
|