@capillarytech/creatives-library 2.0.62 → 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.
Files changed (48) hide show
  1. package/assets/NoImage1.js +50 -0
  2. package/assets/WithImage1.js +57 -0
  3. package/components/EmailPreview/assets/images/iPad.svg +10 -0
  4. package/components/EmailPreview/assets/images/mobile.png +0 -0
  5. package/components/FormBuilder/_formBuilder.scss +7 -1
  6. package/components/FormBuilder/index.js +96 -65
  7. package/components/MobilePushPreviewV2/index.js +120 -0
  8. package/components/MobilePushPreviewV2/messages.js +13 -0
  9. package/components/MobilePushPreviewV2/tests/index.test.js +10 -0
  10. package/components/TemplatePreview/index.js +1 -1
  11. package/containers/CreativesContainer/SlideBoxContent.js +27 -4
  12. package/containers/CreativesContainer/SlideBoxFooter.js +3 -3
  13. package/containers/CreativesContainer/index.js +71 -24
  14. package/containers/MobilePush/Create/_mobilePushCreate.scss +13 -0
  15. package/containers/MobilePush/Create/actions.js +6 -0
  16. package/containers/MobilePush/Create/constants.js +1 -0
  17. package/containers/MobilePush/Create/index.js +630 -1130
  18. package/containers/MobilePush/Create/messages.js +5 -1
  19. package/containers/MobilePush/Create/reducer.js +2 -0
  20. package/containers/MobilePush/Create/selectors.js +3 -3
  21. package/containers/MobilePush/Edit/_mobilePushCreate.scss +10 -0
  22. package/containers/MobilePush/Edit/index.js +375 -1106
  23. package/containers/MobilePush/Edit/messages.js +4 -0
  24. package/containers/MobilePush/Edit/reducer.js +2 -1
  25. package/containers/MobilePush/Edit/selectors.js +3 -1
  26. package/containers/MobilePush/commonMethods.js +249 -0
  27. package/containers/MobilePush/eventsMap.js +127 -0
  28. package/containers/MobilePush/initialSchema.js +1751 -0
  29. package/containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  30. package/containers/MobilepushWrapper/index.js +95 -0
  31. package/containers/MobilepushWrapper/messages.js +25 -0
  32. package/containers/MobilepushWrapper/tests/index.test.js +10 -0
  33. package/containers/WeChat/_wechat.scss +8 -0
  34. package/containers/WeChat/actions.js +52 -0
  35. package/containers/WeChat/constants.js +28 -0
  36. package/containers/WeChat/index.js +1635 -0
  37. package/containers/WeChat/messages.js +73 -0
  38. package/containers/WeChat/reducer.js +74 -0
  39. package/containers/WeChat/sagas.js +86 -0
  40. package/containers/WeChat/selectors.js +25 -0
  41. package/containers/WeChat/tests/actions.test.js +18 -0
  42. package/containers/WeChat/tests/index.test.js +10 -0
  43. package/containers/WeChat/tests/reducer.test.js +9 -0
  44. package/containers/WeChat/tests/sagas.test.js +15 -0
  45. package/containers/WeChat/tests/selectors.test.js +10 -0
  46. package/index.js +1 -1
  47. package/package.json +1 -1
  48. 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 _ from 'lodash';
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 { makeSelectCreate, makeSelectCreateResponse } from './selectors';
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: map,
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 = _.cloneDeep(this.state.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 && !_.isEqual(nextProps.Create.createTemplateError, this.props.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.Create.iosCtasData) {
228
- this.setState({iosCtasData: nextProps.Create.iosCtasData});
114
+ if (nextProps.iosCtasData) {
115
+ this.setState({showIosCtaTable: true});
229
116
  }
230
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
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 && !_.isEqual(this.props.metaEntities.tags, nextProps.metaEntities.tags)) {
251
- let injectedTags = _.cloneDeep(this.state.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 = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
256
- console.log('new injected tags', nextProps.metaEntities.tags.custom);
257
- if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
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 (!_.has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
160
+ if (!has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
261
161
  delete injectedTags["Store custom fields"];
262
162
  }
263
- if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
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
- console.log('removed listener create');
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, currentTab) => {
278
- console.log('Form data changed is ', formData, tabCount, currentTab);
279
- const newFormData = _.cloneDeep(formData);
280
- if (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`]) {
281
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].name;
282
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[0].buttonText;
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 (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1]) {
285
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1].buttonText;
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
- if (this.state.isSchemaChanged) {
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
- const schema = _.cloneDeep(this.state.schema);
333
- _.forEach(schema.containers, (container) => {
334
- _.forEach(container.panes, (pane, paneIndex) => {
335
- _.forEach(pane.sections, (section) => {
336
- _.forEach(section.childSections, (childeSection) => {
337
- _.forEach(childeSection.childSections, (child) => {
338
- const formChaild = child;
339
- if (child.type === 'multicols') {
340
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
341
- if (inputField) {
342
- _.forEach(inputField.cols, (col) => {
343
- if (col.id === field.id && paneIndex === this.state.currentTab - 1) {
344
- console.log(child, fieldIndex, this.state.formData);
345
- const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
346
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
347
- const deeplinkValue = formData[this.state.currentTab - 1][field.id];
348
- const componentIndex = fieldIndex + 1;
349
- const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
350
- if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === child.inputFields.length - 1 || child.inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
351
- const row = {
352
- rowClassName: 'mobile-push-row',
353
- id: 'cta-deeplink-select-section',
354
- cols: [
355
- {
356
- id: "cta-label",
357
- metaType: "label",
358
- value: "",
359
- primitive: true,
360
- dynamicTab: false,
361
- type: "div",
362
- width: 4,
363
- onlyDisplay: true,
364
- colStyle: {
365
- flex: 1,
366
- },
367
- },
368
- {
369
- id: inputId,
370
- placeholder: "Select DeepLink",
371
- type: "select", //Resembles component to be used
372
- options: deepLinkOptions,
373
- metaType: "text",
374
- datatype: "string",
375
- errorMessage: "Select a deeplink",
376
- required: true,
377
- fluid: true,
378
- width: 19,
379
- style: {
380
- fontSize: '14px',
381
- fontFamily: 'open-sans',
382
- fontStyle: 'normal',
383
- // fontWeight: 600,
384
- marginBottom: '16px',
385
- },
386
- styling: "semantic",
387
- order: 1,
388
- customComponent: false,
389
- supportedEvents: [
390
- 'onSelect',
391
- ],
392
- },
393
- ],
394
- };
395
- if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-external-link") {
396
- formChaild.inputFields[componentIndex] = row;
397
- } else {
398
- formChaild.inputFields.splice(componentIndex, 0, row);
399
- }
400
- } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
401
- const row = {
402
- rowClassName: 'mobile-push-row',
403
- id: 'cta-external-link',
404
- cols: [
405
- {
406
- id: "cta-label",
407
- metaType: "label",
408
- value: "",
409
- primitive: true,
410
- dynamicTab: false,
411
- type: "div",
412
- width: 4,
413
- offset: 0,
414
- onlyDisplay: true,
415
- },
416
- {
417
- id: inputId,
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 = (content) => {
473
- console.log('Template content changed to ', content);
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 = _.filter(JSON.parse(deeplinks), (l) => l.link === link);
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 map = this.state.eventsMap;
492
- if (!map[id] || !map[id][event]) {
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,11 +361,12 @@ 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);
364
+ const templateData = this.getTransformedData(this.state.formData);
507
365
  const response = {
508
366
  action: "getFormData",
509
- value: this.getTransformedData(this.state.formData),
367
+ value: templateData,
510
368
  validity: this.state.isFormValid,
369
+ type: templateData.type,
511
370
  };
512
371
  this.setState({checkValidation: true});
513
372
  if (e) {
@@ -543,7 +402,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
543
402
  });
544
403
  obj.versions.base = {};
545
404
  delete android.base;
546
- if (!_.isEmpty(android)) {
405
+ if (!isEmpty(android)) {
547
406
  obj.versions.base.ANDROID = {
548
407
  luid: "{{luid}}",
549
408
  cuid: "{{cuid}}",
@@ -554,7 +413,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
554
413
  style: "BIG_TEXT",
555
414
  message: android['message-editor'],
556
415
  },
557
- custom: _.map(android, (field, key) => {
416
+ custom: map(android, (field, key) => {
558
417
  if (key.indexOf('custom-value') > -1) {
559
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;
560
419
  }
@@ -572,7 +431,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
572
431
  delete obj.versions.base.ANDROID.cta.deepLinkName;
573
432
  }
574
433
  }
575
- if (!_.isEmpty(ios)) {
434
+ if (!isEmpty(ios)) {
576
435
  obj.versions.base.IOS = {
577
436
  luid: "{{luid}}",
578
437
  cuid: "{{cuid}}",
@@ -586,7 +445,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
586
445
  ],
587
446
  categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
588
447
  },
589
- custom: _.map(ios, (field, key) => {
448
+ custom: map(ios, (field, key) => {
590
449
  if (key.indexOf('custom-value') > -1) {
591
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;
592
451
  }
@@ -606,7 +465,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
606
465
  }
607
466
  if (obj.versions.base.ANDROID) {
608
467
  if (obj.versions.base.ANDROID.cta && obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
609
- const params = _.map(android, (field, key) => {
468
+ const params = map(android, (field, key) => {
610
469
  let actionLink;
611
470
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
612
471
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
@@ -639,7 +498,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
639
498
  }
640
499
  obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
641
500
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
642
- const params = _.map(android, (field, key) => {
501
+ const params = map(android, (field, key) => {
643
502
  let actionLink;
644
503
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
645
504
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
@@ -664,7 +523,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
664
523
  }
665
524
  obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
666
525
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
667
- const params = _.map(android, (field, key) => {
526
+ const params = map(android, (field, key) => {
668
527
  let actionLink;
669
528
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
670
529
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
@@ -681,7 +540,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
681
540
  }
682
541
  if (obj.versions.base.IOS) {
683
542
  if (obj.versions.base.IOS.cta && obj.versions.base.IOS.cta.type === "DEEP_LINK") {
684
- const params = _.map(ios, (field, key) => {
543
+ const params = map(ios, (field, key) => {
685
544
  let actionLink;
686
545
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
687
546
  const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
@@ -708,14 +567,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
708
567
  type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
709
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']),
710
569
  ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
711
- templateCtaId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].ctaTemplateDetails[0].id : undefined,
570
+ templateCtaId: get(this.state, "templateCta.ctaTemplateDetails[0].id"),
712
571
  };
713
572
  if (this.props.location.query.type === 'embedded') {
714
573
  delete cta.ioscdeepLinkName;
715
574
  }
716
575
  obj.versions.base.IOS.expandableDetails.ctas.push(cta);
717
576
  if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
718
- const params = _.map(ios, (field, key) => {
577
+ const params = map(ios, (field, key) => {
719
578
  let actionLink;
720
579
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
721
580
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
@@ -766,7 +625,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
766
625
  };
767
626
 
768
627
  moveToTemplates = () => {
769
- console.log('in move to Templates');
770
628
  const modalContent = {
771
629
  title: "Alert",
772
630
  body: this.props.intl.formatMessage(messages["Do you really want to go back? All your temporary changes will be lost!"]),
@@ -791,12 +649,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
791
649
  if (temp.standalone) {
792
650
  temp.standalone.sections = this.injectSections(temp.standalone.sections);
793
651
  }
794
- _.forEach(temp.containers, (container) => {
652
+ forEach(temp.containers, (container) => {
795
653
  let tempContainer = container;
796
654
  tempContainer = this.injectContainer(tempContainer);
797
655
  return tempContainer;
798
656
  });
799
- console.log('final injected schema', schema);
657
+
800
658
  this.setState({schema, isSchemaChanged: true}, () => {
801
659
  this.removeStandAlone();
802
660
  });
@@ -807,10 +665,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
807
665
  const temp = container;
808
666
  if (temp.type === 'tabs') {
809
667
  temp.injectedEvents = {};
810
- _.forEach(temp.supportedEvents, (event) => {
668
+ forEach(temp.supportedEvents, (event) => {
811
669
  temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
812
670
  });
813
- _.forEach(temp.panes, (pane) => {
671
+ forEach(temp.panes, (pane) => {
814
672
  const tempPane = pane;
815
673
  tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
816
674
  tempPane.sections = this.injectSections(tempPane.sections);
@@ -820,8 +678,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
820
678
  };
821
679
 
822
680
  injectMultiColSection = (section) => {
823
- _.forEach(section.inputFields, (inputField) => {
824
- _.forEach(inputField.cols, (col) => {
681
+ forEach(section.inputFields, (inputField) => {
682
+ forEach(inputField.cols, (col) => {
825
683
  const temp = col;
826
684
  if (temp.type === 'popover') {
827
685
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -839,15 +697,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
839
697
  }
840
698
  temp.injectedEvents = {};
841
699
 
842
- _.forEach(col.supportedEvents, (event) => {
843
- console.log('injected event for ', col, event);
700
+ forEach(col.supportedEvents, (event) => {
844
701
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
845
702
  });
846
703
  return true;
847
704
  });
848
705
  });
849
- _.forEach(section.actionFields, (actionField) => {
850
- _.forEach(actionField.cols, (col) => {
706
+ forEach(section.actionFields, (actionField) => {
707
+ forEach(actionField.cols, (col) => {
851
708
  const temp = col;
852
709
  if (temp.type === 'popover') {
853
710
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -855,7 +712,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
855
712
  return true;
856
713
  }
857
714
  temp.injectedEvents = {};
858
- _.forEach(col.supportedEvents, (event) => {
715
+ forEach(col.supportedEvents, (event) => {
859
716
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
860
717
  });
861
718
  return true;
@@ -865,7 +722,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
865
722
  };
866
723
 
867
724
  injectColLabelSection = (section) => {
868
- _.forEach(section.inputFields, (inputField) => {
725
+ forEach(section.inputFields, (inputField) => {
869
726
  const temp = inputField;
870
727
  if (temp.type === 'popover') {
871
728
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -873,12 +730,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
873
730
  return true;
874
731
  }
875
732
  temp.injectedEvents = {};
876
- _.forEach(inputField.supportedEvents, (event) => {
733
+ forEach(inputField.supportedEvents, (event) => {
877
734
  temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
878
735
  });
879
736
  return true;
880
737
  });
881
- _.forEach(section.actionFields, (actionField) => {
738
+ forEach(section.actionFields, (actionField) => {
882
739
  const temp = actionField;
883
740
  if (temp.type === 'popover') {
884
741
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -886,7 +743,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
886
743
  return true;
887
744
  }
888
745
  temp.injectedEvents = {};
889
- _.forEach(actionField.supportedEvents, (event) => {
746
+ forEach(actionField.supportedEvents, (event) => {
890
747
  temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
891
748
  });
892
749
  return true;
@@ -895,7 +752,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
895
752
  };
896
753
 
897
754
  injectSections = (sections) => {
898
- _.forEach(sections, (section) => {
755
+ forEach(sections, (section) => {
899
756
  let temp = section;
900
757
  if (temp.type === 'col-label') {
901
758
  temp = this.injectColLabelSection(temp);
@@ -909,7 +766,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
909
766
  };
910
767
 
911
768
  injectParentSection = (section) => {
912
- _.forEach(section.childSections, (childSection) => {
769
+ forEach(section.childSections, (childSection) => {
913
770
  let temp = childSection;
914
771
  if (temp.type === 'col-label') {
915
772
  temp = this.injectColLabelSection(temp);
@@ -944,9 +801,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
944
801
  };
945
802
 
946
803
  startTemplateCreation = (data) => {
947
- console.log('startTemplateCreation');
948
804
  const content = data.content;
949
- const id = _.uniqueId();
805
+ const id = uniqueId();
950
806
  const tempData = {
951
807
  'message-editor': content,
952
808
  'base': true,
@@ -959,18 +815,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
959
815
  };
960
816
 
961
817
  startLoading = (ifEdit) => {
962
- console.log('startLoading', ifEdit);
963
818
  if (ifEdit) {
964
819
  this.setState({loading: true});
965
820
  }
966
821
  };
967
822
 
968
823
  handleFrameTasks = (e) => {
969
- console.log('data listened to is', e.data);
970
824
  const type = e.data;
971
- console.log('data type', typeof type);
825
+
972
826
  if (typeof type === 'object') {
973
- console.log('received something', type);
974
827
  const action = type.action;
975
828
  switch (action) {
976
829
  case "startTemplateCreation":
@@ -991,15 +844,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
991
844
  this.getFormData(e);
992
845
  break;
993
846
  case "startTemplateCreation":
994
- console.log('Starting to create template');
847
+
995
848
  //this.getFormData(e);
996
849
  break;
997
850
  case "moveToTemplates":
998
- console.log('moving to templates');
851
+
999
852
  this.moveToTemplates();
1000
853
  break;
1001
854
  case "validateContent":
1002
- console.log('validating Content');
855
+
1003
856
  this.validateContent(e);
1004
857
  break;
1005
858
  default:
@@ -1009,7 +862,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1009
862
  };
1010
863
 
1011
864
  removeStandAlone = () => {
1012
- const schema = _.cloneDeep(this.state.schema);
865
+ const schema = cloneDeep(this.state.schema);
1013
866
  if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
1014
867
  schema.standalone.sections.splice(0, 1);
1015
868
  } else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') {
@@ -1021,7 +874,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1021
874
  };
1022
875
 
1023
876
  validateContent = (e) => {
1024
- console.log('posting final validation result', this.state.isFormValid);
1025
877
  const response = {
1026
878
  action: "validateContent",
1027
879
  value: this.state.isFormValid,
@@ -1054,643 +906,347 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1054
906
  copyContent = () => {
1055
907
 
1056
908
  };
1057
- addSecondoryCtaIos = (ev) => {
1058
- const id = ev.target.id;
1059
- const schema = _.cloneDeep(this.state.schema);
1060
- _.forEach(schema.containers, (container) => {
1061
- _.forEach(container.panes, (pane, paneIndex) => {
1062
- _.forEach(pane.sections, (section) => {
1063
- _.forEach(section.childSections, (childeSection) => {
1064
- _.forEach(childeSection.childSections, (child) => {
1065
- if (child.type === 'multicols') {
1066
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1067
- _.forEach(inputField.cols, (col) => {
1068
- const colId = (paneIndex + 1) > 1 ? col.id + (paneIndex + 1) : col.id;
1069
- if (colId === id) {
1070
- const inputId = `secondary-cta-${paneIndex}`;
1071
- console.log(child.inputFields, fieldIndex);
1072
- child.inputFields.splice(fieldIndex, 1, {
1073
- rowClassName: 'mobile-push-row',
1074
- cols: [
1075
- {
1076
- id: `${inputId}-label`,
1077
- metaType: "label",
1078
- value: "Secondary CTA",
1079
- primitive: true,
1080
- dynamicTab: false,
1081
- type: "div",
1082
- width: 4,
1083
- style: {
1084
- backgroundColor: 'white',
1085
- textAlign: 'left',
1086
- color: '#333333',
1087
- lineHeight: '24px',
1088
- fontSize: '14px',
1089
- fontFamily: 'open-sans',
1090
- fontStyle: 'normal',
1091
- paddingTop: '8px',
1092
- },
1093
- offset: 0,
1094
- onlyDisplay: true,
1095
- colStyle: {
1096
- flex: 1,
1097
- },
1098
- },
1099
- {
1100
- id: `${inputId}-table`,
1101
- type: "table", //Resembles component to be used
1102
- metaType: "text",
1103
- datatype: "string",
1104
- pagination: false,
1105
- columns: [
1106
- {
1107
- title: "Name and Description",
1108
- dataIndex: "name",
1109
- key: "name",
1110
- width: 200,
1111
- render: (text, record) => (
1112
- <div>
1113
- <div>{record.name}</div>
1114
- <div>{record.description}</div>
1115
- </div>),
1116
- },
1117
- {
1118
- title: "Button 1",
1119
- dataIndex: "description",
1120
- key: "button1",
1121
- width: 100,
1122
- render: (text, record) => (
1123
- <div>
1124
- {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
1125
- </div>),
1126
- },
1127
- {
1128
- title: "Button 2",
1129
- dataIndex: "description",
1130
- key: "button2",
1131
- width: 100,
1132
- render: (text, record) => (
1133
- <div>
1134
- {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
1135
- </div>
1136
- ),
1137
- },
1138
- ],
1139
- required: true,
1140
- width: 16,
1141
- fluid: true,
1142
- styling: "semantic",
1143
- order: 1,
1144
- customComponent: false,
1145
- supportedEvents: ["onRowClick"],
1146
- },
1147
- ],
1148
- });
1149
-
1150
- const colField = col;
1151
- colField.value = "Add Another CTA";
1152
- colField.fieldsCount += 1;
1153
- if (col.fieldsCount === col.fieldsLimit) {
1154
- child.inputFields.pop();
1155
- }
1156
- }
1157
- });
1158
- });
1159
- }
1160
- });
1161
- });
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
+ }
1162
931
  });
1163
932
  });
1164
- });
1165
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1166
- this.injectEvents(schema);
1167
- this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
933
+ }
1168
934
  };
1169
935
  showSelectedIosCta = (selectedConfig) => {
1170
936
  const currentTab = this.state.currentTab;
1171
- const schema = _.cloneDeep(this.state.schema);
937
+ const schema = cloneDeep(this.state.schema);
1172
938
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1173
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1174
- _.forEach(schema.containers, (container) => {
1175
- _.forEach(container.panes, (pane, paneIndex) => {
1176
- _.forEach(pane.sections, (section) => {
1177
- _.forEach(section.childSections, (childeSection) => {
1178
- _.forEach(childeSection.childSections, (child) => {
1179
- const formChaild = child;
1180
- if (child.type === 'multicols') {
1181
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1182
- _.forEach(inputField.cols, (col) => {
1183
- if (col.id.indexOf(`secondary-cta-${currentTab - 1}-table`) > -1) {
1184
- console.log(child, fieldIndex, this.state.formData);
1185
- const inputId = `secondary-cta-${paneIndex}`;
1186
-
1187
- formChaild.inputFields[fieldIndex] = {
1188
- rowClassName: 'mobile-push-row',
1189
- cols: [
1190
- {
1191
- id: `${inputId}-action-label`,
1192
- metaType: "label",
1193
- value: "Secondary CTA",
1194
- primitive: true,
1195
- dynamicTab: false,
1196
- type: "div",
1197
- width: 4,
1198
- style: {
1199
- backgroundColor: 'white',
1200
- textAlign: 'left',
1201
- color: '#333333',
1202
- lineHeight: '24px',
1203
- fontSize: '14px',
1204
- fontFamily: 'open-sans',
1205
- fontStyle: 'normal',
1206
- paddingTop: '8px',
1207
- },
1208
- offset: 0,
1209
- onlyDisplay: true,
1210
- colStyle: {
1211
- flex: 1,
1212
- },
1213
- },
1214
- {
1215
- id: `${inputId}-label`,
1216
- metaType: "label",
1217
- value: "",
1218
- primitive: true,
1219
- dynamicTab: false,
1220
- type: "div",
1221
- width: 16,
1222
- style: {
1223
- backgroundColor: 'white',
1224
- textAlign: 'left',
1225
- color: '#333333',
1226
- lineHeight: '24px',
1227
- fontSize: '14px',
1228
- fontFamily: 'open-sans',
1229
- fontStyle: 'normal',
1230
- paddingTop: '8px',
1231
- },
1232
- offset: 0,
1233
- colStyle: {
1234
- flex: 1,
1235
- },
1236
- },
1237
- {
1238
- id: `${inputId}-delete-ios`,
1239
- type: "icon",
1240
- value: 'delete',
1241
- width: 4,
1242
- submitAction: "onDelete",
1243
- supportedEvents: ["onDelete"],
1244
- },
1245
- ],
1246
- };
1247
- formChaild.inputFields[fieldIndex + 1] = {
1248
- rowClassName: 'mobile-push-row',
1249
- cols: [
1250
- {
1251
- id: `${inputId}-action-label-empty`,
1252
- metaType: "label",
1253
- value: "",
1254
- primitive: true,
1255
- dynamicTab: false,
1256
- type: "div",
1257
- width: 4,
1258
- onlyDisplay: true,
1259
- colStyle: {
1260
- flex: 1,
1261
- },
1262
- },
1263
- {
1264
- id: `${inputId}-action`,
1265
- metaType: "label",
1266
- value: "",
1267
- primitive: true,
1268
- dynamicTab: false,
1269
- type: "div",
1270
- width: 8,
1271
- offset: 0,
1272
- },
1273
- {
1274
- id: `${inputId}-action2`,
1275
- metaType: "label",
1276
- value: "",
1277
- primitive: true,
1278
- dynamicTab: false,
1279
- type: "div",
1280
- width: 8,
1281
- offset: 0,
1282
- style: {display: 'none'},
1283
- },
1284
- ],
1285
- };
1286
- if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
1287
- formChaild.inputFields[fieldIndex + 2] = {
1288
- rowClassName: "mobile-push-row",
1289
- cols: [
1290
- {
1291
- id: `${inputId}-action-label-empty`,
1292
- metaType: "label",
1293
- value: "",
1294
- primitive: true,
1295
- dynamicTab: false,
1296
- type: "div",
1297
- width: 4,
1298
- offset: 0,
1299
- onlyDisplay: true,
1300
- },
1301
- {
1302
- id: `cta-deeplink-${inputId}`,
1303
- type: "radioGroup", //Resembles component to be used
1304
- metaType: "text",
1305
- datatype: "string",
1306
- options: ["Deeplink", "External Link"],
1307
- value: "Deeplink",
1308
- required: true,
1309
- width: 16,
1310
- offSet: 4,
1311
- errorMessage: "Please select link type",
1312
- fluid: true,
1313
- style: {
1314
- fontFamily: 'open-sans',
1315
- fontSize: '14px',
1316
- lineHeight: '24px',
1317
- },
1318
- styling: "semantic",
1319
- order: 1,
1320
- supportedEvents: ["onChange"],
1321
- customComponent: false,
1322
- },
1323
- ],
1324
- };
1325
- formChaild.inputFields[fieldIndex + 3] = {
1326
- rowClassName: 'mobile-push-row',
1327
- id: 'cta-deeplink-select-section',
1328
- cols: [
1329
- {
1330
- id: "cta-label",
1331
- metaType: "label",
1332
- value: "",
1333
- primitive: true,
1334
- dynamicTab: false,
1335
- type: "div",
1336
- width: 4,
1337
- onlyDisplay: true,
1338
- colStyle: {
1339
- flex: 1,
1340
- },
1341
- },
1342
- {
1343
- id: `cta-deeplink-${inputId}-select2`,
1344
- placeholder: "Select DeepLink",
1345
- type: "select", //Resembles component to be used
1346
- options: deepLinkOptions,
1347
- metaType: "text",
1348
- datatype: "string",
1349
- errorMessage: "Select a deeplink",
1350
- required: true,
1351
- fluid: true,
1352
- width: 19,
1353
- style: {
1354
- fontSize: '14px',
1355
- fontFamily: 'open-sans',
1356
- fontStyle: 'normal',
1357
- // fontWeight: 600,
1358
- marginBottom: '16px',
1359
- },
1360
- styling: "semantic",
1361
- order: 1,
1362
- customComponent: false,
1363
- supportedEvents: [
1364
- 'onSelect',
1365
- ],
1366
- },
1367
- ],
1368
- };
1369
- }
1370
- }
1371
- });
1372
- });
1373
- }
1374
- });
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
+ ],
1375
995
  });
1376
- });
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
+ }
1377
1054
  });
1378
1055
  });
1056
+ // set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
1057
+
1379
1058
  this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1380
1059
  this.injectEvents(schema);
1381
1060
  };
1382
- addPrimaryCta = (ev) => {
1383
- const id = ev.target.id;
1384
- const schema = _.cloneDeep(this.state.schema);
1061
+ addPrimaryCta = (flag, formData, schemaField) => {
1062
+ const id = schemaField.id;
1063
+ const schema = cloneDeep(this.state.schema);
1385
1064
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1386
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1387
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1388
- _.forEach(schema.containers, (container) => {
1389
- _.forEach(container.panes, (pane) => {
1390
- _.forEach(pane.sections, (section) => {
1391
- _.forEach(section.childSections, (childeSection) => {
1392
- _.forEach(childeSection.childSections, (child) => {
1393
- if (child.type === 'multicols') {
1394
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1395
- _.forEach(inputField.cols, (col) => {
1396
- const colId = `${col.id}${this.state.currentTab > 1 ? this.state.currentTab : ''}`;
1397
- if (colId === id) {
1398
- console.log(child.inputFields, fieldIndex);
1399
- child.inputFields.splice(fieldIndex, 1, {
1400
- rowClassName: 'mobile-push-row',
1401
- cols: [
1402
- {
1403
- id: "cta-label",
1404
- metaType: "label",
1405
- value: "Primary CTA",
1406
- primitive: true,
1407
- dynamicTab: false,
1408
- type: "div",
1409
- width: 4,
1410
- style: {
1411
- backgroundColor: 'white',
1412
- textAlign: 'left',
1413
- color: '#333333',
1414
- lineHeight: '24px',
1415
- fontSize: '14px',
1416
- fontFamily: 'open-sans',
1417
- fontStyle: 'normal',
1418
- },
1419
- offset: 0,
1420
- onlyDisplay: true,
1421
- colStyle: {
1422
- flex: 1,
1423
- },
1424
- },
1425
- {
1426
- id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}`,
1427
- type: "radioGroup", //Resembles component to be used
1428
- metaType: "text",
1429
- datatype: "string",
1430
- options: ["Deeplink", "External Link"],
1431
- value: "Deeplink",
1432
- required: true,
1433
- width: 18,
1434
- errorMessage: "Please select link type",
1435
- fluid: true,
1436
- styling: "semantic",
1437
- order: 1,
1438
- customComponent: false,
1439
- supportedEvents: ["onChange"],
1440
- },
1441
- {
1442
- id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-delete`,
1443
- type: "icon",
1444
- value: 'delete',
1445
- width: 1,
1446
- submitAction: "onDelete",
1447
- supportedEvents: ["onDelete"],
1448
- },
1449
- ],
1450
- });
1451
- child.inputFields.splice(fieldIndex + 1, 0, {
1452
- rowClassName: 'mobile-push-row',
1453
- id: 'cta-deeplink-select-section',
1454
- cols: [
1455
- {
1456
- id: "cta-label",
1457
- metaType: "label",
1458
- value: "",
1459
- primitive: true,
1460
- dynamicTab: false,
1461
- type: "div",
1462
- width: 4,
1463
- onlyDisplay: true,
1464
- colStyle: {
1465
- flex: 1,
1466
- },
1467
- },
1468
- {
1469
- id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-select`,
1470
- placeholder: "Select DeepLink",
1471
- type: "select", //Resembles component to be used
1472
- options: deepLinkOptions,
1473
- metaType: "text",
1474
- datatype: "string",
1475
- required: true,
1476
- errorMessage: "Select a deeplink",
1477
- fluid: true,
1478
- width: 19,
1479
- style: {
1480
- fontSize: '14px',
1481
- fontFamily: 'open-sans',
1482
- fontStyle: 'normal',
1483
- // fontWeight: 600,
1484
- marginBottom: '16px',
1485
- },
1486
- styling: "semantic",
1487
- order: 1,
1488
- customComponent: false,
1489
- supportedEvents: [
1490
- 'onSelect',
1491
- ],
1492
- },
1493
- ],
1494
- });
1495
- }
1496
- });
1497
- });
1498
- }
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
+ ],
1499
1096
  });
