@capillarytech/creatives-library 2.0.61 → 2.0.63
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/app.js +1 -1
- package/assets/NoImage1.js +50 -0
- package/assets/WithImage1.js +57 -0
- package/components/FormBuilder/_formBuilder.scss +8 -3
- package/components/FormBuilder/index.js +94 -64
- package/components/PreviewSideBar/_previewsidebar.scss +1 -1
- package/components/TemplatePreview/_templatePreview.scss +1 -1
- package/containers/CreativesContainer/SlideBoxContent.js +1 -1
- package/containers/CreativesContainer/index.js +1 -1
- package/containers/MobilePush/Create/_mobilePushCreate.scss +13 -0
- package/containers/MobilePush/Create/actions.js +6 -0
- package/containers/MobilePush/Create/constants.js +1 -0
- package/containers/MobilePush/Create/index.js +626 -1128
- package/containers/MobilePush/Create/messages.js +5 -1
- package/containers/MobilePush/Create/reducer.js +2 -0
- package/containers/MobilePush/Create/selectors.js +3 -3
- package/containers/MobilePush/Edit/_mobilePushCreate.scss +10 -0
- package/containers/MobilePush/Edit/index.js +375 -1106
- package/containers/MobilePush/Edit/messages.js +4 -0
- package/containers/MobilePush/Edit/reducer.js +2 -1
- package/containers/MobilePush/Edit/selectors.js +3 -1
- package/containers/MobilePush/commonMethods.js +249 -0
- package/containers/MobilePush/eventsMap.js +127 -0
- package/containers/MobilePush/initialSchema.js +1751 -0
- package/containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
- package/containers/MobilepushWrapper/index.js +7 -4
- package/containers/Sms/Create/_smsCreate.scss +1 -1
- package/containers/TemplatesV2/index.js +7 -8
- package/global-styles.js +1 -0
- package/index.html +2 -0
- package/package.json +1 -1
- package/services/api.js +3 -0
|
@@ -10,144 +10,33 @@ import React from 'react';
|
|
|
10
10
|
import { connect } from 'react-redux';
|
|
11
11
|
import { bindActionCreators } from 'redux';
|
|
12
12
|
import { Row, Col, Spin, Breadcrumb, notification } from 'antd';
|
|
13
|
-
import
|
|
13
|
+
import {get, set, filter, isEmpty, map, forEach, uniqueId, cloneDeep, isEqual, merge, has, findIndex} from 'lodash';
|
|
14
14
|
import { createStructuredSelector } from 'reselect';
|
|
15
|
-
import { injectIntl, intlShape } from 'react-intl';
|
|
16
|
-
import
|
|
15
|
+
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
16
|
+
import styled from 'styled-components';
|
|
17
|
+
import { CapSlideBox, CapHeader, CapTable, CapLink, CapRow, CapColumn, CapIcons} from '@capillarytech/cap-ui-library';
|
|
18
|
+
import { makeSelectCreate, makeSelectCreateResponse, makeSelectIosCta } from './selectors';
|
|
17
19
|
import { makeSelectMetaEntities } from '../../Cap/selectors';
|
|
18
20
|
import * as globalActions from '../../../containers/Cap/actions';
|
|
19
21
|
import FormBuilder from '../../../components/FormBuilder';
|
|
20
22
|
import './_mobilePushCreate.scss';
|
|
21
23
|
import * as actions from './actions';
|
|
24
|
+
|
|
22
25
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
23
26
|
import { makeSelectTemplates } from '../../Templates/selectors';
|
|
24
27
|
import messages from './messages';
|
|
25
28
|
import callNativeEvent from '../../../utils/callNativeEvent';
|
|
26
|
-
|
|
29
|
+
import getEventsMap from '../eventsMap';
|
|
27
30
|
const BreadcrumbItem = Breadcrumb.Item;
|
|
31
|
+
|
|
32
|
+
const PrefixWrapper = styled.div`
|
|
33
|
+
margin-right: 16px;
|
|
34
|
+
`;
|
|
28
35
|
export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
29
36
|
constructor(props) {
|
|
30
37
|
super(props);
|
|
38
|
+
const eventsMap = getEventsMap(this);
|
|
31
39
|
if (this.props.Templates.selectedWeChatAccount) {
|
|
32
|
-
const map = {
|
|
33
|
-
"template-name": {
|
|
34
|
-
onChange: this.onTemplateNameChange,
|
|
35
|
-
},
|
|
36
|
-
"cta-deeplink-secondary-cta-0": {
|
|
37
|
-
onChange: this.onLinkTypeChange,
|
|
38
|
-
},
|
|
39
|
-
"cta-deeplink-secondary-cta-1": {
|
|
40
|
-
onChange: this.onLinkTypeChange,
|
|
41
|
-
},
|
|
42
|
-
"cta-deeplink-secondary-cta-12": {
|
|
43
|
-
onChange: this.onLinkTypeChange,
|
|
44
|
-
},
|
|
45
|
-
"cta-deeplink-delete": {
|
|
46
|
-
onDelete: this.deletePrimaryCTA,
|
|
47
|
-
},
|
|
48
|
-
"cta-deeplink2-delete": {
|
|
49
|
-
onDelete: this.deletePrimaryCTA,
|
|
50
|
-
},
|
|
51
|
-
"secondary-cta-0-delete": {
|
|
52
|
-
onDelete: this.deleteSecondaryCTA,
|
|
53
|
-
},
|
|
54
|
-
"secondary-cta-1-delete": {
|
|
55
|
-
onDelete: this.deleteSecondaryCTA,
|
|
56
|
-
},
|
|
57
|
-
"secondary-cta-1-delete-ios": {
|
|
58
|
-
onDelete: this.deleteSecondaryCtaIos,
|
|
59
|
-
},
|
|
60
|
-
"discard-button": {
|
|
61
|
-
discardValues: this.discardValues,
|
|
62
|
-
},
|
|
63
|
-
"cancel-button": {
|
|
64
|
-
cancelTemplate: this.cancelTemplate,
|
|
65
|
-
},
|
|
66
|
-
"copy-android-content": {
|
|
67
|
-
onClick: this.copyAndroidContent,
|
|
68
|
-
},
|
|
69
|
-
"copy-iphone-content": {
|
|
70
|
-
onClick: this.copyIphoneContent,
|
|
71
|
-
},
|
|
72
|
-
"save-button": {
|
|
73
|
-
saveFormData: this.saveFormData,
|
|
74
|
-
},
|
|
75
|
-
"message-editor": {
|
|
76
|
-
onChange: this.onTemplateContentChange,
|
|
77
|
-
},
|
|
78
|
-
"message-editor2": {
|
|
79
|
-
onChange: this.onTemplateContentChange,
|
|
80
|
-
},
|
|
81
|
-
"message-tagList": {
|
|
82
|
-
onTagSelect: this.onTagSelect,
|
|
83
|
-
},
|
|
84
|
-
"message-tagList2": {
|
|
85
|
-
onTagSelect: this.onTagSelect,
|
|
86
|
-
},
|
|
87
|
-
"title-tagList": {
|
|
88
|
-
onTagSelect: this.onTagSelect,
|
|
89
|
-
},
|
|
90
|
-
"title-tagList2": {
|
|
91
|
-
onTagSelect: this.onTagSelect,
|
|
92
|
-
},
|
|
93
|
-
"pane": {
|
|
94
|
-
onTabChange: this.onTabChange,
|
|
95
|
-
},
|
|
96
|
-
"cta-deeplink": {
|
|
97
|
-
onChange: this.onLinkTypeChange,
|
|
98
|
-
},
|
|
99
|
-
"cta-deeplink2": {
|
|
100
|
-
onChange: this.onLinkTypeChange,
|
|
101
|
-
},
|
|
102
|
-
"cta-deeplink-secondary-cta-1-select": {
|
|
103
|
-
onSelect: this.showCtaKeys,
|
|
104
|
-
},
|
|
105
|
-
"cta-deeplink-secondary-cta-0-select": {
|
|
106
|
-
onSelect: this.showCtaKeys,
|
|
107
|
-
},
|
|
108
|
-
"cta-deeplink-secondary-cta-1-select2": {
|
|
109
|
-
onSelect: this.showCtaKeys,
|
|
110
|
-
},
|
|
111
|
-
"cta-deeplink-select": {
|
|
112
|
-
onSelect: this.showCtaKeys,
|
|
113
|
-
},
|
|
114
|
-
"cta-deeplink2-select": {
|
|
115
|
-
onSelect: this.showCtaKeys,
|
|
116
|
-
},
|
|
117
|
-
"add-pri-cta": {
|
|
118
|
-
addPrimaryCta: this.addPrimaryCta,
|
|
119
|
-
},
|
|
120
|
-
"add-pri-cta-ios": {
|
|
121
|
-
addPrimaryCta: this.addPrimaryCta,
|
|
122
|
-
},
|
|
123
|
-
"add-sec-cta": {
|
|
124
|
-
addSecondaryCta: this.addSecondoryCta,
|
|
125
|
-
},
|
|
126
|
-
"add-sec-cta-ios": {
|
|
127
|
-
addSecondaryCtaIos: this.addSecondoryCtaIos,
|
|
128
|
-
},
|
|
129
|
-
"image-upload-android": {
|
|
130
|
-
onUpload: this.uploadImage,
|
|
131
|
-
},
|
|
132
|
-
"image-upload-ios": {
|
|
133
|
-
onUpload: this.uploadImage,
|
|
134
|
-
},
|
|
135
|
-
"secondary-cta-1-table": {
|
|
136
|
-
onRowClick: this.selectCtaIos,
|
|
137
|
-
},
|
|
138
|
-
"cta-deeplink-select-show-keys": {
|
|
139
|
-
onShowCtaKeys: this.showCtaKeys,
|
|
140
|
-
},
|
|
141
|
-
"cta-deeplink-secondary-cta-0-select-show-keys": {
|
|
142
|
-
onShowCtaKeys: this.showCtaKeys,
|
|
143
|
-
},
|
|
144
|
-
"cta-deeplink-secondary-cta-1-select-show-keys": {
|
|
145
|
-
onShowCtaKeys: this.showCtaKeys,
|
|
146
|
-
},
|
|
147
|
-
"wechat-template": {
|
|
148
|
-
onSelect: this.onTemplateChange,
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
40
|
this.state = {
|
|
152
41
|
formData: {},
|
|
153
42
|
tabCount: 1,
|
|
@@ -157,7 +46,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
157
46
|
tabKey: '',
|
|
158
47
|
checkValidation: false,
|
|
159
48
|
schema: {},
|
|
160
|
-
eventsMap
|
|
49
|
+
eventsMap,
|
|
161
50
|
errorData: {},
|
|
162
51
|
displayProps: {},
|
|
163
52
|
modalContent: {title: "Alert", body: "template not configured,", type: 'confirm'},
|
|
@@ -184,28 +73,26 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
184
73
|
};
|
|
185
74
|
|
|
186
75
|
componentDidMount = () => {
|
|
187
|
-
console.log('added listener create,', this.props);
|
|
188
76
|
const query = {
|
|
189
77
|
layout: 'MOBILEPUSH',
|
|
190
78
|
type: 'LAYOUT',
|
|
79
|
+
version: "v2",
|
|
191
80
|
};
|
|
192
81
|
this.props.globalActions.fetchSchemaForEntity(query);
|
|
193
82
|
window.addEventListener("message", this.handleFrameTasks);
|
|
194
83
|
};
|
|
195
84
|
|
|
196
85
|
componentWillReceiveProps = (nextProps) => {
|
|
197
|
-
console.log('recieved props ', nextProps, nextProps.Create, this.props.Create);
|
|
198
86
|
if (nextProps.isGetFormData) {
|
|
199
87
|
nextProps.getFormLibraryData(this.getFormData());
|
|
200
88
|
}
|
|
201
89
|
if (nextProps.Create.uploadedAssetData) {
|
|
202
|
-
const formData =
|
|
90
|
+
const formData = cloneDeep(this.state.formData);
|
|
203
91
|
formData[this.state.currentTab - 1].image = nextProps.Create.uploadedAssetData.metaInfo.public_url;
|
|
204
92
|
this.setState({formData});
|
|
205
93
|
this.props.actions.clearAsset();
|
|
206
94
|
}
|
|
207
95
|
if (nextProps.createResponse && nextProps.createResponse.templateId) {
|
|
208
|
-
console.log('create response', nextProps.createResponse);
|
|
209
96
|
this.discardValues();
|
|
210
97
|
const message = getMessageObject('success', this.props.intl.formatMessage(messages["Mobile Push Template Created Successfully"]), true);
|
|
211
98
|
this.props.globalActions.addMessageToQueue(message);
|
|
@@ -220,16 +107,29 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
220
107
|
if (nextProps.params.mode) {
|
|
221
108
|
this.setState({mode: nextProps.params.mode});
|
|
222
109
|
}
|
|
223
|
-
if (nextProps.Create.createTemplateError && !
|
|
110
|
+
if (nextProps.Create.createTemplateError && !isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
|
|
224
111
|
const message = getMessageObject('error', (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
|
|
225
112
|
this.props.globalActions.addMessageToQueue(message);
|
|
226
113
|
}
|
|
227
|
-
if (nextProps.
|
|
228
|
-
this.setState({
|
|
114
|
+
if (nextProps.iosCtasData) {
|
|
115
|
+
this.setState({showIosCtaTable: true});
|
|
229
116
|
}
|
|
230
|
-
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 &&
|
|
231
|
-
console.log('final schema is**', nextProps.metaEntities.layouts[0].definition);
|
|
117
|
+
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && isEmpty(this.state.schema)) {
|
|
232
118
|
const schema = this.props.params.mode === "text" ? nextProps.metaEntities.layouts[0].definition.textSchema : nextProps.metaEntities.layouts[0].definition.imageSchema;
|
|
119
|
+
const isAndroidSupported = get(this, "props.Templates.selectedWeChatAccount.configs.android") === '1';
|
|
120
|
+
const isIosSupported = get(this, "props.Templates.selectedWeChatAccount.configs.ios") === '1';
|
|
121
|
+
if (!isAndroidSupported) {
|
|
122
|
+
const androidField = get(schema, "containers[0].panes[0]");
|
|
123
|
+
androidField.isSupported = false;
|
|
124
|
+
this.setState({currentTab: 2});
|
|
125
|
+
set(schema, "containers[0].panes[0]", androidField);
|
|
126
|
+
}
|
|
127
|
+
if (!isIosSupported) {
|
|
128
|
+
const iosField = get(schema, "containers[0].panes[1]");
|
|
129
|
+
iosField.isSupported = false;
|
|
130
|
+
|
|
131
|
+
set(schema, "containers[0].panes[1]", iosField);
|
|
132
|
+
}
|
|
233
133
|
schema.standalone.sections.splice(1, 1);
|
|
234
134
|
this.injectEvents(schema);
|
|
235
135
|
const query = {
|
|
@@ -247,47 +147,45 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
247
147
|
}
|
|
248
148
|
}
|
|
249
149
|
|
|
250
|
-
if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && !
|
|
251
|
-
let injectedTags =
|
|
150
|
+
if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && !isEqual(this.props.metaEntities.tags, nextProps.metaEntities.tags)) {
|
|
151
|
+
let injectedTags = cloneDeep(this.state.injectedTags);
|
|
252
152
|
delete injectedTags["Registration custom fields"];
|
|
253
153
|
delete injectedTags["Store custom fields"];
|
|
254
154
|
delete injectedTags["Transaction custom fields"];
|
|
255
|
-
injectedTags =
|
|
256
|
-
|
|
257
|
-
if (!
|
|
155
|
+
injectedTags = merge({}, injectedTags, nextProps.metaEntities.tags.custom);
|
|
156
|
+
|
|
157
|
+
if (!has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
|
|
258
158
|
delete injectedTags["Registration custom fields"];
|
|
259
159
|
}
|
|
260
|
-
if (!
|
|
160
|
+
if (!has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
|
|
261
161
|
delete injectedTags["Store custom fields"];
|
|
262
162
|
}
|
|
263
|
-
if (!
|
|
163
|
+
if (!has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
|
|
264
164
|
delete injectedTags["Transaction custom fields"];
|
|
265
165
|
}
|
|
266
166
|
this.setState({injectedTags});
|
|
267
167
|
}
|
|
268
168
|
};
|
|
269
169
|
componentWillUnmount = () => {
|
|
270
|
-
|
|
170
|
+
this.props.actions.resetStore();
|
|
271
171
|
window.removeEventListener("message", this.handleFrameTasks);
|
|
272
172
|
};
|
|
273
173
|
onTemplateChange = () => {
|
|
274
174
|
|
|
275
175
|
};
|
|
276
176
|
|
|
277
|
-
onFormDataChange = (formData, tabCount
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] =
|
|
282
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] =
|
|
177
|
+
onFormDataChange = (formData, tabCount) => {
|
|
178
|
+
const newFormData = cloneDeep(formData);
|
|
179
|
+
const {templateCta} = this.state;
|
|
180
|
+
if (templateCta) {
|
|
181
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta.name;
|
|
182
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta.ctaTemplateDetails[0].buttonText;
|
|
283
183
|
delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
|
|
284
|
-
if (
|
|
285
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] =
|
|
184
|
+
if (templateCta.ctaTemplateDetails[1]) {
|
|
185
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta.ctaTemplateDetails[1].buttonText;
|
|
286
186
|
}
|
|
287
187
|
}
|
|
288
|
-
|
|
289
|
-
this.setState({isSchemaChanged: false});
|
|
290
|
-
}
|
|
188
|
+
|
|
291
189
|
// copy content code
|
|
292
190
|
// if (newFormData[0]['copy-iphone-content'] === "") {
|
|
293
191
|
//
|
|
@@ -309,18 +207,16 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
309
207
|
// newFormData[1]['copy-android-content'] = "";
|
|
310
208
|
// }
|
|
311
209
|
// }
|
|
312
|
-
this.setState({formData: newFormData, tabCount});
|
|
210
|
+
this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged});
|
|
313
211
|
};
|
|
314
212
|
|
|
315
213
|
onTagSelect = (data, currentTab, srcComp) => {
|
|
316
|
-
console.log('parent data tag', data, currentTab);
|
|
317
214
|
const editorId = srcComp.target;
|
|
318
215
|
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
|
|
319
216
|
document.getElementById(editorId).focus();
|
|
320
217
|
};
|
|
321
218
|
|
|
322
219
|
onTabChange = (data) => {
|
|
323
|
-
console.log('inside parent ontabchange', data, this.state);
|
|
324
220
|
this.setState({currentTab: data});
|
|
325
221
|
};
|
|
326
222
|
onTemplateNameChange = (name) => {
|
|
@@ -329,148 +225,113 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
329
225
|
|
|
330
226
|
|
|
331
227
|
onLinkTypeChange = (eventTriggered, formData, field) => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
placeholder: "External Link",
|
|
419
|
-
type: "input", //Resembles component to be used
|
|
420
|
-
metaType: "text",
|
|
421
|
-
datatype: "string",
|
|
422
|
-
errorMessage: "External Link cannot be empty",
|
|
423
|
-
required: true,
|
|
424
|
-
fluid: true,
|
|
425
|
-
width: 19,
|
|
426
|
-
style: {
|
|
427
|
-
fontSize: '14px',
|
|
428
|
-
fontFamily: 'open-sans',
|
|
429
|
-
fontStyle: 'normal',
|
|
430
|
-
// fontWeight: 600,
|
|
431
|
-
marginBottom: '16px',
|
|
432
|
-
},
|
|
433
|
-
styling: "semantic",
|
|
434
|
-
order: 1,
|
|
435
|
-
offSet: 4,
|
|
436
|
-
customComponent: false,
|
|
437
|
-
standalone: false,
|
|
438
|
-
},
|
|
439
|
-
],
|
|
440
|
-
};
|
|
441
|
-
if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-deeplink-select-section") {
|
|
442
|
-
formChaild.inputFields[componentIndex] = row;
|
|
443
|
-
if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
|
|
444
|
-
formChaild.inputFields.splice(componentIndex + 1, 1);
|
|
445
|
-
}
|
|
446
|
-
if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
|
|
447
|
-
let configkeys = _.filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][`${col.id}-select`]);
|
|
448
|
-
if (configkeys[0]) {
|
|
449
|
-
configkeys = configkeys[0].keys;
|
|
450
|
-
}
|
|
451
|
-
if (configkeys.length) {
|
|
452
|
-
formChaild.inputFields = formChaild.inputFields.slice(0, componentIndex + 1).concat(formChaild.inputFields.slice( componentIndex + 1 + configkeys.length, formChaild.inputFields.length));
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
} else {
|
|
456
|
-
formChaild.inputFields.splice(componentIndex, 0, row);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
});
|
|
228
|
+
let schema = cloneDeep(this.state.schema);
|
|
229
|
+
const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
230
|
+
forEach(inputFields, (inputField, fieldIndex) => {
|
|
231
|
+
if (inputField) {
|
|
232
|
+
forEach(inputField.cols, (col) => {
|
|
233
|
+
if (col.id === field.id) {
|
|
234
|
+
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
235
|
+
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
|
|
236
|
+
const deeplinkValue = formData[this.state.currentTab - 1][field.id];
|
|
237
|
+
const componentIndex = fieldIndex + 1;
|
|
238
|
+
const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
|
|
239
|
+
if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === inputFields.length - 1 || inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
|
|
240
|
+
const row = {
|
|
241
|
+
rowClassName: 'mobile-push-row',
|
|
242
|
+
id: 'cta-deeplink-select-section',
|
|
243
|
+
cols: [
|
|
244
|
+
|
|
245
|
+
{
|
|
246
|
+
id: inputId,
|
|
247
|
+
placeholder: "Select DeepLink",
|
|
248
|
+
type: "select", //Resembles component to be used
|
|
249
|
+
options: deepLinkOptions,
|
|
250
|
+
metaType: "text",
|
|
251
|
+
datatype: "string",
|
|
252
|
+
errorMessage: "Select a deeplink",
|
|
253
|
+
required: true,
|
|
254
|
+
fluid: true,
|
|
255
|
+
width: 18,
|
|
256
|
+
offset: 1,
|
|
257
|
+
style: {
|
|
258
|
+
width: '100%',
|
|
259
|
+
|
|
260
|
+
marginBottom: '16px',
|
|
261
|
+
},
|
|
262
|
+
styling: "semantic",
|
|
263
|
+
order: 1,
|
|
264
|
+
customComponent: false,
|
|
265
|
+
supportedEvents: [
|
|
266
|
+
'onSelect',
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
};
|
|
271
|
+
if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-external-link") {
|
|
272
|
+
inputFields[componentIndex] = row;
|
|
273
|
+
} else {
|
|
274
|
+
inputFields.splice(componentIndex, 0, row);
|
|
275
|
+
}
|
|
276
|
+
} else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
|
|
277
|
+
const row = {
|
|
278
|
+
rowClassName: 'mobile-push-row',
|
|
279
|
+
id: 'cta-external-link',
|
|
280
|
+
cols: [
|
|
281
|
+
|
|
282
|
+
{
|
|
283
|
+
id: inputId,
|
|
284
|
+
placeholder: "External Link",
|
|
285
|
+
type: "input", //Resembles component to be used
|
|
286
|
+
metaType: "text",
|
|
287
|
+
datatype: "string",
|
|
288
|
+
errorMessage: "External Link cannot be empty",
|
|
289
|
+
required: true,
|
|
290
|
+
fluid: true,
|
|
291
|
+
width: 18,
|
|
292
|
+
offset: 1,
|
|
293
|
+
style: {
|
|
294
|
+
width: '100%',
|
|
295
|
+
|
|
296
|
+
marginBottom: '16px',
|
|
297
|
+
},
|
|
298
|
+
styling: "semantic",
|
|
299
|
+
order: 1,
|
|
300
|
+
customComponent: false,
|
|
301
|
+
standalone: false,
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-deeplink-select-section") {
|
|
306
|
+
inputFields[componentIndex] = row;
|
|
307
|
+
if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
|
|
308
|
+
inputFields.splice(componentIndex + 1, 1);
|
|
309
|
+
}
|
|
310
|
+
if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
|
|
311
|
+
let configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][`${col.id}-select`]);
|
|
312
|
+
if (configkeys[0]) {
|
|
313
|
+
configkeys = configkeys[0].keys;
|
|
461
314
|
}
|
|
462
|
-
|
|
315
|
+
if (configkeys.length) {
|
|
316
|
+
//inputFields = inputFields.slice(0, componentIndex + 1).concat(inputFields.slice( componentIndex + 1 + configkeys.length, inputFields.length));
|
|
317
|
+
|
|
318
|
+
inputFields.splice(componentIndex + 1, configkeys.length);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
inputFields.splice(componentIndex, 0, row);
|
|
463
323
|
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
466
326
|
});
|
|
467
|
-
}
|
|
327
|
+
}
|
|
468
328
|
});
|
|
329
|
+
schema = set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
|
|
469
330
|
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
470
331
|
this.injectEvents(schema);
|
|
471
332
|
};
|
|
472
|
-
onTemplateContentChange = (
|
|
473
|
-
|
|
333
|
+
onTemplateContentChange = () => {
|
|
334
|
+
|
|
474
335
|
};
|
|
475
336
|
onModalCancel = () => {
|
|
476
337
|
if (this.state.modalContent && this.state.modalContent.show) {
|
|
@@ -480,7 +341,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
480
341
|
getLinkName = (link) => {
|
|
481
342
|
const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
|
|
482
343
|
const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
483
|
-
const deepLinkOptions =
|
|
344
|
+
const deepLinkOptions = filter(JSON.parse(deeplinks), (l) => l.link === link);
|
|
484
345
|
if (deepLinkOptions[0]) {
|
|
485
346
|
return deepLinkOptions[0].name;
|
|
486
347
|
}
|
|
@@ -488,11 +349,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
488
349
|
};
|
|
489
350
|
|
|
490
351
|
getMappedEvent = (id, event) => {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
console.log(`error map[id] ${map[id]}` );
|
|
494
|
-
}
|
|
495
|
-
return map[id][event];
|
|
352
|
+
const eventsMap = this.state.eventsMap;
|
|
353
|
+
return eventsMap[id][event];
|
|
496
354
|
};
|
|
497
355
|
getCurrentWindow = (e) => {
|
|
498
356
|
const response = {
|
|
@@ -503,7 +361,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
503
361
|
parent.postMessage(JSON.stringify(response), '*');
|
|
504
362
|
};
|
|
505
363
|
getFormData = (e) => {
|
|
506
|
-
console.log('posting final result', this.state.formData);
|
|
507
364
|
const templateData = this.getTransformedData(this.state.formData);
|
|
508
365
|
const response = {
|
|
509
366
|
action: "getFormData",
|
|
@@ -545,7 +402,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
545
402
|
});
|
|
546
403
|
obj.versions.base = {};
|
|
547
404
|
delete android.base;
|
|
548
|
-
if (!
|
|
405
|
+
if (!isEmpty(android)) {
|
|
549
406
|
obj.versions.base.ANDROID = {
|
|
550
407
|
luid: "{{luid}}",
|
|
551
408
|
cuid: "{{cuid}}",
|
|
@@ -556,7 +413,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
556
413
|
style: "BIG_TEXT",
|
|
557
414
|
message: android['message-editor'],
|
|
558
415
|
},
|
|
559
|
-
custom:
|
|
416
|
+
custom: map(android, (field, key) => {
|
|
560
417
|
if (key.indexOf('custom-value') > -1) {
|
|
561
418
|
return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select', ''), value: field} : undefined;
|
|
562
419
|
}
|
|
@@ -574,7 +431,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
574
431
|
delete obj.versions.base.ANDROID.cta.deepLinkName;
|
|
575
432
|
}
|
|
576
433
|
}
|
|
577
|
-
if (!
|
|
434
|
+
if (!isEmpty(ios)) {
|
|
578
435
|
obj.versions.base.IOS = {
|
|
579
436
|
luid: "{{luid}}",
|
|
580
437
|
cuid: "{{cuid}}",
|
|
@@ -588,7 +445,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
588
445
|
],
|
|
589
446
|
categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
|
|
590
447
|
},
|
|
591
|
-
custom:
|
|
448
|
+
custom: map(ios, (field, key) => {
|
|
592
449
|
if (key.indexOf('custom-value') > -1) {
|
|
593
450
|
return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink2-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select2', ''), value: field} : undefined;
|
|
594
451
|
}
|
|
@@ -608,7 +465,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
608
465
|
}
|
|
609
466
|
if (obj.versions.base.ANDROID) {
|
|
610
467
|
if (obj.versions.base.ANDROID.cta && obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
|
|
611
|
-
const params =
|
|
468
|
+
const params = map(android, (field, key) => {
|
|
612
469
|
let actionLink;
|
|
613
470
|
if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
|
|
614
471
|
const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
|
|
@@ -641,7 +498,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
641
498
|
}
|
|
642
499
|
obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
|
|
643
500
|
if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
|
|
644
|
-
const params =
|
|
501
|
+
const params = map(android, (field, key) => {
|
|
645
502
|
let actionLink;
|
|
646
503
|
if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
|
|
647
504
|
const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
|
|
@@ -666,7 +523,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
666
523
|
}
|
|
667
524
|
obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
|
|
668
525
|
if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
|
|
669
|
-
const params =
|
|
526
|
+
const params = map(android, (field, key) => {
|
|
670
527
|
let actionLink;
|
|
671
528
|
if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
|
|
672
529
|
const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
|
|
@@ -683,7 +540,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
683
540
|
}
|
|
684
541
|
if (obj.versions.base.IOS) {
|
|
685
542
|
if (obj.versions.base.IOS.cta && obj.versions.base.IOS.cta.type === "DEEP_LINK") {
|
|
686
|
-
const params =
|
|
543
|
+
const params = map(ios, (field, key) => {
|
|
687
544
|
let actionLink;
|
|
688
545
|
if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
|
|
689
546
|
const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
|
|
@@ -710,14 +567,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
710
567
|
type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
|
|
711
568
|
actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? (ios['cta-deeplink-secondary-cta-1-select2'] || ios['cta-deeplink-secondary-cta-1-select']) : ios['cta-deeplink-secondary-cta-1-text']),
|
|
712
569
|
ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
|
|
713
|
-
templateCtaId:
|
|
570
|
+
templateCtaId: get(this.state, "templateCta.ctaTemplateDetails[0].id"),
|
|
714
571
|
};
|
|
715
572
|
if (this.props.location.query.type === 'embedded') {
|
|
716
573
|
delete cta.ioscdeepLinkName;
|
|
717
574
|
}
|
|
718
575
|
obj.versions.base.IOS.expandableDetails.ctas.push(cta);
|
|
719
576
|
if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
|
|
720
|
-
const params =
|
|
577
|
+
const params = map(ios, (field, key) => {
|
|
721
578
|
let actionLink;
|
|
722
579
|
if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
|
|
723
580
|
const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
|
|
@@ -768,7 +625,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
768
625
|
};
|
|
769
626
|
|
|
770
627
|
moveToTemplates = () => {
|
|
771
|
-
console.log('in move to Templates');
|
|
772
628
|
const modalContent = {
|
|
773
629
|
title: "Alert",
|
|
774
630
|
body: this.props.intl.formatMessage(messages["Do you really want to go back? All your temporary changes will be lost!"]),
|
|
@@ -793,12 +649,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
793
649
|
if (temp.standalone) {
|
|
794
650
|
temp.standalone.sections = this.injectSections(temp.standalone.sections);
|
|
795
651
|
}
|
|
796
|
-
|
|
652
|
+
forEach(temp.containers, (container) => {
|
|
797
653
|
let tempContainer = container;
|
|
798
654
|
tempContainer = this.injectContainer(tempContainer);
|
|
799
655
|
return tempContainer;
|
|
800
656
|
});
|
|
801
|
-
|
|
657
|
+
|
|
802
658
|
this.setState({schema, isSchemaChanged: true}, () => {
|
|
803
659
|
this.removeStandAlone();
|
|
804
660
|
});
|
|
@@ -809,10 +665,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
809
665
|
const temp = container;
|
|
810
666
|
if (temp.type === 'tabs') {
|
|
811
667
|
temp.injectedEvents = {};
|
|
812
|
-
|
|
668
|
+
forEach(temp.supportedEvents, (event) => {
|
|
813
669
|
temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
|
|
814
670
|
});
|
|
815
|
-
|
|
671
|
+
forEach(temp.panes, (pane) => {
|
|
816
672
|
const tempPane = pane;
|
|
817
673
|
tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
|
|
818
674
|
tempPane.sections = this.injectSections(tempPane.sections);
|
|
@@ -822,8 +678,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
822
678
|
};
|
|
823
679
|
|
|
824
680
|
injectMultiColSection = (section) => {
|
|
825
|
-
|
|
826
|
-
|
|
681
|
+
forEach(section.inputFields, (inputField) => {
|
|
682
|
+
forEach(inputField.cols, (col) => {
|
|
827
683
|
const temp = col;
|
|
828
684
|
if (temp.type === 'popover') {
|
|
829
685
|
temp.content.sections = this.injectSections(temp.content.sections);
|
|
@@ -841,15 +697,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
841
697
|
}
|
|
842
698
|
temp.injectedEvents = {};
|
|
843
699
|
|
|
844
|
-
|
|
845
|
-
console.log('injected event for ', col, event);
|
|
700
|
+
forEach(col.supportedEvents, (event) => {
|
|
846
701
|
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
847
702
|
});
|
|
848
703
|
return true;
|
|
849
704
|
});
|
|
850
705
|
});
|
|
851
|
-
|
|
852
|
-
|
|
706
|
+
forEach(section.actionFields, (actionField) => {
|
|
707
|
+
forEach(actionField.cols, (col) => {
|
|
853
708
|
const temp = col;
|
|
854
709
|
if (temp.type === 'popover') {
|
|
855
710
|
temp.content.sections = this.injectSections(temp.content.sections);
|
|
@@ -857,7 +712,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
857
712
|
return true;
|
|
858
713
|
}
|
|
859
714
|
temp.injectedEvents = {};
|
|
860
|
-
|
|
715
|
+
forEach(col.supportedEvents, (event) => {
|
|
861
716
|
temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
|
|
862
717
|
});
|
|
863
718
|
return true;
|
|
@@ -867,7 +722,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
867
722
|
};
|
|
868
723
|
|
|
869
724
|
injectColLabelSection = (section) => {
|
|
870
|
-
|
|
725
|
+
forEach(section.inputFields, (inputField) => {
|
|
871
726
|
const temp = inputField;
|
|
872
727
|
if (temp.type === 'popover') {
|
|
873
728
|
temp.content.sections = this.injectSections(temp.content.sections);
|
|
@@ -875,12 +730,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
875
730
|
return true;
|
|
876
731
|
}
|
|
877
732
|
temp.injectedEvents = {};
|
|
878
|
-
|
|
733
|
+
forEach(inputField.supportedEvents, (event) => {
|
|
879
734
|
temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
|
|
880
735
|
});
|
|
881
736
|
return true;
|
|
882
737
|
});
|
|
883
|
-
|
|
738
|
+
forEach(section.actionFields, (actionField) => {
|
|
884
739
|
const temp = actionField;
|
|
885
740
|
if (temp.type === 'popover') {
|
|
886
741
|
temp.content.sections = this.injectSections(temp.content.sections);
|
|
@@ -888,7 +743,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
888
743
|
return true;
|
|
889
744
|
}
|
|
890
745
|
temp.injectedEvents = {};
|
|
891
|
-
|
|
746
|
+
forEach(actionField.supportedEvents, (event) => {
|
|
892
747
|
temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
|
|
893
748
|
});
|
|
894
749
|
return true;
|
|
@@ -897,7 +752,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
897
752
|
};
|
|
898
753
|
|
|
899
754
|
injectSections = (sections) => {
|
|
900
|
-
|
|
755
|
+
forEach(sections, (section) => {
|
|
901
756
|
let temp = section;
|
|
902
757
|
if (temp.type === 'col-label') {
|
|
903
758
|
temp = this.injectColLabelSection(temp);
|
|
@@ -911,7 +766,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
911
766
|
};
|
|
912
767
|
|
|
913
768
|
injectParentSection = (section) => {
|
|
914
|
-
|
|
769
|
+
forEach(section.childSections, (childSection) => {
|
|
915
770
|
let temp = childSection;
|
|
916
771
|
if (temp.type === 'col-label') {
|
|
917
772
|
temp = this.injectColLabelSection(temp);
|
|
@@ -946,9 +801,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
946
801
|
};
|
|
947
802
|
|
|
948
803
|
startTemplateCreation = (data) => {
|
|
949
|
-
console.log('startTemplateCreation');
|
|
950
804
|
const content = data.content;
|
|
951
|
-
const id =
|
|
805
|
+
const id = uniqueId();
|
|
952
806
|
const tempData = {
|
|
953
807
|
'message-editor': content,
|
|
954
808
|
'base': true,
|
|
@@ -961,18 +815,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
961
815
|
};
|
|
962
816
|
|
|
963
817
|
startLoading = (ifEdit) => {
|
|
964
|
-
console.log('startLoading', ifEdit);
|
|
965
818
|
if (ifEdit) {
|
|
966
819
|
this.setState({loading: true});
|
|
967
820
|
}
|
|
968
821
|
};
|
|
969
822
|
|
|
970
823
|
handleFrameTasks = (e) => {
|
|
971
|
-
console.log('data listened to is', e.data);
|
|
972
824
|
const type = e.data;
|
|
973
|
-
|
|
825
|
+
|
|
974
826
|
if (typeof type === 'object') {
|
|
975
|
-
console.log('received something', type);
|
|
976
827
|
const action = type.action;
|
|
977
828
|
switch (action) {
|
|
978
829
|
case "startTemplateCreation":
|
|
@@ -993,15 +844,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
993
844
|
this.getFormData(e);
|
|
994
845
|
break;
|
|
995
846
|
case "startTemplateCreation":
|
|
996
|
-
|
|
847
|
+
|
|
997
848
|
//this.getFormData(e);
|
|
998
849
|
break;
|
|
999
850
|
case "moveToTemplates":
|
|
1000
|
-
|
|
851
|
+
|
|
1001
852
|
this.moveToTemplates();
|
|
1002
853
|
break;
|
|
1003
854
|
case "validateContent":
|
|
1004
|
-
|
|
855
|
+
|
|
1005
856
|
this.validateContent(e);
|
|
1006
857
|
break;
|
|
1007
858
|
default:
|
|
@@ -1011,7 +862,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1011
862
|
};
|
|
1012
863
|
|
|
1013
864
|
removeStandAlone = () => {
|
|
1014
|
-
const schema =
|
|
865
|
+
const schema = cloneDeep(this.state.schema);
|
|
1015
866
|
if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
|
|
1016
867
|
schema.standalone.sections.splice(0, 1);
|
|
1017
868
|
} else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') {
|
|
@@ -1023,7 +874,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1023
874
|
};
|
|
1024
875
|
|
|
1025
876
|
validateContent = (e) => {
|
|
1026
|
-
console.log('posting final validation result', this.state.isFormValid);
|
|
1027
877
|
const response = {
|
|
1028
878
|
action: "validateContent",
|
|
1029
879
|
value: this.state.isFormValid,
|
|
@@ -1056,643 +906,347 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1056
906
|
copyContent = () => {
|
|
1057
907
|
|
|
1058
908
|
};
|
|
1059
|
-
addSecondoryCtaIos = (
|
|
1060
|
-
const id =
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
primitive: true,
|
|
1082
|
-
dynamicTab: false,
|
|
1083
|
-
type: "div",
|
|
1084
|
-
width: 4,
|
|
1085
|
-
style: {
|
|
1086
|
-
backgroundColor: 'white',
|
|
1087
|
-
textAlign: 'left',
|
|
1088
|
-
color: '#333333',
|
|
1089
|
-
lineHeight: '24px',
|
|
1090
|
-
fontSize: '14px',
|
|
1091
|
-
fontFamily: 'open-sans',
|
|
1092
|
-
fontStyle: 'normal',
|
|
1093
|
-
paddingTop: '8px',
|
|
1094
|
-
},
|
|
1095
|
-
offset: 0,
|
|
1096
|
-
onlyDisplay: true,
|
|
1097
|
-
colStyle: {
|
|
1098
|
-
flex: 1,
|
|
1099
|
-
},
|
|
1100
|
-
},
|
|
1101
|
-
{
|
|
1102
|
-
id: `${inputId}-table`,
|
|
1103
|
-
type: "table", //Resembles component to be used
|
|
1104
|
-
metaType: "text",
|
|
1105
|
-
datatype: "string",
|
|
1106
|
-
pagination: false,
|
|
1107
|
-
columns: [
|
|
1108
|
-
{
|
|
1109
|
-
title: "Name and Description",
|
|
1110
|
-
dataIndex: "name",
|
|
1111
|
-
key: "name",
|
|
1112
|
-
width: 200,
|
|
1113
|
-
render: (text, record) => (
|
|
1114
|
-
<div>
|
|
1115
|
-
<div>{record.name}</div>
|
|
1116
|
-
<div>{record.description}</div>
|
|
1117
|
-
</div>),
|
|
1118
|
-
},
|
|
1119
|
-
{
|
|
1120
|
-
title: "Button 1",
|
|
1121
|
-
dataIndex: "description",
|
|
1122
|
-
key: "button1",
|
|
1123
|
-
width: 100,
|
|
1124
|
-
render: (text, record) => (
|
|
1125
|
-
<div>
|
|
1126
|
-
{record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
|
|
1127
|
-
</div>),
|
|
1128
|
-
},
|
|
1129
|
-
{
|
|
1130
|
-
title: "Button 2",
|
|
1131
|
-
dataIndex: "description",
|
|
1132
|
-
key: "button2",
|
|
1133
|
-
width: 100,
|
|
1134
|
-
render: (text, record) => (
|
|
1135
|
-
<div>
|
|
1136
|
-
{record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
|
|
1137
|
-
</div>
|
|
1138
|
-
),
|
|
1139
|
-
},
|
|
1140
|
-
],
|
|
1141
|
-
required: true,
|
|
1142
|
-
width: 16,
|
|
1143
|
-
fluid: true,
|
|
1144
|
-
styling: "semantic",
|
|
1145
|
-
order: 1,
|
|
1146
|
-
customComponent: false,
|
|
1147
|
-
supportedEvents: ["onRowClick"],
|
|
1148
|
-
},
|
|
1149
|
-
],
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
|
-
const colField = col;
|
|
1153
|
-
colField.value = "Add Another CTA";
|
|
1154
|
-
colField.fieldsCount += 1;
|
|
1155
|
-
if (col.fieldsCount === col.fieldsLimit) {
|
|
1156
|
-
child.inputFields.pop();
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
});
|
|
1163
|
-
});
|
|
909
|
+
addSecondoryCtaIos = (flag, formData, schemaField) => {
|
|
910
|
+
const id = schemaField.id;
|
|
911
|
+
if (formData[this.state.currentTab - 1][id]) {
|
|
912
|
+
if (!this.props.iosCtasData) {
|
|
913
|
+
this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
|
|
914
|
+
} else {
|
|
915
|
+
this.deleteSecondaryCtaIos(() => { // oncick of change
|
|
916
|
+
this.setState({showIosCtaTable: true});
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
} else {
|
|
920
|
+
const schema = cloneDeep(this.state.schema);
|
|
921
|
+
const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
922
|
+
forEach(inputFields, (inputField, fieldIndex) => {
|
|
923
|
+
forEach(inputField.cols, (col) => {
|
|
924
|
+
if (col.id === id) {
|
|
925
|
+
const indexOfNextField = inputFields.length;
|
|
926
|
+
const deleteCount = indexOfNextField - fieldIndex;
|
|
927
|
+
const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputField.length)];
|
|
928
|
+
set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
|
|
929
|
+
this.setState({schema});
|
|
930
|
+
}
|
|
1164
931
|
});
|
|
1165
932
|
});
|
|
1166
|
-
}
|
|
1167
|
-
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
1168
|
-
this.injectEvents(schema);
|
|
1169
|
-
this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
|
|
933
|
+
}
|
|
1170
934
|
};
|
|
1171
935
|
showSelectedIosCta = (selectedConfig) => {
|
|
1172
936
|
const currentTab = this.state.currentTab;
|
|
1173
|
-
const schema =
|
|
937
|
+
const schema = cloneDeep(this.state.schema);
|
|
1174
938
|
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1175
|
-
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ?
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
fontStyle: 'normal',
|
|
1232
|
-
paddingTop: '8px',
|
|
1233
|
-
},
|
|
1234
|
-
offset: 0,
|
|
1235
|
-
colStyle: {
|
|
1236
|
-
flex: 1,
|
|
1237
|
-
},
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
id: `${inputId}-delete-ios`,
|
|
1241
|
-
type: "icon",
|
|
1242
|
-
value: 'delete',
|
|
1243
|
-
width: 4,
|
|
1244
|
-
submitAction: "onDelete",
|
|
1245
|
-
supportedEvents: ["onDelete"],
|
|
1246
|
-
},
|
|
1247
|
-
],
|
|
1248
|
-
};
|
|
1249
|
-
formChaild.inputFields[fieldIndex + 1] = {
|
|
1250
|
-
rowClassName: 'mobile-push-row',
|
|
1251
|
-
cols: [
|
|
1252
|
-
{
|
|
1253
|
-
id: `${inputId}-action-label-empty`,
|
|
1254
|
-
metaType: "label",
|
|
1255
|
-
value: "",
|
|
1256
|
-
primitive: true,
|
|
1257
|
-
dynamicTab: false,
|
|
1258
|
-
type: "div",
|
|
1259
|
-
width: 4,
|
|
1260
|
-
onlyDisplay: true,
|
|
1261
|
-
colStyle: {
|
|
1262
|
-
flex: 1,
|
|
1263
|
-
},
|
|
1264
|
-
},
|
|
1265
|
-
{
|
|
1266
|
-
id: `${inputId}-action`,
|
|
1267
|
-
metaType: "label",
|
|
1268
|
-
value: "",
|
|
1269
|
-
primitive: true,
|
|
1270
|
-
dynamicTab: false,
|
|
1271
|
-
type: "div",
|
|
1272
|
-
width: 8,
|
|
1273
|
-
offset: 0,
|
|
1274
|
-
},
|
|
1275
|
-
{
|
|
1276
|
-
id: `${inputId}-action2`,
|
|
1277
|
-
metaType: "label",
|
|
1278
|
-
value: "",
|
|
1279
|
-
primitive: true,
|
|
1280
|
-
dynamicTab: false,
|
|
1281
|
-
type: "div",
|
|
1282
|
-
width: 8,
|
|
1283
|
-
offset: 0,
|
|
1284
|
-
style: {display: 'none'},
|
|
1285
|
-
},
|
|
1286
|
-
],
|
|
1287
|
-
};
|
|
1288
|
-
if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
|
|
1289
|
-
formChaild.inputFields[fieldIndex + 2] = {
|
|
1290
|
-
rowClassName: "mobile-push-row",
|
|
1291
|
-
cols: [
|
|
1292
|
-
{
|
|
1293
|
-
id: `${inputId}-action-label-empty`,
|
|
1294
|
-
metaType: "label",
|
|
1295
|
-
value: "",
|
|
1296
|
-
primitive: true,
|
|
1297
|
-
dynamicTab: false,
|
|
1298
|
-
type: "div",
|
|
1299
|
-
width: 4,
|
|
1300
|
-
offset: 0,
|
|
1301
|
-
onlyDisplay: true,
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
id: `cta-deeplink-${inputId}`,
|
|
1305
|
-
type: "radioGroup", //Resembles component to be used
|
|
1306
|
-
metaType: "text",
|
|
1307
|
-
datatype: "string",
|
|
1308
|
-
options: ["Deeplink", "External Link"],
|
|
1309
|
-
value: "Deeplink",
|
|
1310
|
-
required: true,
|
|
1311
|
-
width: 16,
|
|
1312
|
-
offSet: 4,
|
|
1313
|
-
errorMessage: "Please select link type",
|
|
1314
|
-
fluid: true,
|
|
1315
|
-
style: {
|
|
1316
|
-
fontFamily: 'open-sans',
|
|
1317
|
-
fontSize: '14px',
|
|
1318
|
-
lineHeight: '24px',
|
|
1319
|
-
},
|
|
1320
|
-
styling: "semantic",
|
|
1321
|
-
order: 1,
|
|
1322
|
-
supportedEvents: ["onChange"],
|
|
1323
|
-
customComponent: false,
|
|
1324
|
-
},
|
|
1325
|
-
],
|
|
1326
|
-
};
|
|
1327
|
-
formChaild.inputFields[fieldIndex + 3] = {
|
|
1328
|
-
rowClassName: 'mobile-push-row',
|
|
1329
|
-
id: 'cta-deeplink-select-section',
|
|
1330
|
-
cols: [
|
|
1331
|
-
{
|
|
1332
|
-
id: "cta-label",
|
|
1333
|
-
metaType: "label",
|
|
1334
|
-
value: "",
|
|
1335
|
-
primitive: true,
|
|
1336
|
-
dynamicTab: false,
|
|
1337
|
-
type: "div",
|
|
1338
|
-
width: 4,
|
|
1339
|
-
onlyDisplay: true,
|
|
1340
|
-
colStyle: {
|
|
1341
|
-
flex: 1,
|
|
1342
|
-
},
|
|
1343
|
-
},
|
|
1344
|
-
{
|
|
1345
|
-
id: `cta-deeplink-${inputId}-select2`,
|
|
1346
|
-
placeholder: "Select DeepLink",
|
|
1347
|
-
type: "select", //Resembles component to be used
|
|
1348
|
-
options: deepLinkOptions,
|
|
1349
|
-
metaType: "text",
|
|
1350
|
-
datatype: "string",
|
|
1351
|
-
errorMessage: "Select a deeplink",
|
|
1352
|
-
required: true,
|
|
1353
|
-
fluid: true,
|
|
1354
|
-
width: 19,
|
|
1355
|
-
style: {
|
|
1356
|
-
fontSize: '14px',
|
|
1357
|
-
fontFamily: 'open-sans',
|
|
1358
|
-
fontStyle: 'normal',
|
|
1359
|
-
// fontWeight: 600,
|
|
1360
|
-
marginBottom: '16px',
|
|
1361
|
-
},
|
|
1362
|
-
styling: "semantic",
|
|
1363
|
-
order: 1,
|
|
1364
|
-
customComponent: false,
|
|
1365
|
-
supportedEvents: [
|
|
1366
|
-
'onSelect',
|
|
1367
|
-
],
|
|
1368
|
-
},
|
|
1369
|
-
],
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
});
|
|
939
|
+
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
|
|
940
|
+
const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
941
|
+
forEach(inputFields, (inputField, fieldIndex) => {
|
|
942
|
+
forEach(inputField.cols, (col) => {
|
|
943
|
+
if (col.id === "add-sec-cta-ios") {
|
|
944
|
+
const inputId = `secondary-cta-${currentTab - 1}`;
|
|
945
|
+
|
|
946
|
+
inputFields.splice(fieldIndex + 1, 0, {
|
|
947
|
+
rowClassName: 'mobile-push-row',
|
|
948
|
+
cols: [
|
|
949
|
+
{
|
|
950
|
+
id: `${inputId}-action-display`,
|
|
951
|
+
metaType: "label",
|
|
952
|
+
value: <CapRow>
|
|
953
|
+
<CapColumn span={18}>
|
|
954
|
+
<CapHeader
|
|
955
|
+
title={this.state.templateCta.name}
|
|
956
|
+
description={get(this.state, "templateCta.ctaTemplateDetails[0].buttonText")}
|
|
957
|
+
size={"label"}/>
|
|
958
|
+
</CapColumn>
|
|
959
|
+
<CapColumn span={6}>
|
|
960
|
+
<CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
|
|
961
|
+
</CapColumn>
|
|
962
|
+
</CapRow>,
|
|
963
|
+
primitive: true,
|
|
964
|
+
dynamicTab: false,
|
|
965
|
+
type: "div",
|
|
966
|
+
width: 18,
|
|
967
|
+
offset: 1,
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
id: `${inputId}-action`,
|
|
971
|
+
metaType: "label",
|
|
972
|
+
value: "",
|
|
973
|
+
primitive: true,
|
|
974
|
+
dynamicTab: false,
|
|
975
|
+
type: "div",
|
|
976
|
+
width: 8,
|
|
977
|
+
offset: 0,
|
|
978
|
+
style: {
|
|
979
|
+
display: 'none',
|
|
980
|
+
},
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
id: `${inputId}-action2`,
|
|
984
|
+
metaType: "label",
|
|
985
|
+
value: "",
|
|
986
|
+
primitive: true,
|
|
987
|
+
dynamicTab: false,
|
|
988
|
+
type: "div",
|
|
989
|
+
width: 8,
|
|
990
|
+
offset: 0,
|
|
991
|
+
style: {display: 'none'},
|
|
992
|
+
},
|
|
993
|
+
|
|
994
|
+
],
|
|
1377
995
|
});
|
|
1378
|
-
|
|
996
|
+
if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
|
|
997
|
+
inputFields.splice(fieldIndex + 2, 0, {
|
|
998
|
+
rowClassName: "mobile-push-row",
|
|
999
|
+
cols: [
|
|
1000
|
+
|
|
1001
|
+
{
|
|
1002
|
+
id: `cta-deeplink-${inputId}`,
|
|
1003
|
+
type: "radioGroup", //Resembles component to be used
|
|
1004
|
+
metaType: "text",
|
|
1005
|
+
datatype: "string",
|
|
1006
|
+
options: ["Deeplink", "External Link"],
|
|
1007
|
+
inductiveText: ["A page within mobile app", "An external web page"],
|
|
1008
|
+
value: "Deeplink",
|
|
1009
|
+
required: true,
|
|
1010
|
+
width: 18,
|
|
1011
|
+
offset: 1,
|
|
1012
|
+
errorMessage: "Please select link type",
|
|
1013
|
+
fluid: true,
|
|
1014
|
+
|
|
1015
|
+
styling: "semantic",
|
|
1016
|
+
order: 1,
|
|
1017
|
+
supportedEvents: ["onChange"],
|
|
1018
|
+
customComponent: false,
|
|
1019
|
+
},
|
|
1020
|
+
],
|
|
1021
|
+
});
|
|
1022
|
+
inputFields.splice(fieldIndex + 3, 0, {
|
|
1023
|
+
rowClassName: 'mobile-push-row',
|
|
1024
|
+
id: 'cta-deeplink-select-section',
|
|
1025
|
+
cols: [
|
|
1026
|
+
|
|
1027
|
+
{
|
|
1028
|
+
id: `cta-deeplink-${inputId}-select2`,
|
|
1029
|
+
placeholder: "Select DeepLink",
|
|
1030
|
+
type: "select", //Resembles component to be used
|
|
1031
|
+
options: deepLinkOptions,
|
|
1032
|
+
metaType: "text",
|
|
1033
|
+
datatype: "string",
|
|
1034
|
+
errorMessage: "Select a deeplink",
|
|
1035
|
+
required: true,
|
|
1036
|
+
fluid: true,
|
|
1037
|
+
width: 18,
|
|
1038
|
+
offset: 1,
|
|
1039
|
+
style: {
|
|
1040
|
+
width: '100%',
|
|
1041
|
+
marginBottom: '16px',
|
|
1042
|
+
},
|
|
1043
|
+
styling: "semantic",
|
|
1044
|
+
order: 1,
|
|
1045
|
+
customComponent: false,
|
|
1046
|
+
supportedEvents: [
|
|
1047
|
+
'onSelect',
|
|
1048
|
+
],
|
|
1049
|
+
},
|
|
1050
|
+
],
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1379
1054
|
});
|
|
1380
1055
|
});
|
|
1056
|
+
// set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
|
|
1057
|
+
|
|
1381
1058
|
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
1382
1059
|
this.injectEvents(schema);
|
|
1383
1060
|
};
|
|
1384
|
-
addPrimaryCta = (
|
|
1385
|
-
const id =
|
|
1386
|
-
const schema =
|
|
1061
|
+
addPrimaryCta = (flag, formData, schemaField) => {
|
|
1062
|
+
const id = schemaField.id;
|
|
1063
|
+
const schema = cloneDeep(this.state.schema);
|
|
1387
1064
|
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1388
|
-
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ?
|
|
1389
|
-
// const eventsMap =
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
fontStyle: 'normal',
|
|
1420
|
-
},
|
|
1421
|
-
offset: 0,
|
|
1422
|
-
onlyDisplay: true,
|
|
1423
|
-
colStyle: {
|
|
1424
|
-
flex: 1,
|
|
1425
|
-
},
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}`,
|
|
1429
|
-
type: "radioGroup", //Resembles component to be used
|
|
1430
|
-
metaType: "text",
|
|
1431
|
-
datatype: "string",
|
|
1432
|
-
options: ["Deeplink", "External Link"],
|
|
1433
|
-
value: "Deeplink",
|
|
1434
|
-
required: true,
|
|
1435
|
-
width: 18,
|
|
1436
|
-
errorMessage: "Please select link type",
|
|
1437
|
-
fluid: true,
|
|
1438
|
-
styling: "semantic",
|
|
1439
|
-
order: 1,
|
|
1440
|
-
customComponent: false,
|
|
1441
|
-
supportedEvents: ["onChange"],
|
|
1442
|
-
},
|
|
1443
|
-
{
|
|
1444
|
-
id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-delete`,
|
|
1445
|
-
type: "icon",
|
|
1446
|
-
value: 'delete',
|
|
1447
|
-
width: 1,
|
|
1448
|
-
submitAction: "onDelete",
|
|
1449
|
-
supportedEvents: ["onDelete"],
|
|
1450
|
-
},
|
|
1451
|
-
],
|
|
1452
|
-
});
|
|
1453
|
-
child.inputFields.splice(fieldIndex + 1, 0, {
|
|
1454
|
-
rowClassName: 'mobile-push-row',
|
|
1455
|
-
id: 'cta-deeplink-select-section',
|
|
1456
|
-
cols: [
|
|
1457
|
-
{
|
|
1458
|
-
id: "cta-label",
|
|
1459
|
-
metaType: "label",
|
|
1460
|
-
value: "",
|
|
1461
|
-
primitive: true,
|
|
1462
|
-
dynamicTab: false,
|
|
1463
|
-
type: "div",
|
|
1464
|
-
width: 4,
|
|
1465
|
-
onlyDisplay: true,
|
|
1466
|
-
colStyle: {
|
|
1467
|
-
flex: 1,
|
|
1468
|
-
},
|
|
1469
|
-
},
|
|
1470
|
-
{
|
|
1471
|
-
id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-select`,
|
|
1472
|
-
placeholder: "Select DeepLink",
|
|
1473
|
-
type: "select", //Resembles component to be used
|
|
1474
|
-
options: deepLinkOptions,
|
|
1475
|
-
metaType: "text",
|
|
1476
|
-
datatype: "string",
|
|
1477
|
-
required: true,
|
|
1478
|
-
errorMessage: "Select a deeplink",
|
|
1479
|
-
fluid: true,
|
|
1480
|
-
width: 19,
|
|
1481
|
-
style: {
|
|
1482
|
-
fontSize: '14px',
|
|
1483
|
-
fontFamily: 'open-sans',
|
|
1484
|
-
fontStyle: 'normal',
|
|
1485
|
-
// fontWeight: 600,
|
|
1486
|
-
marginBottom: '16px',
|
|
1487
|
-
},
|
|
1488
|
-
styling: "semantic",
|
|
1489
|
-
order: 1,
|
|
1490
|
-
customComponent: false,
|
|
1491
|
-
supportedEvents: [
|
|
1492
|
-
'onSelect',
|
|
1493
|
-
],
|
|
1494
|
-
},
|
|
1495
|
-
],
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
});
|
|
1499
|
-
});
|
|
1500
|
-
}
|
|
1065
|
+
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
|
|
1066
|
+
// const eventsMap = cloneDeep(this.state.eventsMap);
|
|
1067
|
+
const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
1068
|
+
forEach(inputFields, (inputField, fieldIndex) => {
|
|
1069
|
+
forEach(inputField.cols, (col) => {
|
|
1070
|
+
const colId = col.id;
|
|
1071
|
+
if (colId === id) {
|
|
1072
|
+
if (formData[this.state.currentTab - 1][id]) { // add primary cta
|
|
1073
|
+
inputFields.splice(fieldIndex + 1, 0, {
|
|
1074
|
+
rowClassName: 'mobile-push-row',
|
|
1075
|
+
cols: [
|
|
1076
|
+
{
|
|
1077
|
+
id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}`,
|
|
1078
|
+
type: "radioGroup", //Resembles component to be used
|
|
1079
|
+
metaType: "text",
|
|
1080
|
+
datatype: "string",
|
|
1081
|
+
options: ["Deeplink", "External Link"],
|
|
1082
|
+
inductiveText: ["A page within mobile app", "An external web page"],
|
|
1083
|
+
value: "Deeplink",
|
|
1084
|
+
required: true,
|
|
1085
|
+
width: 18,
|
|
1086
|
+
offset: 1,
|
|
1087
|
+
errorMessage: "Please select link type",
|
|
1088
|
+
fluid: true,
|
|
1089
|
+
styling: "semantic",
|
|
1090
|
+
order: 1,
|
|
1091
|
+
customComponent: false,
|
|
1092
|
+
supportedEvents: ["onChange"],
|
|
1093
|
+
},
|
|
1094
|
+
|
|
1095
|
+
],
|
|
1501
1096
|
});
|
|
1502
|
-
|
|
1503
|
-
|
|
1097
|
+
inputFields.splice(fieldIndex + 2, 0, {
|
|
1098
|
+
rowClassName: 'mobile-push-row',
|
|
1099
|
+
id: 'cta-deeplink-select-section',
|
|
1100
|
+
cols: [
|
|
1101
|
+
|
|
1102
|
+
{
|
|
1103
|
+
id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-select`,
|
|
1104
|
+
placeholder: "Select DeepLink",
|
|
1105
|
+
type: "select", //Resembles component to be used
|
|
1106
|
+
options: deepLinkOptions,
|
|
1107
|
+
metaType: "text",
|
|
1108
|
+
datatype: "string",
|
|
1109
|
+
required: true,
|
|
1110
|
+
errorMessage: "Select a deeplink",
|
|
1111
|
+
fluid: true,
|
|
1112
|
+
width: 18,
|
|
1113
|
+
offset: 1,
|
|
1114
|
+
style: {
|
|
1115
|
+
width: '100%',
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
marginBottom: '16px',
|
|
1119
|
+
},
|
|
1120
|
+
styling: "semantic",
|
|
1121
|
+
order: 1,
|
|
1122
|
+
customComponent: false,
|
|
1123
|
+
supportedEvents: [
|
|
1124
|
+
'onSelect',
|
|
1125
|
+
],
|
|
1126
|
+
},
|
|
1127
|
+
],
|
|
1128
|
+
});
|
|
1129
|
+
} else { // remove existing primary cta cuz primary cta is unchecked
|
|
1130
|
+
const identifier = (this.state.currentTab - 1) ? 'add-sec-cta-ios' : 'add-sec-cta';
|
|
1131
|
+
const indexOfNextField = findIndex(inputFields, {identifier});
|
|
1132
|
+
const deleteCount = indexOfNextField - fieldIndex;
|
|
1133
|
+
const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
|
|
1134
|
+
set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1504
1137
|
});
|
|
1505
1138
|
});
|
|
1506
|
-
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
1507
|
-
this.injectEvents(schema);
|
|
1139
|
+
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true, formData}, () => this.injectEvents(schema));
|
|
1508
1140
|
};
|
|
1509
|
-
addSecondoryCta = (
|
|
1510
|
-
const id =
|
|
1511
|
-
const schema =
|
|
1141
|
+
addSecondoryCta = (flag, formData, schemaField) => {
|
|
1142
|
+
const id = schemaField.id;
|
|
1143
|
+
const schema = cloneDeep(this.state.schema);
|
|
1512
1144
|
const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
|
|
1513
1145
|
const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1514
|
-
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ?
|
|
1515
|
-
// const eventsMap =
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
fontSize: '14px',
|
|
1545
|
-
fontFamily: 'open-sans',
|
|
1546
|
-
fontStyle: 'normal',
|
|
1547
|
-
paddingTop: '8px',
|
|
1548
|
-
},
|
|
1549
|
-
offset: 0,
|
|
1550
|
-
onlyDisplay: true,
|
|
1551
|
-
colStyle: {
|
|
1552
|
-
flex: 1,
|
|
1553
|
-
},
|
|
1554
|
-
},
|
|
1555
|
-
{
|
|
1556
|
-
id: `${inputId}-label`,
|
|
1557
|
-
label: "link",
|
|
1558
|
-
type: "input", //Resembles component to be used
|
|
1559
|
-
metaType: "text",
|
|
1560
|
-
datatype: "string",
|
|
1561
|
-
required: true,
|
|
1562
|
-
width: 18,
|
|
1563
|
-
offset: 4,
|
|
1564
|
-
placeholder: "Enter CTA Label here",
|
|
1565
|
-
fluid: true,
|
|
1566
|
-
styling: "semantic",
|
|
1567
|
-
order: 1,
|
|
1568
|
-
customComponent: false,
|
|
1569
|
-
errorMessage: "CTA label cannot be empty.",
|
|
1570
|
-
},
|
|
1571
|
-
{
|
|
1572
|
-
id: `${inputId}-delete`,
|
|
1573
|
-
type: "icon",
|
|
1574
|
-
value: 'delete',
|
|
1575
|
-
width: 1,
|
|
1576
|
-
submitAction: "onDelete",
|
|
1577
|
-
supportedEvents: ["onDelete"],
|
|
1578
|
-
},
|
|
1579
|
-
],
|
|
1580
|
-
});
|
|
1581
|
-
child.inputFields.splice(fieldIndex + 1, 0, {
|
|
1582
|
-
rowClassName: 'mobile-push-row',
|
|
1583
|
-
cols: [
|
|
1584
|
-
{
|
|
1585
|
-
id: `${inputId}-label-space`,
|
|
1586
|
-
metaType: "label",
|
|
1587
|
-
value: "",
|
|
1588
|
-
primitive: true,
|
|
1589
|
-
dynamicTab: false,
|
|
1590
|
-
type: "div",
|
|
1591
|
-
width: 4,
|
|
1592
|
-
style: {
|
|
1593
|
-
backgroundColor: 'white',
|
|
1594
|
-
textAlign: 'left',
|
|
1595
|
-
color: '#333333',
|
|
1596
|
-
lineHeight: '24px',
|
|
1597
|
-
fontSize: '14px',
|
|
1598
|
-
fontFamily: 'open-sans',
|
|
1599
|
-
fontStyle: 'normal',
|
|
1600
|
-
paddingTop: '8px',
|
|
1601
|
-
},
|
|
1602
|
-
offset: 0,
|
|
1603
|
-
onlyDisplay: true,
|
|
1604
|
-
colStyle: {
|
|
1605
|
-
flex: 1,
|
|
1606
|
-
},
|
|
1607
|
-
},
|
|
1608
|
-
{
|
|
1609
|
-
id: `cta-deeplink-${inputId}`,
|
|
1610
|
-
type: "radioGroup", //Resembles component to be used
|
|
1611
|
-
metaType: "text",
|
|
1612
|
-
datatype: "string",
|
|
1613
|
-
options: ["Deeplink", "External Link"],
|
|
1614
|
-
value: "Deeplink",
|
|
1615
|
-
required: true,
|
|
1616
|
-
width: 16,
|
|
1617
|
-
errorMessage: "Please select link type",
|
|
1618
|
-
fluid: true,
|
|
1619
|
-
styling: "semantic",
|
|
1620
|
-
order: 1,
|
|
1621
|
-
style: {
|
|
1622
|
-
lineHeight: '24px',
|
|
1623
|
-
fontSize: '14px',
|
|
1624
|
-
},
|
|
1625
|
-
customComponent: false,
|
|
1626
|
-
supportedEvents: ["onChange"],
|
|
1627
|
-
},
|
|
1628
|
-
],
|
|
1629
|
-
});
|
|
1630
|
-
child.inputFields.splice(fieldIndex + 2, 0, {
|
|
1631
|
-
rowClassName: 'mobile-push-row',
|
|
1632
|
-
id: 'cta-deeplink-select-section',
|
|
1633
|
-
cols: [
|
|
1634
|
-
{
|
|
1635
|
-
id: "cta-label",
|
|
1636
|
-
metaType: "label",
|
|
1637
|
-
value: "",
|
|
1638
|
-
primitive: true,
|
|
1639
|
-
dynamicTab: false,
|
|
1640
|
-
type: "div",
|
|
1641
|
-
width: 4,
|
|
1642
|
-
onlyDisplay: true,
|
|
1643
|
-
colStyle: {
|
|
1644
|
-
flex: 1,
|
|
1645
|
-
},
|
|
1646
|
-
},
|
|
1647
|
-
{
|
|
1648
|
-
id: `cta-deeplink-${inputId}-select`,
|
|
1649
|
-
placeholder: "Select DeepLink",
|
|
1650
|
-
type: "select", //Resembles component to be used
|
|
1651
|
-
options: deepLinkOptions,
|
|
1652
|
-
errorMessage: "Select a deeplink",
|
|
1653
|
-
metaType: "text",
|
|
1654
|
-
datatype: "string",
|
|
1655
|
-
required: true,
|
|
1656
|
-
fluid: true,
|
|
1657
|
-
width: 19,
|
|
1658
|
-
style: {
|
|
1659
|
-
fontSize: '14px',
|
|
1660
|
-
fontFamily: 'open-sans',
|
|
1661
|
-
fontStyle: 'normal',
|
|
1662
|
-
// fontWeight: 600,
|
|
1663
|
-
marginBottom: '16px',
|
|
1664
|
-
},
|
|
1665
|
-
styling: "semantic",
|
|
1666
|
-
order: 1,
|
|
1667
|
-
customComponent: false,
|
|
1668
|
-
supportedEvents: [
|
|
1669
|
-
'onSelect',
|
|
1670
|
-
],
|
|
1671
|
-
},
|
|
1672
|
-
],
|
|
1673
|
-
});
|
|
1674
|
-
const colField = col;
|
|
1675
|
-
colField.value = "Add Another CTA";
|
|
1676
|
-
colField.fieldsCount += 1;
|
|
1677
|
-
if (col.fieldsCount === col.fieldsLimit) {
|
|
1678
|
-
child.inputFields.pop();
|
|
1679
|
-
}
|
|
1680
|
-
// eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
});
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1146
|
+
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
|
|
1147
|
+
// const eventsMap = cloneDeep(this.state.eventsMap);
|
|
1148
|
+
const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
1149
|
+
forEach(inputFields, (inputField, fieldIndex) => {
|
|
1150
|
+
forEach(inputField.cols, (col) => {
|
|
1151
|
+
if (col.id === id) {
|
|
1152
|
+
if (formData[this.state.currentTab - 1][id]) {
|
|
1153
|
+
const inputId = `secondary-cta-${col.fieldsCount}`;
|
|
1154
|
+
inputFields.splice(fieldIndex + 1, 0, {
|
|
1155
|
+
rowClassName: 'mobile-push-row',
|
|
1156
|
+
cols: [
|
|
1157
|
+
|
|
1158
|
+
{
|
|
1159
|
+
id: `${inputId}-label`,
|
|
1160
|
+
label: "Button label",
|
|
1161
|
+
type: "input", //Resembles component to be used
|
|
1162
|
+
metaType: "text",
|
|
1163
|
+
datatype: "string",
|
|
1164
|
+
required: true,
|
|
1165
|
+
width: 18,
|
|
1166
|
+
offset: 1,
|
|
1167
|
+
placeholder: "Enter CTA Label here",
|
|
1168
|
+
fluid: true,
|
|
1169
|
+
styling: "semantic",
|
|
1170
|
+
order: 1,
|
|
1171
|
+
customComponent: false,
|
|
1172
|
+
errorMessage: "CTA label cannot be empty.",
|
|
1173
|
+
},
|
|
1174
|
+
|
|
1175
|
+
],
|
|
1686
1176
|
});
|
|
1687
|
-
|
|
1688
|
-
|
|
1177
|
+
inputFields.splice(fieldIndex + 2, 0, {
|
|
1178
|
+
rowClassName: 'mobile-push-row',
|
|
1179
|
+
cols: [
|
|
1180
|
+
|
|
1181
|
+
{
|
|
1182
|
+
id: `cta-deeplink-${inputId}`,
|
|
1183
|
+
type: "radioGroup", //Resembles component to be used
|
|
1184
|
+
metaType: "text",
|
|
1185
|
+
datatype: "string",
|
|
1186
|
+
options: ["Deeplink", "External Link"],
|
|
1187
|
+
inductiveText: ["A page within mobile app", "An external web page"],
|
|
1188
|
+
value: "Deeplink",
|
|
1189
|
+
required: true,
|
|
1190
|
+
width: 18,
|
|
1191
|
+
offset: 1,
|
|
1192
|
+
errorMessage: "Please select link type",
|
|
1193
|
+
fluid: true,
|
|
1194
|
+
styling: "semantic",
|
|
1195
|
+
order: 1,
|
|
1196
|
+
|
|
1197
|
+
customComponent: false,
|
|
1198
|
+
supportedEvents: ["onChange"],
|
|
1199
|
+
},
|
|
1200
|
+
],
|
|
1201
|
+
});
|
|
1202
|
+
inputFields.splice(fieldIndex + 3, 0, {
|
|
1203
|
+
rowClassName: 'mobile-push-row',
|
|
1204
|
+
id: 'cta-deeplink-select-section',
|
|
1205
|
+
cols: [
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
{
|
|
1209
|
+
id: `cta-deeplink-${inputId}-select`,
|
|
1210
|
+
placeholder: "Select DeepLink",
|
|
1211
|
+
type: "select", //Resembles component to be used
|
|
1212
|
+
options: deepLinkOptions,
|
|
1213
|
+
errorMessage: "Select a deeplink",
|
|
1214
|
+
metaType: "text",
|
|
1215
|
+
datatype: "string",
|
|
1216
|
+
required: true,
|
|
1217
|
+
fluid: true,
|
|
1218
|
+
width: 18,
|
|
1219
|
+
offset: 1,
|
|
1220
|
+
style: {
|
|
1221
|
+
width: '100%',
|
|
1222
|
+
marginBottom: '16px',
|
|
1223
|
+
},
|
|
1224
|
+
styling: "semantic",
|
|
1225
|
+
order: 1,
|
|
1226
|
+
customComponent: false,
|
|
1227
|
+
supportedEvents: [
|
|
1228
|
+
'onSelect',
|
|
1229
|
+
],
|
|
1230
|
+
},
|
|
1231
|
+
],
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
// eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
|
|
1235
|
+
} else {
|
|
1236
|
+
const identifier = id === "add-sec-cta" ? 'add-sec-cta-2' : null;
|
|
1237
|
+
const indexOfNextField = identifier ? findIndex(inputFields, {identifier}) : inputFields.length;
|
|
1238
|
+
const deleteCount = indexOfNextField - fieldIndex;
|
|
1239
|
+
const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
|
|
1240
|
+
set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1689
1243
|
});
|
|
1690
1244
|
});
|
|
1691
1245
|
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
1692
1246
|
this.injectEvents(schema);
|
|
1693
1247
|
};
|
|
1694
1248
|
copyIphoneContent = () => {
|
|
1695
|
-
const formData =
|
|
1249
|
+
const formData = cloneDeep(this.state.formData);
|
|
1696
1250
|
if (!!formData[1]['message-title2'] && !!formData[1]['message-editor2']) {
|
|
1697
1251
|
formData[0]['message-title'] = formData[1]['message-title2'];
|
|
1698
1252
|
formData[0]['message-editor'] = formData[1]['message-editor2'];
|
|
@@ -1702,7 +1256,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1702
1256
|
}
|
|
1703
1257
|
};
|
|
1704
1258
|
copyAndroidContent = () => {
|
|
1705
|
-
const formData =
|
|
1259
|
+
const formData = cloneDeep(this.state.formData);
|
|
1706
1260
|
if (!!formData[0]['message-title'] && !!formData[0]['message-editor']) {
|
|
1707
1261
|
formData[1]['message-title2'] = formData[0]['message-title'];
|
|
1708
1262
|
formData[1]['message-editor2'] = formData[0]['message-editor'];
|
|
@@ -1727,76 +1281,40 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1727
1281
|
};
|
|
1728
1282
|
|
|
1729
1283
|
showCtaKeys = (eventTriggered, formData, field) => {
|
|
1730
|
-
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
_.forEach(childeSection.childSections, (child) => {
|
|
1284
|
+
const schema = cloneDeep(this.state.schema);
|
|
1285
|
+
const eventsMap = cloneDeep(this.state.eventsMap);
|
|
1286
|
+
forEach(schema.containers, (container) => {
|
|
1287
|
+
forEach(container.panes, (pane) => {
|
|
1288
|
+
forEach(pane.sections, (section) => {
|
|
1289
|
+
forEach(section.childSections, (childeSection) => {
|
|
1290
|
+
forEach(childeSection.childSections, (child) => {
|
|
1738
1291
|
const formChaild = child;
|
|
1739
1292
|
if (child.type === 'multicols') {
|
|
1740
|
-
|
|
1741
|
-
|
|
1293
|
+
forEach(child.inputFields, (inputField, fieldIndex) => {
|
|
1294
|
+
forEach(inputField.cols, (col) => {
|
|
1742
1295
|
if (col.id === field.id) {
|
|
1743
1296
|
const formDataKey = col.id.replace("-show-keys", "");
|
|
1744
1297
|
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1745
|
-
let keys = this.props.Templates.selectedWeChatAccount ?
|
|
1298
|
+
let keys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][formDataKey]) : [];
|
|
1746
1299
|
if (keys[0]) {
|
|
1747
1300
|
keys = keys[0].keys;
|
|
1748
1301
|
}
|
|
1749
|
-
let rows =
|
|
1302
|
+
let rows = map(keys, (key) => {
|
|
1750
1303
|
const row = {
|
|
1751
1304
|
rowClassName: 'mobile-push-row',
|
|
1752
1305
|
id: 'cta-deeplink-keys',
|
|
1753
1306
|
cols: [
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
metaType: "label",
|
|
1757
|
-
value: "",
|
|
1758
|
-
primitive: true,
|
|
1759
|
-
dynamicTab: false,
|
|
1760
|
-
type: "div",
|
|
1761
|
-
width: 4,
|
|
1762
|
-
offset: 0,
|
|
1763
|
-
onlyDisplay: true,
|
|
1764
|
-
colStyle: {
|
|
1765
|
-
flex: 1,
|
|
1766
|
-
},
|
|
1767
|
-
},
|
|
1768
|
-
{
|
|
1769
|
-
id: `${key}-label`,
|
|
1770
|
-
metaType: "label",
|
|
1771
|
-
value: key.replace('_', " "),
|
|
1772
|
-
primitive: true,
|
|
1773
|
-
dynamicTab: false,
|
|
1774
|
-
type: "div",
|
|
1775
|
-
width: 5,
|
|
1776
|
-
style: {
|
|
1777
|
-
backgroundColor: 'white',
|
|
1778
|
-
textAlign: 'left',
|
|
1779
|
-
lineHeight: '24px',
|
|
1780
|
-
fontSize: '14px',
|
|
1781
|
-
fontFamily: 'open-sans',
|
|
1782
|
-
fontStyle: 'normal',
|
|
1783
|
-
cursor: 'pointer',
|
|
1784
|
-
paddingTop: '8px',
|
|
1785
|
-
},
|
|
1786
|
-
offset: 0,
|
|
1787
|
-
onlyDisplay: true,
|
|
1788
|
-
colStyle: {
|
|
1789
|
-
flex: 1,
|
|
1790
|
-
},
|
|
1791
|
-
},
|
|
1307
|
+
|
|
1308
|
+
|
|
1792
1309
|
{
|
|
1793
1310
|
id: `custom-value-${key}-${col.id}`,
|
|
1794
|
-
label: "
|
|
1311
|
+
label: key.replace('_', " "),
|
|
1795
1312
|
type: "input", //Resembles component to be used
|
|
1796
1313
|
metaType: "text",
|
|
1797
1314
|
datatype: "string",
|
|
1798
1315
|
required: true,
|
|
1799
|
-
width:
|
|
1316
|
+
width: 18,
|
|
1317
|
+
offset: 1,
|
|
1800
1318
|
placeholder: `Please input ${key.replace('_', " ")} here .`,
|
|
1801
1319
|
fluid: true,
|
|
1802
1320
|
styling: "semantic",
|
|
@@ -1810,9 +1328,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1810
1328
|
return row;
|
|
1811
1329
|
// formChaild.inputFields[fieldIndex + index] = field;
|
|
1812
1330
|
});
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
const configkeys =
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
const configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === this.state.formData[this.state.currentTab - 1][field.id]);
|
|
1816
1334
|
if (configkeys.length) {
|
|
1817
1335
|
const options = configkeys[0].keys;
|
|
1818
1336
|
formChaild.inputFields = formChaild.inputFields.slice(0, fieldIndex + 1).concat(formChaild.inputFields.slice( fieldIndex + options.length + 1, formChaild.inputFields.length));
|
|
@@ -1839,109 +1357,42 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1839
1357
|
this.injectEvents(schema);
|
|
1840
1358
|
};
|
|
1841
1359
|
saveFormData = (formData) => {
|
|
1842
|
-
console.log('Saving form data', formData, this.state.tabCount);
|
|
1843
1360
|
const obj = this.getTransformedData(formData);
|
|
1844
|
-
|
|
1361
|
+
|
|
1845
1362
|
this.props.actions.createTemplate(obj);
|
|
1846
1363
|
};
|
|
1847
|
-
deleteSecondaryCtaIos = (
|
|
1848
|
-
const
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
_.forEach(container.panes, (pane) => {
|
|
1857
|
-
_.forEach(pane.sections, (section) => {
|
|
1858
|
-
_.forEach(section.childSections, (childeSection) => {
|
|
1859
|
-
_.forEach(childeSection.childSections, (formChild) => {
|
|
1860
|
-
const child = formChild;
|
|
1861
|
-
if (child.type === 'multicols') {
|
|
1862
|
-
_.forEach(child.inputFields, (inputField, fieldIndex) => {
|
|
1863
|
-
if (inputField) {
|
|
1864
|
-
_.forEach(inputField.cols, (col) => {
|
|
1865
|
-
if (col.id === id) {
|
|
1866
|
-
child.inputFields.splice(fieldIndex, 3);
|
|
1867
|
-
if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
|
|
1868
|
-
child.inputFields.splice(fieldIndex, 1);
|
|
1869
|
-
}
|
|
1870
|
-
if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
|
|
1871
|
-
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1872
|
-
const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
|
|
1873
|
-
if (configkeys.length) {
|
|
1874
|
-
const options = configkeys[0].keys;
|
|
1875
|
-
child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
|
|
1876
|
-
delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
|
|
1877
|
-
delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
|
|
1878
|
-
} else {
|
|
1879
|
-
child.inputFields.splice(fieldIndex, 1);
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
if (device === 'ios') {
|
|
1883
|
-
child.inputFields[fieldIndex] = {
|
|
1884
|
-
cols: [
|
|
1885
|
-
{
|
|
1886
|
-
id: "add-sec-cta-ios",
|
|
1887
|
-
metaType: "label",
|
|
1888
|
-
value: "Add Secondary CTA",
|
|
1889
|
-
primitive: true,
|
|
1890
|
-
dynamicTab: false,
|
|
1891
|
-
type: "div",
|
|
1892
|
-
style: {
|
|
1893
|
-
backgroundColor: 'white',
|
|
1894
|
-
textAlign: 'left',
|
|
1895
|
-
color: '#2673D7',
|
|
1896
|
-
lineHeight: '24px',
|
|
1897
|
-
marginTop: '16px',
|
|
1898
|
-
fontSize: '14px',
|
|
1899
|
-
fontWeight: '600',
|
|
1900
|
-
fontFamily: 'open-sans',
|
|
1901
|
-
fontStyle: 'normal',
|
|
1902
|
-
cursor: 'pointer',
|
|
1903
|
-
},
|
|
1904
|
-
offset: 0,
|
|
1905
|
-
onlyDisplay: true,
|
|
1906
|
-
colStyle: {
|
|
1907
|
-
flex: 1,
|
|
1908
|
-
},
|
|
1909
|
-
submitAction: "addSecondaryCtaIos",
|
|
1910
|
-
supportedEvents: ["addSecondaryCtaIos"],
|
|
1911
|
-
},
|
|
1912
|
-
],
|
|
1913
|
-
};
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
});
|
|
1917
|
-
}
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
});
|
|
1921
|
-
});
|
|
1364
|
+
deleteSecondaryCtaIos = (callback) => {
|
|
1365
|
+
const schema = cloneDeep(this.state.schema);
|
|
1366
|
+
const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
|
|
1367
|
+
forEach(inputFields, (inputField, fieldIndex) => {
|
|
1368
|
+
if (inputField) {
|
|
1369
|
+
forEach(inputField.cols, (col) => {
|
|
1370
|
+
if (col.id === "add-sec-cta-ios") {
|
|
1371
|
+
inputFields.splice(fieldIndex + 1, inputFields.length);
|
|
1372
|
+
}
|
|
1922
1373
|
});
|
|
1923
|
-
}
|
|
1374
|
+
}
|
|
1924
1375
|
});
|
|
1925
|
-
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema,
|
|
1376
|
+
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, callback);
|
|
1926
1377
|
this.injectEvents(schema);
|
|
1927
1378
|
};
|
|
1928
1379
|
deletePrimaryCTA = (event) => {
|
|
1929
1380
|
const id = event.currentTarget.id;
|
|
1930
|
-
const schema =
|
|
1931
|
-
// const eventsMap =
|
|
1381
|
+
const schema = cloneDeep(this.state.schema);
|
|
1382
|
+
// const eventsMap = cloneDeep(this.state.eventsMap);
|
|
1932
1383
|
const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`${id.replace('delete', 'select')}`];
|
|
1933
|
-
const formData =
|
|
1384
|
+
const formData = cloneDeep(this.state.formData);
|
|
1934
1385
|
const self = this;
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1386
|
+
forEach(schema.containers, (container) => {
|
|
1387
|
+
forEach(container.panes, (pane) => {
|
|
1388
|
+
forEach(pane.sections, (section) => {
|
|
1389
|
+
forEach(section.childSections, (childeSection) => {
|
|
1390
|
+
forEach(childeSection.childSections, (formChild) => {
|
|
1940
1391
|
const child = formChild;
|
|
1941
1392
|
if (child.type === 'multicols') {
|
|
1942
|
-
|
|
1393
|
+
forEach(child.inputFields, (inputField, fieldIndex) => {
|
|
1943
1394
|
if (inputField) {
|
|
1944
|
-
|
|
1395
|
+
forEach(inputField.cols, (col) => {
|
|
1945
1396
|
if (col.id === id) {
|
|
1946
1397
|
child.inputFields.splice(fieldIndex, 1);
|
|
1947
1398
|
if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
|
|
@@ -1949,7 +1400,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1949
1400
|
}
|
|
1950
1401
|
if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
|
|
1951
1402
|
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1952
|
-
const configkeys = this.props.Templates.selectedWeChatAccount ?
|
|
1403
|
+
const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
|
|
1953
1404
|
if (configkeys.length) {
|
|
1954
1405
|
const options = configkeys[0].keys;
|
|
1955
1406
|
child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
|
|
@@ -1972,11 +1423,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1972
1423
|
backgroundColor: 'white',
|
|
1973
1424
|
textAlign: 'left',
|
|
1974
1425
|
color: '#2673D7',
|
|
1975
|
-
|
|
1976
|
-
fontSize: '14px',
|
|
1977
|
-
fontWeight: '600',
|
|
1978
|
-
fontFamily: 'open-sans',
|
|
1979
|
-
fontStyle: 'normal',
|
|
1426
|
+
|
|
1980
1427
|
cursor: 'pointer',
|
|
1981
1428
|
},
|
|
1982
1429
|
offset: 0,
|
|
@@ -2013,21 +1460,21 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2013
1460
|
return;
|
|
2014
1461
|
}
|
|
2015
1462
|
}
|
|
2016
|
-
const schema =
|
|
2017
|
-
// const eventsMap =
|
|
1463
|
+
const schema = cloneDeep(this.state.schema);
|
|
1464
|
+
// const eventsMap = cloneDeep(this.state.eventsMap);
|
|
2018
1465
|
const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
|
|
2019
|
-
const formData =
|
|
1466
|
+
const formData = cloneDeep(this.state.formData);
|
|
2020
1467
|
const device = this.state.currentTab === 1 ? 'android' : 'ios';
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
1468
|
+
forEach(schema.containers, (container) => {
|
|
1469
|
+
forEach(container.panes, (pane) => {
|
|
1470
|
+
forEach(pane.sections, (section) => {
|
|
1471
|
+
forEach(section.childSections, (childeSection) => {
|
|
1472
|
+
forEach(childeSection.childSections, (formChild) => {
|
|
2026
1473
|
const child = formChild;
|
|
2027
1474
|
if (child.type === 'multicols') {
|
|
2028
|
-
|
|
1475
|
+
forEach(child.inputFields, (inputField, fieldIndex) => {
|
|
2029
1476
|
if (inputField) {
|
|
2030
|
-
|
|
1477
|
+
forEach(inputField.cols, (col) => {
|
|
2031
1478
|
if (col.id === id) {
|
|
2032
1479
|
if (device === 'ios') {
|
|
2033
1480
|
child.inputFields.splice(fieldIndex, 3);
|
|
@@ -2040,7 +1487,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2040
1487
|
if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
|
|
2041
1488
|
const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
|
|
2042
1489
|
const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
2043
|
-
const configkeys = this.props.Templates.selectedWeChatAccount ?
|
|
1490
|
+
const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
|
|
2044
1491
|
if (configkeys.length) {
|
|
2045
1492
|
const options = configkeys[0].keys;
|
|
2046
1493
|
child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
|
|
@@ -2062,12 +1509,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2062
1509
|
backgroundColor: 'white',
|
|
2063
1510
|
textAlign: 'left',
|
|
2064
1511
|
color: '#2673D7',
|
|
2065
|
-
|
|
2066
|
-
fontSize: '14px',
|
|
2067
|
-
marginTop: '16px',
|
|
2068
|
-
fontWeight: '600',
|
|
2069
|
-
fontFamily: 'open-sans',
|
|
2070
|
-
fontStyle: 'normal',
|
|
1512
|
+
|
|
2071
1513
|
cursor: 'pointer',
|
|
2072
1514
|
},
|
|
2073
1515
|
offset: 0,
|
|
@@ -2095,12 +1537,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2095
1537
|
backgroundColor: 'white',
|
|
2096
1538
|
textAlign: 'left',
|
|
2097
1539
|
color: '#2673D7',
|
|
2098
|
-
|
|
2099
|
-
fontSize: '14px',
|
|
2100
|
-
fontWeight: '600',
|
|
2101
|
-
marginTop: '16px',
|
|
2102
|
-
fontFamily: 'open-sans',
|
|
2103
|
-
fontStyle: 'normal',
|
|
1540
|
+
|
|
2104
1541
|
cursor: 'pointer',
|
|
2105
1542
|
},
|
|
2106
1543
|
offset: 0,
|
|
@@ -2134,11 +1571,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2134
1571
|
backgroundColor: 'white',
|
|
2135
1572
|
textAlign: 'left',
|
|
2136
1573
|
color: '#2673D7',
|
|
2137
|
-
|
|
2138
|
-
fontSize: '14px',
|
|
2139
|
-
fontWeight: '600',
|
|
2140
|
-
fontFamily: 'open-sans',
|
|
2141
|
-
fontStyle: 'normal',
|
|
1574
|
+
|
|
2142
1575
|
cursor: 'pointer',
|
|
2143
1576
|
},
|
|
2144
1577
|
offset: 0,
|
|
@@ -2169,7 +1602,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2169
1602
|
this.injectEvents(schema);
|
|
2170
1603
|
};
|
|
2171
1604
|
handleOnTagsContextChange = (data) => {
|
|
2172
|
-
console.log('parent tags context', data);
|
|
2173
1605
|
const query = {
|
|
2174
1606
|
layout: 'mobilepush',
|
|
2175
1607
|
type: 'TAG',
|
|
@@ -2178,6 +1610,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2178
1610
|
};
|
|
2179
1611
|
this.props.globalActions.fetchSchemaForEntity(query);
|
|
2180
1612
|
};
|
|
1613
|
+
handleClose = () => {
|
|
1614
|
+
const formData = cloneDeep(this.state.formData);
|
|
1615
|
+
formData[this.state.currentTab - 1]['add-sec-cta-ios'] = false;
|
|
1616
|
+
this.setState({showIosCtaTable: false, formData});
|
|
1617
|
+
}
|
|
2181
1618
|
render() {
|
|
2182
1619
|
let tipText = this.props.Create.createTemplateInProgress ? "Saving Template..." : "";
|
|
2183
1620
|
let loading = this.props.Create.createTemplateInProgress ? this.props.Create.createTemplateInProgress : false;
|
|
@@ -2212,7 +1649,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2212
1649
|
onChange={this.onFormDataChange}
|
|
2213
1650
|
currentTab={this.state.currentTab}
|
|
2214
1651
|
parent={this}
|
|
2215
|
-
formData={
|
|
1652
|
+
formData={cloneDeep(this.state.formData)}
|
|
2216
1653
|
location={this.props.location}
|
|
2217
1654
|
tags={tags}
|
|
2218
1655
|
injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
|
|
@@ -2232,6 +1669,65 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
2232
1669
|
setModalContent={this.setModalContent}
|
|
2233
1670
|
/>
|
|
2234
1671
|
</Col>
|
|
1672
|
+
{this.props.iosCtasData && this.state.showIosCtaTable &&
|
|
1673
|
+
<CapSlideBox
|
|
1674
|
+
size="size-l"
|
|
1675
|
+
header={<CapHeader
|
|
1676
|
+
title={<FormattedMessage {...messages.selectActionButton} />}
|
|
1677
|
+
prefix={
|
|
1678
|
+
<PrefixWrapper>
|
|
1679
|
+
<CapIcons.backIcon onClick={this.handleClose} />
|
|
1680
|
+
</PrefixWrapper>
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
/>}
|
|
1684
|
+
content={<CapTable
|
|
1685
|
+
rowSelection={{
|
|
1686
|
+
type: 'radio',
|
|
1687
|
+
onSelect: (record) => {
|
|
1688
|
+
this.setState({templateCta: record, showIosCtaTable: false}, () => this.selectCtaIos(record));
|
|
1689
|
+
},
|
|
1690
|
+
}}
|
|
1691
|
+
dataSource={this.props.iosCtasData} columns={[
|
|
1692
|
+
{
|
|
1693
|
+
title: "Name and Description",
|
|
1694
|
+
dataIndex: "name",
|
|
1695
|
+
key: "name",
|
|
1696
|
+
width: 200,
|
|
1697
|
+
render: (text, record) => (
|
|
1698
|
+
<div>
|
|
1699
|
+
<div>{record.name}</div>
|
|
1700
|
+
<div>{record.description}</div>
|
|
1701
|
+
</div>),
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
title: "Button 1",
|
|
1705
|
+
dataIndex: "description",
|
|
1706
|
+
key: "button1",
|
|
1707
|
+
width: 100,
|
|
1708
|
+
render: (text, record) => (
|
|
1709
|
+
<div>
|
|
1710
|
+
{record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
|
|
1711
|
+
</div>),
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
title: "Button 2",
|
|
1715
|
+
dataIndex: "description",
|
|
1716
|
+
key: "button2",
|
|
1717
|
+
width: 100,
|
|
1718
|
+
render: (text, record) => (
|
|
1719
|
+
<div>
|
|
1720
|
+
{record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
|
|
1721
|
+
</div>
|
|
1722
|
+
),
|
|
1723
|
+
},
|
|
1724
|
+
]}
|
|
1725
|
+
/>}
|
|
1726
|
+
show={this.state.showIosCtaTable}
|
|
1727
|
+
handleClose={this.handleClose}
|
|
1728
|
+
/>
|
|
1729
|
+
}
|
|
1730
|
+
|
|
2235
1731
|
</Row>
|
|
2236
1732
|
</Spin>
|
|
2237
1733
|
</div>
|
|
@@ -2252,6 +1748,7 @@ Create.propTypes = {
|
|
|
2252
1748
|
intl: intlShape.isRequired,
|
|
2253
1749
|
supportedTags: PropTypes.array,
|
|
2254
1750
|
getDefaultTags: PropTypes.string,
|
|
1751
|
+
iosCtasData: PropTypes.array,
|
|
2255
1752
|
};
|
|
2256
1753
|
|
|
2257
1754
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -2259,6 +1756,7 @@ const mapStateToProps = createStructuredSelector({
|
|
|
2259
1756
|
createResponse: makeSelectCreateResponse(),
|
|
2260
1757
|
metaEntities: makeSelectMetaEntities(),
|
|
2261
1758
|
Templates: makeSelectTemplates(),
|
|
1759
|
+
iosCtasData: makeSelectIosCta(),
|
|
2262
1760
|
});
|
|
2263
1761
|
|
|
2264
1762
|
function mapDispatchToProps(dispatch) {
|