@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,1488 +0,0 @@
1
- /*
2
- *
3
- * Create
4
- *
5
- */
6
-
7
- import PropTypes from 'prop-types';
8
-
9
- import React from 'react';
10
- import { connect } from 'react-redux';
11
- import { Row, Col, Spin } from 'antd';
12
- import { injectIntl, intlShape } from 'react-intl';
13
- import { createStructuredSelector } from 'reselect';
14
- import _ from 'lodash';
15
- import { bindActionCreators, compose} from 'redux';
16
- import { makeSelectCreate, makeSelectCreateResponse } from './selectors';
17
- import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
18
- import { UserIsAuthenticated } from '../../../utils/authWrapper';
19
- import './_smsCreate.scss';
20
- import FormBuilder from '../../../components/FormBuilder';
21
- import * as actions from './actions';
22
- import messages from './messages';
23
- import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
24
- import * as globalActions from '../../../containers/Cap/actions';
25
- import {getMessageObject} from '../../../utils/messageUtils';
26
- import injectSaga from '../../../utils/injectSaga';
27
- import injectReducer from '../../../utils/injectReducer';
28
- import reducer from './reducer';
29
- import { createSmsSaga } from './sagas';
30
- import { createQueryString } from '../../../utils/common';
31
-
32
- export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
33
- constructor(props) {
34
- super(props);
35
- this.state = {
36
- formData: {},
37
- tabCount: 1,
38
- currentTab: 1,
39
- schema: {},
40
- loading: false,
41
- isFormValid: true,
42
- injectedTags: {},
43
- checkValidation: false,
44
- tabKey: '',
45
- showModal: false,
46
- modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.deleteVersion), type: 'confirm', id: 'sms-version-modal'},
47
- };
48
- this.saveFormData = this.saveFormData.bind(this);
49
- this.onFormDataChange = this.onFormDataChange.bind(this);
50
- this.onTemplateNameChange = this.onTemplateNameChange.bind(this);
51
- this.onTemplateContentChange = this.onTemplateContentChange.bind(this);
52
- this.handleFrameTasks = this.handleFrameTasks.bind(this);
53
- this.getFormData = this.getFormData.bind(this);
54
- this.validateContent = this.validateContent.bind(this);
55
- this.onTagSelect = this.onTagSelect.bind(this);
56
- this.insertAtCursor = this.insertAtCursor.bind(this);
57
- this.addVersion = this.addVersion.bind(this);
58
- this.onTabChange = this.onTabChange.bind(this);
59
- this.resetSchema = this.resetSchema.bind(this);
60
- this.resetState = this.resetState.bind(this);
61
- this.discardValues = this.discardValues.bind(this);
62
- this.cloneColLabel = this.cloneColLabel.bind(this);
63
- this.cloneMultiCol = this.cloneMultiCol.bind(this);
64
- this.cloneParent = this.cloneParent.bind(this);
65
- this.markFinalVersion = this.markFinalVersion.bind(this);
66
- this.deleteVersion = this.deleteVersion.bind(this);
67
- this.duplicateVersion = this.duplicateVersion.bind(this);
68
- this.renameVersion = this.renameVersion.bind(this);
69
- this.onVersionNameChange = this.onVersionNameChange.bind(this);
70
- this.startTemplateCreation = this.startTemplateCreation.bind(this);
71
- this.startLoading = this.startLoading.bind(this);
72
- this.removeStandAlone = this.removeStandAlone.bind(this);
73
- this.validateFormData = this.validateFormData.bind(this);
74
- this.getCurrentWindow = this.getCurrentWindow.bind(this);
75
- this.moveToTemplates = this.moveToTemplates.bind(this);
76
- this.cancelTemplate = this.cancelTemplate.bind(this);
77
- this.injectEvents = this.injectEvents.bind(this);
78
- this.injectSections = this.injectSections.bind(this);
79
- this.injectContainer = this.injectContainer.bind(this);
80
- this.injectParentSection = this.injectParentSection.bind(this);
81
- this.injectColLabelSection = this.injectColLabelSection.bind(this);
82
- this.injectMultiColSection = this.injectMultiColSection.bind(this);
83
- this.getMappedEvent = this.getMappedEvent.bind(this);
84
- this.setFormValidity = this.setFormValidity.bind(this);
85
- this.showNext = this.showNext.bind(this);
86
- this.injectMessages = this.injectMessages.bind(this);
87
- }
88
-
89
- componentWillMount() {
90
-
91
- if (this.props.route.name === 'view') {
92
- this.setState({loading: false});
93
- // this.removeStandAlone();
94
- }
95
- }
96
-
97
- componentDidMount() {
98
-
99
- const query = {
100
- layout: 'SMS',
101
- type: 'LAYOUT',
102
- };
103
- this.props.globalActions.fetchSchemaForEntity(query);
104
- const type = this.props.location.query.type;
105
- // const module = this.props.location.query.module;
106
- const name = this.props.route.name;
107
- window.addEventListener("message", this.handleFrameTasks);
108
- if (type === 'embedded') {
109
- const response = {
110
- action: 'startTemplateCreation',
111
- window: name === 'view' ? 'view' : 'create',
112
- };
113
- // if (name !== "view" && module.toLowerCase() === "timeline") {
114
- // return;
115
- // }
116
- parent.postMessage(JSON.stringify(response), '*');
117
- }
118
- //For testing embedded mode data injection
119
- // let that = this;
120
- // setTimeout( function() {
121
- // that.startTemplateCreation(
122
- // {
123
- // edit: true,
124
- // content: 'asasasasasas 12122',
125
- // tags: {},
126
- // }
127
- // );
128
- // }, 5000);
129
- }
130
-
131
- componentWillReceiveProps(nextProps) {
132
-
133
- if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
134
- nextProps.getFormSubscriptionData(this.getFormData());
135
- }
136
- if (nextProps.createResponse && nextProps.createResponse.templateId) {
137
-
138
- this.discardValues();
139
- const message = getMessageObject('success', this.props.intl.formatMessage(messages.smsCreateSuccess), true);
140
- this.props.globalActions.addMessageToQueue(message);
141
- this.props.actions.clearCreateResponse();
142
- const type = this.props.location.query.type;
143
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
144
- this.props.router.push({
145
- pathname: `/sms/`,
146
- search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
147
- });
148
- }
149
-
150
- if (nextProps.Create.createTemplateError && !_.isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
151
- const message = getMessageObject('error', (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
152
- this.props.globalActions.addMessageToQueue(message);
153
- }
154
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
155
-
156
- this.injectEvents(nextProps.metaEntities.layouts[0].definition);
157
- if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
158
- const query = {
159
- layout: 'SMS',
160
- type: 'TAG',
161
- context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
162
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
163
- };
164
- if (this.props.getDefaultTags) {
165
- query.context = this.props.getDefaultTags;
166
- }
167
- this.props.globalActions.fetchSchemaForEntity(query);
168
- if (this.props.location.query.type === 'embedded') {
169
- this.showNext();
170
- }
171
- }
172
- }
173
- }
174
-
175
- componentWillUnmount() {
176
-
177
- window.removeEventListener("message", this.handleFrameTasks);
178
- }
179
-
180
- onTemplateNameChange(name) {
181
-
182
- }
183
-
184
- onTemplateContentChange(content) {
185
-
186
- }
187
-
188
- onVersionNameChange(data, versionIndex) {
189
-
190
- }
191
-
192
- onFormDataChange(formData, tabCount, currentTab) {
193
-
194
- this.setState({formData, tabCount});
195
- if (currentTab) {
196
- this.setState({currentTab});
197
- }
198
- }
199
-
200
- onTagSelect(data, currentTab) {
201
-
202
- const editorId = currentTab > 1 ? `sms-editor${currentTab}` : 'sms-editor';
203
- this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
204
- document.getElementById(editorId).focus();
205
- }
206
-
207
- onTabChange(data) {
208
-
209
- this.setState({currentTab: data});
210
- }
211
-
212
- getFormData(e, value) {
213
-
214
- const formData = _.cloneDeep(this.state.formData);
215
- let baseData = {};
216
- let versionIdx;
217
- _.forEach(formData, (val, idx) => {
218
-
219
- if (val.base && idx !== 'base') {
220
- baseData = val;
221
- versionIdx = idx;
222
- }
223
- });
224
- baseData['sms-editor'] = baseData[`sms-editor${versionIdx > 0 ? versionIdx : ''}`];
225
- if (versionIdx !== "0") {
226
- delete baseData[`sms-editor${versionIdx > 0 ? versionIdx : ''}`];
227
- }
228
- const result = {};
229
- result.base = baseData;
230
- const msgObj = updateCharCount(baseData['sms-editor']);
231
- result.base.msg_count = msgObj.msgCount;
232
-
233
- const response = {
234
- action: "getFormData",
235
- value: result,
236
- postAction: value || 'next',
237
- validity: this.state.isFormValid,
238
- };
239
- this.setState({checkValidation: true});
240
-
241
- if (e) {
242
- e.source.postMessage(JSON.stringify(response), e.origin);
243
- }
244
- return response;
245
- }
246
-
247
- getCurrentWindow(e) {
248
-
249
- const response = {
250
- action: e.action,
251
- value: 'edit',
252
- direction: e.value,
253
- };
254
- parent.postMessage(JSON.stringify(response), '*');
255
- }
256
-
257
- getMappedEvent(id, event) {
258
- const map = {
259
- "template-name": {
260
- onChange: this.onTemplateNameChange,
261
- },
262
- "discard-button": {
263
- discardValues: this.discardValues,
264
- },
265
- "cancel-button": {
266
- cancelTemplate: this.cancelTemplate,
267
- },
268
- "save-button": {
269
- saveFormData: this.saveFormData,
270
- },
271
- "sms-editor": {
272
- onChange: this.onTemplateContentChange,
273
- },
274
- "tagList": {
275
- onTagSelect: this.onTagSelect,
276
- },
277
- "unicode-validity": {
278
- onChange: this.onTemplateNameChange,
279
- },
280
- "add-version-button": {
281
- addVersion: this.addVersion,
282
- },
283
- "tab-header": {
284
- onChange: this.onVersionNameChange,
285
- },
286
- "tab-options-popover": {
287
- onTabOptionSelect: this.onTabOptionSelect,
288
- },
289
- "mark-final-version-label": {
290
- markFinalVersion: this.markFinalVersion,
291
- },
292
- "duplicate-version-label": {
293
- duplicateVersion: this.duplicateVersion,
294
- },
295
- "rename-version-label": {
296
- renameVersion: this.renameVersion,
297
- },
298
- "delete-version-label": {
299
- deleteVersion: this.deleteVersion,
300
- },
301
- "pane": {
302
- onTabChange: this.onTabChange,
303
- },
304
- };
305
- const mappedIdObject = map[id];
306
- return mappedIdObject && mappedIdObject[event] ? mappedIdObject[event] : () => {};
307
- }
308
-
309
- setFormValidity(isFormValid) {
310
- this.setState({isFormValid});
311
- }
312
-
313
- injectMessages(elem) {
314
- const temp = elem;
315
- if (temp.value && messages[temp.value]) {
316
- temp.value = this.props.intl.formatMessage(messages[temp.value]);
317
- }
318
- if (temp.label && messages[temp.label]) {
319
- temp.label = this.props.intl.formatMessage(messages[temp.label]);
320
- }
321
- if (temp.errorMessage && messages[temp.errorMessage]) {
322
- temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
323
- }
324
- if (temp.placeholder && messages[temp.placeholder]) {
325
- temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
326
- }
327
- return temp;
328
- }
329
-
330
- showNext() {
331
- const response = {
332
- action: "showNext",
333
- value: true,
334
- };
335
- parent.postMessage(JSON.stringify(response), '*');
336
- }
337
-
338
- moveToTemplates() {
339
-
340
- const modalContent = {
341
- title: this.props.intl.formatMessage(messages.alertMessage),
342
- body: this.props.intl.formatMessage(messages.goBackConfirmation),
343
- type: 'confirm',
344
- id: 'template-back-confirm-modal',
345
- show: true,
346
- };
347
- this.setState({modalContent, showModal: true});
348
- // const type = this.props.location.query.type;
349
- // const module = this.props.location.query.module ? this.props.location.query.module : 'default';
350
- // this.props.router.push({
351
- // pathname: `/sms/`,
352
- // query: type === 'embedded' ? {type: 'embedded', module} : {module},
353
- // });
354
- }
355
-
356
- cancelTemplate() {
357
- const type = this.props.location.query.type;
358
- const module = this.props.location.query.module ? this.props.location.query.module : 'default';
359
- this.props.router.push({
360
- pathname: `/sms/`,
361
- search : createQueryString(type === 'embedded' ? {type: 'embedded', module} : {module})
362
- });
363
- }
364
-
365
- injectEvents(schema) {
366
-
367
- const temp = schema;
368
- temp.standalone.sections = this.injectSections(temp.standalone.sections);
369
- _.forEach(temp.containers, (container) => {
370
- let tempContainer = container;
371
- tempContainer = this.injectContainer(tempContainer);
372
- return tempContainer;
373
- });
374
-
375
- this.setState({schema}, () => {
376
- const type = this.props.location.query.type;
377
- if (type === 'embedded') {
378
- this.removeStandAlone();
379
- }
380
- });
381
- return schema;
382
- }
383
-
384
- injectContainer(container) {
385
- const temp = container;
386
- if (temp.type === 'tabs') {
387
- temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
388
- temp.tabBarExtraContent.sections = this.injectSections(temp.tabBarExtraContent.sections);
389
- temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
390
- temp.injectedEvents = {};
391
- _.forEach(temp.supportedEvents, (event) => {
392
- temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
393
- });
394
- _.forEach(temp.panes, (pane) => {
395
- const tempPane = pane;
396
- tempPane.sections = this.injectSections(tempPane.sections);
397
- });
398
- }
399
- return temp;
400
- }
401
-
402
- injectMultiColSection(section) {
403
- _.forEach(section.inputFields, (inputField) => {
404
- _.forEach(inputField.cols, (col) => {
405
- const temp = col;
406
- if (temp.type === 'popover') {
407
- temp.content.sections = this.injectSections(temp.content.sections);
408
- temp.value.sections = this.injectSections(temp.value.sections);
409
- return true;
410
- }
411
- temp.injectedEvents = {};
412
- _.forEach(col.supportedEvents, (event) => {
413
- console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
414
- temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
415
- });
416
-
417
- if (temp.type === 'icon') {
418
- return true;
419
- }
420
- if (temp.value && messages[temp.value]) {
421
- temp.value = this.props.intl.formatMessage(messages[temp.value]);
422
- }
423
- if (temp.label && messages[temp.label]) {
424
- temp.label = this.props.intl.formatMessage(messages[temp.label]);
425
- }
426
- if (temp.errorMessage && messages[temp.errorMessage]) {
427
- temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
428
- }
429
- if (temp.placeholder && messages[temp.placeholder]) {
430
- temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
431
- }
432
- return true;
433
- });
434
- });
435
- _.forEach(section.actionFields, (actionField) => {
436
- _.forEach(actionField.cols, (col) => {
437
- const temp = col;
438
- if (temp.type === 'popover') {
439
- temp.content.sections = this.injectSections(temp.content.sections);
440
- temp.value.sections = this.injectSections(temp.value.sections);
441
- return true;
442
- }
443
- temp.injectedEvents = {};
444
- _.forEach(col.supportedEvents, (event) => {
445
- temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
446
- });
447
-
448
- if (temp.type === 'icon') {
449
- return true;
450
- }
451
- if (temp.value && messages[temp.value]) {
452
- temp.value = this.props.intl.formatMessage(messages[temp.value]);
453
- }
454
- if (temp.label && messages[temp.label]) {
455
- temp.label = this.props.intl.formatMessage(messages[temp.label]);
456
- }
457
- if (temp.errorMessage && messages[temp.errorMessage]) {
458
- temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
459
- }
460
- if (temp.placeholder && messages[temp.placeholder]) {
461
- temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
462
- }
463
- return true;
464
- });
465
- });
466
- return section;
467
- }
468
-
469
- injectColLabelSection(section) {
470
- _.forEach(section.inputFields, (inputField) => {
471
- const temp = inputField;
472
- if (temp.type === 'popover') {
473
- temp.content.sections = this.injectSections(temp.content.sections);
474
- temp.value.sections = this.injectSections(temp.value.sections);
475
- return true;
476
- }
477
- temp.injectedEvents = {};
478
- _.forEach(inputField.supportedEvents, (event) => {
479
- temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
480
- });
481
-
482
- if (temp.type === 'icon') {
483
- return true;
484
- }
485
- if (temp.value && messages[temp.value]) {
486
- temp.value = this.props.intl.formatMessage(messages[temp.value]);
487
- }
488
- if (temp.label && messages[temp.label]) {
489
- temp.label = this.props.intl.formatMessage(messages[temp.label]);
490
- }
491
- if (temp.errorMessage && messages[temp.errorMessage]) {
492
- temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
493
- }
494
- if (temp.placeholder && messages[temp.placeholder]) {
495
- temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
496
- }
497
- return true;
498
- });
499
- _.forEach(section.actionFields, (actionField) => {
500
- const temp = actionField;
501
- if (temp.type === 'popover') {
502
- temp.content.sections = this.injectSections(temp.content.sections);
503
- temp.value.sections = this.injectSections(temp.value.sections);
504
- return true;
505
- }
506
- temp.injectedEvents = {};
507
- _.forEach(actionField.supportedEvents, (event) => {
508
- temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
509
- });
510
-
511
- if (temp.type === 'icon') {
512
- return true;
513
- }
514
- if (temp.value && messages[temp.value]) {
515
- temp.value = this.props.intl.formatMessage(messages[temp.value]);
516
- }
517
- if (temp.label && messages[temp.label]) {
518
- temp.label = this.props.intl.formatMessage(messages[temp.label]);
519
- }
520
- if (temp.errorMessage && messages[temp.errorMessage]) {
521
- temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
522
- }
523
- if (temp.placeholder && messages[temp.placeholder]) {
524
- temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
525
- }
526
- return true;
527
- });
528
- return section;
529
- }
530
-
531
- injectSections(sections) {
532
- _.forEach(sections, (section) => {
533
- let temp = section;
534
- if (temp.type === 'col-label') {
535
- temp = this.injectColLabelSection(temp);
536
- } else if (section.type === 'multicols') {
537
- temp = this.injectMultiColSection(temp);
538
- } else if (section.type === 'parent') {
539
- temp = this.injectSections(temp.childSections);
540
- }
541
- });
542
- return sections;
543
- }
544
-
545
- injectParentSection(section) {
546
- _.forEach(section.childSections, (childSection) => {
547
- let temp = childSection;
548
- if (temp.type === 'col-label') {
549
- temp = this.injectColLabelSection(temp);
550
- } else if (section.type === 'multicols') {
551
- temp = this.injectMultiColSection(temp);
552
- } else if (section.type === 'parent') {
553
- temp = this.injectParentSection(temp);
554
- }
555
- });
556
- return section;
557
- }
558
-
559
- cloneColLabel(sectionObj, tabIndex) {
560
-
561
- const section = _.cloneDeep(sectionObj);
562
- const inputFields = _.forEach(section.inputFields, (inputField) => {
563
- const inputF = inputField;
564
- inputF.id = `${inputField.id}${tabIndex}`;
565
- inputF.paneIndex = tabIndex;
566
- return inputF;
567
- });
568
- section.inputFields = inputFields;
569
-
570
- return section;
571
- }
572
-
573
- cloneMultiCol(sectionObj, tabIndex) {
574
-
575
- const section = _.cloneDeep(sectionObj);
576
- const inputFields = _.forEach(section.inputFields, (inputField) => {
577
- const inputF = inputField;
578
- const cols = _.forEach(inputF.cols, (col) => {
579
- const colTemp = col;
580
- colTemp.id = `${col.id}${tabIndex}`;
581
- colTemp.paneIndex = tabIndex;
582
- return colTemp;
583
- });
584
- inputF.cols = cols;
585
- return inputF;
586
- });
587
- section.inputFields = inputFields;
588
-
589
- return section;
590
- }
591
-
592
- cloneParent(section, tabIndex) {
593
- console.log('trying to clone', JSON.stringify(section), tabIndex);
594
- const parentsect = section;
595
- const childSectionsBeforeCloning = parentsect.childSections.slice();
596
- const childSections = [];
597
- _.forEach(childSectionsBeforeCloning, (childSection) => {
598
- let sect = {};
599
- if (childSection.type === 'col-label') {
600
- sect = this.cloneColLabel(childSection, tabIndex);
601
- } else if (childSection.type === 'multicols') {
602
- sect = this.cloneMultiCol(childSection, tabIndex);
603
- } else if (childSection.type === 'parent') {
604
- sect = this.cloneParent(childSection, tabIndex);
605
- }
606
-
607
- childSections.push(sect);
608
- return true;
609
- });
610
- console.log('returning cloned parent section final 1', JSON.stringify(childSections));
611
- parentsect.childSections = childSections;
612
-
613
- return _.cloneDeep(parentsect);
614
- }
615
-
616
- deleteVersion(data, currentTab) {
617
-
618
-
619
- if (this.state.tabCount === 1) {
620
- return;
621
- }
622
- const schema = _.cloneDeep(this.state.schema);
623
- schema.containers[0].panes.splice(this.state.tabCount - 1, 1);
624
- schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = false;
625
- this.setState({schema, tabCount: this.state.tabCount - 1});
626
- }
627
-
628
- renameVersion(data, currentTab) {
629
-
630
- }
631
-
632
- markFinalVersion(data, currentTab) {
633
- const message = getMessageObject('success', this.props.intl.formatMessage(messages.templateMarkedFinal), true);
634
- this.props.globalActions.addMessageToQueue(message);
635
-
636
- }
637
-
638
- duplicateVersion(data, currentTab) {
639
-
640
- this.addVersion(this.state.tabCount);
641
- }
642
-
643
- addVersion(data, addNow) {
644
-
645
- let tabIndex = data + 1;
646
- const schema = _.cloneDeep(this.state.schema);
647
- const containers = schema.containers.slice();
648
- const panes = containers[0].panes.slice();
649
- if (addNow && data === 1) {
650
- for (let idx = 1; idx < addNow; idx += 1) {
651
- const sections = [];
652
- const firstPane = _.cloneDeep(panes[0]);
653
- tabIndex = idx + 1;
654
- _.forEach(firstPane.sections, (section) => { // eslint-disable-line no-loop-func
655
- let sect = _.cloneDeep(section);
656
- if (sect.type === 'col-label') {
657
- sect = this.cloneColLabel(sect, tabIndex);
658
- } else if (sect.type === 'multicols') {
659
- sect = this.cloneMultiCol(sect, tabIndex);
660
- } else if (sect.type === 'parent') {
661
- sect = this.cloneParent(sect, tabIndex);
662
- }
663
- sections.push(sect);
664
- return true;
665
- });
666
- firstPane.sections = sections;
667
- schema.containers[0].panes.push(firstPane);
668
-
669
- if (tabIndex === 5) {
670
- schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = true;
671
- }
672
- }
673
- if (schema) {
674
- this.setState({schema});
675
- }
676
- } else if (!addNow) {
677
- const sections = [];
678
- const firstPane = _.cloneDeep(panes[0]);
679
- _.forEach(firstPane.sections, (section) => {
680
- let sect = _.cloneDeep(section);
681
- if (sect.type === 'col-label') {
682
- sect = this.cloneColLabel(sect, tabIndex);
683
- } else if (sect.type === 'multicols') {
684
- sect = this.cloneMultiCol(sect, tabIndex);
685
- } else if (sect.type === 'parent') {
686
- sect = this.cloneParent(sect, tabIndex);
687
- }
688
- sections.push(sect);
689
- return true;
690
- });
691
- firstPane.sections = sections;
692
- schema.containers[0].panes.push(firstPane);
693
-
694
- if (tabIndex === 5) {
695
- schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = true;
696
- }
697
- if (schema) {
698
- this.setState({schema});
699
- }
700
- }
701
- }
702
-
703
- validateFormData(formData) {
704
- const tabCount = this.state.tabCount;
705
- let isValid = true;
706
- for (let cnt = 0; cnt < tabCount; cnt += 1) {
707
- const index = cnt + 1;
708
- if (formData[cnt]) {
709
- const text = formData[cnt][`sms-editor${index > 1 ? index : ''}`];
710
- if (text.indexOf('{{optout}}') === -1) {
711
- isValid = false;
712
- }
713
- }
714
- }
715
- if (isValid) {
716
-
717
- return true;
718
- }
719
- const message = getMessageObject('error', 'Template data is not valid', true);
720
- this.props.globalActions.addMessageToQueue(message);
721
-
722
- return false;
723
- }
724
-
725
- insertAtCursor(field, myValue, currentTab) {
726
- //IE support
727
- const myField = field;
728
- if (document.selection) {
729
- myField.focus();
730
- const sel = document.selection.createRange();
731
- sel.text = myValue;
732
- } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
733
- const startPos = myField.selectionStart;
734
- const endPos = myField.selectionEnd;
735
- myField.value = myField.value.substring(0, startPos)
736
- + myValue
737
- + myField.value.substring(endPos, myField.value.length);
738
- myField.selectionStart = startPos + myValue.length;
739
- myField.selectionEnd = startPos + myValue.length;
740
- } else {
741
- myField.value += myValue;
742
- }
743
- const formData = _.cloneDeep(this.state.formData);
744
- formData[currentTab - 1][field.id] = myField.value;
745
- this.setState({formData});
746
- }
747
-
748
- startTemplateCreation(data) {
749
-
750
- if (data.edit) {
751
-
752
- const ifUnicode = checkUnicode(data.content ? data.content : '');
753
-
754
- const content = data.content;
755
- const id = _.uniqueId();
756
- const tempData = {
757
- 'sms-editor': content,
758
- 'unicode-validity': false,
759
- 'base': true,
760
- 'tabKey': id,
761
- };
762
- const formData = {};
763
- formData[0] = tempData;
764
- formData.base = tempData;
765
- this.setState({formData, loading: false, injectedTags: data.tags, tabKey: id}, () => {
766
- this.setState({tabKey: ''});
767
- });
768
- } else {
769
-
770
- this.setState({injectedTags: data.tags});
771
- }
772
- this.props.globalActions.setInjectedTags(data.tags);
773
- }
774
-
775
- startLoading(ifEdit) {
776
-
777
- if (ifEdit) {
778
- this.setState({loading: true});
779
- }
780
- }
781
-
782
- handleFrameTasks = (e) => {
783
-
784
- const type = e.data;
785
-
786
- if (typeof type === 'object') {
787
-
788
- const action = type.action;
789
- switch (action) {
790
- case "startTemplateCreation":
791
- this.startTemplateCreation(type.value);
792
- break;
793
- case "startLoading":
794
- this.startLoading(type.edit);
795
- break;
796
- case "getCurrentWindow":
797
- this.getCurrentWindow(type);
798
- break;
799
- case "getFormData":
800
- this.getFormData(e, type.value);
801
- break;
802
- default:
803
- break;
804
- }
805
- } else {
806
- switch (type) {
807
- case "getFormData":
808
- this.getFormData(e);
809
- break;
810
- case "startTemplateCreation":
811
-
812
- //this.getFormData(e);
813
- break;
814
- case "moveToTemplates":
815
-
816
- this.moveToTemplates();
817
- break;
818
- case "validateContent":
819
-
820
- this.validateContent(e);
821
- break;
822
- default:
823
- break;
824
- }
825
- }
826
- }
827
-
828
- handleOnTagsContextChange = (data) => {
829
-
830
- const query = {
831
- layout: 'SMS',
832
- type: 'TAG',
833
- context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
834
- embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
835
- };
836
- this.props.globalActions.fetchSchemaForEntity(query);
837
- }
838
-
839
- removeStandAlone() {
840
- const schema = _.cloneDeep(this.state.schema);
841
- delete schema.standalone;
842
- schema.standalone = {};
843
- schema.standalone.sections = [];
844
- _.forEach(schema.containers, (container) => {
845
- const temp = container;
846
- if (temp.type === 'tabs') {
847
- temp.tabBarExtraContent = {};
848
- temp.tabBarExtraContent.sections = [];
849
- const basePane = _.cloneDeep(temp.panes[0]);
850
- temp.tabContent = {};
851
- temp.tabContent.sections = [];
852
- temp.panes = [];
853
- temp.panes.push(basePane);
854
- }
855
- });
856
- this.setState({ schema });
857
- }
858
-
859
- validateContent = (e) => {
860
-
861
- const response = {
862
- action: "validateContent",
863
- value: this.state.isFormValid,
864
- };
865
- // if (content.indexOf('{{optout}}') === -1) {
866
- // const message = getMessageObject('error', 'Template data is not valid', true);
867
- // this.props.globalActions.addMessageToQueue(message);
868
- // response.value = 'invalid';
869
- // }
870
-
871
- e.source.postMessage(JSON.stringify(response), e.origin);
872
- }
873
-
874
- discardValues() {
875
- this.resetSchema();
876
- this.resetState();
877
- }
878
-
879
- resetState() {
880
- this.setState({
881
- formData: {},
882
- tabCount: 1,
883
- currentTab: 1,
884
- });
885
- }
886
- resetSchema() {
887
- // const schema =
888
- // {
889
- // standalone: {
890
- // sections: [
891
- // {
892
- // type: "multicols",
893
- // inputFields: [
894
- // {
895
- // cols: [
896
- // {
897
- // id: "template-name",
898
- // placeholder: "Enter template name",
899
- // type: "input", //Resembles component to be used
900
- // metaType: "text",
901
- // datatype: "string",
902
- // required: true,
903
- // fluid: true,
904
- // style: {
905
- // fontSize: '20px',
906
- // fontFamily: 'proxima-nova,sans-serif',
907
- // fontStyle: 'normal',
908
- // fontWeight: 600,
909
- // marginBottom: '16px',
910
- // },
911
- // styling: "semantic",
912
- // order: 1,
913
- // width: 9,
914
- // offSet: 10,
915
- // customComponent: false,
916
- // standalone: true,
917
- // supportedEvents: {
918
- // onChange: this.onTemplateNameChange,
919
- // },
920
- // },
921
- // {
922
- // id: "discard-button",
923
- // width: 3,
924
- // offset: 8,
925
- // metaType: "submit-button",
926
- // colStyle: {
927
- // // marginLeft: '47.833%',
928
- // textAlign: 'right',
929
- // paddingRight: '12px',
930
- // },
931
- // type: "button",
932
- // buttonType: "cancel",
933
- // value: "Discard",
934
- // customComponent: false,
935
- // standalone: true,
936
- // styling: "semantic",
937
- // order: 3,
938
- // fluid: false,
939
- // submitAction: "discardValues",
940
- // supportedEvents: {
941
- // discardValues: this.discardValues,
942
- // },
943
- // },
944
- // {
945
- // id: "cancel-button",
946
- // width: 2,
947
- // // offset: 11,
948
- // metaType: "submit-button",
949
- // colStyle: {
950
- // textAlign: 'right',
951
- // width: '9%',
952
- // },
953
- // type: "button",
954
- // buttonType: "cancel",
955
- // value: "Cancel",
956
- // customComponent: false,
957
- // standalone: true,
958
- // styling: "semantic",
959
- // order: 3,
960
- // fluid: false,
961
- // submitAction: "cancelTemplate",
962
- // supportedEvents: {
963
- // cancelTemplate: this.cancelTemplate,
964
- // },
965
- // },
966
- // {
967
- // id: "save-button",
968
- // width: 2,
969
- // metaType: "submit-button",
970
- // colStyle: {
971
- // textAlign: 'right',
972
- // width: '7%',
973
- // },
974
- // type: "button",
975
- // buttonType: "primary",
976
- // value: "Save",
977
- // customComponent: false,
978
- // styling: "semantic",
979
- // order: 3,
980
- // fluid: false,
981
- // standalone: true,
982
- // submitAction: "saveFormData",
983
- // supportedEvents: {
984
- // saveFormData: this.saveFormData,
985
- // },
986
- // },
987
- // ],
988
- // },
989
- // ],
990
- // actionFields: [],
991
- // },
992
- // ],
993
- // },
994
- // containers: [
995
- // {
996
- // panes: [
997
- // {
998
- // sections: [
999
- // {
1000
- // type: "parent",
1001
- // width: 16,
1002
- // rowStyle: {
1003
- // height: '100%',
1004
- // },
1005
- // childSections: [
1006
- // {
1007
- // colStyle: {
1008
- // paddingTop: '16px',
1009
- // borderRight: '1px solid #d9d9d9',
1010
- // height: '100%',
1011
- // },
1012
- // width: 16,
1013
- // type: "parent",
1014
- // childSections: [
1015
- // {
1016
- // type: "col-label",
1017
- // inputFields: [
1018
- // {
1019
- // id: "sms-editor",
1020
- // label: "Message",
1021
- // labelStyle: {
1022
- // backgroundColor: 'white',
1023
- // textAlign: 'left',
1024
- // color: '#333333',
1025
- // lineHeight: '24px',
1026
- // fontSize: '16px',
1027
- // fontWeight: '600',
1028
- // fontFamily: 'proxima-nova, sans-serif',
1029
- // fontStyle: 'normal',
1030
- // },
1031
- // style: {
1032
- // textAlign: 'left',
1033
- // color: '#333333',
1034
- // fontFamily: 'Open-Sans',
1035
- // lineHeight: '24px',
1036
- // fontSize: '14px',
1037
- // },
1038
- // type: "textarea",
1039
- // metaType: "text",
1040
- // datatype: "string",
1041
- // required: true,
1042
- // placeholder: "Please input sms template content.",
1043
- // fluid: false,
1044
- // styling: "semantic",
1045
- // onlyDisplay: false,
1046
- // width: 18,
1047
- // autosize: true,
1048
- // autosizeParams: {
1049
- // minRows: 3,
1050
- // },
1051
- // order: 2,
1052
- // customComponent: true,
1053
- // supportedEvents: {
1054
- // onChange: this.onTemplateContentChange,
1055
- // },
1056
- // },
1057
- // ],
1058
- // actionFields: [
1059
- // ],
1060
- // },
1061
- // {
1062
- // type: "multicols",
1063
- // inputFields: [
1064
- // {
1065
- // cols: [
1066
- // {
1067
- // offset: 19,
1068
- // id: "tagList",
1069
- // label: "Tags",
1070
- // type: "tag-list", //Resembles component to be used
1071
- // metaType: "List",
1072
- // datatype: "select",
1073
- // required: true,
1074
- // fluid: true,
1075
- // onlyDisplay: true,
1076
- // styling: "semantic",
1077
- // order: 1,
1078
- // customComponent: true,
1079
- // supportedEvents: {
1080
- // onTagSelect: this.onTagSelect,
1081
- // },
1082
- // },
1083
- // ],
1084
- // },
1085
- // {
1086
- // cols: [
1087
- // {
1088
- // id: "unicode-validity",
1089
- // label: "Allow Unicode characters?",
1090
- // labelStyle: {
1091
- // backgroundColor: "white",
1092
- // },
1093
- // style: {
1094
- // textAlign: 'left',
1095
- // color: '#262626',
1096
- // fontFamily: 'Open-Sans',
1097
- // lineHeight: '24px',
1098
- // fontSize: '14px',
1099
- // },
1100
- // type: "checkbox", //Resembles component to be used
1101
- // metaType: "text",
1102
- // datatype: "boolean",
1103
- // required: true,
1104
- // fluid: true,
1105
- // styling: "semantic",
1106
- // order: 1,
1107
- // width: 10,
1108
- // offset: 4,
1109
- // onlyDisplay: false,
1110
- // customComponent: false,
1111
- // supportedEvents: {
1112
- // onChange: this.onTemplateNameChange,
1113
- // },
1114
- // },
1115
- // ],
1116
- // },
1117
- // ],
1118
- // actionFields: [],
1119
- // },
1120
- // ],
1121
- // },
1122
- // {
1123
- // width: 6,
1124
- // type: "multicols",
1125
- // offset: 1,
1126
- // colStyle: {
1127
- // paddingTop: '16px',
1128
- // },
1129
- // inputFields: [
1130
- // {
1131
- // cols: [
1132
- // {
1133
- // id: "sms-preview",
1134
- // type: "sms-preview", //Resembles component to be used
1135
- // customComponent: true,
1136
- // customStyling: { padding: '0' },
1137
- // metaType: "preview",
1138
- // required: true,
1139
- // fluid: true,
1140
- // styling: "semantic",
1141
- // order: 1,
1142
- // width: 5,
1143
- // onlyDisplay: true,
1144
- // offset: 7,
1145
- // channel: 'SMS',
1146
- // supportedEvents: {
1147
- // onChange: this.onTemplateNameChange,
1148
- // },
1149
- // },
1150
- // ],
1151
- // },
1152
- // ],
1153
- // },
1154
- // ],
1155
- // },
1156
- // ],
1157
- // },
1158
- // ],
1159
- // type: "tabs",
1160
- // defaultPanes: 1,
1161
- // additionalPanes: 0,
1162
- // id: "pane",
1163
- // tabBarExtraContent: {
1164
- // sections: [
1165
- // {
1166
- // type: "multicols",
1167
- // actionFields: [
1168
- // {
1169
- // cols: [
1170
- // {
1171
- // id: "add-version-button",
1172
- // metaType: "submit-button",
1173
- // type: "button",
1174
- // buttonType: "cancel",
1175
- // icon: "plus-circle-o",
1176
- // value: "New Version",
1177
- // customComponent: false,
1178
- // onlyDisplay: true,
1179
- // styling: "semantic",
1180
- // order: 3,
1181
- // fluid: false,
1182
- // submitAction: "addVersion",
1183
- // supportedEvents: {
1184
- // addVersion: this.addVersion,
1185
- // },
1186
- // },
1187
- // ],
1188
- // },
1189
- // ],
1190
- // inputFields: [],
1191
- // },
1192
- // ],
1193
- // },
1194
- // tabContent: {
1195
- // sections: [
1196
- // {
1197
- // type: "multicols",
1198
- // inputFields: [
1199
- // {
1200
- // rowStyle: {
1201
- // display: "flex",
1202
- // flex: 1,
1203
- // },
1204
- // cols: [
1205
- // {
1206
- // id: "tab-header",
1207
- // metaType: "label",
1208
- // value: "Version",
1209
- // primitive: true,
1210
- // dynamicTab: true,
1211
- // type: "div",
1212
- // width: 5,
1213
- // offset: 0,
1214
- // onlyDisplay: true,
1215
- // colStyle: {
1216
- // flex: 1,
1217
- // },
1218
- // supportedEvents: {
1219
- // onChange: this.onVersionNameChange,
1220
- // },
1221
- // },
1222
- // {
1223
- // id: "tab-options-popover",
1224
- // metaType: "display",
1225
- // colStyle: {
1226
- // flex: 0,
1227
- // },
1228
- // type: "popover",
1229
- // customComponent: false,
1230
- // styling: "semantic",
1231
- // order: 3,
1232
- // fluid: false,
1233
- // onlyDisplay: true,
1234
- // submitAction: "onTabOptionSelect",
1235
- // supportedEvents: {
1236
- // onTabOptionSelect: this.onTabOptionSelect,
1237
- // },
1238
- // content: {
1239
- // sections: [
1240
- // {
1241
- // type: "multicols",
1242
- // inputFields: [
1243
- // {
1244
- // cols: [
1245
- // {
1246
- // id: "mark-final-version-label",
1247
- // metaType: "label",
1248
- // type: "div",
1249
- // primitive: true,
1250
- // value: "Mark as Final",
1251
- // onlyDisplay: true,
1252
- // customComponent: false,
1253
- // order: 3,
1254
- // fluid: false,
1255
- // submitAction: "markFinalVersion",
1256
- // supportedEvents: {
1257
- // markFinalVersion: this.markFinalVersion,
1258
- // },
1259
- // },
1260
- // ],
1261
- // },
1262
- // {
1263
- // cols: [
1264
- // {
1265
- // id: "duplicate-version-label",
1266
- // metaType: "label",
1267
- // type: "div",
1268
- // primitive: true,
1269
- // value: "Duplicate",
1270
- // onlyDisplay: true,
1271
- // customComponent: false,
1272
- // order: 3,
1273
- // fluid: false,
1274
- // submitAction: "duplicateVersion",
1275
- // supportedEvents: {
1276
- // duplicateVersion: this.duplicateVersion,
1277
- // },
1278
- // },
1279
- // ],
1280
- // },
1281
- // {
1282
- // cols: [
1283
- // {
1284
- // id: "rename-version-label",
1285
- // metaType: "label",
1286
- // type: "div",
1287
- // primitive: true,
1288
- // value: "Rename",
1289
- // onlyDisplay: true,
1290
- // customComponent: false,
1291
- // order: 3,
1292
- // fluid: false,
1293
- // submitAction: "renameVersion",
1294
- // supportedEvents: {
1295
- // renameVersion: this.renameVersion,
1296
- // },
1297
- // },
1298
- // ],
1299
- // },
1300
- // {
1301
- // cols: [
1302
- // {
1303
- // id: "delete-version-label",
1304
- // metaType: "label",
1305
- // type: "div",
1306
- // primitive: true,
1307
- // value: "Delete",
1308
- // onlyDisplay: true,
1309
- // customComponent: false,
1310
- // order: 3,
1311
- // fluid: false,
1312
- // submitAction: "deleteVersion",
1313
- // supportedEvents: {
1314
- // deleteVersion: this.deleteVersion,
1315
- // },
1316
- // },
1317
- // ],
1318
- // },
1319
- // ],
1320
- // actionFields: [],
1321
- // },
1322
- // ],
1323
- // },
1324
- // value: {
1325
- // sections: [
1326
- // {
1327
- // type: "multicols",
1328
- // inputFields: [
1329
- // {
1330
- // cols: [
1331
- // {
1332
- // id: "tab-option-icon",
1333
- // metaType: "display",
1334
- // type: "icon",
1335
- // onlyDisplay: true,
1336
- // primitive: false,
1337
- // value: "&#xE313;",
1338
- // customComponent: false,
1339
- // order: 3,
1340
- // fluid: false,
1341
- // },
1342
- // ],
1343
- // },
1344
- // ],
1345
- // actionFields: [],
1346
- // },
1347
- // ],
1348
- // },
1349
- // trigger: "click",
1350
- // placement: "bottomRight",
1351
- // },
1352
- // ],
1353
- // },
1354
- // ],
1355
- // actionFields: [],
1356
- // },
1357
- // ],
1358
- // },
1359
- // label: "Version",
1360
- // supportedEvents: {
1361
- // onTabChange: this.onTabChange,
1362
- // },
1363
- // },
1364
- // ],
1365
- // channel: "SMS",
1366
- // module: "Campaigns",
1367
- // };
1368
- this.setState({ schema: this.props.metaEntities.layouts[0].definition });
1369
- }
1370
-
1371
- handleCancelModal = () => {
1372
- this.setState({showModal: false});
1373
- }
1374
-
1375
- saveFormData(formData) {
1376
- //Logic to save in db etc
1377
- // const isValidated = this.validateFormData(formData);
1378
- //
1379
- // if (!isValidated) {
1380
- // return;
1381
- // }
1382
-
1383
- const obj = {};
1384
- obj.versions = {
1385
- base: {},
1386
- history: [],
1387
- };
1388
- obj.type = 'SMS';
1389
- for (let index = 0; index < this.state.tabCount; index += 1 ) {
1390
- obj.versions.history.push(formData[index]);
1391
- // if (formData[index])
1392
- }
1393
- obj.name = formData['template-name'];
1394
- obj.versions.base = formData.base;
1395
-
1396
- this.props.actions.createTemplate(obj);
1397
- }
1398
- render() {
1399
-
1400
- const schema = this.state.schema;
1401
- const spinning = this.state.loading || (this.props.Create && "createTemplateInProgress" in this.props.Create && this.props.Create.createTemplateInProgress);
1402
- let tags = this.props.metaEntities && this.props.metaEntities.tags && this.props.metaEntities.tags.standard ? this.props.metaEntities.tags.standard : [];
1403
-
1404
- if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
1405
- tags = this.props.supportedTags; // if get default tags is not present and supported tags is present use that inlbrary mode
1406
- }
1407
- return (
1408
- <div>
1409
- <Spin tip={this.props.intl.formatMessage(messages.saveTemplateLoader)} spinning={spinning}>
1410
- {/*<\Row style={{marginBottom: '16px', marginLeft: '-40px'}}>
1411
- <Col offset={1}>
1412
- <Breadcrumb>
1413
- <Breadcrumb.Item>Campaigns</Breadcrumb.Item>
1414
- <Breadcrumb.Item>Creatives</Breadcrumb.Item>
1415
- <Breadcrumb.Item>SMS</Breadcrumb.Item>
1416
- </Breadcrumb>
1417
- </Col>
1418
- </Row>*/}
1419
- <Row>
1420
- <Col>
1421
- <FormBuilder
1422
- schema={schema}
1423
- onSubmit={this.saveFormData}
1424
- onChange={this.onFormDataChange}
1425
- currentTab={this.state.currentTab}
1426
- showModal={this.state.showModal}
1427
- modal={this.state.modalContent}
1428
- parent={this}
1429
- iframeParent={parent}
1430
- formData={_.cloneDeep(this.state.formData)}
1431
- location={this.props.location}
1432
- tabKey={this.state.tabKey}
1433
- tags={tags}
1434
- tagModule={this.props.getDefaultTags}
1435
- injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
1436
- onFormValidityChange={this.setFormValidity}
1437
- usingTabContainer
1438
- checkValidation={this.state.checkValidation}
1439
- onContextChange={this.handleOnTagsContextChange}
1440
- handleCancelModal={this.handleCancelModal}
1441
- router={this.props.router}
1442
- />
1443
- </Col>
1444
- </Row>
1445
- </Spin>
1446
- </div>
1447
- );
1448
- }
1449
- }
1450
-
1451
- Create.propTypes = {
1452
- actions: PropTypes.object.isRequired,
1453
- Create: PropTypes.object,
1454
- router: PropTypes.object,
1455
- location: PropTypes.object,
1456
- route: PropTypes.object,
1457
- globalActions: PropTypes.object,
1458
- metaEntities: PropTypes.object,
1459
- intl: intlShape.isRequired,
1460
- supportedTags: PropTypes.array,
1461
- getDefaultTags: PropTypes.string,
1462
- injectedTags: PropTypes.object,
1463
- };
1464
-
1465
- const mapStateToProps = createStructuredSelector({
1466
- Create: makeSelectCreate(),
1467
- createResponse: makeSelectCreateResponse(),
1468
- metaEntities: makeSelectMetaEntities(),
1469
- injectedTags: setInjectedTags(),
1470
- });
1471
-
1472
- function mapDispatchToProps(dispatch) {
1473
- return {
1474
- actions: bindActionCreators(actions, dispatch),
1475
- globalActions: bindActionCreators(globalActions, dispatch),
1476
- };
1477
- }
1478
-
1479
- const withConnect = connect(mapStateToProps, mapDispatchToProps);
1480
- const withReducer = injectReducer({ key: 'create', reducer });
1481
- const withCreateSmsSaga = injectSaga({ key: 'create', saga: createSmsSaga });
1482
-
1483
- export default compose(
1484
- UserIsAuthenticated,
1485
- withCreateSmsSaga,
1486
- withReducer,
1487
- withConnect,
1488
- )(injectIntl(Create));