@capillarytech/creatives-library 3.8.7 → 3.8.8
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/package.json +1 -1
- package/routes.js +5 -0
- package/services/getSchema.js +4 -1
- package/translations/en.json +23 -1
- package/translations/zh.json +23 -1
- package/v2Components/FormBuilder/index.js +163 -31
- package/v2Components/FormBuilder/messages.js +16 -0
- package/v2Components/TemplatePreview/index.js +13 -4
- package/v2Containers/Assets/Gallery/index.js +40 -29
- package/v2Containers/CreativesContainer/SlideBoxContent.js +58 -3
- package/v2Containers/CreativesContainer/index.js +1 -0
- package/v2Containers/EmailWrapper/index.js +3 -5
- package/v2Containers/Line/Create/_lineCreate.scss +40 -19
- package/v2Containers/Line/Create/actions.js +11 -8
- package/v2Containers/Line/Create/index.js +405 -215
- 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 +1 -2
- package/v2Containers/Line/CreateWrapper/constants.js +2 -0
- package/v2Containers/Line/CreateWrapper/index.js +114 -0
- package/v2Containers/Line/CreateWrapper/messages.js +43 -0
- package/v2Containers/Templates/_templates.scss +20 -1
- package/v2Containers/Templates/index.js +59 -5
- package/v2Containers/TemplatesV2/index.js +5 -4
- package/v2Containers/TemplatesV2/messages.js +4 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
+
import get from 'lodash/get';
|
|
3
4
|
import { bindActionCreators } from 'redux';
|
|
4
5
|
import { intlShape } from 'react-intl';
|
|
5
6
|
import { createStructuredSelector } from 'reselect';
|
|
6
|
-
import { Row, Col, Spin
|
|
7
|
+
import { Row, Col, Spin } from 'antd';
|
|
7
8
|
import _ from 'lodash';
|
|
9
|
+
import { CapHeading } 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
15
|
import {makeSelectCreateLine} from './selectors';
|
|
@@ -16,47 +19,48 @@ 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
|
+
galleryPage: 1,
|
|
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,42 @@ 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
|
-
//console.log("ooo", this.state.schema);
|
|
128
|
+
this.setState({ modeType, schema: {} });
|
|
126
129
|
}
|
|
127
130
|
if (nextProps.isGetFormData) {
|
|
128
131
|
nextProps.getFormLibraryData(this.getFormData());
|
|
129
132
|
}
|
|
130
133
|
if (isSchemaReady) {
|
|
131
134
|
// set schema value as per mode type. Supported mode (text & image)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
const { textSchema, imageSchema } = this.updateSchemaWithLabels(
|
|
136
|
+
layouts[0].definition
|
|
137
|
+
);
|
|
138
|
+
const schema =
|
|
139
|
+
modeType === 'text' || editModeType === 'edit_text'
|
|
140
|
+
? textSchema
|
|
141
|
+
: imageSchema;
|
|
142
|
+
this.setState({ schema }, () => {
|
|
136
143
|
// Once schema is ready and set, then inject the available events from the schema
|
|
137
144
|
if (!_.isEmpty(this.state.schema)) {
|
|
138
145
|
this.injectEvents(this.state.schema);
|
|
@@ -141,118 +148,172 @@ export class Line extends Component {
|
|
|
141
148
|
const getTagsQuery = {
|
|
142
149
|
layout: 'LINE',
|
|
143
150
|
type: 'TAG',
|
|
144
|
-
context:
|
|
145
|
-
|
|
151
|
+
context:
|
|
152
|
+
this.props.location.query.type === 'embedded'
|
|
153
|
+
? this.props.location.query.module
|
|
154
|
+
: 'default',
|
|
155
|
+
embedded:
|
|
156
|
+
this.props.location.query.type === 'embedded'
|
|
157
|
+
? this.props.location.query.type
|
|
158
|
+
: 'full',
|
|
146
159
|
};
|
|
147
160
|
if (this.props.getDefaultTags) {
|
|
148
161
|
getTagsQuery.context = this.props.getDefaultTags;
|
|
149
162
|
}
|
|
150
|
-
if (tags
|
|
163
|
+
if (!Object.keys(tags || {}).length && modeType !== 'image') {
|
|
151
164
|
this.props.globalActions.fetchSchemaForEntity(getTagsQuery);
|
|
152
165
|
} else {
|
|
153
|
-
this.setState({isReady: true});
|
|
154
|
-
}
|
|
155
|
-
if (this.props.location.query.type === 'embedded') {
|
|
156
|
-
this.showNext();
|
|
166
|
+
this.setState({ isReady: true });
|
|
157
167
|
}
|
|
158
168
|
});
|
|
159
169
|
}
|
|
160
170
|
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
const lineTemplateId = get(nextProps, 'Line.response.templateId', '');
|
|
172
|
+
if (lineTemplateId) {
|
|
163
173
|
this.discardValues();
|
|
164
|
-
const message = getMessageObject(
|
|
174
|
+
const message = getMessageObject(
|
|
175
|
+
'success',
|
|
176
|
+
this.props.intl.formatMessage(
|
|
177
|
+
messages.lineTemplateCreatedSuccessfully
|
|
178
|
+
),
|
|
179
|
+
true
|
|
180
|
+
);
|
|
165
181
|
this.props.globalActions.addMessageToQueue(message);
|
|
166
182
|
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
183
|
}
|
|
174
184
|
|
|
175
|
-
if (
|
|
176
|
-
|
|
185
|
+
if (
|
|
186
|
+
nextProps.Line.createTemplateError &&
|
|
187
|
+
!_.isEqual(
|
|
188
|
+
nextProps.Line.createTemplateError,
|
|
189
|
+
this.props.Line.createTemplateError
|
|
190
|
+
)
|
|
191
|
+
) {
|
|
192
|
+
const {
|
|
193
|
+
Line: {
|
|
194
|
+
createTemplateErrorMessage,
|
|
195
|
+
},
|
|
196
|
+
} = nextProps;
|
|
197
|
+
const message = getMessageObject(
|
|
198
|
+
'error',
|
|
199
|
+
createTemplateErrorMessage || this.props.intl.formatMessage(messages.somethingWentWrong),
|
|
200
|
+
true
|
|
201
|
+
);
|
|
177
202
|
this.props.globalActions.addMessageToQueue(message);
|
|
178
203
|
}
|
|
179
204
|
|
|
180
205
|
//// Edit Template Logic ////
|
|
181
|
-
|
|
182
|
-
|
|
206
|
+
const isEdit =
|
|
207
|
+
this.state.isEdit &&
|
|
208
|
+
this.props.params.id &&
|
|
209
|
+
(this.props.route.name === 'edit_text' ||
|
|
210
|
+
this.props.route.name === 'edit_image') &&
|
|
211
|
+
this.props.Line.templateDetails &&
|
|
212
|
+
this.props.Line.templateDetails.versions;
|
|
183
213
|
if (isEdit) {
|
|
184
|
-
const formData = this.getEditTransformedData(
|
|
185
|
-
|
|
214
|
+
const formData = this.getEditTransformedData(
|
|
215
|
+
this.props.Line.templateDetails
|
|
216
|
+
);
|
|
217
|
+
this.setState({
|
|
218
|
+
formData,
|
|
219
|
+
editTemplateData: this.props.Line.templateDetails,
|
|
220
|
+
});
|
|
186
221
|
this.props.actions.clearData();
|
|
187
222
|
}
|
|
188
223
|
|
|
189
|
-
const isEditSucceed =
|
|
224
|
+
const isEditSucceed =
|
|
225
|
+
this.state.isEdit &&
|
|
226
|
+
nextProps.Line &&
|
|
227
|
+
nextProps.Line.editResponse &&
|
|
228
|
+
nextProps.Line.editResponse.templateId;
|
|
190
229
|
if (isEditSucceed) {
|
|
191
|
-
this.setState({formData: {} });
|
|
192
|
-
const message = getMessageObject(
|
|
230
|
+
this.setState({ formData: {} });
|
|
231
|
+
const message = getMessageObject(
|
|
232
|
+
'success',
|
|
233
|
+
this.props.intl.formatMessage(
|
|
234
|
+
messages['Line Template Edited Successfully']
|
|
235
|
+
),
|
|
236
|
+
true
|
|
237
|
+
);
|
|
193
238
|
this.props.globalActions.addMessageToQueue(message);
|
|
194
239
|
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},
|
|
200
|
-
});
|
|
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
|
|
|
220
275
|
componentWillUnmount() {
|
|
221
|
-
|
|
222
|
-
window.removeEventListener("message", this.handleFrameTasks);
|
|
276
|
+
window.removeEventListener('message', this.handleFrameTasks);
|
|
223
277
|
}
|
|
224
278
|
|
|
225
279
|
onTagSelect(data, currentTab) {
|
|
226
|
-
console.log('parent data tag', data, currentTab);
|
|
227
280
|
const editorId = 'message-editor';
|
|
228
|
-
this.insertAtCursor(
|
|
281
|
+
this.insertAtCursor(
|
|
282
|
+
document.getElementById(editorId),
|
|
283
|
+
`{{${data}}}`,
|
|
284
|
+
currentTab
|
|
285
|
+
);
|
|
229
286
|
document.getElementById(editorId).focus();
|
|
230
287
|
}
|
|
231
288
|
|
|
232
289
|
onTagSelectTitle(data, currentTab) {
|
|
233
|
-
console.log('parent data tag', data, currentTab);
|
|
234
290
|
const editorId = 'message-title';
|
|
235
|
-
this.insertAtCursor(
|
|
291
|
+
this.insertAtCursor(
|
|
292
|
+
document.getElementById(editorId),
|
|
293
|
+
`{{${data}}}`,
|
|
294
|
+
currentTab
|
|
295
|
+
);
|
|
236
296
|
document.getElementById(editorId).focus();
|
|
237
297
|
}
|
|
238
298
|
|
|
239
299
|
onFormDataChange = (formData, tabCount, currentTab) => {
|
|
240
|
-
|
|
241
|
-
|
|
300
|
+
this.setState({ formData });
|
|
301
|
+
if (tabCount) {
|
|
302
|
+
this.setState({ tabCount });
|
|
303
|
+
}
|
|
242
304
|
if (currentTab) {
|
|
243
|
-
this.setState({currentTab});
|
|
305
|
+
this.setState({ currentTab });
|
|
244
306
|
}
|
|
245
307
|
};
|
|
246
308
|
|
|
247
309
|
getTransformedData = (formData) => {
|
|
248
|
-
console.log("formData before transform@@@", formData);
|
|
249
310
|
const modeType = this.state.modeType;
|
|
250
311
|
const obj = {};
|
|
251
312
|
const msgData = {};
|
|
252
313
|
obj.versions = {
|
|
253
314
|
base: {
|
|
254
315
|
content: {
|
|
255
|
-
to:
|
|
316
|
+
to: '{{line_id}}',
|
|
256
317
|
messages: [],
|
|
257
318
|
},
|
|
258
319
|
},
|
|
@@ -262,7 +323,7 @@ export class Line extends Component {
|
|
|
262
323
|
obj.definition = {
|
|
263
324
|
mode: modeType,
|
|
264
325
|
};
|
|
265
|
-
if (
|
|
326
|
+
if (modeType && modeType !== undefined) {
|
|
266
327
|
msgData.type = modeType;
|
|
267
328
|
}
|
|
268
329
|
if (modeType === 'text') {
|
|
@@ -287,15 +348,6 @@ export class Line extends Component {
|
|
|
287
348
|
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
288
349
|
}
|
|
289
350
|
} 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
351
|
msgData.originalContentUrl = formData['0'].image;
|
|
300
352
|
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
301
353
|
}
|
|
@@ -304,7 +356,7 @@ export class Line extends Component {
|
|
|
304
356
|
return obj;
|
|
305
357
|
};
|
|
306
358
|
|
|
307
|
-
getEditTransformedData = ({name, versions}) => {
|
|
359
|
+
getEditTransformedData = ({ name, versions }) => {
|
|
308
360
|
const modeType = this.state.modeType;
|
|
309
361
|
const obj = {};
|
|
310
362
|
obj['0'] = {};
|
|
@@ -313,33 +365,39 @@ export class Line extends Component {
|
|
|
313
365
|
};
|
|
314
366
|
obj['template-name'] = name;
|
|
315
367
|
if (modeType === 'text') {
|
|
316
|
-
obj.base['message-editor'] =
|
|
317
|
-
|
|
368
|
+
obj.base['message-editor'] =
|
|
369
|
+
versions.base.content.messages[0].text;
|
|
370
|
+
obj['0']['message-editor'] =
|
|
371
|
+
versions.base.content.messages[0].text;
|
|
318
372
|
} else if (modeType === 'image') {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
373
|
+
const {
|
|
374
|
+
base: {
|
|
375
|
+
content: {
|
|
376
|
+
messages: [{
|
|
377
|
+
originalContentUrl,
|
|
378
|
+
previewImageUrl,
|
|
379
|
+
}],
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
} = versions;
|
|
383
|
+
obj.base.image = originalContentUrl;
|
|
384
|
+
obj['0'].image = originalContentUrl;
|
|
385
|
+
obj['0'].imagePreview = previewImageUrl;
|
|
386
|
+
obj.base.imagePreview = previewImageUrl;
|
|
323
387
|
}
|
|
324
|
-
|
|
325
|
-
console.log("getEditTransformedData", obj);
|
|
326
388
|
return obj;
|
|
327
389
|
};
|
|
328
390
|
|
|
329
391
|
setFormValidity = (isFormValid) => {
|
|
330
|
-
this.setState({isFormValid});
|
|
392
|
+
this.setState({ isFormValid });
|
|
331
393
|
};
|
|
332
394
|
|
|
333
395
|
getMappedEvent = (id, event) => {
|
|
334
396
|
const map = this.state.eventsMap;
|
|
335
|
-
if (!map[id] || !map[id][event]) {
|
|
336
|
-
console.log(`error map[id] ${map[id]}` );
|
|
337
|
-
}
|
|
338
397
|
return map[id][event];
|
|
339
398
|
};
|
|
340
399
|
|
|
341
400
|
getCurrentWindow(e) {
|
|
342
|
-
console.log('in Line create@@@', e);
|
|
343
401
|
const response = {
|
|
344
402
|
action: e.action,
|
|
345
403
|
value: 'edit',
|
|
@@ -349,13 +407,12 @@ export class Line extends Component {
|
|
|
349
407
|
}
|
|
350
408
|
|
|
351
409
|
getFormData = (e) => {
|
|
352
|
-
console.log('posting final result', this.state.formData);
|
|
353
410
|
const response = {
|
|
354
|
-
action:
|
|
411
|
+
action: 'getFormData',
|
|
355
412
|
value: this.getTransformedData(this.state.formData),
|
|
356
413
|
validity: this.state.isFormValid,
|
|
357
414
|
};
|
|
358
|
-
this.setState({checkValidation: true});
|
|
415
|
+
this.setState({ checkValidation: true });
|
|
359
416
|
if (e) {
|
|
360
417
|
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
361
418
|
}
|
|
@@ -365,56 +422,62 @@ export class Line extends Component {
|
|
|
365
422
|
injectEvents = (schema) => {
|
|
366
423
|
const temp = schema;
|
|
367
424
|
if (temp.standalone) {
|
|
368
|
-
temp.standalone.sections = this.injectSections(
|
|
425
|
+
temp.standalone.sections = this.injectSections(
|
|
426
|
+
temp.standalone.sections
|
|
427
|
+
);
|
|
369
428
|
}
|
|
370
429
|
_.forEach(temp.containers, (container) => {
|
|
371
430
|
let tempContainer = container;
|
|
372
431
|
tempContainer = this.injectContainer(tempContainer);
|
|
373
432
|
return tempContainer;
|
|
374
433
|
});
|
|
375
|
-
|
|
376
|
-
this.setState({schema, isSchemaChanged: true}, () => {
|
|
434
|
+
this.setState({ schema, isSchemaChanged: true }, () => {
|
|
377
435
|
this.removeStandAlone();
|
|
378
436
|
});
|
|
379
|
-
console.log('final returned schema', this.state.schema);
|
|
380
437
|
return schema;
|
|
381
438
|
};
|
|
382
439
|
|
|
383
440
|
saveFormData = (formData) => {
|
|
384
|
-
console.log("ccc", this.props);
|
|
385
|
-
console.log('Saving form data of LINE @@@', formData, this.state.tabCount);
|
|
386
441
|
const obj = this.getTransformedData(formData);
|
|
387
|
-
console.log('obj final@@@', obj);
|
|
388
442
|
if (obj === 'IMAGE_ERROR') {
|
|
389
|
-
const message = getMessageObject(
|
|
443
|
+
const message = getMessageObject(
|
|
444
|
+
'error',
|
|
445
|
+
this.props.intl.formatMessage(
|
|
446
|
+
messages['Please upload an image to proceed']
|
|
447
|
+
),
|
|
448
|
+
true
|
|
449
|
+
);
|
|
390
450
|
this.props.globalActions.addMessageToQueue(message);
|
|
391
451
|
return;
|
|
392
452
|
}
|
|
393
|
-
if (
|
|
394
|
-
|
|
453
|
+
if (
|
|
454
|
+
obj !== 'IMAGE_ERROR' &&
|
|
455
|
+
obj.versions.base.content.messages[0].type === 'text'
|
|
456
|
+
) {
|
|
457
|
+
const text = obj.versions.base.content.messages[0].text;
|
|
458
|
+
const charCount = text ? text.length : 0;
|
|
395
459
|
if (charCount > 1600) {
|
|
396
|
-
const message = getMessageObject(
|
|
460
|
+
const message = getMessageObject(
|
|
461
|
+
'error',
|
|
462
|
+
this.props.intl.formatMessage(
|
|
463
|
+
messages['Maximum characters length exceeds']
|
|
464
|
+
),
|
|
465
|
+
true
|
|
466
|
+
);
|
|
397
467
|
this.props.globalActions.addMessageToQueue(message);
|
|
398
468
|
return;
|
|
399
469
|
}
|
|
400
470
|
}
|
|
401
471
|
if (this.state.isEdit) {
|
|
402
|
-
|
|
403
|
-
this.props.actions.editTemplate(obj);
|
|
472
|
+
this.props.actions.editTemplate(obj, this.props.onCreateComplete);
|
|
404
473
|
} else {
|
|
405
|
-
this.props.actions.createTemplate(
|
|
474
|
+
this.props.actions.createTemplate(
|
|
475
|
+
obj,
|
|
476
|
+
this.props.onCreateComplete
|
|
477
|
+
);
|
|
406
478
|
}
|
|
407
479
|
};
|
|
408
480
|
|
|
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
481
|
injectSections = (sections) => {
|
|
419
482
|
_.forEach(sections, (section) => {
|
|
420
483
|
let temp = section;
|
|
@@ -434,24 +497,28 @@ export class Line extends Component {
|
|
|
434
497
|
_.forEach(inputField.cols, (col) => {
|
|
435
498
|
const temp = col;
|
|
436
499
|
if (temp.type === 'popover') {
|
|
437
|
-
temp.content.sections = this.injectSections(
|
|
500
|
+
temp.content.sections = this.injectSections(
|
|
501
|
+
temp.content.sections
|
|
502
|
+
);
|
|
438
503
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
439
504
|
return true;
|
|
440
505
|
}
|
|
441
|
-
if (temp.id ===
|
|
442
|
-
temp.colStyle = {...temp.colStyle, display: 'none'};
|
|
506
|
+
if (temp.id === 'discard-button') {
|
|
507
|
+
temp.colStyle = { ...temp.colStyle, display: 'none' };
|
|
443
508
|
}
|
|
444
|
-
if (temp.id ===
|
|
509
|
+
if (temp.id === 'cancel-button') {
|
|
445
510
|
temp.offset = 11;
|
|
446
511
|
}
|
|
447
|
-
if (temp.id ===
|
|
512
|
+
if (temp.id === 'line-push-preview') {
|
|
448
513
|
temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
|
|
449
514
|
}
|
|
450
515
|
temp.injectedEvents = {};
|
|
451
516
|
|
|
452
517
|
_.forEach(col.supportedEvents, (event) => {
|
|
453
|
-
|
|
454
|
-
|
|
518
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
519
|
+
col.id,
|
|
520
|
+
event
|
|
521
|
+
);
|
|
455
522
|
});
|
|
456
523
|
return true;
|
|
457
524
|
});
|
|
@@ -460,13 +527,18 @@ export class Line extends Component {
|
|
|
460
527
|
_.forEach(actionField.cols, (col) => {
|
|
461
528
|
const temp = col;
|
|
462
529
|
if (temp.type === 'popover') {
|
|
463
|
-
temp.content.sections = this.injectSections(
|
|
530
|
+
temp.content.sections = this.injectSections(
|
|
531
|
+
temp.content.sections
|
|
532
|
+
);
|
|
464
533
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
465
534
|
return true;
|
|
466
535
|
}
|
|
467
536
|
temp.injectedEvents = {};
|
|
468
537
|
_.forEach(col.supportedEvents, (event) => {
|
|
469
|
-
temp.injectedEvents[event] = this.getMappedEvent(
|
|
538
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
539
|
+
col.id,
|
|
540
|
+
event
|
|
541
|
+
);
|
|
470
542
|
});
|
|
471
543
|
return true;
|
|
472
544
|
});
|
|
@@ -478,26 +550,36 @@ export class Line extends Component {
|
|
|
478
550
|
_.forEach(section.inputFields, (inputField) => {
|
|
479
551
|
const temp = inputField;
|
|
480
552
|
if (temp.type === 'popover') {
|
|
481
|
-
temp.content.sections = this.injectSections(
|
|
553
|
+
temp.content.sections = this.injectSections(
|
|
554
|
+
temp.content.sections
|
|
555
|
+
);
|
|
482
556
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
483
557
|
return true;
|
|
484
558
|
}
|
|
485
559
|
temp.injectedEvents = {};
|
|
486
560
|
_.forEach(inputField.supportedEvents, (event) => {
|
|
487
|
-
temp.injectedEvents[event] = this.getMappedEvent(
|
|
561
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
562
|
+
inputField.id,
|
|
563
|
+
event
|
|
564
|
+
);
|
|
488
565
|
});
|
|
489
566
|
return true;
|
|
490
567
|
});
|
|
491
568
|
_.forEach(section.actionFields, (actionField) => {
|
|
492
569
|
const temp = actionField;
|
|
493
570
|
if (temp.type === 'popover') {
|
|
494
|
-
temp.content.sections = this.injectSections(
|
|
571
|
+
temp.content.sections = this.injectSections(
|
|
572
|
+
temp.content.sections
|
|
573
|
+
);
|
|
495
574
|
temp.value.sections = this.injectSections(temp.value.sections);
|
|
496
575
|
return true;
|
|
497
576
|
}
|
|
498
577
|
temp.injectedEvents = {};
|
|
499
578
|
_.forEach(actionField.supportedEvents, (event) => {
|
|
500
|
-
temp.injectedEvents[event] = this.getMappedEvent(
|
|
579
|
+
temp.injectedEvents[event] = this.getMappedEvent(
|
|
580
|
+
actionField.id,
|
|
581
|
+
event
|
|
582
|
+
);
|
|
501
583
|
});
|
|
502
584
|
return true;
|
|
503
585
|
});
|
|
@@ -525,12 +607,17 @@ export class Line extends Component {
|
|
|
525
607
|
myField.focus();
|
|
526
608
|
const sel = document.selection.createRange();
|
|
527
609
|
sel.text = myValue;
|
|
528
|
-
} else if (
|
|
610
|
+
} else if (
|
|
611
|
+
myField.selectionStart ||
|
|
612
|
+
myField.selectionStart === '0'
|
|
613
|
+
) {
|
|
614
|
+
//MOZILLA and others
|
|
529
615
|
const startPos = myField.selectionStart;
|
|
530
616
|
const endPos = myField.selectionEnd;
|
|
531
|
-
myField.value =
|
|
532
|
-
+
|
|
533
|
-
+
|
|
617
|
+
myField.value =
|
|
618
|
+
myField.value.substring(0, startPos) +
|
|
619
|
+
myValue +
|
|
620
|
+
myField.value.substring(endPos, myField.value.length);
|
|
534
621
|
myField.selectionStart = startPos + myValue.length;
|
|
535
622
|
myField.selectionEnd = startPos + myValue.length;
|
|
536
623
|
} else {
|
|
@@ -538,7 +625,7 @@ export class Line extends Component {
|
|
|
538
625
|
}
|
|
539
626
|
const formData = _.cloneDeep(this.state.formData);
|
|
540
627
|
formData[currentTab - 1][field.id] = myField.value;
|
|
541
|
-
this.setState({formData});
|
|
628
|
+
this.setState({ formData });
|
|
542
629
|
};
|
|
543
630
|
|
|
544
631
|
startTemplateCreation = (data) => {
|
|
@@ -547,7 +634,6 @@ export class Line extends Component {
|
|
|
547
634
|
type: 'LAYOUT',
|
|
548
635
|
};
|
|
549
636
|
this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
|
|
550
|
-
console.log('startTemplateCreation');
|
|
551
637
|
const content = data.content;
|
|
552
638
|
const obj = {};
|
|
553
639
|
obj['0'] = {};
|
|
@@ -561,14 +647,17 @@ export class Line extends Component {
|
|
|
561
647
|
obj.base.image = content;
|
|
562
648
|
obj['0'].image = content;
|
|
563
649
|
}
|
|
564
|
-
this.setState({
|
|
650
|
+
this.setState({
|
|
651
|
+
formData: obj,
|
|
652
|
+
loading: false,
|
|
653
|
+
injectedTags: data.tags,
|
|
654
|
+
});
|
|
565
655
|
this.props.globalActions.setInjectedTags(data.tags);
|
|
566
656
|
};
|
|
567
657
|
|
|
568
658
|
startLoading = (ifEdit) => {
|
|
569
|
-
console.log('startLoading', ifEdit);
|
|
570
659
|
if (ifEdit) {
|
|
571
|
-
this.setState({loading: true});
|
|
660
|
+
this.setState({ loading: true });
|
|
572
661
|
}
|
|
573
662
|
};
|
|
574
663
|
|
|
@@ -581,7 +670,9 @@ export class Line extends Component {
|
|
|
581
670
|
});
|
|
582
671
|
_.forEach(temp.panes, (pane) => {
|
|
583
672
|
const tempPane = pane;
|
|
584
|
-
tempPane.sectionsHeaders = this.injectSections(
|
|
673
|
+
tempPane.sectionsHeaders = this.injectSections(
|
|
674
|
+
tempPane.sectionsHeaders
|
|
675
|
+
);
|
|
585
676
|
tempPane.sections = this.injectSections(tempPane.sections);
|
|
586
677
|
});
|
|
587
678
|
}
|
|
@@ -589,7 +680,11 @@ export class Line extends Component {
|
|
|
589
680
|
};
|
|
590
681
|
|
|
591
682
|
resetSchema = () => {
|
|
592
|
-
this.setState({
|
|
683
|
+
this.setState({
|
|
684
|
+
schema: this.state.initialState
|
|
685
|
+
? this.state.initialState
|
|
686
|
+
: this.state.schema,
|
|
687
|
+
});
|
|
593
688
|
};
|
|
594
689
|
|
|
595
690
|
resetState = () => {
|
|
@@ -606,7 +701,6 @@ export class Line extends Component {
|
|
|
606
701
|
};
|
|
607
702
|
|
|
608
703
|
moveToTemplates() {
|
|
609
|
-
console.log('in move to Templates');
|
|
610
704
|
const modalContent = {
|
|
611
705
|
title: this.props.intl.formatMessage(messages.alertMessage),
|
|
612
706
|
body: this.props.intl.formatMessage(messages.goBackTemporaryLost),
|
|
@@ -614,12 +708,12 @@ export class Line extends Component {
|
|
|
614
708
|
id: 'template-back-confirm-modal',
|
|
615
709
|
show: true,
|
|
616
710
|
};
|
|
617
|
-
this.setState({modalContent, showModal: true});
|
|
711
|
+
this.setState({ modalContent, showModal: true });
|
|
618
712
|
}
|
|
619
713
|
|
|
620
714
|
showNext() {
|
|
621
715
|
const response = {
|
|
622
|
-
action:
|
|
716
|
+
action: 'showNext',
|
|
623
717
|
value: true,
|
|
624
718
|
};
|
|
625
719
|
parent.postMessage(JSON.stringify(response), '*');
|
|
@@ -631,20 +725,17 @@ export class Line extends Component {
|
|
|
631
725
|
};
|
|
632
726
|
|
|
633
727
|
handleFrameTasks = (e) => {
|
|
634
|
-
console.log('listened from cheetah@@@', e.data);
|
|
635
728
|
const type = e.data;
|
|
636
|
-
console.log('data type', typeof type);
|
|
637
729
|
if (typeof type === 'object') {
|
|
638
|
-
console.log('received something', type);
|
|
639
730
|
const action = type.action;
|
|
640
731
|
switch (action) {
|
|
641
|
-
case
|
|
732
|
+
case 'startTemplateCreation':
|
|
642
733
|
this.startTemplateCreation(type.value);
|
|
643
734
|
break;
|
|
644
|
-
case
|
|
735
|
+
case 'startLoading':
|
|
645
736
|
this.startLoading(type.edit);
|
|
646
737
|
break;
|
|
647
|
-
case
|
|
738
|
+
case 'getCurrentWindow':
|
|
648
739
|
this.getCurrentWindow(type);
|
|
649
740
|
break;
|
|
650
741
|
default:
|
|
@@ -652,19 +743,16 @@ export class Line extends Component {
|
|
|
652
743
|
}
|
|
653
744
|
} else {
|
|
654
745
|
switch (type) {
|
|
655
|
-
case
|
|
746
|
+
case 'getFormData':
|
|
656
747
|
this.getFormData(e);
|
|
657
748
|
break;
|
|
658
|
-
case
|
|
659
|
-
console.log('Starting to create template');
|
|
749
|
+
case 'startTemplateCreation':
|
|
660
750
|
//this.getFormData(e);
|
|
661
751
|
break;
|
|
662
|
-
case
|
|
663
|
-
console.log('moving to templates');
|
|
752
|
+
case 'moveToTemplates':
|
|
664
753
|
this.moveToTemplates();
|
|
665
754
|
break;
|
|
666
|
-
case
|
|
667
|
-
console.log('validating Content');
|
|
755
|
+
case 'validateContent':
|
|
668
756
|
this.validateContent(e);
|
|
669
757
|
break;
|
|
670
758
|
default:
|
|
@@ -675,10 +763,15 @@ export class Line extends Component {
|
|
|
675
763
|
|
|
676
764
|
removeStandAlone = () => {
|
|
677
765
|
const schema = _.cloneDeep(this.state.schema);
|
|
678
|
-
|
|
679
|
-
|
|
766
|
+
if (
|
|
767
|
+
this.props.location.query.type === 'embedded' &&
|
|
768
|
+
this.props.location.query.module === 'loyalty'
|
|
769
|
+
) {
|
|
680
770
|
schema.standalone.sections.splice(0, 1);
|
|
681
|
-
} else if (
|
|
771
|
+
} else if (
|
|
772
|
+
this.props.location.query.type === 'embedded' &&
|
|
773
|
+
typeof this.props.location.query.mode !== 'undefined'
|
|
774
|
+
) {
|
|
682
775
|
delete schema.standalone;
|
|
683
776
|
} else {
|
|
684
777
|
schema.standalone.sections.splice(1, 1);
|
|
@@ -687,74 +780,162 @@ export class Line extends Component {
|
|
|
687
780
|
};
|
|
688
781
|
|
|
689
782
|
validateContent = (e) => {
|
|
690
|
-
console.log('posting final validation result', this.state.isFormValid);
|
|
691
783
|
const response = {
|
|
692
|
-
action:
|
|
784
|
+
action: 'validateContent',
|
|
693
785
|
value: this.state.isFormValid,
|
|
694
786
|
};
|
|
695
787
|
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
696
788
|
};
|
|
697
789
|
|
|
698
790
|
handleOnTagsContextChange = (data) => {
|
|
699
|
-
console.log('parent tags context', data);
|
|
700
791
|
const query = {
|
|
701
792
|
layout: 'LINE',
|
|
702
793
|
type: 'TAG',
|
|
703
|
-
context:
|
|
704
|
-
|
|
794
|
+
context:
|
|
795
|
+
data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
|
|
796
|
+
embedded:
|
|
797
|
+
this.props.location.query.type === 'embedded'
|
|
798
|
+
? this.props.location.query.type
|
|
799
|
+
: 'full',
|
|
705
800
|
};
|
|
706
801
|
this.props.globalActions.fetchSchemaForEntity(query);
|
|
707
802
|
};
|
|
708
803
|
|
|
709
804
|
uploadImage = (pearmData) => {
|
|
710
|
-
console.log("image data line@@@", pearmData);
|
|
711
805
|
const data = pearmData;
|
|
712
806
|
if (data.file.size > 1000000) {
|
|
713
|
-
const message = getMessageObject(
|
|
807
|
+
const message = getMessageObject(
|
|
808
|
+
'error',
|
|
809
|
+
this.props.intl.formatMessage(
|
|
810
|
+
messages['File size cannot be more than 1mb']
|
|
811
|
+
),
|
|
812
|
+
true
|
|
813
|
+
);
|
|
714
814
|
this.props.globalActions.addMessageToQueue(message);
|
|
715
815
|
} else {
|
|
716
816
|
data.fileParams.isGeneratePreview = true;
|
|
717
817
|
const name = data.file.name.split('.');
|
|
718
818
|
const blob = data.file.slice(0, -1, 'image');
|
|
719
|
-
const newFile = new File(
|
|
720
|
-
|
|
819
|
+
const newFile = new File(
|
|
820
|
+
[blob],
|
|
821
|
+
`${name[0]}${Date.now()}.${name[1]}`,
|
|
822
|
+
{ type: 'image' }
|
|
823
|
+
);
|
|
824
|
+
this.props.actions.uploadAsset(
|
|
825
|
+
newFile,
|
|
826
|
+
data.type,
|
|
827
|
+
data.fileParams
|
|
828
|
+
);
|
|
721
829
|
}
|
|
722
830
|
};
|
|
723
831
|
|
|
832
|
+
onGalleryImageSelect = (imageTemplate) => {
|
|
833
|
+
const { formData } = this.state;
|
|
834
|
+
const image = get(imageTemplate, 'metaInfo.secure_file_path');
|
|
835
|
+
const imagePreview = get(imageTemplate, 'metaInfo.secure_file_path_preview');
|
|
836
|
+
this.setState({
|
|
837
|
+
isDrawerRequired: false,
|
|
838
|
+
formData: {
|
|
839
|
+
...formData,
|
|
840
|
+
0: {
|
|
841
|
+
...formData[0],
|
|
842
|
+
image,
|
|
843
|
+
imagePreview,
|
|
844
|
+
},
|
|
845
|
+
base: {
|
|
846
|
+
...formData.base,
|
|
847
|
+
image,
|
|
848
|
+
imagePreview,
|
|
849
|
+
},
|
|
850
|
+
},
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
getGalleryDrawerContent = () => {
|
|
855
|
+
const location = {
|
|
856
|
+
pathname: `/assets`,
|
|
857
|
+
search: '',
|
|
858
|
+
query: !this.props.isFullMode ? {type: 'embedded', module: 'library'} : {},
|
|
859
|
+
};
|
|
860
|
+
const content = (
|
|
861
|
+
<Gallery
|
|
862
|
+
location={location}
|
|
863
|
+
isFullMode={this.props.isFullMode}
|
|
864
|
+
isLineAsset
|
|
865
|
+
onGalleryImageSelect={this.onGalleryImageSelect}
|
|
866
|
+
/>);
|
|
867
|
+
return (
|
|
868
|
+
<>
|
|
869
|
+
<CapHeading type="h3">
|
|
870
|
+
{this.props.intl.formatMessage(messages.imageGallery)}
|
|
871
|
+
</CapHeading>
|
|
872
|
+
{content}
|
|
873
|
+
</>
|
|
874
|
+
);
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
updateSchemaWithLabels = (schema) => {
|
|
878
|
+
/* eslint-disable no-param-reassign */
|
|
879
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].placeholder = this.props.intl.formatMessage(
|
|
880
|
+
messages.templatePlaceholder
|
|
881
|
+
);
|
|
882
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].errorMessage = this.props.intl.formatMessage(
|
|
883
|
+
messages.templateNameErrorPlaceholder
|
|
884
|
+
);
|
|
885
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].label = this.props.intl.formatMessage(
|
|
886
|
+
messages.templateAddTag
|
|
887
|
+
);
|
|
888
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[2].inputFields[0].cols[0].placeholder = this.props.intl.formatMessage(
|
|
889
|
+
messages.templateMessagePlaceholder
|
|
890
|
+
);
|
|
891
|
+
schema.textSchema.standalone.sections[0].childSections[1].childSections[0].childSections[2].inputFields[0].cols[0].errorMessage = this.props.intl.formatMessage(
|
|
892
|
+
messages.templateMessageError
|
|
893
|
+
);
|
|
894
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].placeholder = this.props.intl.formatMessage(
|
|
895
|
+
messages.templatePlaceholder
|
|
896
|
+
);
|
|
897
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].cols[0].errorMessage = this.props.intl.formatMessage(
|
|
898
|
+
messages.templateNameErrorPlaceholder
|
|
899
|
+
);
|
|
900
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].previewProps.label = this.props.intl.formatMessage(
|
|
901
|
+
messages.templateMessagePreviewPropsLabel
|
|
902
|
+
);
|
|
903
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].previewProps.inductiveText = this.props.intl.formatMessage(
|
|
904
|
+
messages.templateMessagePreviewPropsInductiveText
|
|
905
|
+
);
|
|
906
|
+
schema.imageSchema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields[0].cols[0].previewProps.errorMessage = this.props.intl.formatMessage(
|
|
907
|
+
messages.templateMessagePreviewPropsError
|
|
908
|
+
);
|
|
909
|
+
return schema;
|
|
910
|
+
};
|
|
911
|
+
|
|
724
912
|
render() {
|
|
725
|
-
if (
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
913
|
+
if (
|
|
914
|
+
this.state.formData &&
|
|
915
|
+
this.state.formData['0'] &&
|
|
916
|
+
this.state.formData['0'].image
|
|
917
|
+
) {
|
|
918
|
+
console.log('before render@@@', this.state.formData['0'].image);
|
|
919
|
+
}
|
|
920
|
+
let loading = this.props.Line.createTemplateInProgress
|
|
921
|
+
? this.props.Line.createTemplateInProgress
|
|
922
|
+
: false;
|
|
730
923
|
if (this.props.Line.assetUploading) {
|
|
731
924
|
loading = true;
|
|
732
925
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
|
|
926
|
+
let tags =
|
|
927
|
+
this.props.metaEntities && this.props.metaEntities.tags
|
|
928
|
+
? this.props.metaEntities.tags.standard
|
|
929
|
+
: [];
|
|
738
930
|
if (this.props.supportedTags) {
|
|
739
931
|
tags = this.props.supportedTags;
|
|
740
932
|
}
|
|
741
933
|
return (
|
|
742
934
|
<Spin spinning={loading}>
|
|
743
|
-
<Row style={{marginLeft: '-48px'}}>
|
|
744
|
-
<Col offset={1}>
|
|
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
935
|
<Row>
|
|
755
936
|
<Col>
|
|
756
937
|
<FormBuilder
|
|
757
|
-
key={
|
|
938
|
+
key={'form builder'}
|
|
758
939
|
schema={this.state.schema}
|
|
759
940
|
onSubmit={this.saveFormData}
|
|
760
941
|
onChange={this.onFormDataChange}
|
|
@@ -763,7 +944,9 @@ export class Line extends Component {
|
|
|
763
944
|
formData={_.cloneDeep(this.state.formData)}
|
|
764
945
|
location={this.props.location}
|
|
765
946
|
tags={tags}
|
|
766
|
-
injectedTags={
|
|
947
|
+
injectedTags={
|
|
948
|
+
this.props.injectedTags ? this.props.injectedTags : {}
|
|
949
|
+
}
|
|
767
950
|
onFormValidityChange={this.setFormValidity}
|
|
768
951
|
usingTabContainer
|
|
769
952
|
checkValidation={this.state.checkValidation}
|
|
@@ -777,6 +960,11 @@ export class Line extends Component {
|
|
|
777
960
|
router={this.props.router}
|
|
778
961
|
onContextChange={this.handleOnTagsContextChange}
|
|
779
962
|
setModalContent={this.setModalContent}
|
|
963
|
+
capDrawerContent={this.getGalleryDrawerContent()}
|
|
964
|
+
isDrawerRequired={this.state.isDrawerRequired}
|
|
965
|
+
setDrawerVisibility={(drawervisibleFlag) =>
|
|
966
|
+
this.setState({ isDrawerRequired: drawervisibleFlag })
|
|
967
|
+
}
|
|
780
968
|
/>
|
|
781
969
|
</Col>
|
|
782
970
|
</Row>
|
|
@@ -799,6 +987,8 @@ Line.propTypes = {
|
|
|
799
987
|
supportedTags: PropTypes.any,
|
|
800
988
|
getDefaultTags: PropTypes.string,
|
|
801
989
|
injectedTags: PropTypes.object,
|
|
990
|
+
onCreateComplete: PropTypes.func,
|
|
991
|
+
isFullMode: PropTypes.bool,
|
|
802
992
|
};
|
|
803
993
|
|
|
804
994
|
const mapStateToProps = createStructuredSelector({
|