@capillarytech/creatives-library 8.0.136 → 8.0.137-alpha.1

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 (298) hide show
  1. package/constants/unified.js +189 -0
  2. package/package.json +1 -1
  3. package/services/getSchema.js +1 -1
  4. package/services/localStorageApi.js +1 -0
  5. package/tests/i18n.test.js +1 -1
  6. package/utils/common.js +2 -2
  7. package/utils/createMobilePushPayload.js +0 -1
  8. package/utils/tagValidations.js +1 -1
  9. package/utils/tests/checkStore.test.js +1 -1
  10. package/utils/tests/customAuth.test.js +1 -1
  11. package/utils/transformerUtils.js +1 -1
  12. package/v2Components/CapTagList/index.js +9 -14
  13. package/v2Components/Carousel/style.scss +1 -1
  14. package/v2Components/EmailMobilePreview/index.js +2 -2
  15. package/v2Components/FormBuilder/index.js +2 -2
  16. package/v2Components/TemplatePreview/_templatePreview.scss +0 -10
  17. package/v2Components/TemplatePreview/index.js +2 -3
  18. package/v2Containers/Cap/tests/saga.test.js +1 -1
  19. package/v2Containers/Email/index.js +1 -1
  20. package/v2Containers/FTP/index.js +1 -1
  21. package/v2Containers/Line/Container/Text/index.js +1 -1
  22. package/v2Containers/Line/Container/_lineCreate.scss +2 -4
  23. package/v2Containers/MobilePushNew/components/MediaUploaders.js +0 -1
  24. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +271 -0
  25. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +189 -0
  26. package/v2Containers/MobilePushNew/index.scss +9 -16
  27. package/v2Containers/Sms/Create/index.js +2 -2
  28. package/v2Containers/Sms/Edit/index.js +1 -1
  29. package/v2Containers/TagList/index.js +1 -1
  30. package/v2Containers/TagList/utils.js +1 -1
  31. package/v2Containers/Templates/index.js +3 -3
  32. package/v2Containers/Templates/sagas.js +1 -1
  33. package/components/BreadCrumbs/index.js +0 -65
  34. package/components/BreadCrumbs/messages.js +0 -13
  35. package/components/CapTagList/index.js +0 -235
  36. package/components/CapTagList/messages.js +0 -45
  37. package/components/Card/_customCard.scss +0 -40
  38. package/components/Card/index.js +0 -78
  39. package/components/Card/tests/__snapshots__/index.test.js.snap +0 -22
  40. package/components/Card/tests/index.test.js +0 -20
  41. package/components/CardGrid/index.js +0 -71
  42. package/components/Ckeditor/index.js +0 -238
  43. package/components/Ckeditor/messages.js +0 -13
  44. package/components/Ckeditor/style.scss +0 -3
  45. package/components/Component/index.js +0 -29
  46. package/components/CustomPopOver/index.js +0 -81
  47. package/components/CustomPopOver/messages.js +0 -17
  48. package/components/DateFilter/index.js +0 -349
  49. package/components/DateFilter/messages.js +0 -57
  50. package/components/DateRange/index.js +0 -114
  51. package/components/DateRange/messages.js +0 -25
  52. package/components/Edmeditor/index.js +0 -65
  53. package/components/Edmeditor/messages.js +0 -13
  54. package/components/EmailPreview/_emailPreview.scss +0 -119
  55. package/components/EmailPreview/assets/images/iPad.svg +0 -10
  56. package/components/EmailPreview/assets/images/mobile.png +0 -0
  57. package/components/EmailPreview/index.js +0 -107
  58. package/components/EmailPreview/messages.js +0 -33
  59. package/components/Footer/index.js +0 -27
  60. package/components/Footer/messages.js +0 -13
  61. package/components/FormBuilder/_formBuilder.scss +0 -83
  62. package/components/FormBuilder/index.js +0 -3279
  63. package/components/FormBuilder/messages.js +0 -61
  64. package/components/Header/index.js +0 -44
  65. package/components/Header/messages.js +0 -29
  66. package/components/ImagePreview/_imagePreview.scss +0 -63
  67. package/components/ImagePreview/index.js +0 -52
  68. package/components/ImagePreview/messages.js +0 -17
  69. package/components/PageHeader/_pageHeader.scss +0 -22
  70. package/components/PageHeader/index.js +0 -37
  71. package/components/PageHeader/messages.js +0 -13
  72. package/components/Pagination/_pagination.scss +0 -5
  73. package/components/Pagination/index.js +0 -49
  74. package/components/PreviewSideBar/_previewsidebar.scss +0 -28
  75. package/components/PreviewSideBar/index.js +0 -152
  76. package/components/PreviewSideBar/messages.js +0 -41
  77. package/components/Sidebar/_sidebar.scss +0 -115
  78. package/components/Sidebar/index.js +0 -214
  79. package/components/Sidebar/messages.js +0 -21
  80. package/components/SlideBox/_slideBox.scss +0 -63
  81. package/components/SlideBox/index.js +0 -47
  82. package/components/SlideBox/tests/index.test.js +0 -103
  83. package/components/SmsEditor/index.js +0 -55
  84. package/components/SmsTest/index.js +0 -117
  85. package/components/SmsTest/messages.js +0 -21
  86. package/components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +0 -42
  87. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +0 -141
  88. package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +0 -21
  89. package/components/TemplatePreview/_templatePreview.scss +0 -642
  90. package/components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
  91. package/components/TemplatePreview/assets/images/androidPushMessage.svg +0 -45
  92. package/components/TemplatePreview/assets/images/home-screen-android.svg +0 -21
  93. package/components/TemplatePreview/assets/images/home-screen-ios.svg +0 -16
  94. package/components/TemplatePreview/assets/images/iPhonePushMessage.svg +0 -135
  95. package/components/TemplatePreview/assets/images/mobile.svg +0 -24
  96. package/components/TemplatePreview/assets/images/sms-body.png +0 -0
  97. package/components/TemplatePreview/assets/images/sms-icon.png +0 -0
  98. package/components/TemplatePreview/assets/images/sms_mobile.png +0 -0
  99. package/components/TemplatePreview/assets/images/sms_mobile_android.svg +0 -22
  100. package/components/TemplatePreview/assets/images/sms_mobile_ios.svg +0 -16
  101. package/components/TemplatePreview/assets/images/user-icon.svg +0 -19
  102. package/components/TemplatePreview/assets/images/wechat-mobile.svg +0 -78
  103. package/components/TemplatePreview/assets/images/wechat_mobile_android.svg +0 -20
  104. package/components/TemplatePreview/index.js +0 -617
  105. package/components/TemplatePreview/messages.js +0 -78
  106. package/components/Toastr/index.js +0 -60
  107. package/components/Toastr/messages.js +0 -13
  108. package/components/ToastrMessage/index.js +0 -113
  109. package/components/ToastrMessage/messages.js +0 -17
  110. package/components/TopBar/_topbar.scss +0 -46
  111. package/components/TopBar/assets/images/capillary_logo.png +0 -0
  112. package/components/TopBar/assets/images/old_capillary_logo.png +0 -0
  113. package/components/TopBar/index.js +0 -113
  114. package/components/TopBar/messages.js +0 -29
  115. package/containers/App/actions.js +0 -7
  116. package/containers/App/constants.js +0 -114
  117. package/containers/App/index.js +0 -52
  118. package/containers/App/reducer.js +0 -19
  119. package/containers/App/sagas.js +0 -31
  120. package/containers/App/selectors.js +0 -25
  121. package/containers/App/test/saga.test.js +0 -11
  122. package/containers/Assets/Gallery/_gallery.scss +0 -126
  123. package/containers/Assets/Gallery/actions.js +0 -37
  124. package/containers/Assets/Gallery/constants.js +0 -23
  125. package/containers/Assets/Gallery/index.js +0 -473
  126. package/containers/Assets/Gallery/messages.js +0 -93
  127. package/containers/Assets/Gallery/reducer.js +0 -81
  128. package/containers/Assets/Gallery/sagas.js +0 -80
  129. package/containers/Assets/Gallery/selectors.js +0 -25
  130. package/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +0 -9
  131. package/containers/Assets/Gallery/tests/actions.test.js +0 -25
  132. package/containers/Assets/Gallery/tests/reducer.test.js +0 -96
  133. package/containers/Assets/Gallery/tests/saga.test.js +0 -157
  134. package/containers/Cap/actions.js +0 -66
  135. package/containers/Cap/constants.js +0 -25
  136. package/containers/Cap/index.js +0 -402
  137. package/containers/Cap/messages.js +0 -75
  138. package/containers/Cap/reducer.js +0 -113
  139. package/containers/Cap/sagas.js +0 -159
  140. package/containers/Cap/selectors.js +0 -75
  141. package/containers/Cap/tests/__snapshots__/index.test.js.snap +0 -2269
  142. package/containers/Cap/tests/index.test.js +0 -22
  143. package/containers/Cap/tests/saga.test.js +0 -284
  144. package/containers/Dashboard/actions.js +0 -15
  145. package/containers/Dashboard/constants.js +0 -7
  146. package/containers/Dashboard/index.js +0 -76
  147. package/containers/Dashboard/messages.js +0 -13
  148. package/containers/Dashboard/reducer.js +0 -21
  149. package/containers/Dashboard/sagas.js +0 -17
  150. package/containers/Dashboard/selectors.js +0 -25
  151. package/containers/Dashboard/test/saga.test.js +0 -9
  152. package/containers/Ebill/_ebill.scss +0 -5
  153. package/containers/Ebill/actions.js +0 -43
  154. package/containers/Ebill/constants.js +0 -20
  155. package/containers/Ebill/index.js +0 -1278
  156. package/containers/Ebill/messages.js +0 -77
  157. package/containers/Ebill/reducer.js +0 -72
  158. package/containers/Ebill/sagas.js +0 -74
  159. package/containers/Ebill/selectors.js +0 -25
  160. package/containers/Ebill/test/saga.test.js +0 -11
  161. package/containers/Email/_email.scss +0 -141
  162. package/containers/Email/actions.js +0 -81
  163. package/containers/Email/constants.js +0 -36
  164. package/containers/Email/index.js +0 -3325
  165. package/containers/Email/messages.js +0 -289
  166. package/containers/Email/reducer.js +0 -142
  167. package/containers/Email/sagas.js +0 -135
  168. package/containers/Email/selectors.js +0 -31
  169. package/containers/Email/test/saga.test.js +0 -671
  170. package/containers/LanguageProvider/actions.js +0 -17
  171. package/containers/LanguageProvider/constants.js +0 -8
  172. package/containers/LanguageProvider/index.js +0 -80
  173. package/containers/LanguageProvider/reducer.js +0 -30
  174. package/containers/LanguageProvider/selectors.js +0 -20
  175. package/containers/LanguageProvider/tests/actions.test.js +0 -19
  176. package/containers/LanguageProvider/tests/index.test.js +0 -78
  177. package/containers/LanguageProvider/tests/reducer.test.js +0 -20
  178. package/containers/LanguageProvider/tests/selectors.test.js +0 -15
  179. package/containers/Line/Create/_lineCreate.scss +0 -54
  180. package/containers/Line/Create/actions.js +0 -90
  181. package/containers/Line/Create/constants.js +0 -39
  182. package/containers/Line/Create/index.js +0 -836
  183. package/containers/Line/Create/messages.js +0 -189
  184. package/containers/Line/Create/reducer.js +0 -99
  185. package/containers/Line/Create/sagas.js +0 -121
  186. package/containers/Line/Create/selectors.js +0 -36
  187. package/containers/Line/Create/tests/saga.test.js +0 -202
  188. package/containers/Line/Edit/_lineEdit.scss +0 -35
  189. package/containers/Line/Edit/actions.js +0 -79
  190. package/containers/Line/Edit/constants.js +0 -27
  191. package/containers/Line/Edit/index.js +0 -1050
  192. package/containers/Line/Edit/messages.js +0 -177
  193. package/containers/Line/Edit/reducer.js +0 -83
  194. package/containers/Line/Edit/sagas.js +0 -80
  195. package/containers/Line/Edit/selectors.js +0 -29
  196. package/containers/Line/Edit/test/saga.test.js +0 -160
  197. package/containers/Login/assets/images/capillary_logo.png +0 -0
  198. package/containers/Login/components/LoginForm/index.js +0 -62
  199. package/containers/Login/components/LoginForm/messages.js +0 -33
  200. package/containers/Login/index.js +0 -130
  201. package/containers/Login/messages.js +0 -25
  202. package/containers/Login/selectors.js +0 -25
  203. package/containers/MobilePush/Create/_mobilePushCreate.scss +0 -39
  204. package/containers/MobilePush/Create/actions.js +0 -46
  205. package/containers/MobilePush/Create/constants.js +0 -23
  206. package/containers/MobilePush/Create/index.js +0 -2303
  207. package/containers/MobilePush/Create/messages.js +0 -269
  208. package/containers/MobilePush/Create/reducer.js +0 -70
  209. package/containers/MobilePush/Create/sagas.js +0 -74
  210. package/containers/MobilePush/Create/selectors.js +0 -28
  211. package/containers/MobilePush/Create/test/saga.test.js +0 -19
  212. package/containers/MobilePush/Edit/_mobilePushCreate.scss +0 -39
  213. package/containers/MobilePush/Edit/actions.js +0 -91
  214. package/containers/MobilePush/Edit/constants.js +0 -35
  215. package/containers/MobilePush/Edit/index.js +0 -2601
  216. package/containers/MobilePush/Edit/messages.js +0 -266
  217. package/containers/MobilePush/Edit/reducer.js +0 -112
  218. package/containers/MobilePush/Edit/sagas.js +0 -126
  219. package/containers/MobilePush/Edit/selectors.js +0 -29
  220. package/containers/MobilePush/Edit/tests/saga.test.js +0 -255
  221. package/containers/NotFoundPage/index.js +0 -25
  222. package/containers/NotFoundPage/messages.js +0 -13
  223. package/containers/NotFoundPage/tests/index.test.js +0 -17
  224. package/containers/Sms/Create/_smsCreate.scss +0 -42
  225. package/containers/Sms/Create/actions.js +0 -27
  226. package/containers/Sms/Create/constants.js +0 -16
  227. package/containers/Sms/Create/index.js +0 -1488
  228. package/containers/Sms/Create/messages.js +0 -109
  229. package/containers/Sms/Create/reducer.js +0 -41
  230. package/containers/Sms/Create/sagas.js +0 -40
  231. package/containers/Sms/Create/selectors.js +0 -28
  232. package/containers/Sms/Create/test/saga.test.js +0 -11
  233. package/containers/Sms/Edit/actions.js +0 -40
  234. package/containers/Sms/Edit/constants.js +0 -17
  235. package/containers/Sms/Edit/index.js +0 -1472
  236. package/containers/Sms/Edit/messages.js +0 -105
  237. package/containers/Sms/Edit/reducer.js +0 -50
  238. package/containers/Sms/Edit/sagas.js +0 -60
  239. package/containers/Sms/Edit/selectors.js +0 -32
  240. package/containers/Sms/Edit/test/saga.test.js +0 -13
  241. package/containers/TagList/_tagList.scss +0 -8
  242. package/containers/TagList/actions.js +0 -15
  243. package/containers/TagList/constants.js +0 -32
  244. package/containers/TagList/index.js +0 -236
  245. package/containers/TagList/messages.js +0 -13
  246. package/containers/TagList/reducer.js +0 -23
  247. package/containers/TagList/sagas.js +0 -11
  248. package/containers/TagList/selectors.js +0 -25
  249. package/containers/Templates/_templates.scss +0 -333
  250. package/containers/Templates/actions.js +0 -103
  251. package/containers/Templates/constants.js +0 -60
  252. package/containers/Templates/index.js +0 -1756
  253. package/containers/Templates/messages.js +0 -337
  254. package/containers/Templates/reducer.js +0 -142
  255. package/containers/Templates/sagas.js +0 -163
  256. package/containers/Templates/selectors.js +0 -28
  257. package/containers/Templates/test/saga.test.js +0 -241
  258. package/containers/WeChat/MapTemplates/_mapTemplates.scss +0 -8
  259. package/containers/WeChat/MapTemplates/actions.js +0 -52
  260. package/containers/WeChat/MapTemplates/constants.js +0 -28
  261. package/containers/WeChat/MapTemplates/index.js +0 -1610
  262. package/containers/WeChat/MapTemplates/messages.js +0 -157
  263. package/containers/WeChat/MapTemplates/reducer.js +0 -74
  264. package/containers/WeChat/MapTemplates/sagas.js +0 -84
  265. package/containers/WeChat/MapTemplates/selectors.js +0 -25
  266. package/containers/WeChat/MapTemplates/test/saga.test.js +0 -155
  267. package/containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +0 -57
  268. package/containers/WeChat/RichmediaTemplates/Create/actions.js +0 -36
  269. package/containers/WeChat/RichmediaTemplates/Create/constants.js +0 -15
  270. package/containers/WeChat/RichmediaTemplates/Create/index.js +0 -1071
  271. package/containers/WeChat/RichmediaTemplates/Create/messages.js +0 -165
  272. package/containers/WeChat/RichmediaTemplates/Create/reducer.js +0 -60
  273. package/containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +0 -497
  274. package/containers/WeChat/RichmediaTemplates/Create/sagas.js +0 -51
  275. package/containers/WeChat/RichmediaTemplates/Create/selectors.js +0 -37
  276. package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +0 -13
  277. package/containers/WeChat/RichmediaTemplates/Edit/actions.js +0 -20
  278. package/containers/WeChat/RichmediaTemplates/Edit/constants.js +0 -10
  279. package/containers/WeChat/RichmediaTemplates/Edit/index.js +0 -136
  280. package/containers/WeChat/RichmediaTemplates/Edit/messages.js +0 -13
  281. package/containers/WeChat/RichmediaTemplates/Edit/reducer.js +0 -28
  282. package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +0 -36
  283. package/containers/WeChat/RichmediaTemplates/Edit/selectors.js +0 -30
  284. package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +0 -12
  285. package/containers/WeChat/RichmediaTemplates/View/actions.js +0 -15
  286. package/containers/WeChat/RichmediaTemplates/View/constants.js +0 -7
  287. package/containers/WeChat/RichmediaTemplates/View/index.js +0 -47
  288. package/containers/WeChat/RichmediaTemplates/View/messages.js +0 -21
  289. package/containers/WeChat/RichmediaTemplates/View/reducer.js +0 -23
  290. package/containers/WeChat/RichmediaTemplates/View/sagas.js +0 -11
  291. package/containers/WeChat/RichmediaTemplates/View/selectors.js +0 -25
  292. package/utils/asyncInjectors.js +0 -78
  293. package/utils/callNativeEvent.js +0 -16
  294. package/utils/checkStore.js +0 -21
  295. package/utils/customAuthWrapper.js +0 -62
  296. package/utils/customConnectedAuthWrapper.js +0 -26
  297. package/utils/jed.js +0 -1497
  298. package/utils/smsCharCount.js +0 -351