1500
- });
1501
- });
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
+ }
1502
1137
  });
1503
1138
  });
1504
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1505
- this.injectEvents(schema);
1139
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true, formData}, () => this.injectEvents(schema));
1506
1140
  };
1507
- addSecondoryCta = (ev) => {
1508
- const id = ev.target.id;
1509
- const schema = _.cloneDeep(this.state.schema);
1141
+ addSecondoryCta = (flag, formData, schemaField) => {
1142
+ const id = schemaField.id;
1143
+ const schema = cloneDeep(this.state.schema);
1510
1144
  const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
1511
1145
  const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1512
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1513
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1514
- _.forEach(schema.containers, (container) => {
1515
- _.forEach(container.panes, (pane) => {
1516
- _.forEach(pane.sections, (section) => {
1517
- _.forEach(section.childSections, (childeSection) => {
1518
- _.forEach(childeSection.childSections, (child) => {
1519
- if (child.type === 'multicols') {
1520
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1521
- _.forEach(inputField.cols, (col) => {
1522
- if (col.id === id) {
1523
- if (col.fieldsCount < col.fieldsLimit) {
1524
- const inputId = `secondary-cta-${col.fieldsCount}`;
1525
- console.log(child.inputFields, fieldIndex);
1526
- child.inputFields.splice(fieldIndex, 0, {
1527
- rowClassName: 'mobile-push-row',
1528
- cols: [
1529
- {
1530
- id: `${inputId}-space`,
1531
- metaType: "label",
1532
- value: "Secondary CTA",
1533
- primitive: true,
1534
- dynamicTab: false,
1535
- type: "div",
1536
- width: 4,
1537
- style: {
1538
- backgroundColor: 'white',
1539
- textAlign: 'left',
1540
- color: '#333333',
1541
- lineHeight: '24px',
1542
- fontSize: '14px',
1543
- fontFamily: 'open-sans',
1544
- fontStyle: 'normal',
1545
- paddingTop: '8px',
1546
- },
1547
- offset: 0,
1548
- onlyDisplay: true,
1549
- colStyle: {
1550
- flex: 1,
1551
- },
1552
- },
1553
- {
1554
- id: `${inputId}-label`,
1555
- label: "link",
1556
- type: "input", //Resembles component to be used
1557
- metaType: "text",
1558
- datatype: "string",
1559
- required: true,
1560
- width: 18,
1561
- offset: 4,
1562
- placeholder: "Enter CTA Label here",
1563
- fluid: true,
1564
- styling: "semantic",
1565
- order: 1,
1566
- customComponent: false,
1567
- errorMessage: "CTA label cannot be empty.",
1568
- },
1569
- {
1570
- id: `${inputId}-delete`,
1571
- type: "icon",
1572
- value: 'delete',
1573
- width: 1,
1574
- submitAction: "onDelete",
1575
- supportedEvents: ["onDelete"],
1576
- },
1577
- ],
1578
- });
1579
- child.inputFields.splice(fieldIndex + 1, 0, {
1580
- rowClassName: 'mobile-push-row',
1581
- cols: [
1582
- {
1583
- id: `${inputId}-label-space`,
1584
- metaType: "label",
1585
- value: "",
1586
- primitive: true,
1587
- dynamicTab: false,
1588
- type: "div",
1589
- width: 4,
1590
- style: {
1591
- backgroundColor: 'white',
1592
- textAlign: 'left',
1593
- color: '#333333',
1594
- lineHeight: '24px',
1595
- fontSize: '14px',
1596
- fontFamily: 'open-sans',
1597
- fontStyle: 'normal',
1598
- paddingTop: '8px',
1599
- },
1600
- offset: 0,
1601
- onlyDisplay: true,
1602
- colStyle: {
1603
- flex: 1,
1604
- },
1605
- },
1606
- {
1607
- id: `cta-deeplink-${inputId}`,
1608
- type: "radioGroup", //Resembles component to be used
1609
- metaType: "text",
1610
- datatype: "string",
1611
- options: ["Deeplink", "External Link"],
1612
- value: "Deeplink",
1613
- required: true,
1614
- width: 16,
1615
- errorMessage: "Please select link type",
1616
- fluid: true,
1617
- styling: "semantic",
1618
- order: 1,
1619
- style: {
1620
- lineHeight: '24px',
1621
- fontSize: '14px',
1622
- },
1623
- customComponent: false,
1624
- supportedEvents: ["onChange"],
1625
- },
1626
- ],
1627
- });
1628
- child.inputFields.splice(fieldIndex + 2, 0, {
1629
- rowClassName: 'mobile-push-row',
1630
- id: 'cta-deeplink-select-section',
1631
- cols: [
1632
- {
1633
- id: "cta-label",
1634
- metaType: "label",
1635
- value: "",
1636
- primitive: true,
1637
- dynamicTab: false,
1638
- type: "div",
1639
- width: 4,
1640
- onlyDisplay: true,
1641
- colStyle: {
1642
- flex: 1,
1643
- },
1644
- },
1645
- {
1646
- id: `cta-deeplink-${inputId}-select`,
1647
- placeholder: "Select DeepLink",
1648
- type: "select", //Resembles component to be used
1649
- options: deepLinkOptions,
1650
- errorMessage: "Select a deeplink",
1651
- metaType: "text",
1652
- datatype: "string",
1653
- required: true,
1654
- fluid: true,
1655
- width: 19,
1656
- style: {
1657
- fontSize: '14px',
1658
- fontFamily: 'open-sans',
1659
- fontStyle: 'normal',
1660
- // fontWeight: 600,
1661
- marginBottom: '16px',
1662
- },
1663
- styling: "semantic",
1664
- order: 1,
1665
- customComponent: false,
1666
- supportedEvents: [
1667
- 'onSelect',
1668
- ],
1669
- },
1670
- ],
1671
- });
1672
- const colField = col;
1673
- colField.value = "Add Another CTA";
1674
- colField.fieldsCount += 1;
1675
- if (col.fieldsCount === col.fieldsLimit) {
1676
- child.inputFields.pop();
1677
- }
1678
- // eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
1679
- }
1680
- }
1681
- });
1682
- });
1683
- }
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
+ ],
1684
1176
  });
1685
- });
1686
- });
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
+ }
1687
1243
  });
