@capillarytech/creatives-library 2.0.82 → 2.0.83

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 (172) hide show
  1. package/components/CapTagList/index.js +24 -21
  2. package/components/CardGrid/index.js +10 -16
  3. package/components/Ckeditor/index.js +1 -2
  4. package/components/CustomPopOver/index.js +1 -1
  5. package/components/EmailPreview/index.js +2 -3
  6. package/components/FormBuilder/_formBuilder.scss +15 -8
  7. package/components/FormBuilder/index.js +194 -260
  8. package/components/Header/index.js +1 -4
  9. package/components/PreviewSideBar/_previewsidebar.scss +1 -1
  10. package/components/PreviewSideBar/index.js +5 -3
  11. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +3 -2
  12. package/components/TemplatePreview/_templatePreview.scss +1 -1
  13. package/components/TemplatePreview/index.js +47 -47
  14. package/components/TemplatePreview/messages.js +1 -9
  15. package/containers/Assets/Gallery/index.js +1 -1
  16. package/containers/Email/index.js +1 -1
  17. package/containers/Login/components/LoginForm/index.js +1 -1
  18. package/containers/Templates/index.js +1 -1
  19. package/containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
  20. package/package.json +2 -1
  21. package/v2Components/BreadCrumbs/index.js +65 -0
  22. package/v2Components/BreadCrumbs/messages.js +13 -0
  23. package/v2Components/BreadCrumbs/tests/index.test.js +10 -0
  24. package/v2Components/CallTaskPreview/_callTaskPreview.scss +17 -0
  25. package/v2Components/CallTaskPreview/images/Footer.png +0 -0
  26. package/v2Components/CallTaskPreview/images/Header.png +0 -0
  27. package/v2Components/CallTaskPreview/index.js +37 -0
  28. package/v2Components/CallTaskPreview/messages.js +13 -0
  29. package/v2Components/CallTaskPreview/tests/index.test.js +15 -0
  30. package/v2Components/CapTagList/index.js +232 -0
  31. package/v2Components/CapTagList/messages.js +25 -0
  32. package/v2Components/CapTagList/tests/index.test.js +10 -0
  33. package/v2Components/Card/_customCard.scss +27 -0
  34. package/v2Components/Card/index.js +78 -0
  35. package/{containers/WeChat → v2Components/Card}/tests/index.test.js +2 -2
  36. package/v2Components/CardGrid/index.js +77 -0
  37. package/v2Components/CardGrid/tests/index.test.js +10 -0
  38. package/v2Components/Ckeditor/index.js +234 -0
  39. package/v2Components/Ckeditor/messages.js +13 -0
  40. package/v2Components/Ckeditor/tests/index.test.js +10 -0
  41. package/v2Components/CmsTemplatesComponent/index.js +33 -0
  42. package/v2Components/CmsTemplatesComponent/messages.js +17 -0
  43. package/v2Components/CmsTemplatesComponent/tests/index.test.js +10 -0
  44. package/v2Components/Component/index.js +29 -0
  45. package/v2Components/Component/tests/index.test.js +10 -0
  46. package/v2Components/CustomPopOver/index.js +82 -0
  47. package/v2Components/CustomPopOver/messages.js +13 -0
  48. package/v2Components/CustomPopOver/tests/index.test.js +10 -0
  49. package/v2Components/DateFilter/index.js +349 -0
  50. package/v2Components/DateFilter/messages.js +17 -0
  51. package/v2Components/DateFilter/tests/index.test.js +15 -0
  52. package/v2Components/DateRange/index.js +113 -0
  53. package/v2Components/DateRange/messages.js +13 -0
  54. package/v2Components/DateRange/tests/index.test.js +10 -0
  55. package/v2Components/Edmeditor/index.js +65 -0
  56. package/v2Components/Edmeditor/messages.js +13 -0
  57. package/v2Components/Edmeditor/tests/index.test.js +10 -0
  58. package/v2Components/EmailMobilePreview/index.js +129 -0
  59. package/v2Components/EmailMobilePreview/index.scss +55 -0
  60. package/v2Components/EmailPreview/_emailPreview.scss +119 -0
  61. package/v2Components/EmailPreview/index.js +106 -0
  62. package/v2Components/EmailPreview/messages.js +17 -0
  63. package/v2Components/EmailPreview/tests/index.test.js +10 -0
  64. package/v2Components/EmailPreviewV2/_emailPreviewV2.scss +69 -0
  65. package/v2Components/EmailPreviewV2/index.js +132 -0
  66. package/v2Components/EmailPreviewV2/messages.js +41 -0
  67. package/v2Components/EmailPreviewV2/tests/index.test.js +10 -0
  68. package/v2Components/Footer/index.js +27 -0
  69. package/v2Components/Footer/messages.js +13 -0
  70. package/v2Components/Footer/tests/index.test.js +10 -0
  71. package/v2Components/FormBuilder/_formBuilder.scss +78 -0
  72. package/v2Components/FormBuilder/index.js +3309 -0
  73. package/v2Components/FormBuilder/messages.js +13 -0
  74. package/v2Components/FormBuilder/tests/index.test.js +10 -0
  75. package/v2Components/Header/index.js +46 -0
  76. package/v2Components/Header/messages.js +25 -0
  77. package/v2Components/Header/tests/index.test.js +10 -0
  78. package/v2Components/ImagePreview/_imagePreview.scss +63 -0
  79. package/v2Components/ImagePreview/index.js +52 -0
  80. package/v2Components/ImagePreview/messages.js +13 -0
  81. package/v2Components/ImagePreview/tests/index.test.js +10 -0
  82. package/v2Components/MobilePushPreviewV2/index.js +120 -0
  83. package/v2Components/MobilePushPreviewV2/messages.js +13 -0
  84. package/v2Components/MobilePushPreviewV2/tests/index.test.js +10 -0
  85. package/v2Components/NewCallTask/_newCallTask.scss +9 -0
  86. package/v2Components/NewCallTask/index.js +152 -0
  87. package/v2Components/NewCallTask/messages.js +29 -0
  88. package/v2Components/NewCallTask/tests/index.test.js +10 -0
  89. package/v2Components/PageHeader/_pageHeader.scss +22 -0
  90. package/v2Components/PageHeader/index.js +37 -0
  91. package/v2Components/PageHeader/messages.js +13 -0
  92. package/v2Components/PageHeader/tests/index.test.js +10 -0
  93. package/v2Components/Pagination/_pagination.scss +5 -0
  94. package/v2Components/Pagination/index.js +49 -0
  95. package/v2Components/Pagination/tests/index.test.js +10 -0
  96. package/v2Components/PreviewSideBar/_previewsidebar.scss +28 -0
  97. package/v2Components/PreviewSideBar/index.js +150 -0
  98. package/v2Components/PreviewSideBar/messages.js +33 -0
  99. package/v2Components/PreviewSideBar/tests/index.test.js +10 -0
  100. package/v2Components/Sidebar/_sidebar.scss +115 -0
  101. package/v2Components/Sidebar/index.js +208 -0
  102. package/v2Components/Sidebar/messages.js +21 -0
  103. package/v2Components/Sidebar/tests/index.test.js +10 -0
  104. package/v2Components/SlideBox/_slideBox.scss +63 -0
  105. package/v2Components/SlideBox/index.js +48 -0
  106. package/v2Components/SlideBox/tests/index.test.js +103 -0
  107. package/v2Components/SmsEditor/index.js +55 -0
  108. package/v2Components/SmsEditor/tests/index.test.js +10 -0
  109. package/v2Components/SmsTest/index.js +115 -0
  110. package/v2Components/SmsTest/messages.js +13 -0
  111. package/v2Components/SmsTest/tests/index.test.js +10 -0
  112. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +42 -0
  113. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +139 -0
  114. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +21 -0
  115. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/tests/index.test.js +10 -0
  116. package/v2Components/TemplatePreview/_templatePreview.scss +352 -0
  117. package/v2Components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
  118. package/v2Components/TemplatePreview/assets/images/androidPushMessage.svg +45 -0
  119. package/v2Components/TemplatePreview/assets/images/iPhonePushMessage.svg +135 -0
  120. package/v2Components/TemplatePreview/assets/images/mobile.svg +24 -0
  121. package/v2Components/TemplatePreview/assets/images/sms-body.png +0 -0
  122. package/v2Components/TemplatePreview/assets/images/sms-icon.png +0 -0
  123. package/v2Components/TemplatePreview/assets/images/sms_mobile.png +0 -0
  124. package/v2Components/TemplatePreview/assets/images/user-icon.svg +19 -0
  125. package/v2Components/TemplatePreview/assets/images/wechat-mobile.svg +78 -0
  126. package/v2Components/TemplatePreview/index.js +175 -0
  127. package/v2Components/TemplatePreview/messages.js +37 -0
  128. package/v2Components/TemplatePreview/tests/index.test.js +10 -0
  129. package/v2Components/Toastr/index.js +60 -0
  130. package/v2Components/Toastr/messages.js +13 -0
  131. package/v2Components/Toastr/tests/index.test.js +10 -0
  132. package/v2Components/ToastrMessage/index.js +110 -0
  133. package/v2Components/ToastrMessage/messages.js +13 -0
  134. package/v2Components/ToastrMessage/tests/index.test.js +10 -0
  135. package/v2Components/TopBar/_topbar.scss +46 -0
  136. package/v2Components/TopBar/assets/images/capillary_logo.png +0 -0
  137. package/v2Components/TopBar/index.js +113 -0
  138. package/v2Components/TopBar/messages.js +29 -0
  139. package/v2Components/TopBar/tests/index.test.js +10 -0
  140. package/v2Containers/Assets/Gallery/index.js +1 -1
  141. package/v2Containers/CallTask/index.js +1 -1
  142. package/v2Containers/Cap/index.js +2 -2
  143. package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -3
  144. package/v2Containers/CreativesContainer/index.js +1 -0
  145. package/v2Containers/Dashboard/index.js +2 -2
  146. package/v2Containers/Ebill/index.js +2 -2
  147. package/v2Containers/Email/index.js +4 -4
  148. package/v2Containers/EmailWrapper/index.js +1 -1
  149. package/v2Containers/Line/Create/index.js +1 -1
  150. package/v2Containers/Line/Edit/index.js +1 -1
  151. package/v2Containers/Login/index.js +1 -1
  152. package/v2Containers/MobilePush/Create/index.js +1 -1
  153. package/v2Containers/MobilePush/Edit/index.js +1 -1
  154. package/v2Containers/Sms/Create/index.js +1 -1
  155. package/v2Containers/Sms/Edit/index.js +1 -1
  156. package/v2Containers/TagList/index.js +1 -1
  157. package/v2Containers/Templates/index.js +4 -4
  158. package/v2Containers/TestPage/index.js +1 -1
  159. package/v2Containers/WeChat/MapTemplates/index.js +3 -3
  160. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +3 -3
  161. package/containers/WeChat/_wechat.scss +0 -8
  162. package/containers/WeChat/actions.js +0 -46
  163. package/containers/WeChat/constants.js +0 -28
  164. package/containers/WeChat/index.js +0 -1617
  165. package/containers/WeChat/messages.js +0 -73
  166. package/containers/WeChat/reducer.js +0 -74
  167. package/containers/WeChat/sagas.js +0 -86
  168. package/containers/WeChat/selectors.js +0 -25
  169. package/containers/WeChat/tests/actions.test.js +0 -18
  170. package/containers/WeChat/tests/reducer.test.js +0 -9
  171. package/containers/WeChat/tests/sagas.test.js +0 -15
  172. package/containers/WeChat/tests/selectors.test.js +0 -10
