@capillarytech/creatives-library 2.0.80 → 2.0.81

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 (82) hide show
  1. package/components/FormBuilder/index.js +2 -1
  2. package/components/FormBuilder/test +1845 -0
  3. package/containers/CallTask/_callTask.scss +5 -0
  4. package/containers/CallTask/actions.js +15 -0
  5. package/containers/CallTask/constants.js +7 -0
  6. package/containers/CallTask/index.js +141 -0
  7. package/containers/CallTask/messages.js +21 -0
  8. package/containers/CallTask/reducer.js +23 -0
  9. package/containers/CallTask/sagas.js +11 -0
  10. package/containers/CallTask/selectors.js +25 -0
  11. package/containers/CallTask/tests/actions.test.js +18 -0
  12. package/containers/CallTask/tests/index.test.js +10 -0
  13. package/containers/CallTask/tests/reducer.test.js +9 -0
  14. package/containers/CallTask/tests/sagas.test.js +15 -0
  15. package/containers/CallTask/tests/selectors.test.js +10 -0
  16. package/containers/ChannelTemplates/actions.js +20 -0
  17. package/containers/ChannelTemplates/constants.js +8 -0
  18. package/containers/ChannelTemplates/index.js +48 -0
  19. package/containers/ChannelTemplates/messages.js +13 -0
  20. package/containers/ChannelTemplates/reducer.js +34 -0
  21. package/containers/ChannelTemplates/sagas.js +32 -0
  22. package/containers/ChannelTemplates/selectors.js +25 -0
  23. package/containers/ChannelTemplates/tests/actions.test.js +18 -0
  24. package/containers/ChannelTemplates/tests/index.test.js +10 -0
  25. package/containers/ChannelTemplates/tests/reducer.test.js +9 -0
  26. package/containers/ChannelTemplates/tests/sagas.test.js +15 -0
  27. package/containers/ChannelTemplates/tests/selectors.test.js +10 -0
  28. package/containers/CreativesContainer/SlideBoxContent.js +248 -0
  29. package/containers/CreativesContainer/SlideBoxFooter.js +38 -0
  30. package/containers/CreativesContainer/SlideBoxHeader.js +65 -0
  31. package/containers/CreativesContainer/actions.js +27 -0
  32. package/containers/CreativesContainer/constants.js +13 -0
  33. package/containers/CreativesContainer/index.js +418 -0
  34. package/containers/CreativesContainer/index.scss +27 -0
  35. package/containers/CreativesContainer/messages.js +17 -0
  36. package/containers/CreativesContainer/reducer.js +29 -0
  37. package/containers/CreativesContainer/sagas.js +11 -0
  38. package/containers/CreativesContainer/selectors.js +30 -0
  39. package/containers/CreativesContainer/tests/actions.test.js +18 -0
  40. package/containers/CreativesContainer/tests/index.test.js +10 -0
  41. package/containers/CreativesContainer/tests/reducer.test.js +9 -0
  42. package/containers/CreativesContainer/tests/sagas.test.js +15 -0
  43. package/containers/CreativesContainer/tests/selectors.test.js +10 -0
  44. package/containers/EmailWrapper/actions.js +15 -0
  45. package/containers/EmailWrapper/constants.js +7 -0
  46. package/containers/EmailWrapper/index.js +238 -0
  47. package/containers/EmailWrapper/messages.js +57 -0
  48. package/containers/EmailWrapper/reducer.js +23 -0
  49. package/containers/EmailWrapper/sagas.js +11 -0
  50. package/containers/EmailWrapper/selectors.js +25 -0
  51. package/containers/EmailWrapper/tests/actions.test.js +18 -0
  52. package/containers/EmailWrapper/tests/index.test.js +10 -0
  53. package/containers/EmailWrapper/tests/reducer.test.js +9 -0
  54. package/containers/EmailWrapper/tests/sagas.test.js +15 -0
  55. package/containers/EmailWrapper/tests/selectors.test.js +10 -0
  56. package/containers/MobilePush/commonMethods.js +249 -0
  57. package/containers/MobilePush/eventsMap.js +127 -0
  58. package/containers/MobilePush/initialSchema.js +1739 -0
  59. package/containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  60. package/containers/MobilepushWrapper/index.js +97 -0
  61. package/containers/MobilepushWrapper/messages.js +25 -0
  62. package/containers/MobilepushWrapper/tests/index.test.js +10 -0
  63. package/containers/TemplatesV2/_templatesV2.scss +5 -0
  64. package/containers/TemplatesV2/actions.js +16 -0
  65. package/containers/TemplatesV2/constants.js +10 -0
  66. package/containers/TemplatesV2/index.js +207 -0
  67. package/containers/TemplatesV2/messages.js +29 -0
  68. package/containers/TemplatesV2/selectors.js +25 -0
  69. package/containers/TemplatesV2/tests/actions.test.js +18 -0
  70. package/containers/TemplatesV2/tests/index.test.js +10 -0
  71. package/containers/TemplatesV2/tests/reducer.test.js +9 -0
  72. package/containers/TemplatesV2/tests/sagas.test.js +15 -0
  73. package/containers/TemplatesV2/tests/selectors.test.js +10 -0
  74. package/containers/WeChat/RichmediaTemplates/Create/testschema.js +379 -0
  75. package/containers/WeChat/actions.js +6 -0
  76. package/containers/WeChat/index.js +31 -13
  77. package/package.json +1 -1
  78. package/v2Containers/MobilePush/Create/index.js +43 -9
  79. package/v2Containers/MobilePush/Create/messages.js +16 -0
  80. package/v2Containers/MobilePush/Edit/index.js +54 -22
  81. package/v2Containers/MobilePush/Edit/messages.js +17 -1
  82. package/v2Containers/MobilePush/commonMethods.js +9 -7