@@ -1,2601 +0,0 @@
1
-
2
- /*
3
- *
4
- * Create
5
- *
6
- */
7
-
8
- import PropTypes from 'prop-types';
9
-
10
- import React from 'react';
11
- import { bindActionCreators, compose } from "redux";
12
- import { connect } from 'react-redux';
13
- import { Row, Col, Spin, Breadcrumb, notification } from 'antd';
14
- import { createStructuredSelector } from 'reselect';
15
- import { injectIntl, intlShape } from 'react-intl';
16
- import _ from 'lodash';
17
- import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse} from "../../MobilePush/Edit/selectors";
18
- import {makeSelectMetaEntities, setInjectedTags} from "../../Cap/selectors";
19
- import {getMessageObject} from "../../../utils/messageUtils";
20
- import FormBuilder from '../../../components/FormBuilder';
21
- import * as globalActions from "../../Cap/actions";
22
- import * as actions from "../../MobilePush/Edit/actions";
23
- import * as templatesActions from "../../Templates/actions";
24
- import {makeSelectTemplates} from "../../Templates/selectors";
25
- import messages from './messages';
26
- import './_mobilePushCreate.scss';
27
- import {makeSelectCreate} from "../Create/selectors";
28
- import injectSaga from "../../../utils/injectSaga";
29
- import injectReducer from '../../../utils/injectReducer';
30
- import reducer from './reducer';
31
- import { editMPushSaga } from './sagas';
32
- import { templateSaga } from '../../Templates/sagas';
33
- import { UserIsAuthenticated } from '../../../utils/authWrapper';
34
- import { createQueryString } from '../../../utils/common';
35
-
36
- const BreadcrumbItem = Breadcrumb.Item;
37
-
38
- export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
39
- constructor(props) {
40
- super(props);
41
- const map = {
42
- "template-name": {
43
- onChange: this.onTemplateNameChange,
44
- },
45
- "cta-deeplink-secondary-cta-0": {
46
- onChange: this.onLinkTypeChange,
47
- },
48
- "cta-deeplink-secondary-cta-1": {
49
- onChange: this.onLinkTypeChange,
50
- },
51
- "cta-deeplink-delete": {
52
- onDelete: this.deletePrimaryCTA,
53
- },
54
- "cta-deeplink2-delete": {
55
- onDelete: this.deletePrimaryCTA,
56
- },
57
- "secondary-cta-0-delete": {
58
- onDelete: this.deleteSecondaryCTA,
59
- },
60
- "secondary-cta-1-delete": {
61
- onDelete: this.deleteSecondaryCTA,
62
- },
63
- "secondary-cta-1-delete-ios": {
64
- onDelete: this.deleteSecondaryCtaIos,
65
- },
66
- "discard-button": {
67
- discardValues: this.discardValues,
68
- },
69
- "cancel-button": {
70
- cancelTemplate: this.cancelTemplate,
71
- },
72
- "copy-android-content": {
73
- onClick: this.copyAndroidContent,
74
- },
75
- "copy-iphone-content": {
76
- onClick: this.copyIphoneContent,
77
- },
78
- "save-button": {
79
- saveFormData: this.saveFormData,
80
- },
81
- "message-editor": {
82
- onChange: this.onTemplateContentChange,
83
- },
84
- "message-editor2": {
85
- onChange: this.onTemplateContentChange,
86
- },
87
- "message-tagList": {
88
- onTagSelect: this.onTagSelect,
89
- },
90
- "message-tagList2": {
91
- onTagSelect: this.onTagSelect,
92
- },
93
- "title-tagList": {
94
- onTagSelect: this.onTagSelect,
95
- },
96
- "title-tagList2": {
97
- onTagSelect: this.onTagSelect,
98
- },
99
- "pane": {
100
- onTabChange: this.onTabChange,
101
- },
102
- "cta-deeplink": {
103
- onChange: this.onLinkTypeChange,
104
- },
105
- "cta-deeplink2": {
106
- onChange: this.onLinkTypeChange,
107
- },
108
- "cta-deeplink-secondary-cta-1-select": {
109
- onSelect: this.showCtaKeys,
110
- },
111
- "cta-deeplink-secondary-cta-1-select2": {
112
- onSelect: this.showCtaKeys,
113
- },
114
- "cta-deeplink-secondary-cta-0-select": {
115
- onSelect: this.showCtaKeys,
116
- },
117
- "cta-deeplink-select": {
118
- onSelect: this.showCtaKeys,
119
- },
120
- "cta-deeplink2-select": {
121
- onSelect: this.showCtaKeys,
122
- },
123
- "add-pri-cta": {
124
- addPrimaryCta: this.addPrimaryCta,
125
- },
126
- "add-pri-cta-ios": {
127
- addPrimaryCta: this.addPrimaryCta,
128
- },
129
- "add-sec-cta": {
130
- addSecondaryCta: this.addSecondoryCta,
131
- },
132
- "add-sec-cta-ios": {
133
- addSecondaryCtaIos: this.addSecondoryCtaIos,
134
- },
135
- "image-upload-android": {
136
- onUpload: this.uploadImage,
137
- },
138
- "image-upload-ios": {
139
- onUpload: this.uploadImage,
140
- },
141
- "secondary-cta-1-table": {
142
- onRowClick: this.selectCtaIos,
143
- },
144
- "cta-deeplink-select-show-keys": {
145
- onShowCtaKeys: this.showCtaKeys,
146
- },
147
- "cta-deeplink-secondary-cta-0-select-show-keys": {
148
- onShowCtaKeys: this.showCtaKeys,
149
- },
150
- "cta-deeplink-secondary-cta-1-select-show-keys": {
151
- onShowCtaKeys: this.showCtaKeys,
152
- },
153
- "mobilepush-template": {
154
- onSelect: this.onTemplateChange,
155
- },
156
- };
157
- this.state = {
158
- formData: {},
159
- tabCount: 1,
160
- schema: {},
161
- currentTab: 1,
162
- editData: {},
163
- loading: false,
164
- isFormValid: true,
165
- injectedTags: {},
166
- showModal: false,
167
- eventsMap: map,
168
- modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages['template not configured,']), type: 'confirm'},
169
- };
170
- }
171
- componentWillMount() {
172
-
173
- this.props.actions.getWeCrmAccounts("mobilepush");
174
- if (!this.props.Templates.selectedWeChatAccount && this.props.location.query.type !== 'embedded') {
175
- const type = this.props.location.query.type;
176
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
177
- this.props.router.push({
178
- pathname: `/mobilepush/`,
179
- search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
180
- });
181
- } else {
182
- const query = {
183
- layout: 'MOBILEPUSH',
184
- type: 'LAYOUT',
185
- };
186
- this.props.globalActions.fetchSchemaForEntity(query);
187
-
188
- }
189
- }
190
- componentDidMount() {
191
- window.addEventListener("message", this.handleFrameTasks);
192
- if (!_.isEmpty(this.state.schema)) {
193
- this.injectEvents(this.state.schema);
194
- }
195
- if (this.props.location.query && typeof this.props.location.query.module === 'undefined') { // when this containers is imported from creatives library
196
- if (this.props.params.id) {
197
- this.props.actions.getTemplateDetails(this.props.params.id);
198
- } else {
199
- this.props.actions.setTemplateDetails(this.props.templateData);
200
- }
201
- }
202
- const type = this.props.location.query.type;
203
- if (type === 'embedded') {
204
- const response = {
205
- action: 'startTemplateCreation',
206
- };
207
- parent.postMessage(JSON.stringify(response), '*');
208
- }
209
- }
210
- componentWillReceiveProps(nextProps) {
211
- if (nextProps.isGetFormData) {
212
- nextProps.getFormLibraryData(this.getFormData());
213
- }
214
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
215
- if (this.props.location.query.type === 'embedded' && !nextProps.Edit.fetchingWeCrmAccounts && !_.isEqual(this.props.Edit.weCrmAccounts, nextProps.Edit.weCrmAccounts) && (!selectedWeChatAccount || _.isEmpty(selectedWeChatAccount))) {
216
-
217
- this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts);
218
- }
219
- if (!_.isEmpty(nextProps.Edit.selectedWeChatAccount) && !_.isEqual(this.props.Edit.selectedWeChatAccount, nextProps.Edit.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && this.props.location.query.module === "loyalty") {
220
- const params = {
221
- name: '',
222
- sortBy: 'Most Recent',
223
- accountId: nextProps.Edit.selectedWeChatAccount.id,
224
- };
225
- this.props.actions.getMobilepushTemplatesList('mobilepush', params);
226
- }
227
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.fullSchema)) {
228
- this.setState({fullSchema: nextProps.metaEntities.layouts[0].definition, schema: (nextProps.location.query.module === 'loyalty') ? nextProps.metaEntities.layouts[0].definition.textSchema : {}}, () => {
229
- if (nextProps.location.query.module !== 'loyalty' && this.props.params.id !== 'temp') {
230
- this.props.actions.getTemplateDetails(this.props.params.id);
231
- }
232
- const type = this.props.location.query.type;
233
- if (type === 'embedded' && this.props.params.id === 'temp' && _.isEmpty(this.state.formData)) { // when his.props.params.id is temp that means mobile push template content will be passed from post message from parent with startTemplateCreation action
234
- const response = {
235
- action: 'startTemplateCreation',
236
- };
237
- parent.postMessage(JSON.stringify(response), '*');
238
- this.getTags();
239
- }
240
- });
241
- if (this.props.location.query.type === 'embedded') {
242
- this.showNext();
243
- }
244
- }
245
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && nextProps.Edit.mobilepushTemplates && !_.isEqual(nextProps.Edit.mobilepushTemplates, this.props.Edit.mobilepushTemplates)) { //used inloyalty
246
- if (nextProps.location.query.type === 'embedded' && nextProps.location.query.module === 'loyalty') {
247
- this.setTemplateOptions(nextProps.Edit.mobilepushTemplates);
248
- }
249
- }
250
- if (nextProps.templateDetails && nextProps.templateDetails.name && (_.isEmpty(this.state.editData) || !this.state.editData.name) && (this.props.location.query.type !== 'embedded' || (!_.isEmpty(this.state.fullSchema) && selectedWeChatAccount))) {
251
- this.props = nextProps;
252
- const mode = nextProps.templateDetails.definition ? nextProps.templateDetails.definition.mode : nextProps.templateDetails.mode;
253
- const schema = mode === "text" ? this.state.fullSchema?.textSchema : this.state.fullSchema?.imageSchema;
254
- this.setEditState(nextProps.templateDetails, schema);
255
- this.getTags();
256
- }
257
- if (nextProps.Edit.uploadedAssetData) {
258
- const formData = _.cloneDeep(this.state.formData);
259
- formData[this.state.currentTab - 1].image = nextProps.Edit.uploadedAssetData.metaInfo.public_url;
260
- this.setState({formData});
261
- this.props.actions.clearAsset();
262
- }
263
- if (nextProps.Edit.iosCtasData) {
264
- this.setState({iosCtasData: nextProps.Edit.iosCtasData});
265
- }
266
- if (nextProps.Edit.editResponse && nextProps.Edit.editResponse.templateId) {
267
-
268
- this.resetSchema();
269
- this.setState({
270
- formData: {},
271
- tabCount: 1,
272
- currentTab: 1,
273
- editData: {},
274
- });
275
- const message = getMessageObject('success', this.props.intl.formatMessage(messages['MOBILEPUSH Template Edited Successfully']), true);
276
- this.props.globalActions.addMessageToQueue(message);
277
- this.props.actions.clearEditResponse();
278
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
279
- const type = this.props.location.query.type;
280
- this.props.router.push({
281
- pathname: `/mobilepush/`,
282
- search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
283
- });
284
- }
285
-
286
- if (nextProps.Edit.editTemplateError && !_.isEqual(nextProps.Edit.editTemplateError, this.props.Edit.editTemplateError)) {
287
- const message = getMessageObject('error', (nextProps.Edit.editTemplateErrorMessage && nextProps.Edit.editTemplateErrorMessage !== '') ? nextProps.Edit.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
288
- this.props.globalActions.addMessageToQueue(message);
289
- }
290
- }
291
- componentWillUnmount() {
292
- this.props.actions.clearData();
293
- window.removeEventListener("message", this.handleFrameTasks);
294
- }
295
- onTemplateChange = (isEvent, formData) => {
296
- _.forEach(this.props.Edit.mobilepushTemplates, (template) => {
297
- if (template._id === formData['mobilepush-template']) {
298
- this.setState({editData: {}, formData: {}}, () => {
299
- this.props.actions.setSelectedTemplate(template);
300
- });
301
- }
302
- });
303
- };
304
- onFormDataChange = (formData, tabCount, currentTab) => {
305
-
306
- const newFormData = _.cloneDeep(formData);
307
- if (newFormData[this.state.currentTab - 1] && newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`]) {
308
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].name;
309
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[0].buttonText;
310
- delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
311
- if (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1]) {
312
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1].buttonText;
313
- }
314
- }
315
- if (newFormData["mobilepush-accounts"] !== this.state.formData["mobilepush-accounts"]) {
316
- this.setMobilePushAccountOptions(this.props.Edit.weCrmAccounts, newFormData["mobilepush-accounts"]);
317
- delete newFormData['mobilepush-template'];
318
- delete newFormData['template-name'];
319
- if (!_.isEmpty(newFormData[0])) {
320
- delete newFormData[0];
321
- }
322
- if (!_.isEmpty(newFormData[1])) {
323
- delete newFormData[1];
324
- }
325
- }
326
- if (this.state.isSchemaChanged) {
327
- this.setState({isSchemaChanged: false});
328
- }
329
- this.setState({formData: newFormData, tabCount});
330
- if (currentTab) {
331
- this.setState({currentTab});
332
- }
333
- };
334
-
335
- onLinkTypeChange = (eventTriggered, formData, field, tabIndex, inputSchema) => {
336
- const currentTab = tabIndex || this.state.currentTab;
337
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
338
- const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
339
- _.forEach(schema.containers, (container) => {
340
- _.forEach(container.panes, (pane, paneIndex) => {
341
- _.forEach(pane.sections, (section) => {
342
- _.forEach(section.childSections, (childeSection) => {
343
- _.forEach(childeSection.childSections, (child) => {
344
- const formChaild = child;
345
- if (child.type === 'multicols') {
346
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
347
- if (inputField) {
348
- _.forEach(inputField.cols, (col) => {
349
- if (col.id === field.id && currentTab === paneIndex + 1) {
350
-
351
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
352
- const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
353
- const deeplinkValue = formData[currentTab - 1][field.id];
354
- const componentIndex = fieldIndex + 1;
355
- let inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
356
- if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
357
- inputId = `${inputId}${tabIndex || this.state.currentTab}`;
358
- }
359
- if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === child.inputFields.length - 1 || child.inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
360
- const row = {
361
- rowClassName: 'mobile-push-row',
362
- id: 'cta-deeplink-select-section',
363
- cols: [
364
- {
365
- id: "cta-label",
366
- metaType: "label",
367
- value: "",
368
- primitive: true,
369
- dynamicTab: false,
370
- type: "div",
371
- width: 4,
372
- onlyDisplay: true,
373
- colStyle: {
374
- flex: 1,
375
- },
376
- },
377
- {
378
- id: inputId,
379
- placeholder: this.props.intl.formatMessage(messages.selectDeeplink),
380
- type: "select", //Resembles component to be used
381
- options: deepLinkOptions,
382
- errorMessage: this.props.intl.formatMessage(messages.selectADeeplink),
383
- metaType: "text",
384
- datatype: "string",
385
- required: true,
386
- fluid: true,
387
- width: 19,
388
- style: {
389
- fontSize: '14px',
390
- fontFamily: 'open-sans',
391
- fontStyle: 'normal',
392
- // fontWeight: 600,
393
- marginBottom: '16px',
394
- },
395
- styling: "semantic",
396
- order: 1,
397
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
398
- customComponent: false,
399
- supportedEvents: [
400
- 'onSelect',
401
- ],
402
- },
403
- ],
404
- };
405
- if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-external-link") {
406
- formChaild.inputFields[componentIndex] = row;
407
- } else {
408
- formChaild.inputFields.splice(componentIndex, 0, row);
409
- }
410
- } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
411
- const row = {
412
- rowClassName: 'mobile-push-row',
413
- id: 'cta-external-link',
414
- cols: [
415
- {
416
- id: "cta-label",
417
- metaType: "label",
418
- value: "",
419
- primitive: true,
420
- dynamicTab: false,
421
- type: "div",
422
- width: 4,
423
- offset: 0,
424
- onlyDisplay: true,
425
- },
426
- {
427
- id: inputId,
428
- placeholder: "External Link",
429
- type: "input", //Resembles component to be used
430
- metaType: "text",
431
- datatype: "string",
432
- errorMessage: this.props.intl.formatMessage(messages.externalLinkCantEmpty),
433
- required: true,
434
- fluid: true,
435
- width: 19,
436
- style: {
437
- fontSize: '14px',
438
- fontFamily: 'open-sans',
439
- fontStyle: 'normal',
440
- // fontWeight: 600,
441
- marginBottom: '16px',
442
- },
443
- styling: "semantic",
444
- order: 1,
445
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
446
- offSet: 4,
447
- customComponent: false,
448
- standalone: false,
449
- },
450
- ],
451
- };
452
- if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-deeplink-select-section") {
453
- formChaild.inputFields[componentIndex] = row;
454
- if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
455
- formChaild.inputFields.splice(componentIndex + 1, 1);
456
- }
457
- if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
458
- const dataIndex = tabIndex || this.state.currentTab;
459
- let selector = `${col.id}-select`;
460
- if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
461
- selector = `${selector}${tabIndex || this.state.currentTab}`;
462
- }
463
- let configkeys = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === formData[dataIndex - 1][selector]);
464
- if (configkeys[0]) {
465
- configkeys = configkeys[0].keys;
466
- }
467
- if (configkeys.length) {
468
- formChaild.inputFields = formChaild.inputFields.slice(0, componentIndex + 1).concat(formChaild.inputFields.slice( componentIndex + 1 + configkeys.length, formChaild.inputFields.length));
469
- }
470
- }
471
- } else {
472
- formChaild.inputFields.splice(componentIndex, 0, row);
473
- }
474
- }
475
- }
476
- });
477
- }
478
- });
479
- }
480
- });
481
- });
482
- });
483
- });
484
- });
485
- if (tabIndex) {
486
- return schema;
487
- }
488
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
489
- this.injectEvents(schema);
490
- return schema;
491
- };
492
-
493
- onTabChange = (data) => {
494
-
495
- this.setState({currentTab: data});
496
- };
497
-
498
- onTagSelect = (data, currentTab, srcComp) => {
499
-
500
- const editorId = srcComp.target;
501
- this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
502
- document.getElementById(editorId).focus();
503
- };
504
- onModalCancel = () => {
505
- if (this.state.modalContent && this.state.modalContent.show) {
506
- this.setState({modalContent: {...this.state.modalContent, show: false}});
507
- }
508
- };
509
- getTags = () => {
510
- const query = {
511
- layout: 'mobilepush',
512
- type: 'TAG',
513
- context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
514
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
515
- };
516
- if (this.props.getDefaultTags) {
517
- query.context = this.props.getDefaultTags;
518
- }
519
- this.props.globalActions.fetchSchemaForEntity(query);
520
- }
521
- setTemplateOptions = (mobilepushTemplates) => {
522
- const templateOptions = [];
523
- let selectedTemplate = {};
524
- if (!_.isEmpty(mobilepushTemplates)) {
525
- _.forEach(mobilepushTemplates, (template) => {
526
- templateOptions.push({
527
- key: template._id,
528
- label: template.name,
529
- value: template._id,
530
- });
531
- if (this.state.formData['mobilepush-template'] && template._id === this.state.formData['mobilepush-template']) {
532
- selectedTemplate = template;
533
- }
534
- });
535
- }
536
- this.setState({templateOptions}, () => {
537
- if (!_.isEmpty(selectedTemplate)) {
538
- this.props.actions.setSelectedTemplate(selectedTemplate);
539
- }
540
- if (!_.isEmpty(this.state.schema)) {
541
- this.injectEvents(this.state.schema);
542
- }
543
- });
544
- };
545
- setMobilePushAccountOptions = (accounts, newAccountId) => {
546
- let accId = newAccountId || this.props.location.query.account_id;
547
- if (this.props.location.query.module !== "loyalty" && this.props.location.query.module !== "dvs") {
548
- accId = Number(accId);
549
- }
550
- const formData = _.cloneDeep(this.state.formData);
551
- let selectedAccount = {};
552
- if (accId) {
553
- _.forEach(accounts, (account) => {
554
- let acccountId = account.id;
555
- if ((this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs") && typeof accId === 'string') {
556
- acccountId = account.sourceAccountIdentifier;
557
- }
558
- if (acccountId === accId) {
559
- this.props.templatesActions.setWeChatAccount(account);
560
- selectedAccount = account;
561
- formData['mobilepush-accounts'] = account.id;
562
- if (this.props.location.query.account_id) {
563
- formData['mobilepush-template'] = this.props.params.id;
564
- }
565
- }
566
- });
567
- } else {
568
- selectedAccount = accounts[0];
569
- formData['mobilepush-accounts'] = selectedAccount?.id;
570
- }
571
- this.props.actions.setWeChatAccount(selectedAccount);
572
- this.setState({formData, accountsOptions: accounts.map((acc) => ({key: acc.id, label: acc.name, value: acc.id}))});
573
- };
574
-
575
- getTransformedData = (formData) => {
576
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
577
- const obj = _.cloneDeep(this.state.editData);
578
- obj.versions = {
579
- base: {},
580
- };
581
- obj.type = 'MOBILEPUSH';
582
- obj.name = formData['template-name'];
583
- obj.definition = {
584
- accountId: selectedWeChatAccount?.id,
585
- licenseCode: selectedWeChatAccount?.sourceAccountIdentifier,
586
- };
587
- if (this.props.location.query && this.props.location.query.module !== 'dvs') {
588
- obj.definition.mode = _.get(this, 'props.Edit.templateDetails.mode', '');
589
- }
590
- const android = {};
591
- Object.keys(formData[0]).forEach((data) => {
592
- if (!!formData[0][data] && data !== "tabKey") {
593
- android[data] = formData[0][data];
594
- }
595
- });
596
- const ios = {};
597
- Object.keys(formData[1]).forEach((data) => {
598
- if (!!formData[1][data] && data !== "tabKey") {
599
- ios[data] = formData[1][data];
600
- }
601
- });
602
- obj.versions.base = {};
603
- delete android.base;
604
- if (!_.isEmpty(android)) {
605
- obj.versions.base.ANDROID = {
606
- luid: "{{luid}}",
607
- cuid: "{{cuid}}",
608
- communicationId: "{{communicationId}}",
609
- title: android['message-title'],
610
- message: android['message-editor'],
611
- expandableDetails: {
612
- style: "BIG_TEXT",
613
- message: android['message-editor'],
614
- },
615
- custom: _.map(android, (field, key) => {
616
- if (key.indexOf('custom-value') > -1) {
617
- return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select', ''), value: field} : undefined;
618
- }
619
- return undefined;
620
- }).filter((custom) => custom),
621
- };
622
- }
623
- if (android['cta-deeplink'] && android['cta-deeplink'] !== "") {
624
- obj.versions.base.ANDROID.cta = {
625
- type: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
626
- actionLink: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? android['cta-deeplink-select'] : android['cta-deeplink-text'],
627
- deepLinkName: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? this.getLinkName(android['cta-deeplink-select']) : undefined,
628
- };
629
- if (this.props.location.query.type === 'embedded') {
630
- delete obj.versions.base.ANDROID.cta.deepLinkName;
631
- }
632
- }
633
- if (!_.isEmpty(ios)) {
634
- obj.versions.base.IOS = {
635
- luid: "{{luid}}",
636
- cuid: "{{cuid}}",
637
- communicationId: "{{communicationId}}",
638
- title: ios['message-title2'],
639
- message: ios['message-editor2'],
640
- expandableDetails: {
641
- style: "BIG_TEXT",
642
- message: ios['message-editor2'],
643
- ctas: [
644
-
645
- ],
646
- categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
647
- },
648
- custom: _.map(ios, (field, key) => {
649
- if (key.indexOf('custom-value') > -1) {
650
- return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink2-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select2', ''), value: field} : undefined;
651
- }
652
- return undefined;
653
- }).filter((custom) => custom),
654
- };
655
- }
656
- if (ios['cta-deeplink2'] && ios['cta-deeplink2'] !== "") {
657
- obj.versions.base.IOS.cta = {
658
- type: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
659
- actionLink: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? ios['cta-deeplink2-select'] : ios['cta-deeplink2-text'],
660
- deepLinkName: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? this.getLinkName(ios['cta-deeplink2-select']) : undefined,
661
- };
662
- if (this.props.location.query.type === 'embedded') {
663
- delete obj.versions.base.IOS.cta.deepLinkName;
664
- }
665
- }
666
- const imageLink = android.image;
667
- if (imageLink) {
668
- obj.versions.base.ANDROID.expandableDetails.image = imageLink;
669
- obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
670
- }
671
- if (obj.versions.base.ANDROID && obj.versions.base.ANDROID.cta) {
672
- if (obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
673
- const params = _.map(android, (field, key) => {
674
- let actionLink;
675
- if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
676
- const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
677
- actionLink = field !== "" ? `${param}=${field}` : undefined;
678
- }
679
- return actionLink;
680
- }).filter((actionLink) => actionLink);
681
- if (params.length) {
682
- obj.versions.base.ANDROID.cta.actionLink = `${obj.versions.base.ANDROID.cta.actionLink}?${params.join('&')}`;
683
- }
684
- }
685
- }
686
- const secondaryCta1 = !!android["cta-deeplink-secondary-cta-0-select"] || !!android['secondary-cta-0-label'];
687
- const secondaryCta2 = !!android['cta-deeplink-secondary-cta-1-select'] || !!android['secondary-cta-1-label'];
688
- if (secondaryCta1 || secondaryCta2 ) {
689
- obj.versions.base.ANDROID.expandableDetails.ctas = [];
690
- if (secondaryCta1) {
691
- const cta = {
692
- actionText: android['secondary-cta-0-label'],
693
- type: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
694
- actionLink: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
695
- seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
696
- };
697
- if (this.props.location.query.type === 'embedded') {
698
- delete cta.seccdeepLinkName;
699
- }
700
- obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
701
- if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
702
- const params = _.map(android, (field, key) => {
703
- let actionLink;
704
- if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
705
- const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
706
- actionLink = field !== "" ? `${param}=${field}` : undefined;
707
- }
708
- return actionLink;
709
- }).filter((actionLink) => actionLink);
710
- if (params.length) {
711
- obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
712
- }
713
- }
714
- }
715
- if (secondaryCta2) {
716
- obj.versions.base.ANDROID.expandableDetails.ctas.push({
717
- actionText: android['secondary-cta-1-label'],
718
- type: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
719
- actionLink: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
720
- seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
721
- });
722
- if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
723
- const params = _.map(android, (field, key) => {
724
- let actionLink;
725
- if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
726
- const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
727
- actionLink = field !== "" ? `${param}=${field}` : undefined;
728
- }
729
- return actionLink;
730
- }).filter((actionLink) => actionLink);
731
- if (params.length) {
732
- obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
733
- }
734
- }
735
- }
736
- }
737
- const imageLinkIos = ios.image;
738
- if (imageLinkIos) {
739
- obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
740
- obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
741
- }
742
- if (obj.versions.base.IOS && obj.versions.base.IOS.cta) {
743
- if (obj.versions.base.IOS.cta.type === "DEEP_LINK") {
744
- const params = _.map(ios, (field, key) => {
745
- let actionLink;
746
- if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
747
- const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
748
- actionLink = field !== "" ? `${param}=${field}` : undefined;
749
- }
750
- return actionLink;
751
- }).filter((actionLink) => actionLink);
752
- if (params.length) {
753
- obj.versions.base.IOS.cta.actionLink = `${obj.versions.base.IOS.cta.actionLink}?${params.join('&')}`;
754
- }
755
- }
756
- }
757
- const secondaryCtaIos = !!ios['cta-deeplink-secondary-cta-1-select'] || !!ios['secondary-cta-1-label'];
758
-
759
- if (secondaryCtaIos) {
760
- obj.versions.base.IOS.expandableDetails.ctas = [];
761
- const cta = {
762
- actionText: ios['secondary-cta-1-label'],
763
- actionLabel: ios['secondary-cta-1-action'],
764
- actionLabel2: ios['secondary-cta-1-action2'],
765
- type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
766
- actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text2']),
767
- ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
768
- templateCtaId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].ctaTemplateDetails[0].id : undefined,
769
- };
770
- if (this.props.location.query.type === 'embedded') {
771
- delete cta.ioscdeepLinkName;
772
- }
773
- obj.versions.base.IOS.expandableDetails.ctas.push(cta);
774
- if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
775
- const params = _.map(ios, (field, key) => {
776
- let actionLink;
777
- if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
778
- const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
779
- actionLink = field !== "" ? `${param}=${field}` : undefined;
780
- }
781
- return actionLink;
782
- }).filter((actionLink) => actionLink);
783
- if (params.length) {
784
- obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
785
- }
786
- }
787
- }
788
- return obj;
789
- };
790
-
791
- getLinkName = (link) => {
792
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
793
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
794
- const deepLinkOptions = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (l) => l.link === link);
795
- if (deepLinkOptions[0]) {
796
- return deepLinkOptions[0].name;
797
- }
798
- return undefined;
799
- };
800
-
801
- setFormValidity = (isFormValid) => {
802
- this.setState({isFormValid});
803
- };
804
-
805
- getMappedEvent = (id, event) => {
806
- const map = this.state.eventsMap;
807
- if (!map[id] || !map[id][event]) {
808
-
809
- }
810
- return map[id][event];
811
- };
812
-
813
- getCurrentWindow = (e) => {
814
- const response = {
815
- action: e.action,
816
- value: 'edit',
817
- direction: e.value,
818
- };
819
- parent.postMessage(JSON.stringify(response), '*');
820
- };
821
-
822
- getFormData = (e) => {
823
-
824
- const response = {
825
- action: "getFormData",
826
- value: this.getTransformedData(this.state.formData),
827
- validity: this.state.isFormValid,
828
- };
829
-
830
- this.setState({checkValidation: true});
831
- if (e) {
832
- e.source.postMessage(JSON.stringify(response), e.origin);
833
- }
834
- return response;
835
- };
836
-
837
-
838
- setEditState(data, schema) {
839
-
840
- const tabCount = Object.keys(data.versions.base).length;
841
- const formData = {};
842
- if (this.props.location.query.type === 'embedded' && this.props.location.query.module === "loyalty") {
843
- formData["mobilepush-accounts"] = this.state.formData["mobilepush-accounts"];
844
- formData['mobilepush-template'] = this.state.formData['mobilepush-template'];
845
- }
846
- formData['template-name'] = data.name;
847
- const androidData = data.versions.base.ANDROID;
848
- const iosData = data.versions.base.IOS;
849
- const android = {};
850
- android[`message-title`] = androidData ? androidData.title : '';
851
- android['message-editor'] = androidData ? androidData.message : '';
852
- if (data.mode === "image") {
853
- android.image = "";
854
- }
855
- if (androidData) {
856
- if (androidData.cta) {
857
- android['cta-deeplink'] = androidData.cta.type === "DEEP_LINK" ? "Deeplink" : "External Link";
858
- if ( androidData.cta.type === "DEEP_LINK") {
859
- android['cta-deeplink-select'] = androidData ? androidData.cta.actionLink : '';
860
- } else {
861
- android['cta-deeplink-text'] = androidData ? androidData.cta.actionLink : '';
862
- }
863
- if (androidData.cta.type === "DEEP_LINK" ) {
864
- const link = android['cta-deeplink-select'].split('?')[0];
865
- const params = android['cta-deeplink-select'].split('?')[1] && android['cta-deeplink-select'].split('?')[1].split('&');
866
- android['cta-deeplink-select'] = link;
867
- _.forEach(params, (param) => {
868
- android[`custom-value-${param.split('=')[0]}-cta-deeplink-select`] = param.split('=')[1];
869
- });
870
- }
871
- }
872
- if (androidData.expandableDetails && androidData.expandableDetails.image) {
873
- android.image = androidData.expandableDetails.image;
874
- }
875
- if (androidData.expandableDetails && androidData.expandableDetails.ctas && androidData.expandableDetails.ctas.length) {
876
- android['cta-deeplink-secondary-cta-0'] = androidData.expandableDetails.ctas[0].type === "DEEP_LINK" ? "Deeplink" : "External Link";
877
- if ( androidData.expandableDetails.ctas[0].type === "DEEP_LINK") {
878
- android['cta-deeplink-secondary-cta-0-select'] = androidData.expandableDetails.ctas[0].actionLink;
879
- } else {
880
- android['cta-deeplink-secondary-cta-0-text'] = androidData.expandableDetails.ctas[0].actionLink;
881
- }
882
- android['secondary-cta-0-label'] = androidData.expandableDetails.ctas[0].actionText;
883
- if (androidData.expandableDetails.ctas[0].type === "DEEP_LINK") {
884
- const link = android['cta-deeplink-secondary-cta-0-select'].split('?')[0];
885
- const params = android['cta-deeplink-secondary-cta-0-select'].split('?')[1] && android['cta-deeplink-secondary-cta-0-select'].split('?')[1].split('&');
886
- android['cta-deeplink-secondary-cta-0-select'] = link;
887
- _.forEach(params, (param) => {
888
- android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-0-select`] = param.split('=')[1];
889
- });
890
- }
891
- }
892
- if (androidData.expandableDetails && androidData.expandableDetails.ctas && androidData.expandableDetails.ctas.length > 1) {
893
- android['cta-deeplink-secondary-cta-1'] = androidData.expandableDetails.ctas[1].type === "DEEP_LINK" ? "Deeplink" : "External Link";
894
- if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK") {
895
- android['cta-deeplink-secondary-cta-1-select'] = androidData.expandableDetails.ctas[1].actionLink;
896
- } else {
897
- android['cta-deeplink-secondary-cta-1-text'] = androidData.expandableDetails.ctas[1].actionLink;
898
- }
899
- android['secondary-cta-1-label'] = androidData.expandableDetails.ctas[1].actionText;
900
- if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK" && android['cta-deeplink-secondary-cta-1-select']) {
901
- const link = android['cta-deeplink-secondary-cta-1-select'].split('?')[0];
902
- const params = android['cta-deeplink-secondary-cta-1-select'].split('?')[1] && android['cta-deeplink-secondary-cta-1-select'].split('?')[1].split('&');
903
- android['cta-deeplink-secondary-cta-1-select'] = link;
904
- _.forEach(params, (param) => {
905
- android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select`] = param.split('=')[1];
906
- });
907
- }
908
- }
909
- }
910
- formData[0] = android;
911
- const ios = {};
912
- ios[`message-title2`] = iosData ? iosData.title : '';
913
- ios['message-editor2'] = iosData ? iosData.message : '';
914
- if (data.mode === "image") {
915
- ios.image = "";
916
- }
917
- if (iosData) {
918
- if (iosData.cta) {
919
- ios['cta-deeplink2'] = iosData.cta.type === "DEEP_LINK" ? "Deeplink" : "External Link";
920
- if (iosData.cta.type === "DEEP_LINK") {
921
- ios['cta-deeplink2-select'] = iosData ? iosData.cta.actionLink : '';
922
- } else {
923
- ios['cta-deeplink2-text'] = iosData ? iosData.cta.actionLink : '';
924
- }
925
- if (iosData.cta.type === "DEEP_LINK") {
926
- const link = ios['cta-deeplink2-select'].split('?')[0];
927
- let params = ios['cta-deeplink2-select'].split('?');
928
- if (params[1]) {
929
- params = params[1].split('&');
930
- _.forEach(params, (param) => {
931
- ios[`custom-value-${param.split('=')[0]}-cta-deeplink2-select`] = param.split('=')[1];
932
- });
933
- }
934
- ios['cta-deeplink2-select'] = link;
935
- }
936
- }
937
- if (iosData.expandableDetails && iosData.expandableDetails.image) {
938
- ios.image = iosData.expandableDetails.image;
939
- }
940
- if (iosData.expandableDetails && iosData.expandableDetails.ctas && iosData.expandableDetails.ctas.length) {
941
- if (iosData.expandableDetails.ctas[0].type) {
942
- ios['cta-deeplink-secondary-cta-1'] = iosData.expandableDetails.ctas[0].type === "DEEP_LINK" ? "Deeplink" : "External Link";
943
- }
944
- if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK") {
945
- ios['cta-deeplink-secondary-cta-1-select2'] = iosData.expandableDetails.ctas[0].actionLink;
946
- } else {
947
- ios['cta-deeplink-secondary-cta-1-text2'] = iosData.expandableDetails.ctas[0].actionLink;
948
- }
949
- ios['secondary-cta-1-label'] = iosData.expandableDetails.ctas[0].actionText;
950
- if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK" && ios['cta-deeplink-secondary-cta-1-select2']) {
951
- const link = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[0];
952
- const paramsIos = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1] && ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1].split('&');
953
- ios['cta-deeplink-secondary-cta-1-select2'] = link;
954
- _.forEach(paramsIos, (param) => {
955
- ios[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select2`] = param.split('=')[1];
956
- });
957
- }
958
- ios['secondary-cta-1-action'] = iosData.expandableDetails.ctas[0].actionLabel;
959
- if (iosData.expandableDetails.ctas[0].actionLabel2) {
960
- ios['secondary-cta-1-action2'] = iosData.expandableDetails.ctas[0].actionLabel2;
961
- }
962
- }
963
- }
964
- formData[1] = ios;
965
- formData.base = formData[0];
966
- formData[0].base = true;
967
- // formData[0].tabKey = '1';
968
- // formData[1].tabKey = '2';
969
-
970
- this.getSchemaForFormData(formData, schema);
971
- this.setState({tabCount, formData, editData: data, currentTab: 1});
972
- }
973
-
974
- getSchemaForFormData = (formData, inputSchema) => {
975
- let schema = inputSchema;
976
- if (!_.isEmpty(formData[0])) {
977
- if (formData[0]['cta-deeplink']) {
978
- schema = this.addPrimaryCta(null, {id: 'add-pri-cta'}, schema, 1);
979
- schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink'}, 1, schema);
980
- schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-select'}, 1, schema);
981
- }
982
- if (formData[0]['cta-deeplink-secondary-cta-0']) {
983
- schema = this.addSecondoryCta(null, {id: 'add-sec-cta'}, schema);
984
- schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-0'}, 1, schema);
985
- schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-0-select'}, 1, schema);
986
- }
987
- if (formData[0]['cta-deeplink-secondary-cta-1']) {
988
- schema = this.addSecondoryCta(null, {id: 'add-sec-cta'}, schema);
989
- schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 1, schema);
990
- schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select'}, 1, schema);
991
- }
992
- }
993
- if (!_.isEmpty(formData[1])) {
994
- if (formData[1]['cta-deeplink2']) {
995
- schema = this.addPrimaryCta(null, {id: 'add-pri-cta-ios'}, schema, 2);
996
- schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink2'}, 2, schema);
997
- schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink2-select'}, 2, schema);
998
- }
999
- if (formData[1]['secondary-cta-1-action']) {
1000
- schema = this.showSelectedIosCta(schema, {id: 'add-sec-cta-ios'}, 2, undefined, formData[1]['cta-deeplink-secondary-cta-1']);
1001
- schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 2, schema);
1002
- schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select2'}, 2, schema);
1003
- }
1004
- }
1005
- this.setState({schema, isSchemaChanged: true});
1006
- this.injectEvents(schema);
1007
- };
1008
-
1009
- setModalContent = (type) => {
1010
- if (type === 'ios') {
1011
- const modalContent = {
1012
- title: this.props.intl.formatMessage(messages.alertMessage),
1013
- body: this.props.intl.formatMessage(messages.androidTemplateNotConfigured),
1014
- type: 'confirm',
1015
- id: 'ios',
1016
- };
1017
- this.setState({modalContent, showModal: true});
1018
- } else if (type === 'android') {
1019
- const modalContent = {
1020
- title: this.props.intl.formatMessage(messages.alertMessage),
1021
- body: this.props.intl.formatMessage(messages.iosTemplateNotConfigured),
1022
- type: 'confirm',
1023
- id: 'android',
1024
- };
1025
- this.setState({modalContent, showModal: true});
1026
- }
1027
- }
1028
-
1029
- openNotificationWithIcon = (type, message) => {
1030
- const dur = (type === 'error' || type === 'warning') ? null : 5;
1031
- notification[type]({
1032
- message: (`${type.toUpperCase()} ! ! ! `),
1033
- description: message, //'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
1034
- duration: dur,
1035
- });
1036
- }
1037
-
1038
- handleCancelModal = () => {
1039
- this.setState({showModal: false});
1040
- };
1041
-
1042
- insertAtCursor = (field, myValue, currentTab) => {
1043
- //IE support
1044
- const myField = field;
1045
- if (document.selection) {
1046
- myField.focus();
1047
- const sel = document.selection.createRange();
1048
- sel.text = myValue;
1049
- } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
1050
- const startPos = myField.selectionStart;
1051
- const endPos = myField.selectionEnd;
1052
- myField.value = myField.value.substring(0, startPos)
1053
- + myValue
1054
- + myField.value.substring(endPos, myField.value.length);
1055
- myField.selectionStart = startPos + myValue.length;
1056
- myField.selectionEnd = startPos + myValue.length;
1057
- } else {
1058
- myField.value += myValue;
1059
- }
1060
- const formData = _.cloneDeep(this.state.formData);
1061
- formData[currentTab - 1][field.id] = myField.value;
1062
- this.setState({formData});
1063
- };
1064
-
1065
- selectCtaIos = (selectedConfig) => {
1066
- this.showSelectedIosCta(null, null, null, selectedConfig);
1067
- };
1068
-
1069
- uploadImage = (data) => {
1070
- if (data.fileParams.error) {
1071
- const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 5mb']), true);
1072
- this.props.globalActions.addMessageToQueue(message);
1073
- } else {
1074
- const name = data.file.name.split('.');
1075
- // const blob = data.file.slice(0, -1, 'image');
1076
- const newFile = new File([data.file], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
1077
- this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
1078
- }
1079
- };
1080
-
1081
- copyIphoneContent = () => {
1082
- const formData = _.cloneDeep(this.state.formData);
1083
- if (!!formData[1]['message-title2'] && !!formData[1]['message-editor2']) {
1084
- formData[0]['message-title'] = formData[1]['message-title2'];
1085
- formData[0]['message-editor'] = formData[1]['message-editor2'];
1086
- this.setState({formData});
1087
- } else {
1088
- this.openNotificationWithIcon('warning', this.props.intl.formatMessage(messages.cantCopyEmptyField));
1089
- }
1090
- };
1091
- copyAndroidContent = () => {
1092
- const formData = _.cloneDeep(this.state.formData);
1093
- if (!!formData[0]['message-title'] && formData[0]['message-editor']) {
1094
- formData[1]['message-title2'] = formData[0]['message-title'];
1095
- formData[1]['message-editor2'] = formData[0]['message-editor'];
1096
- this.setState({formData});
1097
- } else {
1098
- this.openNotificationWithIcon('warning', this.props.intl.formatMessage(messages.cantCopyEmptyField));
1099
- }
1100
- };
1101
-
1102
- showSelectedIosCta = (inputSchema, field, tab, selectedConfig, showDeeplink) => {
1103
- const currentTab = tab || this.state.currentTab;
1104
- const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1105
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1106
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1107
- const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
1108
-
1109
- _.forEach(schema.containers, (container) => {
1110
- _.forEach(container.panes, (pane, paneIndex) => {
1111
- _.forEach(pane.sections, (section) => {
1112
- _.forEach(section.childSections, (childeSection) => {
1113
- _.forEach(childeSection.childSections, (child) => {
1114
- const formChaild = child;
1115
- if (child.type === 'multicols') {
1116
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1117
- _.forEach(inputField.cols, (col) => {
1118
- if (col.id.indexOf(`secondary-cta-${currentTab - 1}-table`) > -1 || (field && field.id === col.id)) {
1119
-
1120
- const inputId = `secondary-cta-${paneIndex}`;
1121
-
1122
- formChaild.inputFields[fieldIndex] = {
1123
- rowClassName: 'mobile-push-row',
1124
- cols: [
1125
- {
1126
- id: `${inputId}-action-label`,
1127
- metaType: "label",
1128
- value: this.props.intl.formatMessage(messages.secondaryCTA),
1129
- primitive: true,
1130
- dynamicTab: false,
1131
- type: "div",
1132
- width: 4,
1133
- style: {
1134
- backgroundColor: 'white',
1135
- textAlign: 'left',
1136
- color: '#333333',
1137
- lineHeight: '24px',
1138
- fontSize: '14px',
1139
- fontFamily: 'open-sans',
1140
- fontStyle: 'normal',
1141
- paddingTop: '8px',
1142
- },
1143
- offset: 0,
1144
- onlyDisplay: true,
1145
- colStyle: {
1146
- flex: 1,
1147
- },
1148
- },
1149
- {
1150
- id: `${inputId}-label`,
1151
- metaType: "label",
1152
- value: "",
1153
- primitive: true,
1154
- dynamicTab: false,
1155
- type: "div",
1156
- width: 18,
1157
- style: {
1158
- backgroundColor: 'white',
1159
- textAlign: 'left',
1160
- color: '#333333',
1161
- lineHeight: '24px',
1162
- fontSize: '14px',
1163
- fontFamily: 'open-sans',
1164
- fontStyle: 'normal',
1165
- paddingTop: '8px',
1166
- },
1167
- offset: 0,
1168
- colStyle: {
1169
- flex: 1,
1170
- },
1171
- },
1172
- {
1173
- id: `${inputId}-delete-ios`,
1174
- type: "icon",
1175
- value: 'delete',
1176
- width: 1,
1177
- submitAction: "onDelete",
1178
- supportedEvents: ["onDelete"],
1179
- },
1180
- ],
1181
- };
1182
- formChaild.inputFields[fieldIndex + 1] = {
1183
- rowClassName: 'mobile-push-row',
1184
- cols: [
1185
- {
1186
- id: `${inputId}-action-label-empty`,
1187
- metaType: "label",
1188
- value: "",
1189
- primitive: true,
1190
- dynamicTab: false,
1191
- type: "div",
1192
- width: 4,
1193
- colStyle: {
1194
- flex: 1,
1195
- },
1196
- },
1197
- {
1198
- id: `${inputId}-action`,
1199
- metaType: "label",
1200
- value: "",
1201
- primitive: true,
1202
- dynamicTab: false,
1203
- type: "div",
1204
- width: 16,
1205
- offset: 0,
1206
- },
1207
- {
1208
- id: `${inputId}-action2`,
1209
- metaType: "label",
1210
- value: "",
1211
- primitive: true,
1212
- dynamicTab: false,
1213
- type: "div",
1214
- width: 8,
1215
- offset: 0,
1216
- style: {display: 'none'},
1217
- },
1218
- ],
1219
- };
1220
- let showDeeplinkOption = selectedConfig ? (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56") : true;
1221
- if (!selectedConfig) {
1222
- showDeeplinkOption = showDeeplink;
1223
- }
1224
- if (showDeeplinkOption) {
1225
- formChaild.inputFields[fieldIndex + 2] = {
1226
- rowClassName: "mobile-push-row",
1227
- cols: [
1228
- {
1229
- id: `${inputId}-action-label-empty`,
1230
- metaType: "label",
1231
- value: "",
1232
- primitive: true,
1233
- dynamicTab: false,
1234
- type: "div",
1235
- width: 4,
1236
- offset: 0,
1237
- onlyDisplay: true,
1238
- },
1239
- {
1240
- id: `cta-deeplink-${inputId}`,
1241
- type: "radioGroup", //Resembles component to be used
1242
- metaType: "text",
1243
- datatype: "string",
1244
- options: ["Deeplink", "External Link"],
1245
- value: "Deeplink",
1246
- required: true,
1247
- width: 16,
1248
- offSet: 4,
1249
- fluid: true,
1250
- style: {
1251
- fontFamily: 'open-sans',
1252
- fontSize: '14px',
1253
- lineHeight: '24px',
1254
- },
1255
- styling: "semantic",
1256
- order: 1,
1257
- supportedEvents: ["onChange"],
1258
- customComponent: false,
1259
- },
1260
- ],
1261
- };
1262
- formChaild.inputFields[fieldIndex + 3] = {
1263
- rowClassName: 'mobile-push-row',
1264
- id: 'cta-deeplink-select-section',
1265
- cols: [
1266
- {
1267
- id: "cta-label",
1268
- metaType: "label",
1269
- value: "",
1270
- primitive: true,
1271
- dynamicTab: false,
1272
- type: "div",
1273
- width: 4,
1274
- onlyDisplay: true,
1275
- colStyle: {
1276
- flex: 1,
1277
- },
1278
- },
1279
- {
1280
- id: `cta-deeplink-${inputId}-select2`,
1281
- placeholder: this.props.intl.formatMessage(messages.selectDeeplink),
1282
- type: "select", //Resembles component to be used
1283
- options: deepLinkOptions,
1284
- errorMessage: this.props.intl.formatMessage(messages.selectADeeplink),
1285
- metaType: "text",
1286
- datatype: "string",
1287
- required: true,
1288
- fluid: true,
1289
- width: 19,
1290
- style: {
1291
- fontSize: '14px',
1292
- fontFamily: 'open-sans',
1293
- fontStyle: 'normal',
1294
- // fontWeight: 600,
1295
- marginBottom: '16px',
1296
- },
1297
- styling: "semantic",
1298
- order: 1,
1299
- customComponent: false,
1300
- supportedEvents: [
1301
- 'onSelect',
1302
- ],
1303
- },
1304
- ],
1305
- };
1306
- }
1307
- }
1308
- });
1309
- });
1310
- }
1311
- });
1312
- });
1313
- });
1314
- });
1315
- });
1316
- if (!inputSchema) {
1317
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1318
- this.injectEvents(schema);
1319
- }
1320
- return schema;
1321
- };
1322
-
1323
- deletePrimaryCTA = (event) => {
1324
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1325
- const id = event.currentTarget.id;
1326
- const schema = _.cloneDeep(this.state.schema);
1327
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1328
- const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1329
- const formData = _.cloneDeep(this.state.formData);
1330
- const self = this;
1331
- _.forEach(schema.containers, (container) => {
1332
- _.forEach(container.panes, (pane) => {
1333
- _.forEach(pane.sections, (section) => {
1334
- _.forEach(section.childSections, (childeSection) => {
1335
- _.forEach(childeSection.childSections, (formChild) => {
1336
- const child = formChild;
1337
- if (child.type === 'multicols') {
1338
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1339
- if (inputField) {
1340
- _.forEach(inputField.cols, (col) => {
1341
- if (col.id === id) {
1342
- child.inputFields.splice(fieldIndex, 1);
1343
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1344
- child.inputFields.splice(fieldIndex, 1);
1345
- delete formData[self.state.currentTab - 1][`${id.replace('delete', 'text')}`];
1346
- delete formData[self.state.currentTab - 1][`${id.replace('-delete', '')}`];
1347
- }
1348
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1349
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1350
- const configkeys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === selectedDeeplink) : [];
1351
- if (configkeys.length) {
1352
- const options = configkeys[0].keys;
1353
- _.forEach(options, (opt) => {
1354
- delete formData[this.state.currentTab - 1][`custom-value-${opt}-${id.replace('delete', 'select')}`];
1355
- });
1356
- child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1357
- delete formData[self.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1358
- delete formData[self.state.currentTab - 1][`${id.replace('-delete', '')}`];
1359
- } else {
1360
- child.inputFields.splice(fieldIndex, 1);
1361
- }
1362
- }
1363
- child.inputFields.splice(fieldIndex, 0, {
1364
- cols: [
1365
- {
1366
- id: `${this.state.currentTab === 1 ? "add-pri-cta" : "add-pri-cta-ios"}`,
1367
- metaType: "label",
1368
- value: this.props.intl.formatMessage(messages.addPrimaryCTA),
1369
- primitive: true,
1370
- dynamicTab: false,
1371
- type: "div",
1372
- style: {
1373
- backgroundColor: 'white',
1374
- textAlign: 'left',
1375
- color: '#2673D7',
1376
- lineHeight: '24px',
1377
- fontSize: '14px',
1378
- fontWeight: '600',
1379
- fontFamily: 'open-sans',
1380
- fontStyle: 'normal',
1381
- cursor: 'pointer',
1382
- },
1383
- offset: 0,
1384
- onlyDisplay: true,
1385
- colStyle: {
1386
- flex: 1,
1387
- },
1388
- submitAction: "addPrimaryCta",
1389
- supportedEvents: ["addPrimaryCta"],
1390
- },
1391
- ],
1392
- });
1393
- }
1394
- });
1395
- }
1396
- });
1397
- }
1398
- });
1399
- });
1400
- });
1401
- });
1402
- });
1403
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1404
- this.injectEvents(schema);
1405
- };
1406
-
1407
- deleteSecondaryCtaIos = (event) => {
1408
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1409
- const id = event.currentTarget.id;
1410
- const schema = _.cloneDeep(this.state.schema);
1411
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1412
- const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1413
- const formData = _.cloneDeep(this.state.formData);
1414
- const self = this;
1415
- const device = this.state.currentTab === 1 ? 'android' : 'ios';
1416
- _.forEach(schema.containers, (container) => {
1417
- _.forEach(container.panes, (pane) => {
1418
- _.forEach(pane.sections, (section) => {
1419
- _.forEach(section.childSections, (childeSection) => {
1420
- _.forEach(childeSection.childSections, (formChild) => {
1421
- const child = formChild;
1422
- if (child.type === 'multicols') {
1423
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1424
- if (inputField) {
1425
- _.forEach(inputField.cols, (col) => {
1426
- if (col.id === id) {
1427
- if (device === 'ios') {
1428
- child.inputFields.splice(fieldIndex, 3);
1429
- delete formData[self.state.currentTab - 1][`secondary-cta-1-action`];
1430
- delete formData[self.state.currentTab - 1][`secondary-cta-1-action2`];
1431
- delete formData[self.state.currentTab - 1][`secondary-cta-1-label`];
1432
- delete formData[self.state.currentTab - 1][`cta-deeplink-secondary-cta-1`];
1433
- }
1434
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1435
- child.inputFields.splice(fieldIndex, 1);
1436
- delete formData[self.state.currentTab - 1][`cta-deeplink-secondary-cta-1-text2`];
1437
- }
1438
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1439
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1440
- const configkeys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === selectedDeeplink) : [];
1441
- if (configkeys.length) {
1442
- const options = configkeys[0].keys;
1443
- _.forEach(options, (opt) => {
1444
- delete formData[this.state.currentTab - 1][`custom-value-${opt}2-cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1445
- delete formData[this.state.currentTab - 1][`custom-value-${opt}-cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1446
- });
1447
- child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1448
-
1449
- delete formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1450
- } else {
1451
- child.inputFields.splice(fieldIndex, 1);
1452
- }
1453
- }
1454
- if (device === 'ios') {
1455
- child.inputFields[fieldIndex] = {
1456
- cols: [
1457
- {
1458
- id: "add-sec-cta-ios",
1459
- metaType: "label",
1460
- value: this.props.intl.formatMessage(messages.addSecondaryCTA),
1461
- primitive: true,
1462
- dynamicTab: false,
1463
- type: "div",
1464
- style: {
1465
- backgroundColor: 'white',
1466
- textAlign: 'left',
1467
- color: '#2673D7',
1468
- lineHeight: '24px',
1469
- fontSize: '14px',
1470
- marginTop: '16px',
1471
- fontWeight: '600',
1472
- fontFamily: 'open-sans',
1473
- fontStyle: 'normal',
1474
- cursor: 'pointer',
1475
- },
1476
- offset: 0,
1477
- onlyDisplay: true,
1478
- colStyle: {
1479
- flex: 1,
1480
- },
1481
- submitAction: "addSecondaryCtaIos",
1482
- supportedEvents: ["addSecondaryCtaIos"],
1483
- },
1484
- ],
1485
- };
1486
- }
1487
- }
1488
- });
1489
- }
1490
- });
1491
- }
1492
- });
1493
- });
1494
- });
1495
- });
1496
- });
1497
-
1498
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1499
- this.injectEvents(schema);
1500
- };
1501
-
1502
- deleteSecondaryCTA = (event) => {
1503
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1504
- const id = event.currentTarget.id;
1505
- if (id === "secondary-cta-0-delete") {
1506
- const secCta2 = document.getElementById("secondary-cta-1-delete");
1507
- if (secCta2) {
1508
- const modalContent = {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.deleteSecondCTAFirst), type: 'info', show: true, onCancel: this.onModalCancel};
1509
- this.setState({modalContent, showModal: true});
1510
- return;
1511
- }
1512
- }
1513
- const schema = _.cloneDeep(this.state.schema);
1514
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1515
- const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1516
- const formData = _.cloneDeep(this.state.formData);
1517
- const self = this;
1518
- const device = this.state.currentTab === 1 ? 'android' : 'ios';
1519
- _.forEach(schema.containers, (container) => {
1520
- _.forEach(container.panes, (pane) => {
1521
- _.forEach(pane.sections, (section) => {
1522
- _.forEach(section.childSections, (childeSection) => {
1523
- _.forEach(childeSection.childSections, (formChild) => {
1524
- const child = formChild;
1525
- if (child.type === 'multicols') {
1526
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1527
- if (inputField) {
1528
- _.forEach(inputField.cols, (col) => {
1529
- if (col.id === id) {
1530
- if (device === 'ios') {
1531
- child.inputFields.splice(fieldIndex, 3);
1532
- } else {
1533
- child.inputFields.splice(fieldIndex, 2);
1534
- }
1535
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1536
- child.inputFields.splice(fieldIndex, 1);
1537
- delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'text')}`];
1538
- }
1539
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1540
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1541
- const configkeys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === selectedDeeplink) : [];
1542
-
1543
- if (configkeys.length) {
1544
- const options = configkeys[0].keys;
1545
- _.forEach(options, (opt) => {
1546
- delete formData[this.state.currentTab - 1][`custom-value-${opt}-cta-deeplink-${id.replace('delete', 'select')}`];
1547
- });
1548
- child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1549
- delete formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1550
- } else {
1551
- child.inputFields.splice(fieldIndex, 1);
1552
- }
1553
- }
1554
- delete formData[this.state.currentTab - 1][`${id.replace('delete', 'label')}`];
1555
- delete formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1556
- if (device === 'ios') {
1557
- child.inputFields[fieldIndex] = {
1558
- cols: [
1559
- {
1560
- id: "add-sec-cta-ios",
1561
- metaType: "label",
1562
- value: this.props.intl.formatMessage(messages.addSecondaryCTA),
1563
- primitive: true,
1564
- dynamicTab: false,
1565
- type: "div",
1566
- style: {
1567
- backgroundColor: 'white',
1568
- textAlign: 'left',
1569
- color: '#2673D7',
1570
- lineHeight: '24px',
1571
- fontSize: '14px',
1572
- marginTop: '16px',
1573
- fontWeight: '600',
1574
- fontFamily: 'open-sans',
1575
- fontStyle: 'normal',
1576
- cursor: 'pointer',
1577
- },
1578
- offset: 0,
1579
- onlyDisplay: true,
1580
- colStyle: {
1581
- flex: 1,
1582
- },
1583
- submitAction: "addSecondaryCtaIos",
1584
- supportedEvents: ["addSecondaryCtaIos"],
1585
- },
1586
- ],
1587
- };
1588
- } else {
1589
- if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].cols[0] && child.inputFields[fieldIndex].cols[0].id === "add-sec-cta") {
1590
- child.inputFields[fieldIndex] = {
1591
- cols: [
1592
- {
1593
- id: "add-sec-cta",
1594
- metaType: "label",
1595
- value: this.props.intl.formatMessage(messages.addSecondaryCTA),
1596
- primitive: true,
1597
- dynamicTab: false,
1598
- type: "div",
1599
- style: {
1600
- backgroundColor: 'white',
1601
- textAlign: 'left',
1602
- color: '#2673D7',
1603
- lineHeight: '24px',
1604
- fontSize: '14px',
1605
- marginTop: '16px',
1606
- fontWeight: '600',
1607
- fontFamily: 'open-sans',
1608
- fontStyle: 'normal',
1609
- cursor: 'pointer',
1610
- },
1611
- offset: 0,
1612
- onlyDisplay: true,
1613
- colStyle: {
1614
- flex: 1,
1615
- },
1616
- submitAction: "addSecondaryCta",
1617
- supportedEvents: ['addSecondaryCta'],
1618
- fieldsLimit: 2,
1619
- fieldsCount: 0,
1620
- },
1621
- ],
1622
- };
1623
- }
1624
- if (id === "secondary-cta-1-delete" || child.inputFields[fieldIndex].cols[0].id === "cta-label" || child.inputFields[fieldIndex].cols[0].id === "secondary-cta-1-space") {
1625
- let nextFieldIndex = fieldIndex;
1626
- if (id === "secondary-cta-1-delete" || child.inputFields[fieldIndex].cols[0].id === "secondary-cta-1-space") {
1627
- nextFieldIndex = child.inputFields.length;
1628
- }
1629
- child.inputFields[nextFieldIndex] = {
1630
- cols: [
1631
- {
1632
- id: "add-sec-cta",
1633
- metaType: "label",
1634
- value: this.props.intl.formatMessage(messages.addAnotherCTA),
1635
- primitive: true,
1636
- dynamicTab: false,
1637
- type: "div",
1638
- style: {
1639
- backgroundColor: 'white',
1640
- textAlign: 'left',
1641
- color: '#2673D7',
1642
- lineHeight: '24px',
1643
- fontSize: '14px',
1644
- fontWeight: '600',
1645
- fontFamily: 'open-sans',
1646
- fontStyle: 'normal',
1647
- cursor: 'pointer',
1648
- },
1649
- offset: 0,
1650
- onlyDisplay: true,
1651
- colStyle: {
1652
- flex: 1,
1653
- },
1654
- submitAction: "addSecondaryCta",
1655
- supportedEvents: ['addSecondaryCta'],
1656
- fieldsLimit: 2,
1657
- fieldsCount: 1,
1658
- },
1659
- ],
1660
- };
1661
- }
1662
- }
1663
- }
1664
- });
1665
- }
1666
- });
1667
- }
1668
- });
1669
- });
1670
- });
1671
- });
1672
- });
1673
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1674
- this.injectEvents(schema);
1675
- };
1676
-
1677
-
1678
- startTemplateCreation = (data) => {
1679
-
1680
- if (!this.state.isContentEditLoaded && this.state.fullSchema && this.props.Edit.weCrmAccounts) {
1681
- const schema = JSON.stringify(data).indexOf("BIG_PICTURE") > -1 ? this.state.fullSchema.imageSchema : this.state.fullSchema.textSchema;
1682
- this.setMobilePushAccountOptions(this.props.Edit.weCrmAccounts, data.content.accId);
1683
- this.setState({schema, isContentEditLoaded: true, loadingContentEdit: true}, () => {
1684
- this.injectEvents(this.state.schema);
1685
- let editData = data.content;
1686
- editData = editData.versions && editData.versions.base ? editData : {versions: {base: editData}};
1687
- this.setEditState(editData, this.state.schema);
1688
- });
1689
- }
1690
- if (data.tags) {
1691
- this.props.globalActions.setInjectedTags(data.tags);
1692
- }
1693
- };
1694
- discardValues = () => {
1695
-
1696
- this.resetSchema();
1697
- this.setState({
1698
- formData: {},
1699
- tabCount: 1,
1700
- currentTab: 1,
1701
- editData: {},
1702
- }, () => {
1703
- const schema = this.props.Edit.templateDetails.mode === "image" ? this.state.fullSchema.imageSchema : this.state.fullSchema.textSchema;
1704
- this.setEditState(this.props.Edit.templateDetails, schema);
1705
- });
1706
- };
1707
- resetSchema = () => {
1708
- this.setState({ schema: this.state.initialState ? this.state.initialState : this.state.schema});
1709
- };
1710
- showNext = () => {
1711
- const response = {
1712
- action: "showNext",
1713
- value: true,
1714
- };
1715
- parent.postMessage(JSON.stringify(response), '*');
1716
- };
1717
- copyContent = () => {
1718
-
1719
- };
1720
- moveToTemplates = () => {
1721
-
1722
- const modalContent = {
1723
- title: this.props.intl.formatMessage(messages.alertMessage),
1724
- body: this.props.intl.formatMessage(messages.goBackConfirmation),
1725
- type: 'confirm',
1726
- id: 'template-back-confirm-modal',
1727
- show: true,
1728
- };
1729
- this.setState({modalContent, showModal: true});
1730
- };
1731
- injectSections = (sections) => {
1732
- _.forEach(sections, (section) => {
1733
- let temp = section;
1734
- if (temp.type === 'col-label') {
1735
- temp = this.injectColLabelSection(temp);
1736
- } else if (section.type === 'multicols') {
1737
- temp = this.injectMultiColSection(temp);
1738
- } else if (section.type === 'parent') {
1739
- temp = this.injectSections(temp.childSections);
1740
- }
1741
- });
1742
- return sections;
1743
- };
1744
- injectMultiColSection = (section) => {
1745
- const { formatMessage } = this.props.intl;
1746
- _.forEach(section.inputFields, (inputField) => {
1747
- _.forEach(inputField.cols, (col) => {
1748
- const temp = col;
1749
- if (temp.type === 'popover') {
1750
- temp.content.sections = this.injectSections(temp.content.sections);
1751
- temp.value.sections = this.injectSections(temp.value.sections);
1752
- return true;
1753
- }
1754
-
1755
- if (messages?.[temp?.value]) {
1756
- temp.value = formatMessage(messages[temp.value]);
1757
- }
1758
- if (messages?.[temp?.label]) {
1759
- temp.label = formatMessage(messages[temp.label]);
1760
- }
1761
- if (messages?.[temp?.errorMessage]) {
1762
- temp.errorMessage = formatMessage(messages[temp.errorMessage]);
1763
- }
1764
- if (messages?.[temp?.placeholder]) {
1765
- temp.placeholder = formatMessage(messages[temp.placeholder]);
1766
- }
1767
- if (messages?.[temp?.hoverText]) {
1768
- temp.hoverText = formatMessage(messages[temp.hoverText]);
1769
- }
1770
-
1771
- temp.injectedEvents = {};
1772
- temp.className = temp.className ? temp.className : '';
1773
- if (this.props.location.query.type === 'embedded' && ((temp.type === "tag-list" || temp.type === "div" || temp.type === "icon") && this.props.location.query.module !== "dvs") && (temp.supportedEvents)) {
1774
- temp.className = `${temp.className} hide`;
1775
- }
1776
- if (this.props.location.query.type === 'embedded' && (temp.type === "input" || temp.type === "textarea" || temp.type === "radioGroup") && this.props.location.query.module !== "dvs") {
1777
- temp.className = `${temp.className} disabled`;
1778
- temp.disabled = true;
1779
- }
1780
- if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-template" ) {
1781
- temp.options = this.state.templateOptions ? this.state.templateOptions : [];
1782
- }
1783
- if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-accounts" ) {
1784
- temp.options = this.state.templateOptions ? this.state.accountsOptions : [];
1785
- }
1786
- if (temp.id === "mobile-push-preview" && this.props.Templates.selectedWeChatAccount && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
1787
- temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
1788
- }
1789
- _.forEach(col.supportedEvents, (event) => {
1790
- temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
1791
- });
1792
- return true;
1793
- });
1794
- });
1795
- _.forEach(section.actionFields, (actionField) => {
1796
- _.forEach(actionField.cols, (col) => {
1797
- const temp = col;
1798
- temp.disabled = this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs";
1799
- if (temp.type === 'popover') {
1800
- temp.content.sections = this.injectSections(temp.content.sections);
1801
- temp.value.sections = this.injectSections(temp.value.sections);
1802
- return true;
1803
- }
1804
- temp.injectedEvents = {};
1805
- _.forEach(col.supportedEvents, (event) => {
1806
- temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
1807
- });
1808
- return true;
1809
- });
1810
- });
1811
- return section;
1812
- };
1813
-
1814
- saveFormData = (formData) => {
1815
-
1816
- const obj = this.getTransformedData(formData);
1817
-
1818
- this.props.actions.editTemplate(obj);
1819
- };
1820
- handleFrameTasks = (e) => {
1821
- //
1822
- const type = e.data;
1823
-
1824
- if (typeof type === 'object') {
1825
- //
1826
- const action = type.action;
1827
- switch (action) {
1828
- case "startTemplateCreation":
1829
- this.startTemplateCreation(type.value);
1830
- break;
1831
- case "startLoading":
1832
- this.startLoading(type.edit);
1833
- break;
1834
- case "getCurrentWindow":
1835
- this.getCurrentWindow(type);
1836
- break;
1837
- default:
1838
- break;
1839
- }
1840
- } else {
1841
- switch (type) {
1842
- case "getFormData":
1843
- this.getFormData(e);
1844
- break;
1845
- case "startTemplateCreation":
1846
-
1847
- //this.getFormData(e);
1848
- break;
1849
- case "moveToTemplates":
1850
-
1851
- this.moveToTemplates();
1852
- break;
1853
- case "validateContent":
1854
-
1855
- this.validateContent(e);
1856
- break;
1857
- default:
1858
- break;
1859
- }
1860
- }
1861
- };
1862
-
1863
- cancelTemplate = () => {
1864
- const type = this.props.location.query.type;
1865
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
1866
- this.props.router.push({
1867
- pathname: `/mobilepush/`,
1868
- search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
1869
- });
1870
- };
1871
-
1872
- showCtaKeys = (eventTriggered, formData, field, tabIndex, schemaInput) => {
1873
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1874
- const currentTab = tabIndex || this.state.currentTab;
1875
- const schema = _.cloneDeep(schemaInput || this.state.schema);
1876
- const eventsMap = _.cloneDeep(this.state.eventsMap);
1877
- _.forEach(schema.containers, (container) => {
1878
- _.forEach(container.panes, (pane) => {
1879
- _.forEach(pane.sections, (section) => {
1880
- _.forEach(section.childSections, (childeSection) => {
1881
- _.forEach(childeSection.childSections, (child) => {
1882
- const formChaild = child;
1883
- if (child.type === 'multicols') {
1884
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
1885
- _.forEach(inputField.cols, (col) => {
1886
- if (col.id === field.id) {
1887
- const formDataKey = col.id.replace("-show-keys", "");
1888
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1889
- let keys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === formData[currentTab - 1][formDataKey]) : [];
1890
- if (keys[0]) {
1891
- keys = keys[0].keys;
1892
- }
1893
- let rows = _.map(keys, (key) => {
1894
- const row = {
1895
- rowClassName: 'mobile-push-row',
1896
- id: 'cta-deeplink-keys',
1897
- cols: [
1898
- {
1899
- id: `${key}-space`,
1900
- metaType: "label",
1901
- value: "",
1902
- primitive: true,
1903
- dynamicTab: false,
1904
- type: "div",
1905
- width: 4,
1906
- offset: 0,
1907
- onlyDisplay: true,
1908
- colStyle: {
1909
- flex: 1,
1910
- },
1911
- },
1912
- {
1913
- id: `${key}-label`,
1914
- metaType: "label",
1915
- value: key.replace('_', " "),
1916
- primitive: true,
1917
- dynamicTab: false,
1918
- type: "div",
1919
- width: 5,
1920
- style: {
1921
- backgroundColor: 'white',
1922
- textAlign: 'left',
1923
- lineHeight: '24px',
1924
- fontSize: '14px',
1925
- fontFamily: 'open-sans',
1926
- fontStyle: 'normal',
1927
- cursor: 'pointer',
1928
- paddingTop: '8px',
1929
- },
1930
- offset: 0,
1931
- onlyDisplay: true,
1932
- colStyle: {
1933
- flex: 1,
1934
- },
1935
- },
1936
- {
1937
- id: `custom-value-${key}-${col.id}`,
1938
- label: "value",
1939
- type: "input", //Resembles component to be used
1940
- metaType: "text",
1941
- datatype: "string",
1942
- required: true,
1943
- width: 14,
1944
- placeholder: `${this.props.intl.formatMessage(messages.pleaseInput)} ${key.replace('_', " ")}.`,
1945
- fluid: true,
1946
- styling: "semantic",
1947
- order: 1,
1948
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
1949
- customComponent: false,
1950
- errorMessage: this.props.intl.formatMessage(messages.valueCantEmpty),
1951
- },
1952
- ],
1953
- };
1954
- //eventsMap[`custome-${key}`] = {"onChange": this.onMessageTitleChange};
1955
- return row;
1956
- // formChaild.inputFields[fieldIndex + index] = field;
1957
- });
1958
-
1959
-
1960
- if (!tabIndex) { // removes the existing selected options keys so that newly selected options keys can be added.
1961
- const configkeys = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === this.state.formData[currentTab - 1][field.id]);
1962
- if (configkeys.length) {
1963
- const options = configkeys[0].keys;
1964
- formChaild.inputFields = formChaild.inputFields.slice(0, fieldIndex + 1).concat(formChaild.inputFields.slice(fieldIndex + options.length + 1, formChaild.inputFields.length));
1965
- // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1966
- // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1967
- }
1968
- }
1969
- if (formChaild.inputFields[fieldIndex + 1] && formChaild.inputFields[fieldIndex + 1].id === "cta-deeplink-keys") {
1970
- rows = formChaild.inputFields.slice(0, fieldIndex + 1).concat(rows).concat(formChaild.inputFields.slice(fieldIndex + 1, formChaild.inputFields.length));
1971
- formChaild.inputFields = rows;
1972
- } else {
1973
- rows = formChaild.inputFields.slice(0, fieldIndex + 1).concat(rows).concat(formChaild.inputFields.slice(fieldIndex + 1, formChaild.inputFields.length));
1974
- formChaild.inputFields = rows;
1975
- }
1976
- }
1977
- });
1978
- });
1979
- }
1980
- });
1981
- });
1982
- });
1983
- });
1984
- });
1985
- if (tabIndex) {
1986
- return schema;
1987
- }
1988
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, eventsMap, isSchemaChanged: true});
1989
- this.injectEvents(schema);
1990
- return schema;
1991
- };
1992
- addPrimaryCta = (ev, field, inputSchema) => {
1993
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1994
- const id = ev ? ev.target.id : field.id;
1995
- const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1996
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1997
- const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1998
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
1999
- _.forEach(schema.containers, (container) => {
2000
- _.forEach(container.panes, (pane) => {
2001
- _.forEach(pane.sections, (section) => {
2002
- _.forEach(section.childSections, (childeSection) => {
2003
- _.forEach(childeSection.childSections, (child) => {
2004
- if (child.type === 'multicols') {
2005
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
2006
- _.forEach(inputField.cols, (col) => {
2007
- const colId = `${col.id}${this.state.currentTab > 1 ? this.state.currentTab : ''}`;
2008
- if (colId === id) {
2009
-
2010
- child.inputFields.splice(fieldIndex, 1, {
2011
- rowClassName: 'mobile-push-row',
2012
- cols: [
2013
- {
2014
- id: "cta-label",
2015
- metaType: "label",
2016
- value: this.props.intl.formatMessage(messages.primaryCTA),
2017
- primitive: true,
2018
- dynamicTab: false,
2019
- type: "div",
2020
- width: 4,
2021
- style: {
2022
- backgroundColor: 'white',
2023
- textAlign: 'left',
2024
- color: '#333333',
2025
- lineHeight: '24px',
2026
- fontSize: '14px',
2027
- fontFamily: 'open-sans',
2028
- fontStyle: 'normal',
2029
- marginTop: '16px',
2030
- },
2031
- offset: 0,
2032
- onlyDisplay: true,
2033
- colStyle: {
2034
- flex: 1,
2035
- },
2036
- },
2037
- {
2038
- id: `cta-deeplink${id === 'add-pri-cta' ? '' : 2}`,
2039
- type: "radioGroup", //Resembles component to be used
2040
- metaType: "text",
2041
- datatype: "string",
2042
- options: ["Deeplink", "External Link"],
2043
- value: "Deeplink",
2044
- required: true,
2045
- width: 18,
2046
- errorMessage: this.props.intl.formatMessage(messages.selectLinkType),
2047
- fluid: true,
2048
- styling: "semantic",
2049
- order: 1,
2050
- customComponent: false,
2051
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2052
- supportedEvents: ["onChange"],
2053
- style: {
2054
- marginTop: '16px',
2055
- },
2056
- },
2057
- {
2058
- id: `cta-deeplink${id === 'add-pri-cta' ? '' : 2}-delete`,
2059
- type: "icon",
2060
- value: 'delete',
2061
- width: 1,
2062
- submitAction: "onDelete",
2063
- supportedEvents: ["onDelete"],
2064
- style: {
2065
- marginTop: '16px',
2066
- },
2067
- },
2068
- ],
2069
- });
2070
- child.inputFields.splice(fieldIndex + 1, 0, {
2071
- rowClassName: 'mobile-push-row',
2072
- id: 'cta-deeplink-select-section',
2073
- cols: [
2074
- {
2075
- id: "cta-label",
2076
- metaType: "label",
2077
- value: "",
2078
- primitive: true,
2079
- dynamicTab: false,
2080
- type: "div",
2081
- width: 4,
2082
- onlyDisplay: true,
2083
- colStyle: {
2084
- flex: 1,
2085
- },
2086
- },
2087
- {
2088
- id: `cta-deeplink${id === 'add-pri-cta' ? '' : 2}-select`,
2089
- placeholder: this.props.intl.formatMessage(messages.selectDeeplink),
2090
- type: "select", //Resembles component to be used
2091
- options: deepLinkOptions,
2092
- errorMessage: this.props.intl.formatMessage(messages.selectADeeplink),
2093
- metaType: "text",
2094
- datatype: "string",
2095
- required: true,
2096
- fluid: true,
2097
- width: 19,
2098
- style: {
2099
- fontSize: '14px',
2100
- fontFamily: 'open-sans',
2101
- fontStyle: 'normal',
2102
- // fontWeight: 600,
2103
- marginBottom: '16px',
2104
- },
2105
- styling: "semantic",
2106
- order: 1,
2107
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2108
- customComponent: false,
2109
- supportedEvents: [
2110
- 'onSelect',
2111
- ],
2112
- },
2113
- ],
2114
- });
2115
- }
2116
- });
2117
- });
2118
- }
2119
- });
2120
- });
2121
- });
2122
- });
2123
- });
2124
- if (inputSchema) {
2125
- return schema;
2126
- }
2127
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
2128
- this.injectEvents(schema);
2129
- return schema;
2130
- };
2131
-
2132
- addSecondoryCta = (ev, field, inputSchema) => {
2133
- const id = ev ? ev.target.id : field.id;
2134
- const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
2135
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
2136
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
2137
- const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
2138
-
2139
- // const eventsMap = _.cloneDeep(this.state.eventsMap);
2140
- _.forEach(schema.containers, (container) => {
2141
- _.forEach(container.panes, (pane) => {
2142
- _.forEach(pane.sections, (section) => {
2143
- _.forEach(section.childSections, (childeSection) => {
2144
- _.forEach(childeSection.childSections, (child) => {
2145
- if (child.type === 'multicols') {
2146
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
2147
- _.forEach(inputField.cols, (col) => {
2148
- if (col.id === id) {
2149
- if (col.fieldsCount < col.fieldsLimit) {
2150
- const inputId = `secondary-cta-${col.fieldsCount}`;
2151
-
2152
- child.inputFields.splice(fieldIndex, 0, {
2153
- rowClassName: 'mobile-push-row',
2154
- cols: [
2155
- {
2156
- id: `${inputId}-space`,
2157
- metaType: "label",
2158
- value: this.props.intl.formatMessage(messages.secondaryCTA),
2159
- primitive: true,
2160
- dynamicTab: false,
2161
- type: "div",
2162
- width: 4,
2163
- style: {
2164
- backgroundColor: 'white',
2165
- textAlign: 'left',
2166
- color: '#333333',
2167
- lineHeight: '24px',
2168
- fontSize: '14px',
2169
- fontFamily: 'open-sans',
2170
- fontStyle: 'normal',
2171
- paddingTop: '8px',
2172
- },
2173
- offset: 0,
2174
- onlyDisplay: true,
2175
- colStyle: {
2176
- flex: 1,
2177
- },
2178
- },
2179
- {
2180
- id: `${inputId}-label`,
2181
- label: "link",
2182
- type: "input", //Resembles component to be used
2183
- metaType: "text",
2184
- datatype: "string",
2185
- required: true,
2186
- width: 18,
2187
- offset: 4,
2188
- placeholder: this.props.intl.formatMessage(messages.enterCTALabel),
2189
- fluid: true,
2190
- styling: "semantic",
2191
- order: 1,
2192
- customComponent: false,
2193
- errorMessage: this.props.intl.formatMessage(messages.ctaLabelCantEmpty),
2194
- },
2195
- {
2196
- id: `${inputId}-delete`,
2197
- type: "icon",
2198
- value: 'delete',
2199
- width: 1,
2200
- submitAction: "onDelete",
2201
- supportedEvents: ["onDelete"],
2202
- },
2203
- ],
2204
- });
2205
- child.inputFields.splice(fieldIndex + 1, 0, {
2206
- rowClassName: 'mobile-push-row',
2207
- cols: [
2208
- {
2209
- id: `${inputId}-label-space`,
2210
- metaType: "label",
2211
- value: "",
2212
- primitive: true,
2213
- dynamicTab: false,
2214
- type: "div",
2215
- width: 4,
2216
- style: {
2217
- backgroundColor: 'white',
2218
- textAlign: 'left',
2219
- color: '#333333',
2220
- lineHeight: '24px',
2221
- fontSize: '14px',
2222
- fontFamily: 'open-sans',
2223
- fontStyle: 'normal',
2224
- paddingTop: '8px',
2225
- },
2226
- offset: 0,
2227
- onlyDisplay: true,
2228
- colStyle: {
2229
- flex: 1,
2230
- },
2231
- },
2232
- {
2233
- id: `cta-deeplink-${inputId}`,
2234
- type: "radioGroup", //Resembles component to be used
2235
- metaType: "text",
2236
- datatype: "string",
2237
- options: ["Deeplink", "External Link"],
2238
- value: "Deeplink",
2239
- required: true,
2240
- width: 16,
2241
- fluid: true,
2242
- styling: "semantic",
2243
- order: 1,
2244
- style: {
2245
- lineHeight: '24px',
2246
- fontSize: '14px',
2247
- },
2248
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2249
- customComponent: false,
2250
- supportedEvents: ["onChange"],
2251
- },
2252
- ],
2253
- });
2254
- child.inputFields.splice(fieldIndex + 2, 0, {
2255
- rowClassName: 'mobile-push-row',
2256
- id: 'cta-deeplink-select-section',
2257
- cols: [
2258
- {
2259
- id: "cta-label",
2260
- metaType: "label",
2261
- value: "",
2262
- primitive: true,
2263
- dynamicTab: false,
2264
- type: "div",
2265
- width: 4,
2266
- onlyDisplay: true,
2267
- colStyle: {
2268
- flex: 1,
2269
- },
2270
- },
2271
- {
2272
- id: `cta-deeplink-${inputId}-select`,
2273
- placeholder: this.props.intl.formatMessage(messages.selectDeeplink),
2274
- type: "select", //Resembles component to be used
2275
- options: deepLinkOptions,
2276
- errorMessage: this.props.intl.formatMessage(messages.selectADeeplink),
2277
- metaType: "text",
2278
- datatype: "string",
2279
- required: true,
2280
- fluid: true,
2281
- width: 19,
2282
- style: {
2283
- fontSize: '14px',
2284
- fontFamily: 'open-sans',
2285
- fontStyle: 'normal',
2286
- // fontWeight: 600,
2287
- marginBottom: '16px',
2288
- },
2289
- styling: "semantic",
2290
- order: 1,
2291
- disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2292
- customComponent: false,
2293
- supportedEvents: [
2294
- 'onSelect',
2295
- ],
2296
- },
2297
- ],
2298
- });
2299
-
2300
- const colField = col;
2301
- colField.value = this.props.intl.formatMessage(messages.addAnotherCTA);
2302
- colField.fieldsCount += 1;
2303
- if (col.fieldsCount === col.fieldsLimit) {
2304
- child.inputFields.pop();
2305
- }
2306
- // eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
2307
- }
2308
- }
2309
- });
2310
- });
2311
- }
2312
- });
2313
- });
2314
- });
2315
- });
2316
- });
2317
- if (inputSchema) {
2318
- return schema;
2319
- }
2320
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
2321
- this.injectEvents(schema);
2322
- return schema;
2323
- };
2324
-
2325
- addSecondoryCtaIos = (ev) => {
2326
- const id = ev.target.id;
2327
- const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
2328
- const schema = _.cloneDeep(this.state.schema);
2329
- _.forEach(schema.containers, (container) => {
2330
- _.forEach(container.panes, (pane, paneIndex) => {
2331
- _.forEach(pane.sections, (section) => {
2332
- _.forEach(section.childSections, (childeSection) => {
2333
- _.forEach(childeSection.childSections, (child) => {
2334
- if (child.type === 'multicols') {
2335
- _.forEach(child.inputFields, (inputField, fieldIndex) => {
2336
- _.forEach(inputField.cols, (col) => {
2337
- const colId = (paneIndex + 1) > 1 ? col.id + (paneIndex + 1) : col.id;
2338
- if (colId === id) {
2339
- const inputId = `secondary-cta-${paneIndex}`;
2340
-
2341
- child.inputFields.splice(fieldIndex, 1, {
2342
- rowClassName: 'mobile-push-row',
2343
- cols: [
2344
- {
2345
- id: `${inputId}-label`,
2346
- metaType: "label",
2347
- value: this.props.intl.formatMessage(messages.secondaryCTA),
2348
- primitive: true,
2349
- dynamicTab: false,
2350
- type: "div",
2351
- width: 4,
2352
- style: {
2353
- backgroundColor: 'white',
2354
- textAlign: 'left',
2355
- color: '#333333',
2356
- lineHeight: '24px',
2357
- fontSize: '14px',
2358
- fontFamily: 'open-sans',
2359
- fontStyle: 'normal',
2360
- paddingTop: '8px',
2361
- },
2362
- offset: 0,
2363
- onlyDisplay: true,
2364
- colStyle: {
2365
- flex: 1,
2366
- },
2367
- },
2368
- {
2369
- id: `${inputId}-table`,
2370
- type: "table", //Resembles component to be used
2371
- metaType: "text",
2372
- datatype: "string",
2373
- pagination: false,
2374
- columns: [
2375
- {
2376
- title: this.props.intl.formatMessage(messages.nameAndDescription),
2377
- dataIndex: "name",
2378
- key: "name",
2379
- width: 200,
2380
- render: (text, record) => (
2381
- <div>
2382
- <div>{record.name}</div>
2383
- <div>{record.description}</div>
2384
- </div>),
2385
- },
2386
- {
2387
- title: this.props.intl.formatMessage(messages.button1),
2388
- dataIndex: "description",
2389
- key: "button1",
2390
- width: 100,
2391
- render: (text, record) => (
2392
- <div>
2393
- {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
2394
- </div>),
2395
- },
2396
- {
2397
- title: this.props.intl.formatMessage(messages.button2),
2398
- dataIndex: "description",
2399
- key: "button2",
2400
- width: 100,
2401
- render: (text, record) => (
2402
- <div>
2403
- {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
2404
- </div>
2405
- ),
2406
- },
2407
- ],
2408
- required: true,
2409
- width: 16,
2410
- fluid: true,
2411
- styling: "semantic",
2412
- order: 1,
2413
- customComponent: false,
2414
- supportedEvents: ["onRowClick"],
2415
- },
2416
- ],
2417
- });
2418
-
2419
- const colField = col;
2420
- colField.value = this.props.intl.formatMessage(messages.addAnotherCTA);
2421
- colField.fieldsCount += 1;
2422
- if (col.fieldsCount === col.fieldsLimit) {
2423
- child.inputFields.pop();
2424
- }
2425
- }
2426
- });
2427
- });
2428
- }
2429
- });
2430
- });
2431
- });
2432
- });
2433
- });
2434
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
2435
- this.injectEvents(schema);
2436
- this.props.actions.getIosCtas(selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
2437
- };
2438
-
2439
- injectContainer = (container) => {
2440
- const temp = container;
2441
- if (temp.type === 'tabs') {
2442
- temp.injectedEvents = {};
2443
- _.forEach(temp.supportedEvents, (event) => {
2444
- temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
2445
- });
2446
- _.forEach(temp.panes, (pane) => {
2447
- const tempPane = pane;
2448
- tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
2449
- tempPane.sections = this.injectSections(tempPane.sections);
2450
- });
2451
- }
2452
- return temp;
2453
- };
2454
-
2455
- injectEvents = (schema = {}) => {
2456
- const temp = schema;
2457
- if (this.injectSections && temp.standalone) {
2458
- temp.standalone.sections = this.injectSections(temp.standalone.sections);
2459
- }
2460
- _.forEach(temp.containers, (container) => {
2461
- let tempContainer = container;
2462
- tempContainer = this.injectContainer(tempContainer);
2463
- return tempContainer;
2464
- });
2465
-
2466
- this.setState({schema, loadingContentEdit: false}, () => {
2467
- this.removeStandAlone();
2468
- });
2469
- return schema;
2470
- };
2471
- removeStandAlone = () => {
2472
- const schema = _.cloneDeep(this.state.schema);
2473
- if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
2474
- if (schema.standalone.sections.length === 2) {
2475
- schema.standalone.sections.splice(0, 1);
2476
- }
2477
- } else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') {
2478
- delete schema.standalone;
2479
- } else {
2480
- schema.standalone.sections.splice(1, 1);
2481
- }
2482
- this.setState({ schema });
2483
- };
2484
- handleOnTagsContextChange = (data) => {
2485
-
2486
- const query = {
2487
- layout: 'mobilepush',
2488
- type: 'TAG',
2489
- context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
2490
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
2491
- };
2492
- this.props.globalActions.fetchSchemaForEntity(query);
2493
- };
2494
-
2495
- render() {
2496
- const schema = this.state.schema;
2497
- let tipText = this.props.Edit && ("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) ? this.props.intl.formatMessage(messages.gettingTemplate) : '';
2498
- tipText = this.props.Edit && ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress) ? this.props.intl.formatMessage(messages.savingTemplate) : '';
2499
- const loadingContentEdit = this.state.loadingContentEdit || (this.props.location.query.module === 'dvs' && _.isEmpty(this.state.schema));
2500
- const spinning = loadingContentEdit || this.props.Edit.fetchingDefaultTemplates || this.props.Edit.assetUploading || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
2501
- let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
2502
- if (this.props.supportedTags) {
2503
- tags = this.props.supportedTags;
2504
- }
2505
- return (
2506
- <div>
2507
- <Spin tip={tipText} spinning={spinning}>
2508
- {<Row style={{marginBottom: '16px', marginLeft: '-40px'}}>
2509
- <Col offset={1}>
2510
- { this.props.location.query.type !== "embedded" &&
2511
- <Breadcrumb>
2512
- <BreadcrumbItem>{this.props.intl.formatMessage(messages.Campaigns)}</BreadcrumbItem>
2513
- <BreadcrumbItem>{this.props.intl.formatMessage(messages.Creatives)}</BreadcrumbItem>
2514
- <BreadcrumbItem>{this.props.intl.formatMessage(messages.mobilePush)}</BreadcrumbItem>
2515
- </Breadcrumb>
2516
- }
2517
- </Col>
2518
- </Row>}
2519
- <Row>
2520
- <Col>
2521
- <FormBuilder
2522
- schema={schema}
2523
- onSubmit={this.saveFormData}
2524
- onChange={this.onFormDataChange}
2525
- formData={_.cloneDeep(this.state.formData)}
2526
- currentTab={this.state.currentTab}
2527
- parent={this}
2528
- location={this.props.location}
2529
- isEdit
2530
- tabCount={2}
2531
- iosCtasData={this.state.iosCtasData}
2532
- tags={tags}
2533
- injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
2534
- onFormValidityChange={this.setFormValidity}
2535
- usingTabContainer
2536
- checkValidation={this.state.checkValidation}
2537
- onContextChange={this.handleOnTagsContextChange}
2538
- showModal={this.state.showModal}
2539
- iframeParent={parent}
2540
- router={this.props.router}
2541
- isSchemaChanged={this.state.isSchemaChanged}
2542
- handleCancelModal={this.handleCancelModal}
2543
- modal={this.state.modalContent}
2544
- setModalContent={this.setModalContent}
2545
- />
2546
- </Col>
2547
- </Row>
2548
- </Spin>
2549
- </div>
2550
- );
2551
- }
2552
- }
2553
-
2554
- Edit.propTypes = {
2555
- actions: PropTypes.object.isRequired,
2556
- Edit: PropTypes.object,
2557
- params: PropTypes.object,
2558
- router: PropTypes.object,
2559
- location: PropTypes.object,
2560
- globalActions: PropTypes.object,
2561
- templatesActions: PropTypes.object,
2562
- Templates: PropTypes.object,
2563
- metaEntities: PropTypes.object,
2564
- templateDetails: PropTypes.object,
2565
- intl: intlShape.isRequired,
2566
- supportedTags: PropTypes.array,
2567
- getDefaultTags: PropTypes.string,
2568
- templateData: PropTypes.object,
2569
- injectedTags: PropTypes.object,
2570
- };
2571
-
2572
- const mapStateToProps = createStructuredSelector({
2573
- Edit: makeSelectEdit(),
2574
- Create: makeSelectCreate(),
2575
- editResponse: makeSelectEditResponse(),
2576
- templateDetails: makeSelectTemplateDetailsResponse(),
2577
- metaEntities: makeSelectMetaEntities(),
2578
- Templates: makeSelectTemplates(),
2579
- injectedTags: setInjectedTags(),
2580
- });
2581
-
2582
- function mapDispatchToProps(dispatch) {
2583
- return {
2584
- actions: bindActionCreators(actions, dispatch),
2585
- globalActions: bindActionCreators(globalActions, dispatch),
2586
- templatesActions: bindActionCreators(templatesActions, dispatch),
2587
- };
2588
- }
2589
-
2590
- const withConnect = connect(mapStateToProps, mapDispatchToProps);
2591
- const withReducer = injectReducer({ key: 'mobileEdit', reducer });
2592
- const withSaga = injectSaga({ key: 'mobileEdit', saga: editMPushSaga });
2593
- const withTemplatesSaga = injectSaga({ key: 'templates', saga: templateSaga });
2594
-
2595
- export default compose(
2596
- UserIsAuthenticated,
2597
- withReducer,
2598
- withSaga,
2599
- withTemplatesSaga,
2600
- withConnect,
2601
- )(injectIntl(Edit));