@capillarytech/creatives-library 2.0.69 → 2.0.71

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