@@ -0,0 +1,379 @@
1
+ export default {
2
+ standalone: {
3
+ sections: [
4
+ {
5
+ type: "multicols",
6
+ inputFields: [
7
+ {
8
+ rowClassName: "wechat-richmedia-row",
9
+ cols: [
10
+ {
11
+ id: "title-label",
12
+ metaType: "label",
13
+ value: "Title",
14
+ primitive: true,
15
+ dynamicTab: false,
16
+ type: "div",
17
+ width: 4,
18
+ style: {
19
+ backgroundColor: "white",
20
+ textAlign: "left",
21
+ color: "#333333",
22
+ lineHeight: "24px",
23
+ fontSize: "14px",
24
+ fontFamily: "open-sans",
25
+ fontStyle: "normal",
26
+ },
27
+ onlyDisplay: true,
28
+ colStyle: {
29
+ flex: 1,
30
+ },
31
+ },
32
+ {
33
+ id: "title-value",
34
+ label: "Title",
35
+ type: "input",
36
+ metaType: "text",
37
+ datatype: "string",
38
+ required: true,
39
+ width: 16,
40
+ placeholder: "Please input title",
41
+ fluid: true,
42
+ styling: "semantic",
43
+ order: 1,
44
+ disabled: false,
45
+ customComponent: false,
46
+ onlyDisplay: false,
47
+ supportedEvents: [
48
+ "onChange",
49
+ ],
50
+ errorMessage: "This field is required!",
51
+ }],
52
+ },
53
+ {
54
+ rowClassName: "wechat-richmedia-row",
55
+ cols: [
56
+ {
57
+ id: "author-label",
58
+ metaType: "label",
59
+ value: "Author",
60
+ primitive: true,
61
+ dynamicTab: false,
62
+ type: "div",
63
+ width: 4,
64
+ style: {
65
+ backgroundColor: "white",
66
+ textAlign: "left",
67
+ color: "#333333",
68
+ lineHeight: "24px",
69
+ fontSize: "14px",
70
+ fontFamily: "open-sans",
71
+ fontStyle: "normal",
72
+ },
73
+ onlyDisplay: true,
74
+ colStyle: {
75
+ flex: 1,
76
+ },
77
+ },
78
+ {
79
+ id: "author-value",
80
+ label: "Author",
81
+ type: "input",
82
+ metaType: "text",
83
+ datatype: "string",
84
+ required: true,
85
+ width: 16,
86
+ placeholder: "Please input author",
87
+ fluid: true,
88
+ styling: "semantic",
89
+ order: 1,
90
+ disabled: false,
91
+ customComponent: false,
92
+ supportedEvents: [
93
+ "onChange",
94
+ ],
95
+ errorMessage: "This field is required!",
96
+ }],
97
+ },
98
+ {
99
+ rowClassName: "wechat-richmedia-row",
100
+ cols: [
101
+ {
102
+ id: "image-label",
103
+ metaType: "label",
104
+ value: "Cover image",
105
+ primitive: true,
106
+ dynamicTab: false,
107
+ type: "div",
108
+ width: 4,
109
+ style: {
110
+ backgroundColor: "white",
111
+ textAlign: "left",
112
+ color: "#333333",
113
+ lineHeight: "24px",
114
+ fontSize: "14px",
115
+ fontFamily: "open-sans",
116
+ fontStyle: "normal",
117
+ },
118
+ offset: 0,
119
+ onlyDisplay: true,
120
+ colStyle: {
121
+ flex: 1,
122
+ },
123
+ },
124
+ {
125
+ id: "image-value",
126
+ label: "Upload Image",
127
+ type: "upload",
128
+ width: 5,
129
+ metaType: "text",
130
+ datatype: "string",
131
+ required: true,
132
+ fluid: true,
133
+ styling: "semantic",
134
+ order: 1,
135
+ disabled: false,
136
+ customComponent: true,
137
+ submitAction: "onUpload",
138
+ supportedEvents: [
139
+ "onUpload",
140
+ ],
141
+ }],
142
+ },
143
+ {
144
+ rowClassName: "wechat-richmedia-row",
145
+ cols: [
146
+ {
147
+ id: "cover-abstract-label",
148
+ metaType: "label",
149
+ value: "Cover abstract",
150
+ primitive: true,
151
+ dynamicTab: false,
152
+ type: "div",
153
+ width: 4,
154
+ style: {
155
+ backgroundColor: "white",
156
+ textAlign: "left",
157
+ color: "#333333",
158
+ lineHeight: "24px",
159
+ fontSize: "14px",
160
+ fontFamily: "open-sans",
161
+ fontStyle: "normal",
162
+ },
163
+ onlyDisplay: true,
164
+ colStyle: {
165
+ flex: 1,
166
+ },
167
+ },
168
+ {
169
+ id: "cover-abstract-value",
170
+ label: "Cover abstract",
171
+ type: "input",
172
+ metaType: "text",
173
+ datatype: "string",
174
+ required: true,
175
+ width: 16,
176
+ placeholder: "Please input cover abstract",
177
+ fluid: true,
178
+ styling: "semantic",
179
+ order: 1,
180
+ disabled: false,
181
+ customComponent: false,
182
+ supportedEvents: [
183
+ "onChange",
184
+ ],
185
+ errorMessage: "This field is required!",
186
+ }],
187
+ },
188
+ {
189
+ rowClassName: "wechat-richmedia-row",
190
+ cols: [
191
+ {
192
+ id: "source-link-label",
193
+ metaType: "label",
194
+ value: "Source link",
195
+ primitive: true,
196
+ dynamicTab: false,
197
+ type: "div",
198
+ width: 4,
199
+ style: {
200
+ backgroundColor: "white",
201
+ textAlign: "left",
202
+ color: "#333333",
203
+ lineHeight: "24px",
204
+ fontSize: "14px",
205
+ fontFamily: "open-sans",
206
+ fontStyle: "normal",
207
+ },
208
+ onlyDisplay: true,
209
+ colStyle: {
210
+ flex: 1,
211
+ },
212
+ },
213
+ {
214
+ id: "source-link-value",
215
+ label: "Cover abstract",
216
+ type: "input",
217
+ metaType: "text",
218
+ datatype: "string",
219
+ required: true,
220
+ width: 16,
221
+ placeholder: "Please input source link",
222
+ fluid: true,
223
+ styling: "semantic",
224
+ order: 1,
225
+ disabled: false,
226
+ customComponent: false,
227
+ supportedEvents: [
228
+ "onChange",
229
+ ],
230
+ errorMessage: "This field is required!",
231
+ }],
232
+ },
233
+ {
234
+ rowClassName: "wechat-richmedia-row",
235
+ cols: [
236
+ {
237
+ id: "content-label",
238
+ metaType: "label",
239
+ value: "Content",
240
+ primitive: true,
241
+ dynamicTab: false,
242
+ type: "div",
243
+ width: 4,
244
+ style: {
245
+ backgroundColor: "white",
246
+ textAlign: "left",
247
+ color: "#333333",
248
+ lineHeight: "24px",
249
+ fontSize: "14px",
250
+ fontFamily: "open-sans",
251
+ fontStyle: "normal",
252
+ },
253
+ onlyDisplay: true,
254
+
255
+ },
256
+ {
257
+ id: "content-value",
258
+ label: "Content",
259
+ type: "textarea",
260
+ metaType: "text",
261
+ datatype: "string",
262
+ required: true,
263
+ errorMessage: "This field is required!",
264
+ placeholder: "Please input content",
265
+ fluid: false,
266
+ styling: "semantic",
267
+ onlyDisplay: false,
268
+ width: 16,
269
+ disabled: false,
270
+ autosize: true,
271
+ autosizeParams: {
272
+ maxRows: 18,
273
+ minRows: 3,
274
+ },
275
+ order: 2,
276
+ customComponent: true,
277
+ supportedEvents: [
278
+ "onChange",
279
+ ],
280
+ }],
281
+ },
282
+ {
283
+ rowClassName: "wechat-richmedia-row",
284
+ cols: [
285
+ {
286
+ id: "show-cover-pic-label",
287
+ metaType: "label",
288
+ value: "Show cover picture",
289
+ primitive: true,
290
+ dynamicTab: false,
291
+ type: "div",
292
+ width: 4,
293
+ style: {
294
+ backgroundColor: "white",
295
+ textAlign: "left",
296
+ color: "#333333",
297
+ lineHeight: "24px",
298
+ fontSize: "14px",
299
+ fontFamily: "open-sans",
300
+ fontStyle: "normal",
301
+ },
302
+ offset: 0,
303
+ onlyDisplay: true,
304
+ colStyle: {
305
+ flex: 1,
306
+ },
307
+ },
308
+ {
309
+ id: "show-cover-pic-value",
310
+ supportedEvents: [
311
+ "onChange",
312
+ ],
313
+ type: "checkbox",
314
+ metaType: "text",
315
+ datatype: "boolean",
316
+ required: true,
317
+ fluid: true,
318
+ styling: "semantic",
319
+ order: 1,
320
+ width: 10,
321
+ offset: 0,
322
+ value: 0,
323
+ onlyDisplay: false,
324
+ disabled: false,
325
+ errorMessage: "Please check if you intend to use unicode characters.",
326
+ customComponent: false,
327
+ }],
328
+ },
329
+ {
330
+ rowClassName: "wechat-richmedia-row",
331
+ cols: [
332
+ {
333
+ id: "post-comments-label",
334
+ metaType: "label",
335
+ value: "Who can post comments on this content",
336
+ primitive: true,
337
+ dynamicTab: false,
338
+ type: "div",
339
+ width: 4,
340
+ style: {
341
+ backgroundColor: "white",
342
+ textAlign: "left",
343
+ color: "#333333",
344
+ lineHeight: "24px",
345
+ fontSize: "14px",
346
+ fontFamily: "open-sans",
347
+ fontStyle: "normal",
348
+ },
349
+ offset: 0,
350
+ onlyDisplay: true,
351
+ colStyle: {
352
+ flex: 1,
353
+ },
354
+ },
355
+ {
356
+ id: "post-comments-value",
357
+ type: "radioGroup",
358
+ metaType: "text",
359
+ datatype: "string",
360
+ options: ["No one", "Anyone", "Only followers"],
361
+ value: "No one",
362
+ required: true,
363
+ width: 18,
364
+ errorMessage: "Please select",
365
+ fluid: true,
366
+ styling: "semantic",
367
+ order: 1,
368
+ disabled: false,
369
+ customComponent: false,
370
+ supportedEvents: ["onChange"],
371
+ }],
372
+ }],
373
+ actionFields: [],
374
+ }],
375
+ },
376
+
377
+ channel: "WECHAT",
378
+ module: "Campaigns",
379
+ };
@@ -44,3 +44,9 @@ export function getTemplateDetails(id) {
44
44
  type: types.GET_TEMPLATE_DETAILS_REQUEST, id,
45
45
  };
