@capillarytech/creatives-library 2.0.70 → 2.0.72

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 (395) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/EmailMobilePreview/index.scss +0 -1
  4. package/components/EmailPreviewV2/_emailPreviewV2.scss +4 -1
  5. package/components/EmailPreviewV2/index.js +1 -1
  6. package/components/FormBuilder/index.js +25 -10
  7. package/components/Header/index.js +3 -1
  8. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  9. package/components/TemplatePreview/index.js +45 -51
  10. package/components/TemplatePreview/messages.js +1 -1
  11. package/config/app.js +1 -0
  12. package/containers/Cap/actions.js +0 -5
  13. package/containers/Cap/reducer.js +1 -1
  14. package/containers/Cap/selectors.js +0 -13
  15. package/containers/Ebill/index.js +1 -2
  16. package/containers/Email/_email.scss +1 -0
  17. package/containers/Email/actions.js +3 -8
  18. package/containers/Email/constants.js +0 -1
  19. package/containers/Email/index.js +947 -322
  20. package/containers/Email/reducer.js +0 -3
  21. package/containers/Email/sagas.js +6 -3
  22. package/containers/Email/selectors.js +1 -4
  23. package/containers/Line/Create/index.js +1 -2
  24. package/containers/Line/Edit/_lineEdit.scss +4 -0
  25. package/containers/Line/Edit/index.js +1 -3
  26. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  27. package/containers/MobilePush/Create/actions.js +0 -6
  28. package/containers/MobilePush/Create/constants.js +0 -1
  29. package/containers/MobilePush/Create/index.js +1133 -628
  30. package/containers/MobilePush/Create/messages.js +1 -5
  31. package/containers/MobilePush/Create/reducer.js +0 -2
  32. package/containers/MobilePush/Create/selectors.js +3 -3
  33. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  34. package/containers/MobilePush/Edit/index.js +1127 -393
  35. package/containers/MobilePush/Edit/messages.js +0 -4
  36. package/containers/MobilePush/Edit/reducer.js +1 -2
  37. package/containers/MobilePush/Edit/selectors.js +3 -6
  38. package/containers/Sms/Create/_smsCreate.scss +2 -1
  39. package/containers/Sms/Create/actions.js +4 -4
  40. package/containers/Sms/Create/index.js +570 -102
  41. package/containers/Sms/Create/sagas.js +2 -1
  42. package/containers/Sms/Edit/actions.js +5 -10
  43. package/containers/Sms/Edit/constants.js +0 -1
  44. package/containers/Sms/Edit/index.js +548 -103
  45. package/containers/Sms/Edit/reducer.js +0 -2
  46. package/containers/Sms/Edit/sagas.js +3 -1
  47. package/containers/TagList/index.js +3 -3
  48. package/containers/Templates/actions.js +1 -3
  49. package/containers/Templates/index.js +299 -268
  50. package/containers/Templates/messages.js +90 -122
  51. package/containers/Templates/reducer.js +3 -3
  52. package/containers/Templates/sagas.js +1 -5
  53. package/containers/Templates/selectors.js +1 -41
  54. package/containers/WeChat/MapTemplates/index.js +3 -4
  55. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  56. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  57. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  58. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  59. package/index.js +31 -31
  60. package/initialState.js +6 -0
  61. package/package.json +3 -3
  62. package/routes.js +24 -19
  63. package/services/api.js +6 -2
  64. package/services/getSchema.js +18 -0
  65. package/v2Containers/App/actions.js +7 -0
  66. package/v2Containers/App/constants.js +3 -0
  67. package/v2Containers/App/reducer.js +19 -0
  68. package/v2Containers/App/sagas.js +26 -0
  69. package/v2Containers/App/selectors.js +25 -0
  70. package/v2Containers/App/tests/actions.test.js +18 -0
  71. package/v2Containers/App/tests/reducer.test.js +9 -0
  72. package/v2Containers/App/tests/sagas.test.js +15 -0
  73. package/v2Containers/App/tests/selectors.test.js +10 -0
  74. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  75. package/v2Containers/Assets/Gallery/actions.js +37 -0
  76. package/v2Containers/Assets/Gallery/constants.js +23 -0
  77. package/v2Containers/Assets/Gallery/index.js +479 -0
  78. package/v2Containers/Assets/Gallery/messages.js +97 -0
  79. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  80. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  81. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  82. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  83. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  84. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  85. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  86. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  87. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  88. package/v2Containers/CallTask/_callTask.scss +5 -0
  89. package/v2Containers/CallTask/actions.js +15 -0
  90. package/v2Containers/CallTask/constants.js +7 -0
  91. package/v2Containers/CallTask/index.js +141 -0
  92. package/v2Containers/CallTask/messages.js +21 -0
  93. package/v2Containers/CallTask/reducer.js +23 -0
  94. package/v2Containers/CallTask/sagas.js +11 -0
  95. package/v2Containers/CallTask/selectors.js +25 -0
  96. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  97. package/v2Containers/CallTask/tests/index.test.js +10 -0
  98. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  99. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  100. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  101. package/v2Containers/Cap/actions.js +64 -0
  102. package/v2Containers/Cap/constants.js +24 -0
  103. package/v2Containers/Cap/index.js +349 -0
  104. package/v2Containers/Cap/messsages.js +63 -0
  105. package/v2Containers/Cap/reducer.js +111 -0
  106. package/v2Containers/Cap/sagas.js +143 -0
  107. package/v2Containers/Cap/selectors.js +85 -0
  108. package/v2Containers/Cap/tests/index.test.js +16 -0
  109. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  110. package/v2Containers/ChannelTemplates/actions.js +20 -0
  111. package/v2Containers/ChannelTemplates/constants.js +8 -0
  112. package/v2Containers/ChannelTemplates/index.js +48 -0
  113. package/v2Containers/ChannelTemplates/messages.js +13 -0
  114. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  115. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  116. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  117. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  118. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  119. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  120. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  121. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  122. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  123. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  124. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  125. package/v2Containers/CreativesContainer/actions.js +27 -0
  126. package/v2Containers/CreativesContainer/constants.js +16 -0
  127. package/v2Containers/CreativesContainer/index.js +483 -0
  128. package/v2Containers/CreativesContainer/index.scss +27 -0
  129. package/v2Containers/CreativesContainer/messages.js +293 -0
  130. package/v2Containers/CreativesContainer/reducer.js +29 -0
  131. package/v2Containers/CreativesContainer/sagas.js +11 -0
  132. package/v2Containers/CreativesContainer/selectors.js +30 -0
  133. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  134. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  135. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  136. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  137. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  138. package/v2Containers/Dashboard/actions.js +15 -0
  139. package/v2Containers/Dashboard/constants.js +7 -0
  140. package/v2Containers/Dashboard/index.js +54 -0
  141. package/v2Containers/Dashboard/messages.js +13 -0
  142. package/v2Containers/Dashboard/reducer.js +21 -0
  143. package/v2Containers/Dashboard/sagas.js +11 -0
  144. package/v2Containers/Dashboard/selectors.js +25 -0
  145. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  146. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  147. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  148. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  149. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  150. package/v2Containers/Ebill/_ebill.scss +5 -0
  151. package/v2Containers/Ebill/actions.js +43 -0
  152. package/v2Containers/Ebill/constants.js +20 -0
  153. package/v2Containers/Ebill/index.js +1261 -0
  154. package/v2Containers/Ebill/messages.js +73 -0
  155. package/v2Containers/Ebill/reducer.js +72 -0
  156. package/v2Containers/Ebill/sagas.js +65 -0
  157. package/v2Containers/Ebill/selectors.js +25 -0
  158. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  159. package/v2Containers/Ebill/tests/index.test.js +10 -0
  160. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  161. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  162. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  163. package/v2Containers/Email/_email.scss +140 -0
  164. package/v2Containers/Email/actions.js +86 -0
  165. package/v2Containers/Email/constants.js +37 -0
  166. package/v2Containers/Email/index.js +2703 -0
  167. package/v2Containers/Email/initialSchema.js +540 -0
  168. package/v2Containers/Email/messages.js +237 -0
  169. package/v2Containers/Email/reducer.js +147 -0
  170. package/v2Containers/Email/sagas.js +133 -0
  171. package/v2Containers/Email/selectors.js +34 -0
  172. package/v2Containers/Email/tests/actions.test.js +18 -0
  173. package/v2Containers/Email/tests/index.test.js +10 -0
  174. package/v2Containers/Email/tests/reducer.test.js +9 -0
  175. package/v2Containers/Email/tests/sagas.test.js +15 -0
  176. package/v2Containers/Email/tests/selectors.test.js +10 -0
  177. package/v2Containers/EmailWrapper/actions.js +15 -0
  178. package/v2Containers/EmailWrapper/constants.js +7 -0
  179. package/v2Containers/EmailWrapper/index.js +258 -0
  180. package/v2Containers/EmailWrapper/messages.js +57 -0
  181. package/v2Containers/EmailWrapper/reducer.js +23 -0
  182. package/v2Containers/EmailWrapper/sagas.js +11 -0
  183. package/v2Containers/EmailWrapper/selectors.js +25 -0
  184. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  185. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  186. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  187. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  188. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  189. package/v2Containers/LanguageProvider/actions.js +17 -0
  190. package/v2Containers/LanguageProvider/constants.js +8 -0
  191. package/v2Containers/LanguageProvider/index.js +46 -0
  192. package/v2Containers/LanguageProvider/reducer.js +30 -0
  193. package/v2Containers/LanguageProvider/selectors.js +20 -0
  194. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  195. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  196. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  197. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  198. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  199. package/v2Containers/Line/Create/actions.js +90 -0
  200. package/v2Containers/Line/Create/constants.js +39 -0
  201. package/v2Containers/Line/Create/index.js +822 -0
  202. package/v2Containers/Line/Create/messages.js +173 -0
  203. package/v2Containers/Line/Create/reducer.js +99 -0
  204. package/v2Containers/Line/Create/sagas.js +107 -0
  205. package/v2Containers/Line/Create/selectors.js +36 -0
  206. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  207. package/v2Containers/Line/Edit/actions.js +79 -0
  208. package/v2Containers/Line/Edit/constants.js +27 -0
  209. package/v2Containers/Line/Edit/index.js +1050 -0
  210. package/v2Containers/Line/Edit/messages.js +157 -0
  211. package/v2Containers/Line/Edit/reducer.js +83 -0
  212. package/v2Containers/Line/Edit/sagas.js +81 -0
  213. package/v2Containers/Line/Edit/selectors.js +29 -0
  214. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  215. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  216. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  217. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  218. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  219. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  220. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  221. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  222. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  223. package/v2Containers/Login/index.js +106 -0
  224. package/v2Containers/Login/messages.js +21 -0
  225. package/v2Containers/Login/selectors.js +25 -0
  226. package/v2Containers/Login/tests/index.test.js +10 -0
  227. package/v2Containers/Login/tests/sagas.test.js +15 -0
  228. package/v2Containers/Login/tests/selectors.test.js +10 -0
  229. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  230. package/v2Containers/MobilePush/Create/actions.js +52 -0
  231. package/v2Containers/MobilePush/Create/constants.js +24 -0
  232. package/v2Containers/MobilePush/Create/index.js +1759 -0
  233. package/v2Containers/MobilePush/Create/messages.js +237 -0
  234. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  235. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  236. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  237. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  238. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  239. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  240. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  241. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  242. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  243. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  244. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  245. package/v2Containers/MobilePush/Edit/index.js +1851 -0
  246. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  247. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  248. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  249. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  250. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  251. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  252. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  253. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  254. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  255. package/v2Containers/MobilePush/commonMethods.js +249 -0
  256. package/v2Containers/MobilePush/eventsMap.js +127 -0
  257. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  258. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  259. package/v2Containers/MobilepushWrapper/index.js +136 -0
  260. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  261. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  262. package/v2Containers/NotFoundPage/index.js +25 -0
  263. package/v2Containers/NotFoundPage/messages.js +13 -0
  264. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  265. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  266. package/v2Containers/Sms/Create/actions.js +27 -0
  267. package/v2Containers/Sms/Create/constants.js +16 -0
  268. package/v2Containers/Sms/Create/index.js +1017 -0
  269. package/v2Containers/Sms/Create/messages.js +85 -0
  270. package/v2Containers/Sms/Create/reducer.js +41 -0
  271. package/v2Containers/Sms/Create/sagas.js +35 -0
  272. package/v2Containers/Sms/Create/selectors.js +28 -0
  273. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  274. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  275. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  276. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  277. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  278. package/v2Containers/Sms/Edit/actions.js +45 -0
  279. package/v2Containers/Sms/Edit/constants.js +18 -0
  280. package/v2Containers/Sms/Edit/index.js +1018 -0
  281. package/v2Containers/Sms/Edit/messages.js +89 -0
  282. package/v2Containers/Sms/Edit/reducer.js +52 -0
  283. package/v2Containers/Sms/Edit/sagas.js +50 -0
  284. package/v2Containers/Sms/Edit/selectors.js +32 -0
  285. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  286. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  287. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  288. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  289. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  290. package/v2Containers/Sms/initialSchema.js +281 -0
  291. package/v2Containers/TagList/_tagList.scss +8 -0
  292. package/v2Containers/TagList/actions.js +15 -0
  293. package/v2Containers/TagList/constants.js +7 -0
  294. package/v2Containers/TagList/index.js +236 -0
  295. package/v2Containers/TagList/messages.js +13 -0
  296. package/v2Containers/TagList/reducer.js +23 -0
  297. package/v2Containers/TagList/sagas.js +11 -0
  298. package/v2Containers/TagList/selectors.js +25 -0
  299. package/v2Containers/TagList/tests/actions.test.js +18 -0
  300. package/v2Containers/TagList/tests/index.test.js +10 -0
  301. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  302. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  303. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  304. package/v2Containers/Templates/_templates.scss +349 -0
  305. package/v2Containers/Templates/actions.js +110 -0
  306. package/v2Containers/Templates/constants.js +45 -0
  307. package/v2Containers/Templates/index.js +1725 -0
  308. package/v2Containers/Templates/messages.js +278 -0
  309. package/v2Containers/Templates/reducer.js +142 -0
  310. package/v2Containers/Templates/sagas.js +180 -0
  311. package/v2Containers/Templates/selectors.js +68 -0
  312. package/v2Containers/Templates/tests/actions.test.js +18 -0
  313. package/v2Containers/Templates/tests/index.test.js +10 -0
  314. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  315. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  316. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  317. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  318. package/v2Containers/TemplatesV2/actions.js +16 -0
  319. package/v2Containers/TemplatesV2/constants.js +10 -0
  320. package/v2Containers/TemplatesV2/index.js +217 -0
  321. package/v2Containers/TemplatesV2/messages.js +29 -0
  322. package/v2Containers/TemplatesV2/selectors.js +25 -0
  323. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  324. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  325. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  326. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  327. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  328. package/v2Containers/TestPage/constants.js +7 -0
  329. package/v2Containers/TestPage/index.js +31 -0
  330. package/v2Containers/TestPage/messages.js +13 -0
  331. package/v2Containers/TestPage/reducer.js +21 -0
  332. package/v2Containers/TestPage/sagas.js +11 -0
  333. package/v2Containers/Testv2/actions.js +15 -0
  334. package/v2Containers/Testv2/constants.js +7 -0
  335. package/v2Containers/Testv2/index.js +47 -0
  336. package/v2Containers/Testv2/messages.js +13 -0
  337. package/v2Containers/Testv2/reducer.js +23 -0
  338. package/v2Containers/Testv2/sagas.js +11 -0
  339. package/v2Containers/Testv2/selectors.js +25 -0
  340. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  341. package/v2Containers/Testv2/tests/index.test.js +10 -0
  342. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  343. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  344. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  345. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  346. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  347. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  348. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  349. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  350. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  351. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  352. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  354. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  355. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  356. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  357. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  392. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  393. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  394. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  395. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -0,0 +1,1018 @@
