@capillarytech/creatives-library 2.0.70 → 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,822 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { Component } from 'react';
3
+ import {connect} from 'react-redux';
4
+ import { bindActionCreators } from 'redux';
5
+ import { injectIntl, intlShape } from 'react-intl';
6
+ import { createStructuredSelector } from 'reselect';
7
+ import { Row, Col, Spin, Breadcrumb } from 'antd';
8
+ import _ from 'lodash';
9
+ import messages from './messages';
10
+ import * as actions from './actions';
11
+ import FormBuilder from '../../../components/FormBuilder';
12
+ import { UserIsAuthenticated } from '../../../utils/authWrapper';
13
+ import * as globalActions from '../../../containers/Cap/actions';
14
+ //import { makeSelectCreate, makeSelectCreateResponse, makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse } from './selectors';
15
+ import {makeSelectCreateLine} from './selectors';
16
+ import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
17
+ import {getMessageObject} from '../../../utils/messageUtils';
18
+ import { makeSelectTemplates } from '../../Templates/selectors';
19
+ import './_lineCreate.scss';
20
+ import callNativeEvent from '../../../utils/callNativeEvent';
21
+
22
+ const BreadcrumbItem = Breadcrumb.Item;
23
+
24
+ export class Line extends Component {
25
+
26
+ constructor(props) {
27
+ super(props);
28
+ const map = {
29
+ "save-button": {
30
+ saveFormData: this.saveFormData,
31
+ },
32
+ "template-name": {
33
+ onChange: this.onTemplateNameChange,
34
+ },
35
+ "discard-button": {
36
+ discardValues: this.discardValues,
37
+ },
38
+ "cancel-button": {
39
+ cancelTemplate: this.cancelTemplate,
40
+ },
41
+ "message-editor": {
42
+ onChange: this.onTemplateContentChange,
43
+ },
44
+ "message-editor2": {
45
+ onChange: this.onTemplateContentChange,
46
+ },
47
+ "message-tagList": {
48
+ onTagSelect: this.onTagSelect,
49
+ },
50
+ "title-tagList": {
51
+ onTagSelect: this.onTagSelectTitle,
52
+ },
53
+ "pane": {
54
+ onTabChange: this.onTabChange,
55
+ },
56
+ "line-template": {
57
+ onSelect: this.onTemplateChange,
58
+ },
59
+ "image-upload-line": {
60
+ onUpload: this.uploadImage,
61
+ },
62
+ };
63
+ this.state = {
64
+ schema: {},
65
+ isSchemaChanged: false,
66
+ formData: {},
67
+ tabCount: 1,
68
+ currentTab: 1,
69
+ loading: false,
70
+ isFormValid: true,
71
+ tabKey: '',
72
+ checkValidation: false,
73
+ eventsMap: map,
74
+ errorData: {},
75
+ displayProps: {},
76
+ modalContent: {title: "Alert", body: "template not configured,", type: 'confirm'},
77
+ injectedTags: {},
78
+ isEdit: false,
79
+ isEdited: false,
80
+ editTemplateData: {},
81
+ isReady: false,
82
+ modeType: null,
83
+ };
84
+ }
85
+
86
+ componentWillMount() {
87
+ if (this.props.params.id) {
88
+ const editTemplateId = this.props.params.id;
89
+ this.props.actions.getTemplateDetails(editTemplateId, 'LINE');
90
+ this.setState({isEdit: true});
91
+ }
92
+ }
93
+
94
+ componentDidMount() {
95
+ const getSchemaQuery = {
96
+ layout: 'LINE',
97
+ type: 'LAYOUT',
98
+ };
99
+ this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
100
+ const type = this.props.location.query.type;
101
+ const name = this.props.route.name;
102
+ window.addEventListener("message", this.handleFrameTasks);
103
+ if (type === 'embedded') {
104
+ const response = {
105
+ action: 'startTemplateCreation',
106
+ window: name === 'view' ? 'view' : '',
107
+ };
108
+ parent.postMessage(JSON.stringify(response), '*');
109
+ }
110
+ }
111
+
112
+ componentWillReceiveProps(nextProps) {
113
+ console.log("nextProps line @@@", nextProps);
114
+
115
+ //// Create template logic ////
116
+
117
+ let modeType;
118
+ const {layouts, tags} = nextProps.metaEntities;
119
+ const isSchemaReady = (layouts !== undefined && layouts.length > 0);
120
+ const editModeType = nextProps.route.name;
121
+ if (nextProps.params.mode === 'text' || nextProps.route.name === 'edit_text') {
122
+ modeType = 'text';
123
+ } else {
124
+ modeType = 'image';
125
+ }
126
+ if (modeType) {
127
+ this.setState({modeType, schema: {}});
128
+ //console.log("ooo", this.state.schema);
129
+ }
130
+ if (nextProps.isGetFormData) {
131
+ nextProps.getFormLibraryData(this.getFormData());
132
+ }
133
+ if (isSchemaReady) {
134
+ // set schema value as per mode type. Supported mode (text & image)
135
+ console.log("modeType", this.state.modeType);
136
+ const {textSchema, imageSchema} = layouts[0].definition;
137
+ const schema = (modeType === "text" || editModeType === 'edit_text') ? textSchema : imageSchema;
138
+ this.setState({schema}, () => {
139
+ // Once schema is ready and set, then inject the available events from the schema
140
+ if (!_.isEmpty(this.state.schema)) {
141
+ this.injectEvents(this.state.schema);
142
+ }
143
+ // Once schema is ready, then only get the tags.
144
+ const getTagsQuery = {
145
+ layout: 'LINE',
146
+ type: 'TAG',
147
+ context: 'outbound',
148
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
149
+ };
150
+ if (this.props.getDefaultTags) {
151
+ getTagsQuery.context = this.props.getDefaultTags;
152
+ }
153
+ if (tags === undefined && modeType !== 'image') {
154
+ this.props.globalActions.fetchSchemaForEntity(getTagsQuery);
155
+ } else {
156
+ this.setState({isReady: true});
157
+ }
158
+ if (this.props.location.query.type === 'embedded') {
159
+ this.showNext();
160
+ }
161
+ });
162
+ }
163
+
164
+ if ( nextProps.Line && (nextProps.Line.response && nextProps.Line.response.templateId) ) {
165
+ console.log('create response', nextProps.Line);
166
+ this.discardValues();
167
+ const message = getMessageObject('success', this.props.intl.formatMessage(messages["Line Template Created Successfully"]), true);
168
+ this.props.globalActions.addMessageToQueue(message);
169
+ this.props.actions.clearCreateResponse();
170
+ const type = this.props.location.query.type;
171
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
172
+ this.props.router.push({
173
+ pathname: `/line/`,
174
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
175
+ });
176
+ }
177
+
178
+ if (nextProps.Line.createTemplateError && !_.isEqual(nextProps.Line.createTemplateError, this.props.Line.createTemplateError)) {
179
+ const message = getMessageObject('error', (nextProps.Line.createTemplateErrorMessage && nextProps.Line.createTemplateErrorMessage !== '') ? nextProps.Line.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
180
+ this.props.globalActions.addMessageToQueue(message);
181
+ }
182
+
183
+ //// Edit Template Logic ////
184
+
185
+ const isEdit = this.state.isEdit && this.props.params.id && (this.props.route.name === 'edit_text' || this.props.route.name === 'edit_image') && this.props.Line.templateDetails && this.props.Line.templateDetails.versions;
186
+ if (isEdit) {
187
+ const formData = this.getEditTransformedData(this.props.Line.templateDetails);
188
+ this.setState({formData, editTemplateData: this.props.Line.templateDetails});
189
+ this.props.actions.clearData();
190
+ }
191
+
192
+ const isEditSucceed = (this.state.isEdit && nextProps.Line && nextProps.Line.editResponse && nextProps.Line.editResponse.templateId);
193
+ if (isEditSucceed) {
194
+ this.setState({formData: {} });
195
+ const message = getMessageObject('success', this.props.intl.formatMessage(messages['Line Template Edited Successfully']), true);
196
+ this.props.globalActions.addMessageToQueue(message);
197
+ this.props.actions.clearEditResponse();
198
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
199
+ const type = this.props.location.query.type;
200
+ this.props.router.push({
201
+ pathname: `/line/`,
202
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
203
+ });
204
+ }
205
+
206
+ if (nextProps.Line.editTemplateError && !_.isEqual(nextProps.Line.editTemplateError, this.props.Line.editTemplateError)) {
207
+ const message = getMessageObject('error', (nextProps.Line.editTemplateErrorMessage && nextProps.Line.editTemplateErrorMessage !== '') ? nextProps.Line.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
208
+ this.props.globalActions.addMessageToQueue(message);
209
+ }
210
+
211
+ if (nextProps.Line.uploadAssetSuccess && nextProps.Line.uploadedAssetData) {
212
+ const formData = _.cloneDeep(this.state.formData);
213
+ // TODO: if multiple image upload supports, change below accordingly.
214
+ formData[this.state.currentTab - 1].image = nextProps.Line.uploadedAssetData.metaInfo.secure_file_path;
215
+ formData[this.state.currentTab - 1].imagePreview = nextProps.Line.uploadedAssetData.metaInfo.secure_file_path_preview;
216
+ console.log("before 2", formData[this.state.currentTab - 1].image);
217
+ this.setState({formData});
218
+ console.log("ooo", this.state.formData);
219
+ this.props.actions.clearAsset();
220
+ }
221
+ }
222
+
223
+ componentWillUnmount() {
224
+ console.log('removed listener templates');
225
+ window.removeEventListener("message", this.handleFrameTasks);
226
+ }
227
+
228
+ onTagSelect(data, currentTab) {
229
+ console.log('parent data tag', data, currentTab);
230
+ const editorId = 'message-editor';
231
+ this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
232
+ document.getElementById(editorId).focus();
233
+ }
234
+
235
+ onTagSelectTitle(data, currentTab) {
236
+ console.log('parent data tag', data, currentTab);
237
+ const editorId = 'message-title';
238
+ this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
239
+ document.getElementById(editorId).focus();
240
+ }
241
+
242
+ onFormDataChange = (formData, tabCount, currentTab) => {
243
+ console.log('Form data changed is ', formData, tabCount, currentTab);
244
+ this.setState({formData, tabCount});
245
+ if (currentTab) {
246
+ this.setState({currentTab});
247
+ }
248
+ };
249
+
250
+ getTransformedData = (formData) => {
251
+ console.log("formData before transform@@@", formData);
252
+ const modeType = this.state.modeType;
253
+ const obj = {};
254
+ const msgData = {};
255
+ obj.versions = {
256
+ base: {
257
+ content: {
258
+ to: "{{line_id}}",
259
+ messages: [],
260
+ },
261
+ },
262
+ };
263
+ obj.type = 'LINE';
264
+ obj.name = formData['template-name'];
265
+ obj.definition = {
266
+ mode: modeType,
267
+ };
268
+ if ( modeType && modeType !== undefined) {
269
+ msgData.type = modeType;
270
+ }
271
+ if (modeType === 'text') {
272
+ if (this.state.isEdit) {
273
+ const editTemplateId = this.state.editTemplateData._id;
274
+ if (editTemplateId && editTemplateId !== undefined) {
275
+ obj._id = this.state.editTemplateData._id;
276
+ msgData.text = formData['0']['message-editor'];
277
+ }
278
+ } else {
279
+ msgData.text = formData.base['message-editor'];
280
+ }
281
+ } else if (modeType === 'image') {
282
+ if (formData['0'].image.length < 1) {
283
+ return 'IMAGE_ERROR';
284
+ }
285
+ if (this.state.isEdit) {
286
+ const editTemplateId = this.state.editTemplateData._id;
287
+ if (editTemplateId && editTemplateId !== undefined) {
288
+ obj._id = editTemplateId;
289
+ msgData.originalContentUrl = formData['0'].image;
290
+ msgData.previewImageUrl = formData['0'].imagePreview;
291
+ }
292
+ } else {
293
+ // const img = new Image();
294
+ // img.src = formData['0'].image;
295
+ // img.onload = () => {
296
+ // console.log(`Image aspect ratio details line@@@${img.width} and ${img.height}`);
297
+ // };
298
+ // // Preview Image set to 240px max
299
+ // const prevImgSet = new Image(240, 240);
300
+ // prevImgSet.src = formData['0'].image;
301
+
302
+ msgData.originalContentUrl = formData['0'].image;
303
+ msgData.previewImageUrl = formData['0'].imagePreview;
304
+ }
305
+ }
306
+ obj.versions.base.content.messages.push(msgData);
307
+ return obj;
308
+ };
309
+
310
+ getEditTransformedData = ({name, versions}) => {
311
+ const modeType = this.state.modeType;
312
+ const obj = {};
313
+ obj['0'] = {};
314
+ obj.base = {
315
+ base: true,
316
+ };
317
+ obj['template-name'] = name;
318
+ if (modeType === 'text') {
319
+ obj.base['message-editor'] = versions.base.content.messages[0].text;
320
+ obj['0']['message-editor'] = versions.base.content.messages[0].text;
321
+ } else if (modeType === 'image') {
322
+ obj.base.image = versions.base.content.messages[0].originalContentUrl;
323
+ obj['0'].image = versions.base.content.messages[0].originalContentUrl;
324
+ obj['0'].imagePreview = versions.base.content.messages[0].previewImageUrl;
325
+ obj.base.imagePreview = versions.base.content.messages[0].previewImageUrl;
326
+ }
327
+
328
+ console.log("getEditTransformedData", obj);
329
+ return obj;
330
+ };
331
+
332
+ setFormValidity = (isFormValid) => {
333
+ this.setState({isFormValid});
334
+ };
335
+
336
+ getMappedEvent = (id, event) => {
337
+ const map = this.state.eventsMap;
338
+ if (!map[id] || !map[id][event]) {
339
+ console.log(`error map[id] ${map[id]}` );
340
+ }
341
+ return map[id][event];
342
+ };
343
+
344
+ getCurrentWindow(e) {
345
+ console.log('in Line create@@@', e);
346
+ const response = {
347
+ action: e.action,
348
+ value: 'edit',
349
+ direction: e.value,
350
+ };
351
+ parent.postMessage(JSON.stringify(response), '*');
352
+ }
353
+
354
+ getFormData = (e) => {
355
+ console.log('posting final result', this.state.formData);
356
+ const response = {
357
+ action: "getFormData",
358
+ value: this.getTransformedData(this.state.formData),
359
+ validity: this.state.isFormValid,
360
+ };
361
+ this.setState({checkValidation: true});
362
+ if (e) {
363
+ e.source.postMessage(JSON.stringify(response), e.origin);
364
+ }
365
+ return response;
366
+ };
367
+
368
+ injectEvents = (schema) => {
369
+ const temp = schema;
370
+ if (temp.standalone) {
371
+ temp.standalone.sections = this.injectSections(temp.standalone.sections);
372
+ }
373
+ _.forEach(temp.containers, (container) => {
374
+ let tempContainer = container;
375
+ tempContainer = this.injectContainer(tempContainer);
376
+ return tempContainer;
377
+ });
378
+ console.log('final injected schema', schema);
379
+ this.setState({schema, isSchemaChanged: true}, () => {
380
+ this.removeStandAlone();
381
+ });
382
+ console.log('final returned schema', this.state.schema);
383
+ return schema;
384
+ };
385
+
386
+ saveFormData = (formData) => {
387
+ console.log("ccc", this.props);
388
+ console.log('Saving form data of LINE @@@', formData, this.state.tabCount);
389
+ const obj = this.getTransformedData(formData);
390
+ console.log('obj final@@@', obj);
391
+ if (obj === 'IMAGE_ERROR') {
392
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages['Please upload an image to proceed']), true);
393
+ this.props.globalActions.addMessageToQueue(message);
394
+ return;
395
+ }
396
+ if (obj !== 'IMAGE_ERROR' && obj.versions.base.content.messages[0].type === 'text') {
397
+ const charCount = obj.versions.base.content.messages[0].text.length;
398
+ if (charCount > 1600) {
399
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages['Maximum characters length exceeds']), true);
400
+ this.props.globalActions.addMessageToQueue(message);
401
+ return;
402
+ }
403
+ }
404
+ if (this.state.isEdit) {
405
+ console.log("Inside edit line template@@");
406
+ this.props.actions.editTemplate(obj);
407
+ } else {
408
+ this.props.actions.createTemplate(obj);
409
+ }
410
+ };
411
+
412
+ cancelTemplate = () => {
413
+ const type = this.props.location.query.type;
414
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
415
+ this.props.router.push({
416
+ pathname: `/LINE/`,
417
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
418
+ });
419
+ };
420
+
421
+ injectSections = (sections) => {
422
+ _.forEach(sections, (section) => {
423
+ let temp = section;
424
+ if (temp.type === 'col-label') {
425
+ temp = this.injectColLabelSection(temp);
426
+ } else if (section.type === 'multicols') {
427
+ temp = this.injectMultiColSection(temp);
428
+ } else if (section.type === 'parent') {
429
+ temp = this.injectSections(temp.childSections);
430
+ }
431
+ });
432
+ return sections;
433
+ };
434
+
435
+ injectMultiColSection = (section) => {
436
+ _.forEach(section.inputFields, (inputField) => {
437
+ _.forEach(inputField.cols, (col) => {
438
+ const temp = col;
439
+ if (temp.type === 'popover') {
440
+ temp.content.sections = this.injectSections(temp.content.sections);
441
+ temp.value.sections = this.injectSections(temp.value.sections);
442
+ return true;
443
+ }
444
+ if (temp.id === "discard-button") {
445
+ temp.colStyle = {...temp.colStyle, display: 'none'};
446
+ }
447
+ if (temp.id === "cancel-button") {
448
+ temp.offset = 11;
449
+ }
450
+ if (temp.id === "line-push-preview") {
451
+ temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
452
+ }
453
+ temp.injectedEvents = {};
454
+
455
+ _.forEach(col.supportedEvents, (event) => {
456
+ console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
457
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
458
+ });
459
+ return true;
460
+ });
461
+ });
462
+ _.forEach(section.actionFields, (actionField) => {
463
+ _.forEach(actionField.cols, (col) => {
464
+ const temp = col;
465
+ if (temp.type === 'popover') {
466
+ temp.content.sections = this.injectSections(temp.content.sections);
467
+ temp.value.sections = this.injectSections(temp.value.sections);
468
+ return true;
469
+ }
470
+ temp.injectedEvents = {};
471
+ _.forEach(col.supportedEvents, (event) => {
472
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
473
+ });
474
+ return true;
475
+ });
476
+ });
477
+ return section;
478
+ };
479
+
480
+ injectColLabelSection = (section) => {
481
+ _.forEach(section.inputFields, (inputField) => {
482
+ const temp = inputField;
483
+ if (temp.type === 'popover') {
484
+ temp.content.sections = this.injectSections(temp.content.sections);
485
+ temp.value.sections = this.injectSections(temp.value.sections);
486
+ return true;
487
+ }
488
+ temp.injectedEvents = {};
489
+ _.forEach(inputField.supportedEvents, (event) => {
490
+ temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
491
+ });
492
+ return true;
493
+ });
494
+ _.forEach(section.actionFields, (actionField) => {
495
+ const temp = actionField;
496
+ if (temp.type === 'popover') {
497
+ temp.content.sections = this.injectSections(temp.content.sections);
498
+ temp.value.sections = this.injectSections(temp.value.sections);
499
+ return true;
500
+ }
501
+ temp.injectedEvents = {};
502
+ _.forEach(actionField.supportedEvents, (event) => {
503
+ temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
504
+ });
505
+ return true;
506
+ });
507
+ return section;
508
+ };
509
+
510
+ injectParentSection = (section) => {
511
+ _.forEach(section.childSections, (childSection) => {
512
+ let temp = childSection;
513
+ if (temp.type === 'col-label') {
514
+ temp = this.injectColLabelSection(temp);
515
+ } else if (section.type === 'multicols') {
516
+ temp = this.injectMultiColSection(temp);
517
+ } else if (section.type === 'parent') {
518
+ temp = this.injectParentSection(temp);
519
+ }
520
+ });
521
+ return section;
522
+ };
523
+
524
+ insertAtCursor = (field, myValue) => {
525
+ //IE support
526
+ const myField = field;
527
+ if (document.selection) {
528
+ myField.focus();
529
+ const sel = document.selection.createRange();
530
+ sel.text = myValue;
531
+ } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
532
+ const startPos = myField.selectionStart;
533
+ const endPos = myField.selectionEnd;
534
+ myField.value = myField.value.substring(0, startPos)
535
+ + myValue
536
+ + myField.value.substring(endPos, myField.value.length);
537
+ myField.selectionStart = startPos + myValue.length;
538
+ myField.selectionEnd = startPos + myValue.length;
539
+ } else {
540
+ myField.value += myValue;
541
+ }
542
+ const event = new Event('input', { bubbles: true });
543
+ callNativeEvent({field, value: myField.value, event});
544
+ };
545
+
546
+ startTemplateCreation = (data) => {
547
+ const getSchemaQuery = {
548
+ layout: 'LINE',
549
+ type: 'LAYOUT',
550
+ };
551
+ this.props.globalActions.fetchSchemaForEntity(getSchemaQuery);
552
+ console.log('startTemplateCreation');
553
+ const content = data.content;
554
+ const obj = {};
555
+ obj['0'] = {};
556
+ obj.base = {
557
+ base: true,
558
+ };
559
+ if (data.type === 'text') {
560
+ obj.base['message-editor'] = content;
561
+ obj['0']['message-editor'] = content;
562
+ } else {
563
+ obj.base.image = content;
564
+ obj['0'].image = content;
565
+ }
566
+ this.setState({formData: obj, loading: false, injectedTags: data.tags});
567
+ this.props.globalActions.setInjectedTags(data.tags);
568
+ };
569
+
570
+ startLoading = (ifEdit) => {
571
+ console.log('startLoading', ifEdit);
572
+ if (ifEdit) {
573
+ this.setState({loading: true});
574
+ }
575
+ };
576
+
577
+ injectContainer = (container) => {
578
+ const temp = container;
579
+ if (temp.type === 'tabs') {
580
+ temp.injectedEvents = {};
581
+ _.forEach(temp.supportedEvents, (event) => {
582
+ temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
583
+ });
584
+ _.forEach(temp.panes, (pane) => {
585
+ const tempPane = pane;
586
+ tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
587
+ tempPane.sections = this.injectSections(tempPane.sections);
588
+ });
589
+ }
590
+ return temp;
591
+ };
592
+
593
+ resetSchema = () => {
594
+ this.setState({ schema: this.state.initialState ? this.state.initialState : this.state.schema});
595
+ };
596
+
597
+ resetState = () => {
598
+ this.setState({
599
+ formData: {},
600
+ tabCount: 1,
601
+ currentTab: 1,
602
+ });
603
+ };
604
+
605
+ discardValues = () => {
606
+ this.resetSchema();
607
+ this.resetState();
608
+ };
609
+
610
+ moveToTemplates() {
611
+ console.log('in move to Templates');
612
+ const modalContent = {
613
+ title: "Alert",
614
+ body: "Do you really want to go back? All your temporary changes will be lost!",
615
+ type: 'confirm',
616
+ id: 'template-back-confirm-modal',
617
+ show: true,
618
+ };
619
+ this.setState({modalContent, showModal: true});
620
+ }
621
+
622
+ showNext() {
623
+ const response = {
624
+ action: "showNext",
625
+ value: true,
626
+ };
627
+ parent.postMessage(JSON.stringify(response), '*');
628
+ }
629
+
630
+ discardValues = () => {
631
+ this.resetSchema();
632
+ this.resetState();
633
+ };
634
+
635
+ handleFrameTasks = (e) => {
636
+ console.log('listened from cheetah@@@', e.data);
637
+ const type = e.data;
638
+ console.log('data type', typeof type);
639
+ if (typeof type === 'object') {
640
+ console.log('received something', type);
641
+ const action = type.action;
642
+ switch (action) {
643
+ case "startTemplateCreation":
644
+ this.startTemplateCreation(type.value);
645
+ break;
646
+ case "startLoading":
647
+ this.startLoading(type.edit);
648
+ break;
649
+ case "getCurrentWindow":
650
+ this.getCurrentWindow(type);
651
+ break;
652
+ default:
653
+ break;
654
+ }
655
+ } else {
656
+ switch (type) {
657
+ case "getFormData":
658
+ this.getFormData(e);
659
+ break;
660
+ case "startTemplateCreation":
661
+ console.log('Starting to create template');
662
+ //this.getFormData(e);
663
+ break;
664
+ case "moveToTemplates":
665
+ console.log('moving to templates');
666
+ this.moveToTemplates();
667
+ break;
668
+ case "validateContent":
669
+ console.log('validating Content');
670
+ this.validateContent(e);
671
+ break;
672
+ default:
673
+ break;
674
+ }
675
+ }
676
+ };
677
+
678
+ removeStandAlone = () => {
679
+ const schema = _.cloneDeep(this.state.schema);
680
+ console.log("schema line", schema);
681
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
682
+ schema.standalone.sections.splice(0, 1);
683
+ } else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.mode !== 'undefined') {
684
+ delete schema.standalone;
685
+ } else {
686
+ schema.standalone.sections.splice(1, 1);
687
+ }
688
+ this.setState({ schema });
689
+ };
690
+
691
+ validateContent = (e) => {
692
+ console.log('posting final validation result', this.state.isFormValid);
693
+ const response = {
694
+ action: "validateContent",
695
+ value: this.state.isFormValid,
696
+ };
697
+ e.source.postMessage(JSON.stringify(response), e.origin);
698
+ };
699
+
700
+ handleOnTagsContextChange = (data) => {
701
+ console.log('parent tags context', data);
702
+ const query = {
703
+ layout: 'LINE',
704
+ type: 'TAG',
705
+ context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
706
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
707
+ };
708
+ this.props.globalActions.fetchSchemaForEntity(query);
709
+ };
710
+
711
+ uploadImage = (pearmData) => {
712
+ console.log("image data line@@@", pearmData);
713
+ const data = pearmData;
714
+ if (data.file.size > 1000000) {
715
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 1mb']), true);
716
+ this.props.globalActions.addMessageToQueue(message);
717
+ } else {
718
+ data.fileParams.isGeneratePreview = true;
719
+ const name = data.file.name.split('.');
720
+ const blob = data.file.slice(0, -1, 'image');
721
+ const newFile = new File([blob], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
722
+ this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
723
+ }
724
+ };
725
+
726
+ render() {
727
+ if (this.state.formData && this.state.formData["0"] && this.state.formData["0"].image) {
728
+ console.log("before render@@@", this.state.formData["0"].image);
729
+ }
730
+ console.log("render state", this.state);
731
+ let tipText = this.props.Line.createTemplateInProgress ? "Saving Template..." : "";
732
+ let loading = this.props.Line.createTemplateInProgress ? this.props.Line.createTemplateInProgress : false;
733
+ if (this.props.Line.assetUploading) {
734
+ tipText = "Uploading Image...";
735
+ loading = true;
736
+ }
737
+ // if (!this.state.isReady) {
738
+ // tipText = "Please wait..";
739
+ // loading = true;
740
+ // }
741
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
742
+ if (this.props.supportedTags) {
743
+ tags = this.props.supportedTags;
744
+ }
745
+ return (
746
+ <Spin tip={tipText} spinning={loading}>
747
+ <Row style={{marginLeft: '-48px'}}>
748
+ <Col offset={1}>
749
+ {this.props.location.query.type !== "embedded" &&
750
+ <Breadcrumb>
751
+ <BreadcrumbItem>{this.props.intl.formatMessage(messages.Campaigns)}</BreadcrumbItem>
752
+ <BreadcrumbItem>{this.props.intl.formatMessage(messages.Creatives)}</BreadcrumbItem>
753
+ <BreadcrumbItem>{this.props.intl.formatMessage(messages.Line)}</BreadcrumbItem>
754
+ </Breadcrumb>
755
+ }
756
+ </Col>
757
+ </Row>
758
+ <Row>
759
+ <Col>
760
+ <FormBuilder
761
+ key={"form builder"}
762
+ schema={this.state.schema}
763
+ onSubmit={this.saveFormData}
764
+ onChange={this.onFormDataChange}
765
+ currentTab={this.state.currentTab}
766
+ parent={this}
767
+ formData={_.cloneDeep(this.state.formData)}
768
+ location={this.props.location}
769
+ tags={tags}
770
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
771
+ onFormValidityChange={this.setFormValidity}
772
+ usingTabContainer
773
+ checkValidation={this.state.checkValidation}
774
+ tabKey={this.state.tabKey}
775
+ tabCount={2}
776
+ showModal={this.state.showModal}
777
+ isSchemaChanged={this.state.isSchemaChanged}
778
+ modal={this.state.modalContent}
779
+ handleCancelModal={this.handleCancelModal}
780
+ iframeParent={parent}
781
+ router={this.props.router}
782
+ onContextChange={this.handleOnTagsContextChange}
783
+ setModalContent={this.setModalContent}
784
+ />
785
+ </Col>
786
+ </Row>
787
+ </Spin>
788
+ );
789
+ }
790
+ }
791
+
792
+ Line.propTypes = {
793
+ actions: PropTypes.object.isRequired,
794
+ globalActions: PropTypes.object,
795
+ Templates: PropTypes.object,
796
+ location: PropTypes.object,
797
+ router: PropTypes.object,
798
+ params: PropTypes.object,
799
+ metaEntities: PropTypes.object,
800
+ intl: intlShape.isRequired,
801
+ route: PropTypes.object,
802
+ Line: PropTypes.object,
803
+ supportedTags: PropTypes.any,
804
+ getDefaultTags: PropTypes.string,
805
+ injectedTags: PropTypes.object,
806
+ };
807
+
808
+ const mapStateToProps = createStructuredSelector({
809
+ Line: makeSelectCreateLine(),
810
+ Templates: makeSelectTemplates(),
811
+ metaEntities: makeSelectMetaEntities(),
812
+ injectedTags: setInjectedTags(),
813
+ });
814
+
815
+ function mapDispatchToProps(dispatch) {
816
+ return {
817
+ actions: bindActionCreators(actions, dispatch),
818
+ globalActions: bindActionCreators(globalActions, dispatch),
819
+ };
820
+ }
821
+
822
+ export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(Line)));