46
46
  }
47
+ export function setTemplateDetails(templateDetails) {
48
+ return {
49
+ type: types.GET_TEMPLATE_DETAILS_SUCCESS,
50
+ data: templateDetails,
51
+ };
52
+ }
@@ -4,13 +4,14 @@
4
4
  *
5
5
  */
6
6
 
7
- import React, { PropTypes } from 'react';
7
+ import PropTypes from 'prop-types';
8
+
9
+ import React from 'react';
8
10
  import { connect } from 'react-redux';
9
11
  import { bindActionCreators } from 'redux';
10
12
  import Helmet from 'react-helmet';
11
13
  import { injectIntl, intlShape } from 'react-intl';
12
14
  import { createStructuredSelector } from 'reselect';
13
- // import { CapButton, CapSelect } from '@capillarytech/cap-react-ui-library';
14
15
  import { Row, Col, Spin } from 'antd';
15
16
  import _ from 'lodash';
16
17
  import { makeSelectTemplates } from '../Templates/selectors';
@@ -21,10 +22,12 @@ import * as actions from './actions';
21
22
  import FormBuilder from '../../components/FormBuilder';
22
23
  import { UserIsAuthenticated } from '../../utils/authWrapper';
23
24
  import * as globalActions from '../../containers/Cap/actions';