1688
1244
  });
1689
1245
  this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1690
1246
  this.injectEvents(schema);
1691
1247
  };
1692
1248
  copyIphoneContent = () => {
1693
- const formData = _.cloneDeep(this.state.formData);
1249
+ const formData = cloneDeep(this.state.formData);
1694
1250
  if (!!formData[1]['message-title2'] && !!formData[1]['message-editor2']) {
1695
1251
  formData[0]['message-title'] = formData[1]['message-title2'];
1696
1252
  formData[0]['message-editor'] = formData[1]['message-editor2'];
@@ -1700,7 +1256,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1700
1256
  }
1701
1257
  };
1702
1258
  copyAndroidContent = () => {
1703
- const formData = _.cloneDeep(this.state.formData);
1259
+ const formData = cloneDeep(this.state.formData);
1704
1260
  if (!!formData[0]['message-title'] && !!formData[0]['message-editor']) {
1705
1261
  formData[1]['message-title2'] = formData[0]['message-title'];
1706
1262
  formData[1]['message-editor2'] = formData[0]['message-editor'];
@@ -1725,76 +1281,40 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1725
1281
  };
1726
1282
 
1727
1283
  showCtaKeys = (eventTriggered, formData, field) => {
1728
- console.log(this.props.Templates);
1729
- const schema = _.cloneDeep(this.state.schema);
1730
- const eventsMap = _.cloneDeep(this.state.eventsMap);
1731
- _.forEach(schema.containers, (container) => {
1732
- _.forEach(container.panes, (pane) => {
1733
- _.forEach(pane.sections, (section) => {
1734
- _.forEach(section.childSections, (childeSection) => {
1735
- _.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) => {
1736
1291
  const formChaild = child;
1737
1292
  if (child.type === 'multicols') {
1738
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1739
- _.forEach(inputField.cols, (col) => {
1293
+ forEach(child.inputFields, (inputField, fieldIndex) => {
1294
+ forEach(inputField.cols, (col) => {
1740
1295
  if (col.id === field.id) {
1741
1296
  const formDataKey = col.id.replace("-show-keys", "");
1742
1297
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1743
- let keys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][formDataKey]) : [];
1298
+ let keys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][formDataKey]) : [];
1744
1299
  if (keys[0]) {
1745
1300
  keys = keys[0].keys;
1746
1301
  }
1747
- let rows = _.map(keys, (key) => {
1302
+ let rows = map(keys, (key) => {
1748
1303
  const row = {
1749
1304
  rowClassName: 'mobile-push-row',
1750
1305
  id: 'cta-deeplink-keys',
1751
1306
  cols: [
1752
- {
1753
- id: `${key}-space`,
1754
- metaType: "label",
1755
- value: "",
1756
- primitive: true,
1757
- dynamicTab: false,
1758
- type: "div",
1759
- width: 4,
1760
- offset: 0,
1761
- onlyDisplay: true,
1762
- colStyle: {
1763
- flex: 1,
1764
- },
1765
- },
1766
- {
1767
- id: `${key}-label`,
1768
- metaType: "label",
1769
- value: key.replace('_', " "),
1770
- primitive: true,
1771
- dynamicTab: false,
1772
- type: "div",
1773
- width: 5,
1774
- style: {
1775
- backgroundColor: 'white',
1776
- textAlign: 'left',
1777
- lineHeight: '24px',
1778
- fontSize: '14px',
1779
- fontFamily: 'open-sans',
1780
- fontStyle: 'normal',
1781
- cursor: 'pointer',
1782
- paddingTop: '8px',
1783
- },
1784
- offset: 0,
1785
- onlyDisplay: true,
1786
- colStyle: {
1787
- flex: 1,
1788
- },
1789
- },
1307
+
1308
+
1790
1309
  {
1791
1310
  id: `custom-value-${key}-${col.id}`,
1792
- label: "value",
1311
+ label: key.replace('_', " "),
1793
1312
  type: "input", //Resembles component to be used
1794
1313
  metaType: "text",
1795
1314
  datatype: "string",
1796
1315
  required: true,
1797
- width: 14,
1316
+ width: 18,
1317
+ offset: 1,
1798
1318
  placeholder: `Please input ${key.replace('_', " ")} here .`,
1799
1319
  fluid: true,
1800
1320
  styling: "semantic",
@@ -1808,9 +1328,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1808
1328
  return row;
1809
1329
  // formChaild.inputFields[fieldIndex + index] = field;
1810
1330
  });
1811
- console.log(formChaild);
1812
- console.log("this in getctakeys", this);
1813
- const configkeys = _.filter(JSON.parse(deeplinks), (dl) => dl.link === this.state.formData[this.state.currentTab - 1][field.id]);
1331
+
1332
+
1333
+ const configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === this.state.formData[this.state.currentTab - 1][field.id]);
1814
1334
  if (configkeys.length) {
1815
1335
  const options = configkeys[0].keys;
1816
1336
  formChaild.inputFields = formChaild.inputFields.slice(0, fieldIndex + 1).concat(formChaild.inputFields.slice( fieldIndex + options.length + 1, formChaild.inputFields.length));
@@ -1837,109 +1357,42 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1837
1357
  this.injectEvents(schema);
1838
1358
  };
1839
1359
  saveFormData = (formData) => {
1840
- console.log('Saving form data', formData, this.state.tabCount);
1841
1360
  const obj = this.getTransformedData(formData);
1842
- console.log('obj', obj);
1361
+
1843
1362
  this.props.actions.createTemplate(obj);
1844
1363
  };
1845
- deleteSecondaryCtaIos = (event) => {
1846
- const id = event.currentTarget.id;
1847
- const schema = _.cloneDeep(this.state.schema);
1848
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1849
- const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1850
- const formData = _.cloneDeep(this.state.formData);
1851
- const self = this;
1852
- const device = this.state.currentTab === 1 ? 'android' : 'ios';
1853
- _.forEach(schema.containers, (container) => {
1854
- _.forEach(container.panes, (pane) => {
1855
- _.forEach(pane.sections, (section) => {
1856
- _.forEach(section.childSections, (childeSection) => {
1857
- _.forEach(childeSection.childSections, (formChild) => {
1858
- const child = formChild;
1859
- if (child.type === 'multicols') {
1860
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1861
- if (inputField) {
1862
- _.forEach(inputField.cols, (col) => {
1863
- if (col.id === id) {
1864
- child.inputFields.splice(fieldIndex, 3);
1865
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1866
- child.inputFields.splice(fieldIndex, 1);
1867
- }
1868
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1869
- const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1870
- const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1871
- if (configkeys.length) {
1872
- const options = configkeys[0].keys;
1873
- child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1874
- delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1875
- delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1876
- } else {
1877
- child.inputFields.splice(fieldIndex, 1);
1878
- }
1879
- }
1880
- if (device === 'ios') {
1881
- child.inputFields[fieldIndex] = {
1882
- cols: [
1883
- {
1884
- id: "add-sec-cta-ios",
1885
- metaType: "label",
1886
- value: "Add Secondary CTA",
1887
- primitive: true,
1888
- dynamicTab: false,
1889
- type: "div",
1890
- style: {
1891
- backgroundColor: 'white',
1892
- textAlign: 'left',
1893
- color: '#2673D7',
1894
- lineHeight: '24px',
1895
- marginTop: '16px',
1896
- fontSize: '14px',
1897
- fontWeight: '600',
1898
- fontFamily: 'open-sans',
1899
- fontStyle: 'normal',
1900
- cursor: 'pointer',
1901
- },
1902
- offset: 0,
1903
- onlyDisplay: true,
1904
- colStyle: {
1905
- flex: 1,
1906
- },
1907
- submitAction: "addSecondaryCtaIos",
1908
- supportedEvents: ["addSecondaryCtaIos"],
1909
- },
1910
- ],
1911
- };
1912
- }
1913
- }
1914
- });
1915
- }
1916
- });
1917
- }
1918
- });
1919
- });
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
+ }
1920
1373
  });
1921
- });
1374
+ }
1922
1375
  });
1923
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1376
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, callback);
1924
1377
  this.injectEvents(schema);
1925
1378
  };
1926
1379
  deletePrimaryCTA = (event) => {
1927
1380
  const id = event.currentTarget.id;
1928
- const schema = _.cloneDeep(this.state.schema);
1929
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1381
+ const schema = cloneDeep(this.state.schema);
1382
+ // const eventsMap = cloneDeep(this.state.eventsMap);
1930
1383
  const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1931
- const formData = _.cloneDeep(this.state.formData);
1384
+ const formData = cloneDeep(this.state.formData);
1932
1385
  const self = this;
1933
- _.forEach(schema.containers, (container) => {
1934
- _.forEach(container.panes, (pane) => {
1935
- _.forEach(pane.sections, (section) => {
1936
- _.forEach(section.childSections, (childeSection) => {
1937
- _.forEach(childeSection.childSections, (formChild) => {
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) => {
1938
1391
  const child = formChild;
1939
1392
  if (child.type === 'multicols') {
1940
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1393
+ forEach(child.inputFields, (inputField, fieldIndex) => {
1941
1394
  if (inputField) {
1942
- _.forEach(inputField.cols, (col) => {
1395
+ forEach(inputField.cols, (col) => {
1943
1396
  if (col.id === id) {
1944
1397
  child.inputFields.splice(fieldIndex, 1);
1945
1398
  if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
@@ -1947,7 +1400,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1947
1400
  }
1948
1401
  if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1949
1402
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1950
- const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1403
+ const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1951
1404
  if (configkeys.length) {
1952
1405
  const options = configkeys[0].keys;
1953
1406
  child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
@@ -1970,11 +1423,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1970
1423
  backgroundColor: 'white',
1971
1424
  textAlign: 'left',
1972
1425
  color: '#2673D7',
1973
- lineHeight: '24px',
1974
- fontSize: '14px',
1975
- fontWeight: '600',
1976
- fontFamily: 'open-sans',
1977
- fontStyle: 'normal',
1426
+
1978
1427
  cursor: 'pointer',
1979
1428
  },
1980
1429
  offset: 0,
@@ -2011,21 +1460,21 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2011
1460
  return;
2012
1461
  }
2013
1462
  }
2014
- const schema = _.cloneDeep(this.state.schema);
2015
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1463
+ const schema = cloneDeep(this.state.schema);
1464
+ // const eventsMap = cloneDeep(this.state.eventsMap);
2016
1465
  const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
2017
- const formData = _.cloneDeep(this.state.formData);
1466
+ const formData = cloneDeep(this.state.formData);
2018
1467
  const device = this.state.currentTab === 1 ? 'android' : 'ios';
2019
- _.forEach(schema.containers, (container) => {
2020
- _.forEach(container.panes, (pane) => {
2021
- _.forEach(pane.sections, (section) => {
2022
- _.forEach(section.childSections, (childeSection) => {
2023
- _.forEach(childeSection.childSections, (formChild) => {
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) => {
2024
1473
  const child = formChild;
2025
1474
  if (child.type === 'multicols') {
2026
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1475
+ forEach(child.inputFields, (inputField, fieldIndex) => {
2027
1476
  if (inputField) {
2028
- _.forEach(inputField.cols, (col) => {
1477
+ forEach(inputField.cols, (col) => {
2029
1478
  if (col.id === id) {
2030
1479
  if (device === 'ios') {
2031
1480
  child.inputFields.splice(fieldIndex, 3);
@@ -2038,7 +1487,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2038
1487
  if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
2039
1488
  const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
2040
1489
  const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
2041
- const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1490
+ const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
2042
1491
  if (configkeys.length) {
2043
1492
  const options = configkeys[0].keys;
2044
1493
  child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
@@ -2060,12 +1509,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2060
1509
  backgroundColor: 'white',
2061
1510
  textAlign: 'left',
2062
1511
  color: '#2673D7',
2063
- lineHeight: '24px',
2064
- fontSize: '14px',
2065
- marginTop: '16px',
2066
- fontWeight: '600',
2067
- fontFamily: 'open-sans',
2068
- fontStyle: 'normal',
1512
+
2069
1513
  cursor: 'pointer',
2070
1514
  },
2071
1515
  offset: 0,
@@ -2093,12 +1537,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2093
1537
  backgroundColor: 'white',
2094
1538
  textAlign: 'left',
2095
1539
  color: '#2673D7',
2096
- lineHeight: '24px',
2097
- fontSize: '14px',
2098
- fontWeight: '600',
2099
- marginTop: '16px',
2100
- fontFamily: 'open-sans',
2101
- fontStyle: 'normal',
1540
+
2102
1541
  cursor: 'pointer',
2103
1542
  },
2104
1543
  offset: 0,
@@ -2132,11 +1571,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2132
1571
  backgroundColor: 'white',
2133
1572
  textAlign: 'left',
2134
1573
  color: '#2673D7',
2135
- lineHeight: '24px',
2136
- fontSize: '14px',
2137
- fontWeight: '600',
2138
- fontFamily: 'open-sans',
2139
- fontStyle: 'normal',
1574
+
2140
1575
  cursor: 'pointer',
2141
1576
  },
2142
1577
  offset: 0,
@@ -2167,7 +1602,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2167
1602
  this.injectEvents(schema);
2168
1603
  };
2169
1604
  handleOnTagsContextChange = (data) => {
2170
- console.log('parent tags context', data);
2171
1605
  const query = {
2172
1606
  layout: 'mobilepush',
2173
1607
  type: 'TAG',
@@ -2176,6 +1610,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2176
1610
  };
2177
1611
  this.props.globalActions.fetchSchemaForEntity(query);
2178
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
+ }
2179
1618
  render() {
2180
1619
  let tipText = this.props.Create.createTemplateInProgress ? "Saving Template..." : "";
2181
1620
  let loading = this.props.Create.createTemplateInProgress ? this.props.Create.createTemplateInProgress : false;
@@ -2210,13 +1649,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2210
1649
  onChange={this.onFormDataChange}
2211
1650
  currentTab={this.state.currentTab}
2212
1651
  parent={this}
2213
- formData={_.cloneDeep(this.state.formData)}
1652
+ formData={cloneDeep(this.state.formData)}
2214
1653
  location={this.props.location}
2215
1654
  tags={tags}
2216
1655
  injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
2217
1656
  onFormValidityChange={this.setFormValidity}
2218
1657
  usingTabContainer
2219
- checkValidation={false}
1658
+ checkValidation={this.state.checkValidation}
2220
1659
  iosCtasData={this.state.iosCtasData}
2221
1660
  tabKey={this.state.tabKey}
2222
1661
  tabCount={2}
@@ -2230,6 +1669,65 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2230
1669
  setModalContent={this.setModalContent}
2231
1670
  />
2232
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
+
2233
1731
  </Row>
2234
1732
  </Spin>
2235
1733
  </div>
@@ -2250,6 +1748,7 @@ Create.propTypes = {
2250
1748
  intl: intlShape.isRequired,
2251
1749
  supportedTags: PropTypes.array,
2252
1750
  getDefaultTags: PropTypes.string,
1751
+ iosCtasData: PropTypes.array,
2253
1752
  };
2254
1753
 
2255
1754
  const mapStateToProps = createStructuredSelector({
@@ -2257,6 +1756,7 @@ const mapStateToProps = createStructuredSelector({
2257
1756
  createResponse: makeSelectCreateResponse(),
2258
1757
  metaEntities: makeSelectMetaEntities(),
2259
1758
  Templates: makeSelectTemplates(),
1759
+ iosCtasData: makeSelectIosCta(),
2260
1760
  });
2261
1761
 
2262
1762
  function mapDispatchToProps(dispatch) {