@@ -1,1617 +0,0 @@
1
- /*
2
- *
3
- * WeChat
4
- *
5
- */
6
-
7
- import React, { PropTypes } from 'react';
8
- import { connect } from 'react-redux';
9
- import { bindActionCreators } from 'redux';
10
- import Helmet from 'react-helmet';
11
- import { injectIntl, intlShape } from 'react-intl';
12
- import { createStructuredSelector } from 'reselect';
13
- // import { CapButton, CapSelect } from '@capillarytech/cap-react-ui-library';
14
- import { Row, Col, Spin } from 'antd';
15
- import _ from 'lodash';
16
- import { makeSelectTemplates } from '../Templates/selectors';
17
- import { makeSelectMetaEntities } from '../Cap/selectors';
18
- import makeSelectWeChat from './selectors';
19
- import messages from './messages';
20
- import * as actions from './actions';
21
- import FormBuilder from '../../components/FormBuilder';
22
- import { UserIsAuthenticated } from '../../utils/authWrapper';
23
- import * as globalActions from '../../containers/Cap/actions';
24
- import {getMessageObject} from '../../utils/messageUtils';
25
- // import SlideBox from '../../components/SlideBox';
26
- // import PageHeader from '../../components/PageHeader';
27
- import './_wechat.scss';
28
-
29
- // const Option = Select.Option;
30
-
31
- export class WeChat extends React.Component { // eslint-disable-line react/prefer-stateless-function
32
- constructor(props) {
33
- super(props);
34
- this.state = {
35
- schema: {},
36
- // schema:
37
- // {
38
- // standalone: {
39
- // sections: [
40
- // {
41
- // type: "parent",
42
- // width: 24,
43
- // rowStyle: {
44
- // height: '100%',
45
- // },
46
- // childSections: [
47
- // {
48
- // type: "multicols",
49
- // inputFields: [
50
- // {
51
- // cols: [
52
- // {
53
- // id: "template-header",
54
- // metaType: "label",
55
- // value: 'Template mapping',
56
- // primitive: true,
57
- // type: "div",
58
- // width: 9,
59
- // offset: 0,
60
- // onlyDisplay: true,
61
- // colStyle: {
62
- // flex: 1,
63
- // color: '#323B4E',
64
- // fontFamily: 'proxima-nova',
65
- // fontWeight: '600',
66
- // lineHeight: '32px',
67
- // fontSize: '24px',
68
- // display: (this.props.location.query.type === 'embedded' ? 'none' : 'block'),
69
- // },
70
- // },
71
- // {
72
- // id: "discard-button",
73
- // width: 3,
74
- // offset: 8,
75
- // metaType: "submit-button",
76
- // colStyle: {
77
- // // marginLeft: '47.833%',
78
- // textAlign: 'right',
79
- // paddingRight: '12px',
80
- // display: (this.props.location.query.type === 'embedded' ? 'none' : 'block'),
81
- // },
82
- // type: "button",
83
- // buttonType: "cancel",
84
- // value: 'Discard',
85
- // customComponent: false,
86
- // standalone: true,
87
- // styling: "semantic",
88
- // order: 3,
89
- // fluid: false,
90
- // submitAction: "discardValues",
91
- // supportedEvents: [
92
- // 'discardValues',
93
- // ],
94
- // },
95
- // {
96
- // id: "cancel-button",
97
- // width: 2,
98
- // // offset: 11,
99
- // metaType: "submit-button",
100
- // colStyle: {
101
- // textAlign: 'center',
102
- // width: '9%',
103
- // display: (this.props.location.query.type === 'embedded' ? 'none' : 'block'),
104
- // },
105
- // type: "button",
106
- // buttonType: "cancel",
107
- // value: 'Cancel',
108
- // customComponent: false,
109
- // standalone: true,
110
- // styling: "semantic",
111
- // order: 3,
112
- // fluid: false,
113
- // submitAction: "cancelTemplate",
114
- // supportedEvents: [
115
- // 'cancelTemplate',
116
- // ],
117
- // },
118
- // {
119
- // id: "save-button",
120
- // width: 2,
121
- // metaType: "submit-button",
122
- // colStyle: {
123
- // textAlign: 'right',
124
- // width: '7%',
125
- // display: (this.props.location.query.type === 'embedded' ? 'none' : 'block'),
126
- // },
127
- // type: "button",
128
- // buttonType: "primary",
129
- // value: 'Save',
130
- // customComponent: false,
131
- // styling: "semantic",
132
- // order: 3,
133
- // fluid: false,
134
- // standalone: true,
135
- // submitAction: "saveFormData",
136
- // supportedEvents: [
137
- // 'saveFormData',
138
- // ],
139
- // },
140
- // ],
141
- // },
142
- // ],
143
- // },
144
- // {
145
- // width: 24,
146
- // type: 'parent',
147
- // rowStyle: {
148
- // height: '100%',
149
- // border: '1px solid #d9d9d9',
150
- // marginTop: '16px',
151
- // },
152
- // childSections: [
153
- // {
154
- // colStyle: {
155
- // paddingTop: '16px',
156
- // borderRight: '1px solid #d9d9d9',
157
- // height: '100%',
158
- // // overflowY: 'auto',
159
- // },
160
- // width: 15,
161
- // type: 'parent',
162
- // childSections: [
163
- // {
164
- // type: "col-label",
165
- // inputFields: [
166
- // {
167
- // id: "wechat-accounts",
168
- // label: 'Account Id',
169
- // labelStyle: {
170
- // backgroundColor: 'white',
171
- // textAlign: 'left',
172
- // color: '#333333',
173
- // lineHeight: '24px',
174
- // fontSize: '14px',
175
- // fontWeight: '400',
176
- // fontFamily: 'open-sans',
177
- // fontStyle: 'normal',
178
- // padding: '.5em .833em',
179
- // display: (this.props.location.query.module === 'loyalty' ? 'block' : 'none'),
180
- // },
181
- // placeholder: 'Select Wechat Account',
182
- // type: "select", //Resembles component to be used
183
- // options: [],
184
- // metaType: "text",
185
- // datatype: "string",
186
- // required: true,
187
- // fluid: true,
188
- // style: {
189
- // fontSize: '14px',
190
- // fontFamily: 'open-sans',
191
- // fontStyle: 'normal',
192
- // // fontWeight: 600,
193
- // marginBottom: '16px',
194
- // display: (this.props.location.query.module === 'loyalty' ? 'block' : 'none'),
195
- // },
196
- // styling: "semantic",
197
- // order: 1,
198
- // width: 15,
199
- // offSet: 6,
200
- // customComponent: false,
201
- // standalone: true,
202
- // supportedEvents: [
203
- // 'onSelect',
204
- // ],
205
- // },
206
- // {
207
- // id: "wechat-template",
208
- // label: 'Template',
209
- // labelStyle: {
210
- // backgroundColor: 'white',
211
- // textAlign: 'left',
212
- // color: '#333333',
213
- // lineHeight: '24px',
214
- // fontSize: '14px',
215
- // fontWeight: '400',
216
- // fontFamily: 'open-sans',
217
- // fontStyle: 'normal',
218
- // padding: '.5em .833em',
219
- // },
220
- // placeholder: 'Select Wechat Template',
221
- // type: "select", //Resembles component to be used
222
- // options: [],
223
- // metaType: "text",
224
- // datatype: "string",
225
- // required: true,
226
- // fluid: true,
227
- // disabled: (this.props.params.id && this.props.location.query.module !== 'loyalty'),
228
- // style: {
229
- // fontSize: '14px',
230
- // fontFamily: 'open-sans',
231
- // fontStyle: 'normal',
232
- // // fontWeight: 600,
233
- // marginBottom: '16px',
234
- // },
235
- // styling: "semantic",
236
- // order: 1,
237
- // width: 15,
238
- // offSet: 6,
239
- // customComponent: false,
240
- // standalone: true,
241
- // supportedEvents: [
242
- // 'onSelect',
243
- // ],
244
- // },
245
- // ],
246
- // actionFields: [],
247
- // },
248
- // {
249
- // type: "multicols",
250
- // inputFields: [
251
- // {
252
- // cols: [],
253
- // },
254
- // ],
255
- // },
256
- // ],
257
- // },
258
- // {
259
- // width: 8,
260
- // type: 'multicols',
261
- // colStyle: {
262
- // paddingTop: '16px',
263
- // height: '100%',
264
- // },
265
- // inputFields: [
266
- // {
267
- // cols: [
268
- // {
269
- // id: "sms-preview",
270
- // type: "sms-preview", //Resembles component to be used
271
- // customComponent: true,
272
- // charCounterEnabled: false,
273
- // customStyling: { padding: '0', overflowX: 'hidden' },
274
- // style: {
275
- // overflowX: 'hidden',
276
- // },
277
- // content: '',
278
- // metaType: "preview",
279
- // required: true,
280
- // fluid: true,
281
- // styling: "semantic",
282
- // order: 1,
283
- // width: 5,
284
- // onlyDisplay: true,
285
- // offset: 7,
286
- // channel: 'WECHAT',
287
- // },
288
- // ],
289
- // },
290
- // ],
291
- // },
292
- // ],
293
- // },
294
- // ],
295
- // },
296
- // ],
297
- // },
298
- // containers: [],
299
- // channel: "WECHAT",
300
- // module: "Campaigns",
301
- // },
302
- baseSchema: {},
303
- formData: {},
304
- map: {
305
- "discard-button": {
306
- discardValues: this.discardValues,
307
- },
308
- "cancel-button": {
309
- cancelTemplate: this.cancelTemplate,
310
- },
311
- "save-button": {
312
- saveFormData: this.saveFormData,
313
- },
314
- "wechat-template": {
315
- onSelect: this.selectWechatTemplate,
316
- },
317
- "wechat-accounts": {
318
- onSelect: this.selectWechatAccount,
319
- },
320
- "template-link": {
321
- onChange: this.setContent,
322
- },
323
- "is-internal-url": {
324
- onChange: this.internalUrlChecked,
325
- },
326
- },
327
- selectedTemplateTags: [],
328
- isEdit: false,
329
- editTemplateData: {},
330
- isFormValid: true,
331
- checkValidation: false,
332
- injectedTags: {},
333
- isLoading: true,
334
- showModal: false,
335
- modalContent: {
336
- title: "Alert",
337
- body: "Do you really want to go back? All your temporary changes will be lost!",
338
- type: 'confirm',
339
- id: 'template-back-confirm-modal',
340
- },
341
- };
342
-
343
- this.saveFormData = this.saveFormData.bind(this);
344
- this.onFormDataChange = this.onFormDataChange.bind(this);
345
- this.setTemplateOptions = this.setTemplateOptions.bind(this);
346
- this.cancelTemplate = this.cancelTemplate.bind(this);
347
- this.setSelectedTemplateData = this.setSelectedTemplateData.bind(this);
348
- this.discardValues = this.discardValues.bind(this);
349
- this.internalUrlChecked = this.internalUrlChecked.bind(this);
350
- this.getTagsFromContent = this.getTagsFromContent.bind(this);
351
- this.onTagSelect = this.onTagSelect.bind(this);
352
- this.insertAtCursor = this.insertAtCursor.bind(this);
353
- this.setFormValidity = this.setFormValidity.bind(this);
354
- this.setContent = this.setContent.bind(this);
355
- this.prepareWeChatPreviewData = this.prepareWeChatPreviewData.bind(this);
356
- this.setEditData = this.setEditData.bind(this);
357
- this.maskTemplateUrl = this.maskTemplateUrl.bind(this);
358
- this.unMaskTemplateUrl = this.unMaskTemplateUrl.bind(this);
359
- this.resetState = this.resetState.bind(this);
360
- this.resetSchema = this.resetSchema.bind(this);
361
- this.handleFrameTasks = this.handleFrameTasks.bind(this);
362
- this.getCurrentWindow = this.getCurrentWindow.bind(this);
363
- this.startLoading = this.startLoading.bind(this);
364
- this.startTemplateCreation = this.startTemplateCreation.bind(this);
365
- this.selectWechatTemplate = this.selectWechatTemplate.bind(this);
366
- this.removeActionButtons = this.removeActionButtons.bind(this);
367
- this.setWechatAccountOptions = this.setWechatAccountOptions.bind(this);
368
- this.selectWechatAccount = this.selectWechatAccount.bind(this);
369
- this.moveToTemplates = this.moveToTemplates.bind(this);
370
- this.injectMessages = this.injectMessages.bind(this);
371
- this.hideSchemaElementsByModule = this.hideSchemaElementsByModule.bind(this);
372
-
373
- this.injectEvents = this.injectEvents.bind(this);
374
- this.injectSections = this.injectSections.bind(this);
375
- this.injectContainer = this.injectContainer.bind(this);
376
- this.injectParentSection = this.injectParentSection.bind(this);
377
- this.injectColLabelSection = this.injectColLabelSection.bind(this);
378
- this.injectMultiColSection = this.injectMultiColSection.bind(this);
379
- this.getMappedEvent = this.getMappedEvent.bind(this);
380
- this.showNext = this.showNext.bind(this);
381
- this.updateSchema = false;
382
- }
383
-
384
- componentWillMount() {
385
- const query = {
386
- layout: 'WECHAT',
387
- type: 'LAYOUT',
388
- context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
389
- };
390
- this.props.globalActions.fetchSchemaForEntity(query);
391
- this.props.actions.getWeCrmAccounts();
392
- if (this.props.params.id) {
393
- this.props.actions.getTemplateDetails(this.props.params.id);
394
- this.setState({isEdit: true});
395
- }
396
- console.log("Mount Params ", this.props.Templates.selectedWeChatAccount, this.props.location.query.type);
397
- if (this.props.Templates.selectedWeChatAccount || (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty')) {
398
- if (this.props.Templates.selectedWeChatAccount) {
399
- const params = {
400
- name: '',
401
- sortBy: 'Most Recent',
402
- wecrmId: this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id,
403
- wecrmToken: this.props.Templates.selectedWeChatAccount.configs.wecrm_token,
404
- };
405
- this.props.actions.getDefaultWeChatTemplates('wechat', params);
406
- } else {
407
- this.setWechatAccountOptions(this.props.WeChat.weCrmAccounts);
408
- }
409
- window.addEventListener("message", this.handleFrameTasks);
410
- } else if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'outbound') {
411
- console.log('Inside embedded Outbound');
412
- } else {
413
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
414
- const type = this.props.location.query.type;
415
- this.props.router.push({
416
- pathname: `/wechat`,
417
- query: type === 'embedded' ? {type: 'embedded', module} : {module},
418
- });
419
- }
420
- }
421
-
422
- componentDidMount() {
423
- console.log('added listener create,', this.props);
424
- const query = {
425
- layout: 'WECHAT',
426
- type: 'LAYOUT',
427
- context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
428
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
429
- };
430
- this.props.globalActions.fetchSchemaForEntity(query);
431
-
432
- window.addEventListener("message", this.handleFrameTasks);
433
- }
434
-
435
- componentWillReceiveProps(nextProps) {
436
- if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
437
- this.getFormData();
438
- }
439
- console.log('MetaEntity nextprops ', nextProps.metaEntities);
440
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
441
- this.injectEvents(nextProps.metaEntities.layouts[0].definition);
442
- const query = {
443
- layout: 'WECHAT',
444
- type: 'TAG',
445
- context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
446
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
447
- };
448
- if (this.props.getDefaultTags) { // handling dynamic tags in library mode, but handling static and synamic tags in email and sms.
449
- query.context = this.props.getDefaultTags;
450
- }
451
- this.props.globalActions.fetchSchemaForEntity(query);
452
- }
453
-
454
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && !_.isEmpty(this.state.schema)) {
455
- if (nextProps.WeChat.weChatDefaultTemplate && !_.isEqual(nextProps.WeChat.weChatDefaultTemplate, this.props.WeChat.weChatDefaultTemplate)) {
456
- this.injectEvents(this.state.schema);
457
- if (nextProps.location.query.type === 'embedded' && nextProps.location.query.module === 'loyalty') {
458
- this.setTemplateOptions(nextProps.WeChat.weChatTemplates);
459
- } else {
460
- this.setTemplateOptions(nextProps.WeChat.weChatDefaultTemplate);
461
- }
462
- }
463
- if ((this.props.location.query.type === 'embedded' && (this.props.location.query.module === 'loyalty' || this.props.location.query.module === 'outbound')) && !_.isEmpty(nextProps.WeChat.templateDetails) && !_.isEqual(nextProps.WeChat.templateDetails, this.props.WeChat.templateDetails)) {
464
- this.setState({editTemplateData: nextProps.WeChat.templateDetails}, () => {
465
- if ( !_.isEmpty(this.state.baseSchema)) {
466
- this.setEditData();
467
- } else {
468
- this.setState({baseSchema: _.cloneDeep(this.state.schema)}, () => {
469
- this.setEditData();
470
- });
471
- }
472
- });
473
- }
474
- // has to be un commented when wechat edit is implemented in embedded mode.
475
- // if (nextProps.location.query.type === "embedded" && nextProps.location.query.module === "library" && nextProps.templateData && nextProps.templateData.versions) { // Edit of already added message in library mode
476
- // this.setState({editTemplateData: nextProps.templateData}, () => {
477
- // this.setEditData();
478
- // });
479
- // }
480
- if (nextProps.params.id && !_.isEqual(nextProps.params.id, this.props.params.id)) {
481
- this.setState({isEdit: true});
482
- }
483
- if (this.state.isEdit && _.isEmpty(this.state.editTemplateData) && !_.isEmpty(nextProps.WeChat.weChatTemplates)) {
484
- const templateIndex = _.findIndex(nextProps.WeChat.weChatTemplates, {"_id": nextProps.params.id});
485
- this.setState({editTemplateData: nextProps.WeChat.weChatTemplates[templateIndex]}, () => {
486
- if (_.isEmpty(this.state.baseSchema)) {
487
- this.setState({ baseSchema: _.cloneDeep(this.state.schema)}, () => {
488
- this.setEditData();
489
- });
490
- } else {
491
- this.setEditData();
492
- }
493
- });
494
- }
495
- if (nextProps.location.query.type === 'embedded') {
496
- this.removeActionButtons();
497
- }
498
-
499
- if (nextProps.WeChat.createResponse && nextProps.WeChat.createResponse.templateId) {
500
- // this.resetSchema();
501
- let message;
502
- if (this.state.isEdit) {
503
- message = getMessageObject('success', this.props.intl.formatMessage(messages.wechatEditSuccess), true);
504
- } else {
505
- message = getMessageObject('success', this.props.intl.formatMessage(messages.wechatCreateSuccess), true);
506
- }
507
- this.props.globalActions.addMessageToQueue(message);
508
- this.props.actions.clearCreateResponse();
509
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
510
- const type = this.props.location.query.type;
511
- this.props.router.push({
512
- pathname: `/wechat`,
513
- query: type === 'embedded' ? {type: 'embedded', module} : {module},
514
- });
515
- }
516
- if (nextProps.WeChat.createTemplateError && !_.isEqual(nextProps.WeChat.createTemplateError, this.props.WeChat.createTemplateError)) {
517
- const message = getMessageObject('error', this.props.intl.formatMessage(messages.somethingWentWrong), true);
518
- this.props.globalActions.addMessageToQueue(message);
519
- }
520
-
521
- // console.log('All Dont Hail ', query);
522
- // this.injectEvents(nextProps.metaEntities.layouts[0].definition);
523
- // const query = {
524
- // layout: 'WECHAT',
525
- // type: 'TAG',
526
- // context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
527
- // };
528
- // this.props.globalActions.fetchSchemaForEntity(query);
529
- if (this.props.location.query.type === 'embedded') {
530
- this.showNext();
531
- }
532
-
533
- if (!_.isEqual(this.props.WeChat.weCrmAccounts, nextProps.WeChat.weCrmAccounts) && (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty')) {
534
- this.injectEvents(this.state.schema);
535
- this.setWechatAccountOptions(nextProps.WeChat.weCrmAccounts);
536
- }
537
-
538
- if (!_.isEmpty(nextProps.WeChat.selectedWeChatAccount) && !_.isEqual(this.props.WeChat.selectedWeChatAccount, nextProps.WeChat.selectedWeChatAccount) && (this.props.location.query.type === 'embedded')) {
539
- const params = {
540
- name: '',
541
- sortBy: 'Most Recent',
542
- wecrmId: nextProps.WeChat.selectedWeChatAccount.configs.wecrm_app_id,
543
- wecrmToken: nextProps.WeChat.selectedWeChatAccount.configs.wecrm_token,
544
- };
545
- this.props.actions.getDefaultWeChatTemplates('wechat', params);
546
- }
547
-
548
- if (_.isEmpty(nextProps.WeChat.selectedWeChatAccount) && (this.props.location.query.type === 'embedded')) {
549
- let selectedAccount = {};
550
- _.forEach(nextProps.WeChat.weCrmAccounts, (account) => {
551
- if (account.configs && account.configs.is_wecrm_enabled) {
552
- if (account.sourceAccountIdentifier === this.props.location.query.source_account_id) {
553
- selectedAccount = account;
554
- }
555
- }
556
- });
557
- if (!_.isEmpty(selectedAccount)) {
558
- this.props.actions.setWeChatAccount(selectedAccount);
559
- }
560
- }
561
-
562
- if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && this.props.metaEntities.tags !== nextProps.metaEntities.tags) {
563
- let injectedTags = _.cloneDeep(this.state.injectedTags);
564
- delete injectedTags["Registration custom fields"];
565
- delete injectedTags["Store custom fields"];
566
- delete injectedTags["Transaction custom fields"];
567
- injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
568
- console.log('new injected tags', nextProps.metaEntities.tags.custom);
569
- if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
570
- delete injectedTags["Registration custom fields"];
571
- }
572
- if (!_.has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
573
- delete injectedTags["Store custom fields"];
574
- }
575
- if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
576
- delete injectedTags["Transaction custom fields"];
577
- }
578
- this.setState({injectedTags});
579
- }
580
-
581
- // if (this.props.location.query.type.type === 'embedded' && this.props.location.query.module === 'loyalty' && this.state.formData['wechat-template'] !== '') {
582
- // }
583
-
584
- if (!nextProps.WeChat.fetchingDefaultTemplates && nextProps.location.query.module === 'outbound' && nextProps.params.id !== undefined) {
585
- this.setState({ isLoading: false});
586
- }
587
- if ((!nextProps.WeChat.fetchingDefaultTemplates && !_.isEqual(nextProps.WeChat.fetchingDefaultTemplates, this.props.WeChat.fetchingDefaultTemplates) && nextProps.location.query.module !== 'loyalty') || (nextProps.location.query.module === 'loyalty')) {
588
- this.setState({ isLoading: false});
589
- }
590
-
591
- if (nextProps.WeChat.fetchingDefaultTemplates && nextProps.location.query.module === 'loyalty' && nextProps.params.id === undefined) {
592
- this.setState({ isLoading: true});
593
- }
594
- }
595
- }
596
-
597
- componentWillUnmount() {
598
- console.log('removed listener create');
599
- window.removeEventListener("message", this.handleFrameTasks);
600
- this.resetState();
601
- }
602
-
603
- onFormDataChange(formData) {
604
- console.log('Form Data Change ', formData);
605
- let selectedWechatTemplateIndex = -1;
606
- let selectedTemplate = {};
607
- let selectedTemplateData = {};
608
-
609
- if (this.props.location.query.type === 'embedded' && (this.props.location.query.module === 'loyalty')) {
610
- if (this.props.params.id && _.isEmpty(this.props.WeChat.weChatTemplates) && _.isEqual(formData['wechat-template'], this.state.formData['wechat-template'])) {
611
- console.log('In If', formData['wechat-template']);
612
- selectedTemplate = {
613
- template_id: this.props.WeChat.templateDetails.versions.base.template_id,
614
- title: this.props.WeChat.templateDetails.versions.base.Title,
615
- content: this.props.WeChat.templateDetails.versions.base.content,
616
- };
617
- selectedTemplateData = this.props.WeChat.templateDetails;
618
- } else {
619
- console.log('In Else', formData['wechat-template']);
620
- _.forEach(this.props.WeChat.weChatTemplates, (template) => {
621
- if (template.versions.base.template_id === formData['wechat-template']) {
622
- selectedTemplate = {
623
- template_id: template.versions.base.template_id,
624
- title: template.versions.base.Title,
625
- content: template.versions.base.content,
626
- };
627
- selectedTemplateData = template;
628
- }
629
- });
630
- }
631
- } else if (this.state.isEdit && this.state.editTemplateData.versions) {
632
- console.log('this.state.editTemplateData', this.state.editTemplateData);
633
- selectedTemplateData = _.cloneDeep(this.state.editTemplateData);
634
- selectedTemplate = {
635
- template_id: selectedTemplateData.versions.base.template_id,
636
- title: selectedTemplateData.versions.base.Title,
637
- content: selectedTemplateData.versions.base.content,
638
- };
639
- } else if (!this.state.isEdit) {
640
- selectedWechatTemplateIndex = _.findIndex(this.props.WeChat.weChatDefaultTemplate, {template_id: formData['wechat-template']});
641
- selectedTemplate = this.props.WeChat.weChatDefaultTemplate[selectedWechatTemplateIndex];
642
- }
643
- if (!_.isEqual(formData['wechat-template'], this.state.formData['wechat-template'])) {
644
- this.updateSchema = true;
645
- }
646
- this.setState({formData, editTemplateData: selectedTemplateData}, () => {
647
- if (!_.isEmpty(this.state.editTemplateData) && this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
648
- this.setEditData();
649
- }
650
- if (selectedWechatTemplateIndex !== -1 || this.state.isEdit) {
651
- let templateData = {};
652
- if (this.state.isEdit && !_.isEmpty(this.state.editTemplateData)) {
653
- templateData = {
654
- template_id: this.state.editTemplateData.versions.base.template_id,
655
- title: this.state.editTemplateData.versions.base.Title,
656
- content: this.state.editTemplateData.versions.base.content,
657
- };
658
- if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
659
- this.setSelectedTemplateData(selectedTemplate);
660
- } else {
661
- const templateTags = this.getTagsFromContent(templateData.content);
662
- this.prepareWeChatPreviewData(templateData, templateTags);
663
- }
664
- } else if (!this.updateSchema) {
665
- const templateTags = this.getTagsFromContent(selectedTemplate.content);
666
- this.prepareWeChatPreviewData(selectedTemplate, templateTags);
667
- } else {
668
- this.updateSchema = false;
669
- this.setSelectedTemplateData(selectedTemplate);
670
- }
671
- } else {
672
- let selectedAccount = {};
673
- _.forEach(this.props.WeChat.weCrmAccounts, (account) => {
674
- if (account.configs && account.configs.is_wecrm_enabled) {
675
- if (account.name === formData['wechat-accounts']) {
676
- selectedAccount = account;
677
- }
678
- }
679
- });
680
- this.props.actions.setWeChatAccount(selectedAccount);
681
- }
682
- });
683
- }
684
-
685
- onTagSelect(data, currentTab, value) {
686
- const editorId = (value.id).replace('tagList', 'template');
687
- this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
688
- document.getElementById(editorId).focus();
689
- }
690
-
691
- getFormData(e) {
692
- console.log('posting final result', this.state.formData, this.state.editTemplateData);
693
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.WeChat.selectedWeChatAccount);
694
- const data = {
695
- "template_id": this.state.editTemplateData.versions.base.template_id,
696
- "Title": this.state.editTemplateData.versions.base.Title,
697
- Tag: [],
698
- url: this.state.formData['is-internal-url'] ? this.maskTemplateUrl(this.state.formData['template-link']) : this.state.formData['template-link'],
699
- TopColor: "#000000",
700
- data: {},
701
- preview: '',
702
- BrandId: (selectedWeChatAccount.configs.brand_id ? selectedWeChatAccount.configs.brand_id : ''),
703
- OriginalId: selectedWeChatAccount.sourceAccountIdentifier,
704
- content: this.state.editTemplateData.versions.base.content,
705
- isInternalUrl: this.state.formData['is-internal-url'],
706
- creative_template_id: this.state.editTemplateData._id,
707
- };
708
- _.forEach(this.state.selectedTemplateTags, (templateTag) => {
709
- const tagName = templateTag.substr(0, templateTag.indexOf('.'));
710
- let newTagname = tagName;
711
- data.Tag.push(tagName);
712
- if (tagName.match(/first/i)) {
713
- newTagname = "Header";
714
- }
715
- if (tagName.match(/remark/i)) {
716
- newTagname = "Footer";
717
- }
718
- data.data[tagName] = {};
719
- data.data[tagName] = {
720
- value: this.state.formData[`template-${newTagname}`],
721
- color: "#00000",
722
- };
723
- });
724
- const response = {
725
- action: "getFormData",
726
- value: data,
727
- validity: this.state.isFormValid,
728
- };
729
- console.log('response ', response);
730
- this.setState({checkValidation: true});
731
- if (this.props.location.query.module === 'library') {
732
- this.props.getLibraryFormData(response);
733
- } else {
734
- e.source.postMessage(JSON.stringify(response), e.origin);
735
- }
736
- }
737
-
738
- getCurrentWindow(e) {
739
- console.log('in sms create', e);
740
- const response = {
741
- action: e.action,
742
- value: 'edit',
743
- direction: e.value,
744
- };
745
- parent.postMessage(JSON.stringify(response), '*');
746
- }
747
-
748
- getTagsFromContent(string) {
749
- const foundTags = [];
750
- const rxp = /{{([^}]+)}}/g;
751
- let curMatch;
752
- /* eslint-disable */
753
- while ( curMatch = rxp.exec( string ) ) {
754
- foundTags.push( curMatch[1] );
755
- }
756
- return foundTags;
757
- }
758
-
759
- startLoading(ifEdit) {
760
- console.log('startLoading', ifEdit);
761
- if (ifEdit) {
762
- this.setState({loading: true});
763
- }
764
- }
765
-
766
- handleFrameTasks = (e) => {
767
- // console.log('data listened to is', e.data);
768
- const type = e.data;
769
- // console.log('data type', typeof type);
770
- if (typeof type === 'object') {
771
- // console.log('received something', type);
772
- const action = type.action;
773
- switch (action) {
774
- case "startTemplateCreation":
775
- this.startTemplateCreation(type.value);
776
- break;
777
- case "startLoading":
778
- this.startLoading(type.edit);
779
- break;
780
- case "getCurrentWindow":
781
- this.getCurrentWindow(type);
782
- break;
783
- default:
784
- break;
785
- }
786
- } else {
787
- switch (type) {
788
- case "getFormData":
789
- this.getFormData(e);
790
- break;
791
- case "startTemplateCreation":
792
- console.log('Starting to create template');
793
- //this.getFormData(e);
794
- break;
795
- case "moveToTemplates":
796
- console.log('moving to templates');
797
- this.moveToTemplates();
798
- break;
799
- case "validateContent":
800
- console.log('validating Content');
801
- this.validateContent(e);
802
- break;
803
- default:
804
- break;
805
- }
806
- }
807
- }
808
-
809
- moveToTemplates() {
810
- console.log('in move to Templates');
811
- const modalContent = {
812
- title: "Alert",
813
- body: "Do you really want to go back? All your temporary changes will be lost!",
814
- type: 'confirm',
815
- id: 'template-back-confirm-modal',
816
- show: true,
817
- };
818
- this.setState({modalContent, showModal: true});
819
- }
820
-
821
- injectMessages(elem) {
822
- const temp = elem;
823
- if (temp.value && messages[temp.value]) {
824
- temp.value = this.props.intl.formatMessage(messages[temp.value]);
825
- }
826
- if (temp.label && messages[temp.label]) {
827
- temp.label = this.props.intl.formatMessage(messages[temp.label]);
828
- }
829
- if (temp.errorMessage && messages[temp.errorMessage]) {
830
- temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
831
- }
832
- if (temp.placeholder && messages[temp.placeholder]) {
833
- temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
834
- }
835
- return temp;
836
- }
837
-
838
- setSelectedTemplateData(weChatData) {
839
- if (_.isEmpty(weChatData)) {
840
- return;
841
- }
842
- console.log('Setting Data ', weChatData, this.state.baseSchema);
843
- const {map} = _.cloneDeep(this.state);
844
- const schema = _.cloneDeep(this.state.baseSchema);
845
- const templateTags = this.getTagsFromContent(weChatData.content);
846
- const formData = _.cloneDeep(this.state.formData);
847
- _.forEach(templateTags, (tag) => {
848
- const tagTitle = tag.substr(0, tag.indexOf('.'));
849
- let title = tagTitle;
850
-
851
- if (tagTitle.match(/first/i)) {
852
- title = "Header";
853
- }
854
- if (tagTitle.match(/remark/i)) {
855
- title = "Footer";
856
- }
857
-
858
- const colsData = {
859
- cols: [
860
- {
861
- id: `template-label-${title}`,
862
- metaType: "label",
863
- value: `${title}`,
864
- primitive: true,
865
- type: "div",
866
- width: 4,
867
- offset: 0,
868
- onlyDisplay: true,
869
- colStyle: {
870
- flex: 1,
871
- textAlign: 'left',
872
- color: '#333333',
873
- lineHeight: '24px',
874
- fontSize: '14px',
875
- fontWeight: '400',
876
- fontFamily: 'open-sans',
877
- fontStyle: 'normal',
878
- textTransform: 'capitalize',
879
- padding: '1em .833em',
880
- },
881
- },
882
- {
883
- id: `template-${title}`,
884
- placeholder: `${title}`,
885
- type: "input", //Resembles component to be used
886
- metaType: "text",
887
- datatype: "string",
888
- errorMessage: `${title} has invalid content.`,
889
- required: true,
890
- fluid: true,
891
- disabled: (this.props.location.query.type === 'embedded'),
892
- style: {
893
- fontSize: '14px',
894
- fontFamily: 'open-sans',
895
- fontStyle: 'normal',
896
- // fontWeight: 600,
897
- marginBottom: '16px',
898
- },
899
- styling: "semantic",
900
- order: 1,
901
- width: 15,
902
- // offSet: 2,
903
- customComponent: false,
904
- standalone: true,
905
- supportedEvents: [
906
- 'onChange',
907
- ],
908
- },
909
- ],
910
- };
911
-
912
- if(this.props.location.query.type !== 'embedded') {
913
- colsData.cols.push({
914
- offset: 20,
915
- id: `tagList-${title}`,
916
- label: "Tags",
917
- type: "tag-list", //Resembles component to be used
918
- metaType: "List",
919
- datatype: "select",
920
- required: true,
921
- fluid: true,
922
- onlyDisplay: true,
923
- styling: "semantic",
924
- order: 1,
925
- customComponent: true,
926
- supportedEvents: [
927
- 'onTagSelect',
928
- ],
929
- },);
930
- }
931
-
932
- map[`tagList-${title}`] = {
933
- onTagSelect: this.onTagSelect,
934
- };
935
-
936
- // if(!tagTitle.match(/first/i) && !tagTitle.match(/remark/i) && this.props.location.query.type !== 'embedded') {
937
- // colsData.cols.push({
938
- // offset: 20,
939
- // id: `tagList-${title}`,
940
- // // label: "Tags",
941
- // type: "tag-list", //Resembles component to be used
942
- // metaType: "List",
943
- // datatype: "select",
944
- // required: true,
945
- // fluid: true,
946
- // onlyDisplay: true,
947
- // styling: "semantic",
948
- // order: 1,
949
- // customComponent: true,
950
- // supportedEvents: [
951
- // 'onTagSelect',
952
- // ],
953
- // },);
954
-
955
- // map[`tagList-${title}`] = {
956
- // onTagSelect: this.onTagSelect,
957
- // };
958
- // }
959
- map[`template-${title}`] = {
960
- onChange: this.setContent,
961
- };
962
-
963
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields.push(colsData);
964
- });
965
-
966
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields.push(
967
- {
968
- cols: [
969
- {
970
- id: "template-label-link",
971
- metaType: "label",
972
- value: 'Link',
973
- primitive: true,
974
- type: "div",
975
- width: 4,
976
- offset: 0,
977
- onlyDisplay: true,
978
- colStyle: {
979
- flex: 1,
980
- textAlign: 'left',
981
- color: '#333333',
982
- lineHeight: '24px',
983
- fontSize: '14px',
984
- fontWeight: '400',
985
- fontFamily: 'open-sans',
986
- fontStyle: 'normal',
987
- textTransform: 'capitalize',
988
- padding: '.5em .833em',
989
- },
990
- },
991
- {
992
- id: 'template-link',
993
- placeholder: this.props.intl.formatMessage(messages.Link),
994
- type: "input", //Resembles component to be used
995
- metaType: "text",
996
- datatype: "string",
997
- errorMessage: `Link cannot be empty.`,
998
- required: true,
999
- fluid: true,
1000
- disabled: (this.props.location.query.type === 'embedded'),
1001
- style: {
1002
- fontSize: '14px',
1003
- fontFamily: 'open-sans',
1004
- fontStyle: 'normal',
1005
- // fontWeight: 600,
1006
- // marginBottom: '16px',
1007
- },
1008
- styling: "semantic",
1009
- order: 1,
1010
- width: 15,
1011
- // offSet: 6,
1012
- customComponent: false,
1013
- standalone: true,
1014
- supportedEvents: [
1015
- 'onChange',
1016
- ],
1017
- },
1018
- ],
1019
- },
1020
- {
1021
- cols: [
1022
- {
1023
- id: "is-internal-url",
1024
- label: 'Is this internal url',
1025
- standalone: true,
1026
- labelStyle: {
1027
- backgroundColor: "white",
1028
- },
1029
- colStyle: {
1030
- marginBottom: '24px',
1031
- },
1032
- style: {
1033
- textAlign: 'left',
1034
- color: '#262626',
1035
- fontFamily: 'Open-Sans',
1036
- lineHeight: '24px',
1037
- fontSize: '14px',
1038
- padding: '.5833em .833em',
1039
- marginBottom: '24px',
1040
- paddingLeft: '0',
1041
- },
1042
- type: "checkbox",
1043
- disabled: (this.props.location.query.type === 'embedded'),
1044
- metaType: "text",
1045
- datatype: "boolean",
1046
- required: true,
1047
- fluid: true,
1048
- styling: "semantic",
1049
- order: 1,
1050
- width: 10,
1051
- offset: 4,
1052
- onlyDisplay: false,
1053
- customComponent: false,
1054
- supportedEvents: [
1055
- 'onChange',
1056
- ],
1057
- },
1058
- ],
1059
- }
1060
- );
1061
- if (this.state.isEdit) {
1062
- _.forEach(this.state.editTemplateData.versions.base.Tag, (tag) => {
1063
- let tagName = tag;
1064
- if (tag.match(/first/i)) {
1065
- tagName = "Header";
1066
- }
1067
- if (tag.match(/remark/i)) {
1068
- tagName = "Footer";
1069
- }
1070
- formData[`template-${tagName}`] = this.state.editTemplateData.versions.base.data[tag].value;
1071
- });
1072
- if (this.state.editTemplateData.versions.base.url) {
1073
- formData[`template-link`] = this.state.editTemplateData.versions.base.isInternalUrl ? this.unMaskTemplateUrl(this.state.editTemplateData.versions.base.url) : this.state.editTemplateData.versions.base.url;
1074
- }
1075
- if (this.state.editTemplateData.versions.base.isInternalUrl) {
1076
- formData['is-internal-url'] = this.state.editTemplateData.versions.base.isInternalUrl;
1077
- }
1078
- // schema.standalone.sections[0].childSections[1].childSections[1].inputFields[0].cols[0].content = weChatData.content;
1079
- } else {
1080
- // schema.standalone.sections[0].childSections[1].childSections[1].inputFields[0].cols[0].content = weChatData.content;
1081
- }
1082
- // schema.standalone.sections[0].childSections[1].childSections[1].inputFields[0].cols[0].content = weChatData.content;
1083
-
1084
- this.setState({schema, map, selectedTemplateTags: templateTags, formData}, () => {
1085
- console.log('Is internal URL ', this.state.schema, formData);
1086
- this.prepareWeChatPreviewData(weChatData, templateTags);
1087
- });
1088
- }
1089
-
1090
- resetState() {
1091
- this.setState({
1092
- formData: {},
1093
- schema: {},
1094
- baseSchema: {},
1095
- selectedTemplateTags: [],
1096
- isEdit: false,
1097
- editTemplateData: {},
1098
- isFormValid: true,
1099
- checkValidation: false,
1100
- injectedTags: {},
1101
- isLoading: true,
1102
- });
1103
- }
1104
-
1105
- resetSchema() {
1106
- const formData = _.cloneDeep(this.state.formData);
1107
- if (this.state.isEdit) {
1108
- const templateData = {
1109
- template_id: this.state.editTemplateData.versions.base.template_id,
1110
- title: this.state.editTemplateData.versions.base.Title,
1111
- content: this.state.editTemplateData.versions.base.content,
1112
- };
1113
- this.setSelectedTemplateData(templateData);
1114
- } else {
1115
- this.setState({ schema: this.state.baseSchema, formData: {'wechat-template': "" }});
1116
- // this.setState({ schema: this.props.metaEntities.layouts[0].definition });
1117
- }
1118
- }
1119
-
1120
- setWechatAccountOptions(weCrmAccounts) {
1121
- const schema = _.cloneDeep(this.state.schema);
1122
- const formData = _.cloneDeep(this.state.formData);
1123
- if (!_.isEmpty(weCrmAccounts)) {
1124
- _.forEach(weCrmAccounts, (account) => {
1125
- if (account.configs && account.configs.is_wecrm_enabled) {
1126
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].options.push({
1127
- key: account.uuid,
1128
- label: account.name,
1129
- value: account.name,
1130
- });
1131
- }
1132
-
1133
- if (this.props.WeChat.templateDetails && this.props.WeChat.templateDetails.versions.base.OriginalId === account.sourceAccountIdentifier) {
1134
- formData['wechat-accounts'] = account.name;
1135
- this.props.actions.setWeChatAccount(account);
1136
- }
1137
- });
1138
- this.setState({schema, formData});
1139
- }
1140
- }
1141
-
1142
- selectWechatAccount(value, option) {
1143
- // console.log('Test ', value, option);
1144
- // templateActions.setWeChatAccount();
1145
- }
1146
-
1147
- setTemplateOptions(weChatData) {
1148
- 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);
1152
- const baseSchemaTemplateOptionEmpty = (!_.isEmpty(baseSchema) && _.isEmpty(baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options));
1153
- _.forEach(weChatData, (template) => {
1154
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options.push({
1155
- key: (template.versions) ? template.versions.base.template_id : template.template_id,
1156
- label: (template.versions) ? template.name : `${template.title} : ${template.template_id}`,
1157
- value: (template.versions) ? template.versions.base.template_id : template.template_id,
1158
- });
1159
- if ((!_.isEmpty(baseSchema) && this.props.location.query.module === 'loyalty') || (baseSchemaTemplateOptionEmpty)) {
1160
- baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options.push({
1161
- key: (template.versions) ? template.versions.base.template_id : template.template_id,
1162
- label: (template.versions) ? template.name : `${template.title} : ${template.template_id}`,
1163
- value: (template.versions) ? template.versions.base.template_id : template.template_id,
1164
- });
1165
- }
1166
- });
1167
- this.setState({schema, baseSchema: _.cloneDeep(baseSchema)}, () => {
1168
- console.log('setTemplateOptions', this.state.baseSchema, schema);
1169
- if (_.isEmpty(this.state.baseSchema)) {
1170
- this.setState({baseSchema: _.cloneDeep(schema)});
1171
- }
1172
- });
1173
- }
1174
-
1175
- setFormValidity(isFormValid) {
1176
- this.setState({isFormValid});
1177
- }
1178
-
1179
- setContent(content) {
1180
- console.log('Template content changed to ', content);
1181
- }
1182
-
1183
- setEditData() {
1184
- console.log('Inside Edit Data ', this.state.editTemplateData);
1185
- const formData = _.cloneDeep(this.state.formData);
1186
- const baseSchema = _.cloneDeep(this.state.baseSchema);
1187
- if (_.isEmpty(baseSchema)) {
1188
- return;
1189
- }
1190
- formData['wechat-template'] = this.state.editTemplateData.versions.base.template_id;
1191
- if (this.props.location.query.module !== 'loyalty' && !_.isEmpty(baseSchema)) {
1192
- baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options = [];
1193
- baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options.push({
1194
- key: this.state.editTemplateData.versions.base.template_id,
1195
- label: this.state.editTemplateData.name,
1196
- value: this.state.editTemplateData.versions.base.template_id,
1197
- });
1198
- }
1199
- const templateData = {
1200
- 'template_id': this.state.editTemplateData.versions.base.template_id,
1201
- 'title': this.state.editTemplateData.versions.base.Title,
1202
- 'content': this.state.editTemplateData.versions.base.content,
1203
- };
1204
-
1205
- this.setState({baseSchema, formData, isEdit: true}, () => {
1206
- this.setSelectedTemplateData(templateData);
1207
- })
1208
- }
1209
-
1210
- maskTemplateUrl(url) {
1211
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.WeChat.selectedWeChatAccount);
1212
- console.log('wecrm url', selectedWeChatAccount.configs.wecrm_app_id);
1213
-
1214
- const appid = selectedWeChatAccount.configs.wecrm_app_id;
1215
- const domain = selectedWeChatAccount.configs.domain;
1216
- const maskedUrl = `${domain}/web?appid=${appid}&redirect_uri=${escape(url)}&response_type=code&scope=snsapi_base&state=STATE`;
1217
- console.log('wecrm masked url', maskedUrl);
1218
- return maskedUrl;
1219
- }
1220
-
1221
- unMaskTemplateUrl(url) {
1222
- let startIndex, endIndex;
1223
- startIndex = url.indexOf('&redirect_uri=') + 14;
1224
- endIndex = url.indexOf('&response_type');
1225
- return decodeURIComponent(url.substring(startIndex, endIndex));
1226
- }
1227
-
1228
- getMappedEvent(id, event) {
1229
- return this.state.map[id][event];
1230
- }
1231
-
1232
- handleOnTagsContextChange = (data) => {
1233
- console.log('parent tags context', data);
1234
- const query = {
1235
- layout: 'WECHAT',
1236
- type: 'TAG',
1237
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
1238
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
1239
- };
1240
- this.props.globalActions.fetchSchemaForEntity(query);
1241
- }
1242
-
1243
- startTemplateCreation(data) {
1244
- console.log('startTemplateCreation');
1245
- }
1246
-
1247
- selectWechatTemplate() {
1248
- console.log('Updated data');
1249
- }
1250
-
1251
- removeActionButtons() {
1252
- const schema = _.cloneDeep(this.state.schema);
1253
- const headerCols = schema.standalone.sections[0].childSections[0].inputFields[0].cols;
1254
- _.forEach(headerCols, (col) => {
1255
- col.colStyle.display = 'none';
1256
- });
1257
- this.setState({schema});
1258
- }
1259
-
1260
- showNext() {
1261
- const response = {
1262
- action: "showNext",
1263
- value: true,
1264
- };
1265
- parent.postMessage(JSON.stringify(response), '*');
1266
- }
1267
-
1268
- insertAtCursor(field, myValue) {
1269
- //IE support
1270
- const myField = field;
1271
- if (document.selection) {
1272
- myField.focus();
1273
- const sel = document.selection.createRange();
1274
- sel.text = myValue;
1275
- } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
1276
- const startPos = myField.selectionStart;
1277
- const endPos = myField.selectionEnd;
1278
- myField.value = myField.value.substring(0, startPos)
1279
- + myValue
1280
- + myField.value.substring(endPos, myField.value.length);
1281
- myField.selectionStart = startPos + myValue.length;
1282
- myField.selectionEnd = startPos + myValue.length;
1283
- } else {
1284
- myField.value += myValue;
1285
- }
1286
- const event = new Event('input', { bubbles: true });
1287
- myField.dispatchEvent(event);
1288
- }
1289
-
1290
- internalUrlChecked() {
1291
-
1292
- }
1293
-
1294
- discardValues() {
1295
- // this.setState({ schema: this.state.baseSchema, formData: {}});
1296
- this.resetSchema();
1297
- // this.resetState();
1298
- }
1299
-
1300
- cancelTemplate() {
1301
- const type = this.props.location.query.type;
1302
- this.props.router.push({
1303
- pathname: `/wechat`,
1304
- query: type === 'embedded' ? {type: 'embedded'} : {},
1305
- });
1306
- }
1307
-
1308
- saveFormData(formData) {
1309
- const obj = {};
1310
- let selectedWechatData = {};
1311
- if (this.state.isEdit) {
1312
- obj['_id'] = this.state.editTemplateData._id;
1313
- selectedWechatData = {
1314
- 'template_id': this.state.editTemplateData.versions.base.template_id,
1315
- 'title': this.state.editTemplateData.versions.base.Title,
1316
- 'content': this.state.editTemplateData.versions.base.content,
1317
- };
1318
- } else {
1319
- const selectedWechatTemplateIndex = _.findIndex(this.props.WeChat.weChatDefaultTemplate, {template_id: formData['wechat-template']});
1320
- selectedWechatData = this.props.WeChat.weChatDefaultTemplate[selectedWechatTemplateIndex];
1321
- }
1322
- obj.name = `${selectedWechatData.title}: ${selectedWechatData.template_id}`;
1323
- obj.versions = {
1324
- base: {},
1325
- history: [],
1326
- };
1327
- obj.versions.base = {
1328
- "template_id": selectedWechatData.template_id,
1329
- "Title": selectedWechatData.title,
1330
- Tag: [],
1331
- url: this.state.formData['is-internal-url'] ? this.maskTemplateUrl(this.state.formData['template-link']) : this.state.formData['template-link'],
1332
- TopColor: "#000000",
1333
- data: {},
1334
- preview: '',
1335
- BrandId: (this.props.Templates.selectedWeChatAccount.configs.brand_id ? this.props.Templates.selectedWeChatAccount.configs.brand_id : ''),
1336
- OriginalId: this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier,
1337
- content: selectedWechatData.content,
1338
- isInternalUrl: this.state.formData['is-internal-url'],
1339
- }
1340
- _.forEach(this.state.selectedTemplateTags, (templateTag) => {
1341
- const tagName = templateTag.substr(0, templateTag.indexOf('.'));
1342
- let newTagname = tagName;
1343
- obj.versions.base.Tag.push(tagName);
1344
- if (tagName.match(/first/i)) {
1345
- newTagname = "Header";
1346
- }
1347
- if (tagName.match(/remark/i)) {
1348
- newTagname = "Footer";
1349
- }
1350
- obj.versions.base.data[tagName] = {};
1351
- obj.versions.base.data[tagName] = {
1352
- value: this.state.formData[`template-${newTagname}`],
1353
- color: "#00000",
1354
- }
1355
- });
1356
- console.log("Final Object ", obj);
1357
- this.props.actions.createTemplate(obj);
1358
- }
1359
-
1360
- prepareWeChatPreviewData(wechatData, templateTags) {
1361
- let content = _.cloneDeep(wechatData.content);
1362
- const {formData} = _.cloneDeep(this.state);
1363
- _.forEach(templateTags, (tag) => {
1364
- let tagName = tag.substr(0, tag.indexOf('.'));
1365
- if (tagName.match(/first/i)) {
1366
- tagName = "Header";
1367
- }
1368
- if (tagName.match(/remark/i)) {
1369
- tagName = "Footer";
1370
- }
1371
- if(this.state.formData[`template-${tagName}`] !== undefined && this.state.formData[`template-${tagName}`] !== '') {
1372
- content = content.replace(`{{${tag}}}`, this.state.formData[`template-${tagName}`]);
1373
- }
1374
- })
1375
- formData['sms-preview'] = content;
1376
- // schema.standalone.sections[0].childSections[1].childSections[1].inputFields[0].cols[0].content = content;
1377
- this.setState({formData}, () => {
1378
- this.injectEvents(this.state.schema);
1379
- });
1380
- }
1381
-
1382
- injectEvents(schema) {
1383
- console.log('injecting events', schema);
1384
- const temp = schema;
1385
- let newSchema = _.cloneDeep(schema);
1386
- temp.standalone.sections = this.injectSections(temp.standalone.sections);
1387
- _.forEach(temp.containers, (container) => {
1388
- let tempContainer = container;
1389
- tempContainer = this.injectContainer(tempContainer);
1390
- return tempContainer;
1391
- });
1392
- newSchema = this.hideSchemaElementsByModule(schema);
1393
- this.setState({schema: newSchema});
1394
- return schema;
1395
- }
1396
-
1397
- hideSchemaElementsByModule(schema) {
1398
- schema.standalone.sections[0].childSections[0].inputFields[0].cols[0].colStyle.display = (this.props.location.query.type === 'embedded' ? 'none' : 'block');
1399
- schema.standalone.sections[0].childSections[0].inputFields[0].cols[1].colStyle.display = (this.props.location.query.type === 'embedded' ? 'none' : 'block');
1400
- schema.standalone.sections[0].childSections[0].inputFields[0].cols[2].colStyle.display = (this.props.location.query.type === 'embedded' ? 'none' : 'block');
1401
- schema.standalone.sections[0].childSections[0].inputFields[0].cols[3].colStyle.display = (this.props.location.query.type === 'embedded' ? 'none' : 'block');
1402
-
1403
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].labelStyle.display = (this.props.location.query.module === 'loyalty' ? 'block' : 'none');
1404
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[0].style.display = (this.props.location.query.module === 'loyalty' ? 'block' : 'none');
1405
-
1406
- schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].disabled = (this.props.params.id && this.props.location.query.module !== 'loyalty');
1407
- return schema;
1408
- }
1409
-
1410
- injectContainer(container) {
1411
- const temp = container;
1412
- if (temp.type === 'tabs') {
1413
- temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
1414
- temp.tabBarExtraContent.sections = this.injectSections(temp.tabBarExtraContent.sections);
1415
- temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
1416
- temp.injectedEvents = {};
1417
- _.forEach(temp.supportedEvents, (event) => {
1418
- temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
1419
- });
1420
- _.forEach(temp.panes, (pane) => {
1421
- const tempPane = pane;
1422
- tempPane.sections = this.injectSections(tempPane.sections);
1423
- });
1424
- }
1425
- return temp;
1426
- }
1427
-
1428
- injectMultiColSection(section) {
1429
- _.forEach(section.inputFields, (inputField) => {
1430
- _.forEach(inputField.cols, (col) => {
1431
- console.log('injecting for col', col);
1432
- let temp = col;
1433
- if (temp.type === 'popover') {
1434
- temp.content.sections = this.injectSections(temp.content.sections);
1435
- temp.value.sections = this.injectSections(temp.value.sections);
1436
- return true;
1437
- }
1438
- temp.injectedEvents = {};
1439
- _.forEach(col.supportedEvents, (event) => {
1440
- temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
1441
- });
1442
- temp = this.injectMessages(temp);
1443
- return true;
1444
- });
1445
- });
1446
- _.forEach(section.actionFields, (actionField) => {
1447
- _.forEach(actionField.cols, (col) => {
1448
- let temp = col;
1449
- if (temp.type === 'popover') {
1450
- temp.content.sections = this.injectSections(temp.content.sections);
1451
- temp.value.sections = this.injectSections(temp.value.sections);
1452
- return true;
1453
- }
1454
- temp.injectedEvents = {};
1455
- _.forEach(col.supportedEvents, (event) => {
1456
- temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
1457
- });
1458
- temp = this.injectMessages(temp);
1459
- return true;
1460
- });
1461
- });
1462
- return section;
1463
- }
1464
-
1465
- injectColLabelSection(section) {
1466
- _.forEach(section.inputFields, (inputField) => {
1467
- let temp = inputField;
1468
- if (temp.type === 'popover') {
1469
- temp.content.sections = this.injectSections(temp.content.sections);
1470
- temp.value.sections = this.injectSections(temp.value.sections);
1471
- return true;
1472
- }
1473
- temp.injectedEvents = {};
1474
- _.forEach(inputField.supportedEvents, (event) => {
1475
- temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
1476
- });
1477
- temp = this.injectMessages(temp);
1478
- return true;
1479
- });
1480
- _.forEach(section.actionFields, (actionField) => {
1481
- let temp = actionField;
1482
- if (temp.type === 'popover') {
1483
- temp.content.sections = this.injectSections(temp.content.sections);
1484
- temp.value.sections = this.injectSections(temp.value.sections);
1485
- return true;
1486
- }
1487
- temp.injectedEvents = {};
1488
- _.forEach(actionField.supportedEvents, (event) => {
1489
- temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
1490
- });
1491
- temp = this.injectMessages(temp);
1492
- return true;
1493
- });
1494
- return section;
1495
- }
1496
-
1497
- injectSections(sections) {
1498
- _.forEach(sections, (section) => {
1499
- let temp = section;
1500
- if (temp.type === 'col-label') {
1501
- temp = this.injectColLabelSection(temp);
1502
- } else if (section.type === 'multicols') {
1503
- temp = this.injectMultiColSection(temp);
1504
- } else if (section.type === 'parent') {
1505
- temp = this.injectSections(temp.childSections);
1506
- }
1507
- });
1508
- return sections;
1509
- }
1510
-
1511
- handleCancelModal = () => {
1512
- this.setState({showModal: false});
1513
- }
1514
-
1515
- injectParentSection(section) {
1516
- _.forEach(section.childSections, (childSection) => {
1517
- let temp = childSection;
1518
- if (temp.type === 'col-label') {
1519
- temp = this.injectColLabelSection(temp);
1520
- } else if (section.type === 'multicols') {
1521
- temp = this.injectMultiColSection(temp);
1522
- } else if (section.type === 'parent') {
1523
- temp = this.injectParentSection(temp);
1524
- }
1525
- });
1526
- return section;
1527
- }
1528
-
1529
- render() {
1530
- // const schema = this.state.schema;
1531
- // const options = [
1532
- // {
1533
- // label: 'Test',
1534
- // value: 'Test',
1535
- // },
1536
- // {
1537
- // label: 'Test1',
1538
- // value: 'Test1',
1539
- // },
1540
- // {
1541
- // label: 'Test2',
1542
- // value: 'Test2',
1543
- // },
1544
- // {
1545
- // label: 'Test3',
1546
- // value: 'Test3',
1547
- // },
1548
- // ];
1549
- return (
1550
- <Spin
1551
- tip={this.props.intl.formatMessage(messages.gettingTemplateData)}
1552
- spinning={this.state.isLoading}>
1553
- <div>
1554
- <Helmet
1555
- title="WeChat"
1556
- />
1557
- {/* <CapSelect options={options} /> */}
1558
- <Row className="wechat-container">
1559
- <Col>
1560
- <FormBuilder
1561
- schema={this.state.schema}
1562
- onSubmit={this.saveFormData}
1563
- onChange={this.onFormDataChange}
1564
- parent={this}
1565
- modal={this.state.modalContent}
1566
- showModal={this.state.showModal}
1567
- iframeParent={parent}
1568
- formData={_.cloneDeep(this.state.formData)}
1569
- onFormValidityChange={this.setFormValidity}
1570
- location= {this.props.location}
1571
- tags={this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : []}
1572
- tagModule={this.props.getDefaultTags}
1573
- injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
1574
- isEdit={this.state.isEdit}
1575
- usingTabContainer={false}
1576
- router={this.props.router}
1577
- checkValidation={this.state.checkValidation}
1578
- handleCancelModal={this.handleCancelModal}
1579
- onContextChange={this.handleOnTagsContextChange}
1580
- />
1581
- </Col>
1582
- </Row>
1583
- </div>
1584
- </Spin>
1585
- );
1586
- }
1587
- }
1588
-
1589
- WeChat.propTypes = {
1590
- actions: PropTypes.object.isRequired,
1591
- WeChat: PropTypes.object,
1592
- globalActions: PropTypes.object,
1593
- Templates: PropTypes.object,
1594
- location: PropTypes.object,
1595
- router: PropTypes.object,
1596
- params: PropTypes.object,
1597
- metaEntities: PropTypes.object,
1598
- intl: intlShape.isRequired,
1599
- isGetFormData: PropTypes.bool,
1600
- getLibraryFormData: PropTypes.func,
1601
- getDefaultTags: PropTypes.string,
1602
- };
1603
-
1604
- const mapStateToProps = createStructuredSelector({
1605
- WeChat: makeSelectWeChat(),
1606
- Templates: makeSelectTemplates(),
1607
- metaEntities: makeSelectMetaEntities(),
1608
- });
1609
-
1610
- function mapDispatchToProps(dispatch) {
1611
- return {
1612
- actions: bindActionCreators(actions, dispatch),
1613
- globalActions: bindActionCreators(globalActions, dispatch),
1614
- };
1615
- }
1616
-
1617
- export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(WeChat)));