25
+ import * as templateActions from '../../containers/Templates/actions';
24
26
  import {getMessageObject} from '../../utils/messageUtils';
25
27
  // import SlideBox from '../../components/SlideBox';
26
28
  // import PageHeader from '../../components/PageHeader';
27
29
  import './_wechat.scss';
30
+ import callNativeEvent from '../../utils/callNativeEvent';
28
31
 
29
32
  // const Option = Select.Option;
30
33
 
@@ -401,6 +404,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
401
404
  sortBy: 'Most Recent',
402
405
  wecrmId: this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id,
403
406
  wecrmToken: this.props.Templates.selectedWeChatAccount.configs.wecrm_token,
407
+ originalId: this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier,
404
408
  };
405
409
  this.props.actions.getDefaultWeChatTemplates('wechat', params);
406
410
  } else {
@@ -433,7 +437,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
433
437
  }
434
438
 
435
439
  componentWillReceiveProps(nextProps) {
436
- if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
440
+ if (nextProps.isGetFormData) {
437
441
  this.getFormData();
438
442
  }
439
443
  console.log('MetaEntity nextprops ', nextProps.metaEntities);
@@ -481,7 +485,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
481
485
  this.setState({isEdit: true});
482
486
  }
483
487
  if (this.state.isEdit && _.isEmpty(this.state.editTemplateData) && !_.isEmpty(nextProps.WeChat.weChatTemplates)) {
484
- const templateIndex = _.findIndex(nextProps.WeChat.weChatTemplates, {"_id": nextProps.params.id});
488
+ const templateIndex = _.findIndex(nextProps.WeChat.weChatTemplates, {_id: nextProps.params.id});
485
489
  this.setState({editTemplateData: nextProps.WeChat.weChatTemplates[templateIndex]}, () => {
486
490
  if (_.isEmpty(this.state.baseSchema)) {
487
491
  this.setState({ baseSchema: _.cloneDeep(this.state.schema)}, () => {
@@ -541,6 +545,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
541
545
  sortBy: 'Most Recent',
542
546
  wecrmId: nextProps.WeChat.selectedWeChatAccount.configs.wecrm_app_id,
543
547
  wecrmToken: nextProps.WeChat.selectedWeChatAccount.configs.wecrm_token,
548
+ originalId: nextProps.WeChat.selectedWeChatAccount.sourceAccountIdentifier,
544
549
  };
545
550
  this.props.actions.getDefaultWeChatTemplates('wechat', params);
546
551
  }
@@ -597,11 +602,11 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
597
602
  componentWillUnmount() {
598
603
  console.log('removed listener create');
599
604
  window.removeEventListener("message", this.handleFrameTasks);
605
+ this.props.templateActions.resetTemplate();
600
606
  this.resetState();
601
607
  }
602
608
 
603
609
  onFormDataChange(formData) {
604
- console.log('Form Data Change ', formData);
605
610
  let selectedWechatTemplateIndex = -1;
606
611
  let selectedTemplate = {};
607
612
  let selectedTemplateData = {};
@@ -640,6 +645,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
640
645
  selectedWechatTemplateIndex = _.findIndex(this.props.WeChat.weChatDefaultTemplate, {template_id: formData['wechat-template']});
641
646
  selectedTemplate = this.props.WeChat.weChatDefaultTemplate[selectedWechatTemplateIndex];
642
647
  }
648
+
643
649
  if (!_.isEqual(formData['wechat-template'], this.state.formData['wechat-template'])) {
644
650
  this.updateSchema = true;
645
651
  }
@@ -692,8 +698,8 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
692
698
  console.log('posting final result', this.state.formData, this.state.editTemplateData);
693
699
  const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.WeChat.selectedWeChatAccount);
694
700
  const data = {
695
- "template_id": this.state.editTemplateData.versions.base.template_id,
696
- "Title": this.state.editTemplateData.versions.base.Title,
701
+ template_id: this.state.editTemplateData.versions.base.template_id,
702
+ Title: this.state.editTemplateData.versions.base.Title,
697
703
  Tag: [],
698
704
  url: this.state.formData['is-internal-url'] ? this.maskTemplateUrl(this.state.formData['template-link']) : this.state.formData['template-link'],
699
705
  TopColor: "#000000",
@@ -704,6 +710,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
704
710
  content: this.state.editTemplateData.versions.base.content,
705
711
  isInternalUrl: this.state.formData['is-internal-url'],
706
712
  creative_template_id: this.state.editTemplateData._id,
713
+ touser: "{{wechat_open_id}}",
707
714
  };
708
715
  _.forEach(this.state.selectedTemplateTags, (templateTag) => {
709
716
  const tagName = templateTag.substr(0, templateTag.indexOf('.'));
@@ -1146,10 +1153,15 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
1146
1153
 
1147
1154
  setTemplateOptions(weChatData) {
1148
1155
  console.log('Set Templates ', weChatData);
1149
- const {schema, baseSchema} = this.state;
1150
- // const schema = _.cloneDeep(this.state.schema);
1151
- // const baseSchema = _.cloneDeep(this.state.baseSchema);
1156
+ //const {schema, baseSchema} = this.state;
1157
+ const schema = _.cloneDeep(this.state.schema);
1158
+ const baseSchema = _.cloneDeep(this.state.baseSchema);
1152
1159
  const baseSchemaTemplateOptionEmpty = (!_.isEmpty(baseSchema) && _.isEmpty(baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options));
1160
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options = [];
1161
+ if (!_.isEmpty(baseSchema)) {
1162
+ baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options = [];
1163
+
1164
+ }
1153
1165
  _.forEach(weChatData, (template) => {
1154
1166
  schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options.push({
1155
1167
  key: (template.versions) ? template.versions.base.template_id : template.template_id,
@@ -1284,7 +1296,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
1284
1296
  myField.value += myValue;
1285
1297
  }
1286
1298
  const event = new Event('input', { bubbles: true });
1287
- myField.dispatchEvent(event);
1299
+ callNativeEvent({field, value: myField.value, event});
1288
1300
  }
1289
1301
 
1290
1302
  internalUrlChecked() {
@@ -1546,6 +1558,10 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
1546
1558
  // value: 'Test3',
1547
1559
  // },
1548
1560
  // ];
1561
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
1562
+ if (this.props.supportedTags) {
1563
+ tags = this.props.supportedTags;
1564
+ }
1549
1565
  return (
1550
1566
  <Spin
1551
1567
  tip={this.props.intl.formatMessage(messages.gettingTemplateData)}
@@ -1554,7 +1570,6 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
1554
1570
  <Helmet
1555
1571
  title="WeChat"
1556
1572
  />
1557
- {/* <CapSelect options={options} /> */}
1558
1573
  <Row className="wechat-container">
1559
1574
  <Col>
1560
1575
  <FormBuilder
@@ -1568,7 +1583,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
1568
1583
  formData={_.cloneDeep(this.state.formData)}
1569
1584
  onFormValidityChange={this.setFormValidity}
1570
1585
  location= {this.props.location}
1571
- tags={this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : []}
1586
+ tags={tags}
1572
1587
  tagModule={this.props.getDefaultTags}
1573
1588
  injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
1574
1589
  isEdit={this.state.isEdit}
@@ -1599,6 +1614,8 @@ WeChat.propTypes = {
1599
1614
  isGetFormData: PropTypes.bool,
1600
1615
  getLibraryFormData: PropTypes.func,
1601
1616
  getDefaultTags: PropTypes.string,
1617
+ templateData: PropTypes.object,
1618
+ templateActions: PropTypes.object,
1602
1619
  };
1603
1620
 
1604
1621
  const mapStateToProps = createStructuredSelector({
@@ -1611,6 +1628,7 @@ function mapDispatchToProps(dispatch) {
1611
1628
  return {
1612
1629
  actions: bindActionCreators(actions, dispatch),
1613
1630
  globalActions: bindActionCreators(globalActions, dispatch),
1631
+ templateActions: bindActionCreators(templateActions, dispatch),
1614
1632
  };
1615
1633
  }
1616
1634
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "2.0.80",
4
+ "version": "2.0.81",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -110,7 +110,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
110
110
  const message = getMessageObject('error', (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
111
111
  this.props.globalActions.addMessageToQueue(message);
112
112
  }
113
- if (nextProps.iosCtasData) {
113
+ if (nextProps.iosCtasData && isEmpty(this.state.templateCta)) {
114
114
  this.setState({showIosCtaTable: true});
115
115
  }
116
116
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && isEmpty(this.state.schema)) {
@@ -155,11 +155,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
155
155
  const newFormData = cloneDeep(formData);
156
156
  const {templateCta} = this.state;
157
157
  if (!isEmpty(templateCta)) {
158
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta.name;
159
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta.ctaTemplateDetails[0].buttonText;
158
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = get(templateCta, 'name');
159
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = get(templateCta, 'ctaTemplateDetails[0].buttonText');
160
160
  delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
161
- if (templateCta.ctaTemplateDetails[1]) {
162
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta.ctaTemplateDetails[1].buttonText;
161
+ if (get(templateCta, 'ctaTemplateDetails[1]')) {
162
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = get(templateCta, 'ctaTemplateDetails[1].buttonText');
163
163
  }
164
164
  }
165
165
 
@@ -351,14 +351,46 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
351
351
  validity: this.state.isFormValid,
352
352
  type: templateData.type,
353
353
  };
354
- this.setState({checkValidation: true});
354
+ this.setState({checkValidation: true}, this.showError);
355
355
  if (e) {
356
356
  e.source.postMessage(JSON.stringify(response), e.origin);
357
357
  }
358
358
  return response;
359
359
  };
360
- setFormValidity = (isFormValid) => {
361
- this.setState({isFormValid});
360
+ showError = () => {
361
+ const {intl} = this.props;
362
+ const {errorData} = this.state;
363
+ const errorMessage = {key: 'validation-error', message: intl.formatMessage(messages.validationError)};
364
+ if (!isEmpty(this.state.formData) && !this.state.isFormValid) {
365
+ let tab = this.state.currentTab;
366
+ const isAndroidInvalid = Object.values(errorData[0]).includes(true);
367
+ const isIosInvalid = Object.values(errorData[1]).includes(true);
368
+ let isTagErrorExist = false;
369
+ if (isAndroidInvalid) {
370
+ tab = 1;
371
+ errorMessage.description = intl.formatMessage(messages.invalidAndroidMessage);
372
+ const invalidTags = errorData[0]['invalid-tags'];
373
+ if (!isEmpty(invalidTags)) {
374
+ isTagErrorExist = true;
375
+ errorMessage.description = `${intl.formatMessage(messages.invalidAndroidMessage)} ${intl.formatMessage(messages.invalidTags)}: ${invalidTags.join(',')} `;
376
+ }
377
+ } else if (isIosInvalid) {
378
+ tab = 2;
379
+ errorMessage.description = intl.formatMessage(messages.invalidIosMessage);
380
+ const invalidTags = errorData[1]['invalid-tags'];
381
+ if (!isEmpty(invalidTags)) {
382
+ isTagErrorExist = true;
383
+ errorMessage.description = `${intl.formatMessage(messages.invalidIosMessage)} ${intl.formatMessage(messages.invalidTags)}: ${invalidTags.join(',')} `;
384
+ }
385
+ }
386
+ if (tab !== this.state.currentTab || isTagErrorExist) {
387
+ CapNotification.error(errorMessage);
388
+ }
389
+ }
390
+ }
391
+ setFormValidity = (isFormValid, errorData) => {
392
+ const newState = {isFormValid, errorData};
393
+ this.setState(newState);
362
394
  };
363
395
  getTransformedData = (formData) => {
364
396
  const obj = {};
@@ -987,7 +1019,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
987
1019
 
988
1020
  ],
989
1021
  });
990
- if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
1022
+ const selectedConfigTemplateCtaId = get(selectedConfig, 'ctaTemplateDetails[0].id');
1023
+ // the option to select deeplink and externa link should not come for these ctas
1024
+ if (selectedConfigTemplateCtaId && (selectedConfigTemplateCtaId.id !== "3heicig" && selectedConfigTemplateCtaId.id !== "6eigf4f" && selectedConfigTemplateCtaId.id !== "c97d0ed")) {
991
1025
  inputFields.splice(fieldIndex + 2, 0, {
992
1026
  rowClassName: "mobile-push-row",
993
1027
  cols: [
@@ -246,4 +246,20 @@ export default defineMessages({
246
246
  id: 'app.containers.MobilePush.Create.uploadImageSizeErrorDescription',
247
247
  defaultMessage: 'File size cannot be more than 3mb',
248
248
  },
249
+ "validationError": {
250
+ id: 'app.containers.MobilePush.Create.validationError',
251
+ defaultMessage: 'Validation error',
252
+ },
253
+ "invalidIosMessage": {
254
+ id: 'app.containers.MobilePush.Create.invalidIosMessage',
255
+ defaultMessage: 'Validation failed for IOS',
256
+ },
257
+ "invalidAndroidMessage": {
258
+ id: 'app.containers.MobilePush.Create.invalidAndroidMessage',
259
+ defaultMessage: 'Validation failed for Android',
260
+ },
261
+ "invalidTags": {
262
+ id: 'app.containers.MobilePush.Create.invalidTags',
263
+ defaultMessage: 'Invalid tags',
264
+ },
249
265
  });