1
+ /*jshint loopfunc:true */
2
+ /*
3
+ *
4
+ * Create
5
+ *
6
+ */
7
+
8
+ import PropTypes from 'prop-types';
9
+
10
+ import React from 'react';
11
+ import { connect } from 'react-redux';
12
+ import { Row, Col, Spin } from 'antd';
13
+ import { injectIntl, intlShape } from 'react-intl';
14
+ import { createStructuredSelector } from 'reselect';
15
+ import _ from 'lodash';
16
+ import { bindActionCreators } from 'redux';
17
+ import { makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse } from './selectors';
18
+ import { makeSelectMetaEntities, isLoadingMetaEntities, setInjectedTags } from '../../Cap/selectors';
19
+ import { UserIsAuthenticated } from '../../../utils/authWrapper';
20
+ import FormBuilder from '../../../components/FormBuilder';
21
+ import * as actions from './actions';
22
+ import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
23
+ import '../Create/_smsCreate.scss';
24
+ import messages from './messages';
25
+ import * as globalActions from '../../../containers/Cap/actions';
26
+ import {getMessageObject} from '../../../utils/messageUtils';
27
+ import * as creativesContainerActions from '../../CreativesContainer/actions';
28
+ // import callNativeEvent from '../../../utils/callNativeEvent';
29
+
30
+ export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
31
+ constructor(props) {
32
+ super(props);
33
+ this.state = {
34
+ loadingStatus: 0,
35
+ formData: {},
36
+ tabCount: 1,
37
+ schema: {},
38
+ currentTab: 1,
39
+ editData: {},
40
+ loading: false,
41
+ isFormValid: true,
42
+ injectedTags: {},
43
+ showModal: false,
44
+ modalContent: {title: "Alert", body: "Do you really want to delete this version?", type: 'confirm', id: 'sms-version-modal'},
45
+ };
46
+ this.saveFormData = this.saveFormData.bind(this);
47
+ this.onFormDataChange = this.onFormDataChange.bind(this);
48
+ this.onTemplateNameChange = this.onTemplateNameChange.bind(this);
49
+ this.onTemplateContentChange = this.onTemplateContentChange.bind(this);
50
+ this.handleFrameTasks = this.handleFrameTasks.bind(this);
51
+ this.getFormData = this.getFormData.bind(this);
52
+ this.validateContent = this.validateContent.bind(this);
53
+ this.onTagSelect = this.onTagSelect.bind(this);
54
+ this.insertAtCursor = this.insertAtCursor.bind(this);
55
+ this.addVersion = this.addVersion.bind(this);
56
+ this.onTabChange = this.onTabChange.bind(this);
57
+ this.setEditState = this.setEditState.bind(this);
58
+ this.discardValues = this.discardValues.bind(this);
59
+ this.resetSchema = this.resetSchema.bind(this);
60
+ this.cloneColLabel = this.cloneColLabel.bind(this);
61
+ this.cloneMultiCol = this.cloneMultiCol.bind(this);
62
+ this.cloneParent = this.cloneParent.bind(this);
63
+ this.markFinalVersion = this.markFinalVersion.bind(this);
64
+ this.deleteVersion = this.deleteVersion.bind(this);
65
+ this.duplicateVersion = this.duplicateVersion.bind(this);
66
+ this.renameVersion = this.renameVersion.bind(this);
67
+ this.onVersionNameChange = this.onVersionNameChange.bind(this);
68
+ this.validateFormData = this.validateFormData.bind(this);
69
+ this.getCurrentWindow = this.getCurrentWindow.bind(this);
70
+ this.removeStandAlone = this.removeStandAlone.bind(this);
71
+ this.startTemplateCreation = this.startTemplateCreation.bind(this);
72
+ this.startLoading = this.startLoading.bind(this);
73
+ this.moveToTemplates = this.moveToTemplates.bind(this);
74
+ this.cancelTemplate = this.cancelTemplate.bind(this);
75
+ this.injectEvents = this.injectEvents.bind(this);
76
+ this.injectSections = this.injectSections.bind(this);
77
+ this.injectContainer = this.injectContainer.bind(this);
78
+ this.injectParentSection = this.injectParentSection.bind(this);
79
+ this.injectColLabelSection = this.injectColLabelSection.bind(this);
80
+ this.injectMultiColSection = this.injectMultiColSection.bind(this);
81
+ this.getMappedEvent = this.getMappedEvent.bind(this);
82
+ this.setFormValidity = this.setFormValidity.bind(this);
83
+ this.showNext = this.showNext.bind(this);
84
+ this.injectMessages = this.injectMessages.bind(this);
85
+ this.smsCount = React.createRef();
86
+
87
+ this.componentRefs = {
88
+ 'sms-count': this.smsCount,
89
+ };
90
+ }
91
+
92
+ componentWillMount() {
93
+ const query = {
94
+ layout: 'SMS',
95
+ type: 'LAYOUT',
96
+ version: 'v2',
97
+ };
98
+ this.props.globalActions.fetchSchemaForEntity(query);
99
+ }
100
+ componentDidMount() {
101
+ if (this.props.location.query && this.props.location.query.module === 'library') {
102
+ if (this.props.params && this.props.params.id) {
103
+ this.props.actions.getTemplateDetails(this.props.params.id);
104
+ } else {
105
+ this.props.actions.setTemplateDetails(this.props.templateData);
106
+ }
107
+ } else {
108
+ this.props.actions.getTemplateDetails(this.props.params.id);
109
+ }
110
+ const type = this.props.location.query.type;
111
+ // const module = this.props.location.query.module;
112
+ // const name = this.props.route.name;
113
+ window.addEventListener("message", this.handleFrameTasks);
114
+ if (type === 'embedded') {
115
+ const response = {
116
+ action: 'startTemplateCreation',
117
+ window: 'edit',
118
+ };
119
+ // if (name !== "view" && module.toLowerCase() === "timeline") {
120
+ // return;
121
+ // }
122
+ parent.postMessage(JSON.stringify(response), '*');
123
+ }
124
+ }
125
+
126
+ componentWillReceiveProps(nextProps) {
127
+ if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
128
+ nextProps.getFormSubscriptionData(this.getFormData());
129
+ }
130
+ if ( nextProps.location.query.module === 'library' && nextProps.subscriptionTemplateDetails && nextProps.subscriptionTemplateDetails.name && _.isEmpty(this.state.editData) && !_.isEmpty(this.state.schema)) {
131
+ this.setEditState(nextProps.subscriptionTemplateDetails);
132
+ }
133
+ if (nextProps.templateDetails && nextProps.templateDetails.name && _.isEmpty(this.state.editData) && !_.isEmpty(this.state.schema)) {
134
+ this.setEditState(nextProps.templateDetails);
135
+ }
136
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
137
+ this.setState({schema: nextProps.metaEntities.layouts[0].definition, loadingStatus: this.state.loadingStatus + 1}, () => {
138
+ this.injectEvents(nextProps.metaEntities.layouts[0].definition);
139
+ });
140
+ if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
141
+ const query = {
142
+ layout: 'SMS',
143
+ type: 'TAG',
144
+ context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
145
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
146
+ };
147
+ if (this.props.getDefaultTags) {
148
+ query.context = this.props.getDefaultTags;
149
+ }
150
+ this.props.globalActions.fetchSchemaForEntity(query);
151
+ if (this.props.location.query.type === 'embedded') {
152
+ this.showNext();
153
+ }
154
+ }
155
+ }
156
+ if (nextProps.Edit.editResponse && nextProps.Edit.editResponse.templateId) {
157
+ this.resetSchema();
158
+ this.setState({
159
+ formData: {},
160
+ tabCount: 1,
161
+ currentTab: 1,
162
+ editData: {},
163
+ });
164
+ const message = getMessageObject('success', 'SMS Template Edited Successfully', true);
165
+ this.props.globalActions.addMessageToQueue(message);
166
+ this.props.actions.clearEditResponse();
167
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
168
+ const type = this.props.location.query.type;
169
+ this.props.router.push({
170
+ pathname: `/sms/`,
171
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
172
+ });
173
+ }
174
+
175
+ if (nextProps.Edit.editTemplateError && !_.isEqual(nextProps.Edit.editTemplateError, this.props.Edit.editTemplateError)) {
176
+ const message = getMessageObject('error', (nextProps.Edit.editTemplateErrorMessage && nextProps.Edit.editTemplateErrorMessage !== '') ? nextProps.Edit.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
177
+ this.props.globalActions.addMessageToQueue(message);
178
+ }
179
+ }
180
+
181
+ componentWillUnmount() {
182
+ if (this.props.setIsLoadingContent) {
183
+ this.props.setIsLoadingContent(true); // setting isLoading of CreativesContainer so that slidebox foot can be hidden till content is loaded
184
+ }
185
+ this.props.actions.resetEditTemplate();
186
+ window.removeEventListener("message", this.handleFrameTasks);
187
+ }
188
+
189
+ onTemplateNameChange() {
190
+
191
+ }
192
+
193
+ onTemplateContentChange() {
194
+ const content = _.get(this.state, `formData[0]['sms-editor']`);
195
+ const unicodeEnabled = _.get(this.state, `formData[0]['unicode-validity']`);
196
+ const smsDetails = updateCharCount(content || "", unicodeEnabled || false);
197
+ if (this.smsCount.current) {
198
+ this.smsCount.current.innerText = `${smsDetails.parts}SMS (${smsDetails.chars_used} characters)`;
199
+ }
200
+ }
201
+
202
+ onFormDataChange(formData, tabCount, currentTab) {
203
+ this.setState({formData, tabCount, currentTab}, this.onTemplateContentChange);
204
+ if (currentTab) {
205
+ this.setState({currentTab});
206
+ }
207
+ }
208
+
209
+ onVersionNameChange() {
210
+
211
+ }
212
+
213
+ onTagSelect(data, currentTab) {
214
+ const editorId = currentTab > 1 ? `sms-editor${currentTab}` : 'sms-editor';
215
+ this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
216
+ document.getElementById(editorId).focus();
217
+ }
218
+
219
+ onTabChange(data) {
220
+ this.setState({currentTab: data});
221
+ }
222
+ onUpdateTemplateComplete = (editResponse) => {
223
+ if (editResponse.templateId) {
224
+ this.resetSchema();
225
+ this.setState({
226
+ formData: {},
227
+ tabCount: 1,
228
+ currentTab: 1,
229
+ editData: {},
230
+ });
231
+ const message = getMessageObject('success', 'SMS Template Edited Successfully', true);
232
+ this.props.globalActions.addMessageToQueue(message);
233
+ this.props.actions.clearEditResponse();
234
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
235
+ const type = this.props.location.query.type;
236
+ if (this.props.isFullMode) {
237
+ const {versions, ...rest} = editResponse.templateId;
238
+ this.props.getFormSubscriptionData({ value: versions, ...rest, validity: true});
239
+ } else {
240
+ this.props.router.push({
241
+ pathname: `/sms/`,
242
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
243
+ });
244
+ }
245
+ }
246
+ }
247
+ setEditState(data) {
248
+ const that = this;
249
+ const tabCount = data.versions.history.length;
250
+ const formData = {};
251
+ formData['template-name'] = data.name;
252
+ const type = this.props.location.query.type;
253
+ let ifBase = false;
254
+ let currentTab = 1;
255
+ for (let count = 0; count < tabCount; count += 1) {
256
+ formData[count] = _.cloneDeep(data.versions.history[count]);
257
+ if (data.versions && data.versions.history && data.versions.history[count] && data.versions.history[count].base) {
258
+ if (!formData[count]) {
259
+ formData[count] = {};
260
+ }
261
+ formData[count].base = true;
262
+ ifBase = true;
263
+ currentTab = count + 1;
264
+ }
265
+ if (type === 'embedded' || count > 0) {
266
+ setTimeout( () => {
267
+ if (type === 'embedded' && !_.isEmpty(that.state.formData)) {
268
+ that.removeStandAlone();
269
+ } else {
270
+ that.addVersion(count, tabCount);
271
+ }
272
+ }, 0 );
273
+ }
274
+ }
275
+ if (!ifBase) {
276
+ if (!formData[0]) {
277
+ formData[0] = {};
278
+ }
279
+ formData[0].base = true;
280
+ }
281
+ formData.base = data.versions.base;
282
+ if (formData && formData.base && formData.base['sms-editor']) { //in case versions are present
283
+ const ifUnicode = checkUnicode(formData.base['sms-editor']);
284
+ formData.base['unicode-validity'] = ifUnicode;
285
+ }
286
+ if (formData && formData[0] && formData[0]['sms-editor']) { //when verions are not present
287
+ const ifUnicode = checkUnicode(formData.base['sms-editor']);
288
+ formData[0]['unicode-validity'] = ifUnicode;
289
+ }
290
+ this.setState({tabCount, formData, editData: data, currentTab}, () => {
291
+ });
292
+ }
293
+
294
+ setFormValidity(isFormValid) {
295
+ this.setState({isFormValid});
296
+ }
297
+
298
+ getFormData(e, value) {
299
+ const formData = _.cloneDeep(this.state.formData);
300
+ let baseData = {};
301
+ let versionIdx;
302
+ _.forEach(formData, (val, idx) => {
303
+ if (val.base && idx !== 'base') {
304
+ baseData = val;
305
+ versionIdx = idx;
306
+ }
307
+ });
308
+ baseData['sms-editor'] = baseData[`sms-editor${versionIdx > 0 ? versionIdx : ''}`];
309
+ if (versionIdx !== "0") {
310
+ delete baseData[`sms-editor${versionIdx > 0 ? versionIdx : ''}`];
311
+ }
312
+ const result = {};
313
+ result.base = baseData;
314
+ if (this.state.isFormValid) {
315
+ const msgObj = updateCharCount(baseData['sms-editor']);
316
+ result.base.msg_count = msgObj.msgCount;
317
+ }
318
+ const response = {
319
+ action: "getFormData",
320
+ value: result,
321
+ postAction: value || 'next',
322
+ validity: this.state.isFormValid,
323
+ type: 'SMS',
324
+ };
325
+ this.setState({checkValidation: true});
326
+
327
+ if (e) {
328
+ e.source.postMessage(JSON.stringify(response), e.origin);
329
+ }
330
+ return response;
331
+ }
332
+
333
+ getCurrentWindow(e) {
334
+ const response = {
335
+ action: e.action,
336
+ value: 'edit',
337
+ direction: e.value,
338
+ };
339
+ parent.postMessage(JSON.stringify(response), '*');
340
+ }
341
+
342
+ getMappedEvent(id, event) {
343
+ const map = {
344
+ "template-name": {
345
+ onChange: this.onTemplateNameChange,
346
+ },
347
+ "discard-button": {
348
+ discardValues: this.discardValues,
349
+ },
350
+ "cancel-button": {
351
+ cancelTemplate: this.cancelTemplate,
352
+ },
353
+ "save-button": {
354
+ saveFormData: this.saveFormData,
355
+ },
356
+ "sms-editor": {
357
+ onChange: this.onTemplateContentChange,
358
+ },
359
+ "tagList": {
360
+ onTagSelect: this.onTagSelect,
361
+ },
362
+ "unicode-validity": {
363
+ onChange: this.onTemplateNameChange,
364
+ },
365
+ "add-version-button": {
366
+ addVersion: this.addVersion,
367
+ },
368
+ "tab-header": {
369
+ onChange: this.onVersionNameChange,
370
+ },
371
+ "tab-options-popover": {
372
+ onTabOptionSelect: this.onTabOptionSelect,
373
+ },
374
+ "mark-final-version-label": {
375
+ markFinalVersion: this.markFinalVersion,
376
+ },
377
+ "duplicate-version-label": {
378
+ duplicateVersion: this.duplicateVersion,
379
+ },
380
+ "rename-version-label": {
381
+ renameVersion: this.renameVersion,
382
+ },
383
+ "delete-version-label": {
384
+ deleteVersion: this.deleteVersion,
385
+ },
386
+ "pane": {
387
+ onTabChange: this.onTabChange,
388
+ },
389
+ };
390
+ return map[id][event];
391
+ }
392
+
393
+ handleOnTagsContextChange = (data) => {
394
+ const query = {
395
+ layout: 'SMS',
396
+ type: 'TAG',
397
+ context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
398
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
399
+ };
400
+ this.props.globalActions.fetchSchemaForEntity(query);
401
+ }
402
+
403
+ showNext() {
404
+ const response = {
405
+ action: "showNext",
406
+ value: true,
407
+ };
408
+ parent.postMessage(JSON.stringify(response), '*');
409
+ }
410
+
411
+ startTemplateCreation(data) {
412
+ if (data.edit) {
413
+ const ifUnicode = checkUnicode(data.content);
414
+
415
+ const content = data.content;
416
+ const tempData = {
417
+ 'sms-editor': content,
418
+ 'unicode-validity': ifUnicode,
419
+ 'base': true,
420
+ };
421
+ const formData = {};
422
+ formData[0] = tempData;
423
+ formData.base = tempData;
424
+ this.setState({formData, loading: false, injectedTags: data.tags});
425
+ } else {
426
+ this.setState({injectedTags: data.tags});
427
+ }
428
+ this.props.globalActions.setInjectedTags(data.tags);
429
+ }
430
+
431
+ startLoading(ifEdit) {
432
+ if (ifEdit) {
433
+ this.setState({loading: true});
434
+ }
435
+ }
436
+
437
+ moveToTemplates() {
438
+ const modalContent = {
439
+ title: "Alert",
440
+ body: "Do you really want to go back? All your temporary changes will be lost!",
441
+ type: 'confirm',
442
+ id: 'template-back-confirm-modal',
443
+ show: true,
444
+ };
445
+ this.setState({modalContent, showModal: true});
446
+ // const type = this.props.location.query.type;
447
+ // this.props.router.push({
448
+ // pathname: `/sms/`,
449
+ // query: type === 'embedded' ? {type: 'embedded', module} : {module},
450
+ // });
451
+ }
452
+
453
+ discardValues() {
454
+ this.resetSchema();
455
+ this.setState({
456
+ formData: {},
457
+ tabCount: 1,
458
+ currentTab: 1,
459
+ editData: {},
460
+ }, () => {
461
+ this.setEditState(this.props.Edit.templateDetails);
462
+ });
463
+ }
464
+
465
+ resetSchema() {
466
+ this.setState({ schema: this.props.metaEntities.layouts[0].definition });
467
+ }
468
+
469
+ validateFormData(formData) {
470
+ const tabCount = this.state.tabCount;
471
+ let isValid = true;
472
+ for (let cnt = 0; cnt < tabCount; cnt += 1) {
473
+ const index = cnt + 1;
474
+ if (formData[cnt]) {
475
+ const text = formData[cnt][`sms-editor${index > 1 ? index : ''}`];
476
+ if (text.indexOf('{{optout}}') === -1) {
477
+ isValid = false;
478
+ }
479
+ }
480
+ }
481
+ if (isValid) {
482
+ return true;
483
+ }
484
+
485
+ return false;
486
+ }
487
+
488
+ injectEvents(schema) {
489
+ const temp = schema;
490
+ temp.standalone.sections = this.injectSections(temp.standalone.sections);
491
+ _.forEach(temp.containers, (container) => {
492
+ let tempContainer = container;
493
+ tempContainer = this.injectContainer(tempContainer);
494
+ return tempContainer;
495
+ });
496
+ this.setState({schema, loadingStatus: this.state.loadingStatus + 1});
497
+ return schema;
498
+ }
499
+
500
+ injectContainer(container) {
501
+ const temp = container;
502
+ if (temp.type === 'tabs') {
503
+ temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
504
+ temp.tabBarExtraContent.sections = this.injectSections(temp.tabBarExtraContent.sections);
505
+ temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
506
+ temp.injectedEvents = {};
507
+ _.forEach(temp.supportedEvents, (event) => {
508
+ temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
509
+ });
510
+ _.forEach(temp.panes, (pane) => {
511
+ const tempPane = pane;
512
+ tempPane.sections = this.injectSections(tempPane.sections);
513
+ });
514
+ }
515
+ return temp;
516
+ }
517
+
518
+ injectMultiColSection(section) {
519
+ _.forEach(section.inputFields, (inputField) => {
520
+ _.forEach(inputField.cols, (col) => {
521
+ let temp = col;
522
+ if (temp.type === 'popover') {
523
+ temp.content.sections = this.injectSections(temp.content.sections);
524
+ temp.value.sections = this.injectSections(temp.value.sections);
525
+ return true;
526
+ }
527
+ temp.injectedEvents = {};
528
+ _.forEach(col.supportedEvents, (event) => {
529
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
530
+ });
531
+
532
+ temp = this.injectMessages(temp);
533
+ return true;
534
+ });
535
+ });
536
+ _.forEach(section.actionFields, (actionField) => {
537
+ _.forEach(actionField.cols, (col) => {
538
+ let temp = col;
539
+ if (temp.type === 'popover') {
540
+ temp.content.sections = this.injectSections(temp.content.sections);
541
+ temp.value.sections = this.injectSections(temp.value.sections);
542
+ return true;
543
+ }
544
+ temp.injectedEvents = {};
545
+ _.forEach(col.supportedEvents, (event) => {
546
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
547
+ });
548
+
549
+ temp = this.injectMessages(temp);
550
+ return true;
551
+ });
552
+ });
553
+ return section;
554
+ }
555
+
556
+ injectColLabelSection(section) {
557
+ _.forEach(section.inputFields, (inputField) => {
558
+ let temp = inputField;
559
+ if (temp.type === 'popover') {
560
+ temp.content.sections = this.injectSections(temp.content.sections);
561
+ temp.value.sections = this.injectSections(temp.value.sections);
562
+ return true;
563
+ }
564
+ temp.injectedEvents = {};
565
+ _.forEach(inputField.supportedEvents, (event) => {
566
+ temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
567
+ });
568
+
569
+ temp = this.injectMessages(temp);
570
+ return true;
571
+ });
572
+ _.forEach(section.actionFields, (actionField) => {
573
+ let temp = actionField;
574
+ if (temp.type === 'popover') {
575
+ temp.content.sections = this.injectSections(temp.content.sections);
576
+ temp.value.sections = this.injectSections(temp.value.sections);
577
+ return true;
578
+ }
579
+ temp.injectedEvents = {};
580
+ _.forEach(actionField.supportedEvents, (event) => {
581
+ temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
582
+ });
583
+
584
+ temp = this.injectMessages(temp);
585
+ return true;
586
+ });
587
+ return section;
588
+ }
589
+
590
+ injectSections(sections) {
591
+ _.forEach(sections, (section) => {
592
+ let temp = section;
593
+ if (temp.type === 'col-label') {
594
+ temp = this.injectColLabelSection(temp);
595
+ } else if (section.type === 'multicols') {
596
+ temp = this.injectMultiColSection(temp);
597
+ } else if (section.type === 'parent') {
598
+ temp = this.injectSections(temp.childSections);
599
+ }
600
+ });
601
+ return sections;
602
+ }
603
+
604
+ injectParentSection(section) {
605
+ _.forEach(section.childSections, (childSection) => {
606
+ let temp = childSection;
607
+ if (temp.type === 'col-label') {
608
+ temp = this.injectColLabelSection(temp);
609
+ } else if (section.type === 'multicols') {
610
+ temp = this.injectMultiColSection(temp);
611
+ } else if (section.type === 'parent') {
612
+ temp = this.injectParentSection(temp);
613
+ }
614
+ });
615
+ return section;
616
+ }
617
+
618
+ injectMessages(elem) {
619
+ const temp = elem;
620
+ if (temp.value && messages[temp.value]) {
621
+ temp.value = this.props.intl.formatMessage(messages[temp.value]);
622
+ }
623
+ if (temp.label && messages[temp.label]) {
624
+ temp.label = this.props.intl.formatMessage(messages[temp.label]);
625
+ }
626
+ if (temp.errorMessage && messages[temp.errorMessage]) {
627
+ temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
628
+ }
629
+ if (temp.placeholder && messages[temp.placeholder]) {
630
+ temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
631
+ }
632
+ return temp;
633
+ }
634
+
635
+ cloneColLabel(sectionObj, tabIndex) {
636
+ const section = _.cloneDeep(sectionObj);
637
+ const inputFields = _.forEach(section.inputFields, (inputField) => {
638
+ const inputF = inputField;
639
+ inputF.id = `${inputField.id}${tabIndex}`;
640
+ return inputF;
641
+ });
642
+ section.inputFields = inputFields;
643
+ return section;
644
+ }
645
+
646
+ cloneMultiCol(sectionObj, tabIndex) {
647
+ const section = _.cloneDeep(sectionObj);
648
+ const inputFields = _.forEach(section.inputFields, (inputField) => {
649
+ const inputF = inputField;
650
+ const cols = _.forEach(inputF.cols, (col) => {
651
+ const colTemp = col;
652
+ colTemp.id = `${col.id}${tabIndex}`;
653
+ return colTemp;
654
+ });
655
+ inputF.cols = cols;
656
+ return inputF;
657
+ });
658
+ section.inputFields = inputFields;
659
+ return section;
660
+ }
661
+
662
+ cloneParent(section, tabIndex) {
663
+ const parentsect = section;
664
+ const childSectionsBeforeCloning = parentsect.childSections.slice();
665
+ const childSections = [];
666
+ _.forEach(childSectionsBeforeCloning, (childSection) => {
667
+ let sect = {};
668
+ if (childSection.type === 'col-label') {
669
+ sect = this.cloneColLabel(childSection, tabIndex);
670
+ } else if (childSection.type === 'multicols') {
671
+ sect = this.cloneMultiCol(childSection, tabIndex);
672
+ } else if (childSection.type === 'parent') {
673
+ sect = this.cloneParent(childSection, tabIndex);
674
+ }
675
+ childSections.push(sect);
676
+ return true;
677
+ });
678
+ parentsect.childSections = childSections;
679
+ return _.cloneDeep(parentsect);
680
+ }
681
+
682
+ deleteVersion() {
683
+ if (this.state.tabCount === 1) {
684
+ return;
685
+ }
686
+ const schema = _.cloneDeep(this.state.schema);
687
+ schema.containers[0].panes.splice(this.state.tabCount - 1, 1);
688
+ schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = false;
689
+ this.setState({schema, tabCount: this.state.tabCount - 1});
690
+ }
691
+
692
+ renameVersion() {
693
+
694
+ }
695
+
696
+ markFinalVersion() {
697
+ const message = getMessageObject('success', 'Template Marked as Final Successfully', true);
698
+ this.props.globalActions.addMessageToQueue(message);
699
+ }
700
+
701
+ duplicateVersion() {
702
+ this.addVersion(this.state.tabCount);
703
+ }
704
+
705
+ cancelTemplate() {
706
+ const type = this.props.location.query.type;
707
+ const module = this.props.location.query.module;
708
+ this.props.router.push({
709
+ pathname: `/sms/`,
710
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
711
+ });
712
+ }
713
+
714
+ addVersion(data, addNow) {
715
+ let tabIndex = data + 1;
716
+ const schema = _.cloneDeep(this.state.schema);
717
+ const containers = schema.containers.slice();
718
+ const panes = containers[0].panes.slice();
719
+ if (addNow && data === 1) {
720
+ for (let idx = 1; idx < addNow; idx += 1) {
721
+ const sections = [];
722
+ const firstPane = _.cloneDeep(panes[0]);
723
+ tabIndex = idx + 1;
724
+ _.forEach(firstPane.sections, (section) => { // eslint-disable-line no-loop-func
725
+ let sect = _.cloneDeep(section);
726
+ if (sect.type === 'col-label') {
727
+ sect = this.cloneColLabel(sect, tabIndex);
728
+ } else if (sect.type === 'multicols') {
729
+ sect = this.cloneMultiCol(sect, tabIndex);
730
+ } else if (sect.type === 'parent') {
731
+ sect = this.cloneParent(sect, tabIndex);
732
+ }
733
+ sections.push(sect);
734
+ return true;
735
+ });
736
+ firstPane.sections = sections;
737
+ schema.containers[0].panes.push(firstPane);
738
+
739
+ if (tabIndex === 5) {
740
+ schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = true;
741
+ }
742
+ }
743
+ if (schema) {
744
+ this.setState({schema});
745
+ }
746
+ } else if (!addNow) {
747
+ const sections = [];
748
+ const firstPane = _.cloneDeep(panes[0]);
749
+ _.forEach(firstPane.sections, (section) => {
750
+ let sect = _.cloneDeep(section);
751
+ if (sect.type === 'col-label') {
752
+ sect = this.cloneColLabel(sect, tabIndex);
753
+ } else if (sect.type === 'multicols') {
754
+ sect = this.cloneMultiCol(sect, tabIndex);
755
+ } else if (sect.type === 'parent') {
756
+ sect = this.cloneParent(sect, tabIndex);
757
+ }
758
+ sections.push(sect);
759
+ return true;
760
+ });
761
+ firstPane.sections = sections;
762
+ schema.containers[0].panes.push(firstPane);
763
+
764
+ if (tabIndex === 5) {
765
+ schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = true;
766
+ }
767
+ if (schema) {
768
+ this.setState({schema});
769
+ }
770
+ }
771
+ }
772
+ insertAtCursor(field, myValue, currentTab) {
773
+ //IE support
774
+ const myField = field;
775
+ if (document.selection) {
776
+ myField.focus();
777
+ const sel = document.selection.createRange();
778
+ sel.text = myValue;
779
+ } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
780
+ const startPos = myField.selectionStart;
781
+ const endPos = myField.selectionEnd;
782
+ myField.value = myField.value.substring(0, startPos)
783
+ + myValue
784
+ + myField.value.substring(endPos, myField.value.length);
785
+ myField.selectionStart = startPos + myValue.length;
786
+ myField.selectionEnd = startPos + myValue.length;
787
+ } else {
788
+ myField.value += myValue;
789
+ }
790
+ const formData = _.cloneDeep(this.state.formData);
791
+ formData[currentTab - 1][field.id] = myField.value;
792
+ this.setState({formData});
793
+ // const event = new Event('input', { bubbles: true });
794
+ // callNativeEvent({field, value: myField.value, event});
795
+ }
796
+
797
+ handleFrameTasks = (e) => {
798
+ const type = e.data;
799
+ if (typeof type === 'object') {
800
+ const action = type.action;
801
+ switch (action) {
802
+ case "startTemplateCreation":
803
+ this.startTemplateCreation(type.value);
804
+ break;
805
+ case "startLoading":
806
+ this.startLoading(type.edit);
807
+ break;
808
+ case "getCurrentWindow":
809
+ this.getCurrentWindow(type);
810
+ break;
811
+ case "getFormData":
812
+ this.getFormData(e, type.value);
813
+ break;
814
+ default:
815
+ break;
816
+ }
817
+ }
818
+ switch (type) {
819
+ case "getFormData":
820
+ this.getFormData(e);
821
+ break;
822
+ case "startTemplateCreation":
823
+
824
+ //this.getFormData(e);
825
+ break;
826
+ case "moveToTemplates":
827
+
828
+ this.moveToTemplates();
829
+ break;
830
+ case "validateContent":
831
+
832
+ this.validateContent(e);
833
+ break;
834
+ default:
835
+ break;
836
+ }
837
+ }
838
+
839
+ removeStandAlone() {
840
+ let formData = _.cloneDeep(this.state.formData);
841
+
842
+ let baseFormData = {};
843
+ const oldBaseKeys = formData[0];
844
+ let baseIndex = -1;
845
+ for (let idx = 0; idx < this.state.tabCount; idx += 1 ) {
846
+ if (!formData[idx].base) {
847
+ delete formData[idx];
848
+ } else {
849
+ baseFormData = formData[idx];
850
+ baseIndex = idx;
851
+ }
852
+ }
853
+ formData = {};
854
+ formData[0] = {};
855
+ _.forEach(oldBaseKeys, (val, key) => {
856
+ if (key === 'tabKey') {
857
+ formData[0].tabKey = baseFormData.tabKey;
858
+ } else if (key === 'base') {
859
+ formData[0].base = baseFormData.base;
860
+ } else {
861
+ formData[0][key] = baseFormData[`${key}${baseIndex + 1 > 1 ? baseIndex + 1 : ''}`];
862
+ }
863
+ });
864
+ formData.base = formData[0];
865
+ const schema = _.cloneDeep(this.state.schema);
866
+ const childSections = _.get(schema, 'standalone.sections[0].childSections');
867
+ childSections.splice(2, 1);
868
+ _.set(schema, 'standalone.sections[0].childSections', childSections);
869
+ const fields = _.get(childSections, '[1].childSections[0].childSections');//removing template name section
870
+ fields.splice(0, 1);
871
+ _.set(childSections, '[1].childSections[0].childSections', fields);
872
+ this.setState({ schema, loadingStatus: this.state.loadingStatus + 1, formData, tabCount: 1, tabKey: formData.base.tabKey, currentTab: 1 });
873
+ }
874
+
875
+ validateContent = (e) => {
876
+ const response = {
877
+ action: "validateContent",
878
+ value: this.state.isFormValid,
879
+ };
880
+ // if (content.indexOf('{{optout}}') === -1) {
881
+ // const message = getMessageObject('error', 'Template data is not valid', true);
882
+ // this.props.globalActions.addMessageToQueue(message);
883
+ // response.value = 'invalid';
884
+ // }
885
+
886
+ e.source.postMessage(JSON.stringify(response), e.origin);
887
+ }
888
+
889
+ handleCancelModal = () => {
890
+ this.setState({showModal: false});
891
+ }
892
+
893
+ saveFormData(formData) {
894
+ //Logic to save in db etc
895
+
896
+ const obj = _.cloneDeep(this.state.editData);
897
+ obj.versions = {
898
+ base: {},
899
+ history: [],
900
+ };
901
+ for (let index = 0; index < this.state.tabCount; index += 1 ) {
902
+ obj.versions.history.push(formData[index]);
903
+ }
904
+ obj.name = formData['template-name'];
905
+ obj.versions.base = formData.base;
906
+
907
+ this.props.actions.editTemplate(obj, this.onUpdateTemplateComplete);
908
+ }
909
+ isSmsLoading = () => {
910
+ //let {isLoading} = this.props;
911
+ let isLoading = this.props.isLoadingMetaEntities || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
912
+
913
+ if (!isLoading) {
914
+ isLoading = this.props.isFullMode ? this.state.loadingStatus < 2 : this.state.loadingStatus < 3;
915
+ }
916
+ // if (isLoading && this.state.loadingStatus >= 3) {
917
+ // this.props.creativesContainerActions.hideCreativesContanerLoader();
918
+ // }
919
+ if (!isLoading && this.props.setIsLoadingContent) {
920
+ this.props.setIsLoadingContent(isLoading);
921
+ }
922
+ return isLoading;
923
+ }
924
+ render() {
925
+ const schema = this.state.schema;
926
+ let tipText = this.props.Edit && ("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) ? this.props.intl.formatMessage(messages.getTemplateDetailsLoader) : '';
927
+ tipText = this.props.Edit && ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress) ? this.props.intl.formatMessage(messages.saveTemplateLoader) : '';
928
+ const spinning = this.isSmsLoading();
929
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
930
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
931
+ tags = this.props.supportedTags;
932
+ }
933
+ return (
934
+ <div className="sms-email-container">
935
+ <Spin tip={tipText} spinning={spinning}>
936
+ {/*<Row style={{marginBottom: '16px', marginLeft: '-40px'}}>
937
+ <Col offset={1}>
938
+ <Breadcrumb>
939
+ <Breadcrumb.Item>Campaigns</Breadcrumb.Item>
940
+ <Breadcrumb.Item>Creatives</Breadcrumb.Item>
941
+ <Breadcrumb.Item>SMS</Breadcrumb.Item>
942
+ </Breadcrumb>
943
+ </Col>
944
+ </Row>*/}
945
+ <Row>
946
+ <Col>
947
+ <FormBuilder
948
+ isFullMode={this.props.isFullMode}
949
+ refs={this.componentRefs}
950
+ schema={schema}
951
+ onSubmit={this.saveFormData}
952
+ onChange={this.onFormDataChange}
953
+ formData={this.state.formData}
954
+ tabCount={this.state.tabCount}
955
+ currentTab={this.state.currentTab}
956
+ parent={this}
957
+ iframeParent={parent}
958
+ location={this.props.location}
959
+ isEdit
960
+ showModal={this.state.showModal}
961
+ modal={this.state.modalContent}
962
+ tags={tags}
963
+ tagModule={this.props.getDefaultTags}
964
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
965
+ onFormValidityChange={this.setFormValidity}
966
+ usingTabContainer
967
+ checkValidation={this.state.checkValidation}
968
+ onContextChange={this.handleOnTagsContextChange}
969
+ handleCancelModal={this.handleCancelModal}
970
+ router={this.props.router}
971
+ />
972
+ </Col>
973
+ </Row>
974
+ </Spin>
975
+ </div>
976
+ );
977
+ }
978
+ }
979
+
980
+ Edit.propTypes = {
981
+ actions: PropTypes.object.isRequired,
982
+ Edit: PropTypes.object,
983
+ params: PropTypes.object,
984
+ router: PropTypes.object,
985
+ location: PropTypes.object,
986
+ globalActions: PropTypes.object,
987
+ metaEntities: PropTypes.object,
988
+ intl: intlShape.isRequired,
989
+ templateData: PropTypes.object,
990
+ supportedTags: PropTypes.array,
991
+ getDefaultTags: PropTypes.string,
992
+ isLoadingMetaEntities: PropTypes.bool,
993
+ // creativesContainerActions: PropTypes.object,
994
+ isFullMode: PropTypes.bool,
995
+ getFormSubscriptionData: PropTypes.func,
996
+ setIsLoadingContent: PropTypes.func,
997
+ // route: PropTypes.object,
998
+ injectedTags: PropTypes.object,
999
+ };
1000
+
1001
+ const mapStateToProps = createStructuredSelector({
1002
+ Edit: makeSelectEdit(),
1003
+ editResponse: makeSelectEditResponse(),
1004
+ templateDetails: makeSelectTemplateDetailsResponse(),
1005
+ metaEntities: makeSelectMetaEntities(),
1006
+ injectedTags: setInjectedTags(),
1007
+ isLoadingMetaEntities: isLoadingMetaEntities(),
1008
+ });
1009
+
1010
+ function mapDispatchToProps(dispatch) {
1011
+ return {
1012
+ actions: bindActionCreators(actions, dispatch),
1013
+ globalActions: bindActionCreators(globalActions, dispatch),
1014
+ creativesContainerActions: bindActionCreators(creativesContainerActions, dispatch),
1015
+ };
1016
+ }
1017
+
1018
+ export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(Edit)));