@capillarytech/creatives-library 2.0.70 → 2.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/EmailMobilePreview/index.scss +0 -1
  4. package/components/EmailPreviewV2/_emailPreviewV2.scss +4 -1
  5. package/components/EmailPreviewV2/index.js +1 -1
  6. package/components/FormBuilder/index.js +25 -10
  7. package/components/Header/index.js +3 -1
  8. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  9. package/components/TemplatePreview/index.js +45 -51
  10. package/components/TemplatePreview/messages.js +1 -1
  11. package/config/app.js +1 -0
  12. package/containers/Cap/actions.js +0 -5
  13. package/containers/Cap/reducer.js +1 -1
  14. package/containers/Cap/selectors.js +0 -13
  15. package/containers/Ebill/index.js +1 -2
  16. package/containers/Email/_email.scss +1 -0
  17. package/containers/Email/actions.js +3 -8
  18. package/containers/Email/constants.js +0 -1
  19. package/containers/Email/index.js +947 -322
  20. package/containers/Email/reducer.js +0 -3
  21. package/containers/Email/sagas.js +6 -3
  22. package/containers/Email/selectors.js +1 -4
  23. package/containers/Line/Create/index.js +1 -2
  24. package/containers/Line/Edit/_lineEdit.scss +4 -0
  25. package/containers/Line/Edit/index.js +1 -3
  26. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  27. package/containers/MobilePush/Create/actions.js +0 -6
  28. package/containers/MobilePush/Create/constants.js +0 -1
  29. package/containers/MobilePush/Create/index.js +1133 -628
  30. package/containers/MobilePush/Create/messages.js +1 -5
  31. package/containers/MobilePush/Create/reducer.js +0 -2
  32. package/containers/MobilePush/Create/selectors.js +3 -3
  33. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  34. package/containers/MobilePush/Edit/index.js +1127 -393
  35. package/containers/MobilePush/Edit/messages.js +0 -4
  36. package/containers/MobilePush/Edit/reducer.js +1 -2
  37. package/containers/MobilePush/Edit/selectors.js +3 -6
  38. package/containers/Sms/Create/_smsCreate.scss +2 -1
  39. package/containers/Sms/Create/actions.js +4 -4
  40. package/containers/Sms/Create/index.js +570 -102
  41. package/containers/Sms/Create/sagas.js +2 -1
  42. package/containers/Sms/Edit/actions.js +5 -10
  43. package/containers/Sms/Edit/constants.js +0 -1
  44. package/containers/Sms/Edit/index.js +548 -103
  45. package/containers/Sms/Edit/reducer.js +0 -2
  46. package/containers/Sms/Edit/sagas.js +3 -1
  47. package/containers/TagList/index.js +3 -3
  48. package/containers/Templates/actions.js +1 -3
  49. package/containers/Templates/index.js +299 -268
  50. package/containers/Templates/messages.js +90 -122
  51. package/containers/Templates/reducer.js +3 -3
  52. package/containers/Templates/sagas.js +1 -5
  53. package/containers/Templates/selectors.js +1 -41
  54. package/containers/WeChat/MapTemplates/index.js +3 -4
  55. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  56. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  57. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  58. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  59. package/index.js +31 -31
  60. package/initialState.js +6 -0
  61. package/package.json +3 -3
  62. package/routes.js +24 -19
  63. package/services/api.js +6 -2
  64. package/services/getSchema.js +18 -0
  65. package/v2Containers/App/actions.js +7 -0
  66. package/v2Containers/App/constants.js +3 -0
  67. package/v2Containers/App/reducer.js +19 -0
  68. package/v2Containers/App/sagas.js +26 -0
  69. package/v2Containers/App/selectors.js +25 -0
  70. package/v2Containers/App/tests/actions.test.js +18 -0
  71. package/v2Containers/App/tests/reducer.test.js +9 -0
  72. package/v2Containers/App/tests/sagas.test.js +15 -0
  73. package/v2Containers/App/tests/selectors.test.js +10 -0
  74. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  75. package/v2Containers/Assets/Gallery/actions.js +37 -0
  76. package/v2Containers/Assets/Gallery/constants.js +23 -0
  77. package/v2Containers/Assets/Gallery/index.js +479 -0
  78. package/v2Containers/Assets/Gallery/messages.js +97 -0
  79. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  80. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  81. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  82. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  83. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  84. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  85. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  86. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  87. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  88. package/v2Containers/CallTask/_callTask.scss +5 -0
  89. package/v2Containers/CallTask/actions.js +15 -0
  90. package/v2Containers/CallTask/constants.js +7 -0
  91. package/v2Containers/CallTask/index.js +141 -0
  92. package/v2Containers/CallTask/messages.js +21 -0
  93. package/v2Containers/CallTask/reducer.js +23 -0
  94. package/v2Containers/CallTask/sagas.js +11 -0
  95. package/v2Containers/CallTask/selectors.js +25 -0
  96. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  97. package/v2Containers/CallTask/tests/index.test.js +10 -0
  98. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  99. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  100. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  101. package/v2Containers/Cap/actions.js +64 -0
  102. package/v2Containers/Cap/constants.js +24 -0
  103. package/v2Containers/Cap/index.js +349 -0
  104. package/v2Containers/Cap/messsages.js +63 -0
  105. package/v2Containers/Cap/reducer.js +111 -0
  106. package/v2Containers/Cap/sagas.js +143 -0
  107. package/v2Containers/Cap/selectors.js +85 -0
  108. package/v2Containers/Cap/tests/index.test.js +16 -0
  109. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  110. package/v2Containers/ChannelTemplates/actions.js +20 -0
  111. package/v2Containers/ChannelTemplates/constants.js +8 -0
  112. package/v2Containers/ChannelTemplates/index.js +48 -0
  113. package/v2Containers/ChannelTemplates/messages.js +13 -0
  114. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  115. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  116. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  117. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  118. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  119. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  120. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  121. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  122. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  123. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  124. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  125. package/v2Containers/CreativesContainer/actions.js +27 -0
  126. package/v2Containers/CreativesContainer/constants.js +16 -0
  127. package/v2Containers/CreativesContainer/index.js +483 -0
  128. package/v2Containers/CreativesContainer/index.scss +27 -0
  129. package/v2Containers/CreativesContainer/messages.js +293 -0
  130. package/v2Containers/CreativesContainer/reducer.js +29 -0
  131. package/v2Containers/CreativesContainer/sagas.js +11 -0
  132. package/v2Containers/CreativesContainer/selectors.js +30 -0
  133. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  134. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  135. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  136. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  137. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  138. package/v2Containers/Dashboard/actions.js +15 -0
  139. package/v2Containers/Dashboard/constants.js +7 -0
  140. package/v2Containers/Dashboard/index.js +54 -0
  141. package/v2Containers/Dashboard/messages.js +13 -0
  142. package/v2Containers/Dashboard/reducer.js +21 -0
  143. package/v2Containers/Dashboard/sagas.js +11 -0
  144. package/v2Containers/Dashboard/selectors.js +25 -0
  145. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  146. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  147. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  148. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  149. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  150. package/v2Containers/Ebill/_ebill.scss +5 -0
  151. package/v2Containers/Ebill/actions.js +43 -0
  152. package/v2Containers/Ebill/constants.js +20 -0
  153. package/v2Containers/Ebill/index.js +1261 -0
  154. package/v2Containers/Ebill/messages.js +73 -0
  155. package/v2Containers/Ebill/reducer.js +72 -0
  156. package/v2Containers/Ebill/sagas.js +65 -0
  157. package/v2Containers/Ebill/selectors.js +25 -0
  158. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  159. package/v2Containers/Ebill/tests/index.test.js +10 -0
  160. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  161. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  162. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  163. package/v2Containers/Email/_email.scss +140 -0
  164. package/v2Containers/Email/actions.js +86 -0
  165. package/v2Containers/Email/constants.js +37 -0
  166. package/v2Containers/Email/index.js +2703 -0
  167. package/v2Containers/Email/initialSchema.js +540 -0
  168. package/v2Containers/Email/messages.js +237 -0
  169. package/v2Containers/Email/reducer.js +147 -0
  170. package/v2Containers/Email/sagas.js +133 -0
  171. package/v2Containers/Email/selectors.js +34 -0
  172. package/v2Containers/Email/tests/actions.test.js +18 -0
  173. package/v2Containers/Email/tests/index.test.js +10 -0
  174. package/v2Containers/Email/tests/reducer.test.js +9 -0
  175. package/v2Containers/Email/tests/sagas.test.js +15 -0
  176. package/v2Containers/Email/tests/selectors.test.js +10 -0
  177. package/v2Containers/EmailWrapper/actions.js +15 -0
  178. package/v2Containers/EmailWrapper/constants.js +7 -0
  179. package/v2Containers/EmailWrapper/index.js +258 -0
  180. package/v2Containers/EmailWrapper/messages.js +57 -0
  181. package/v2Containers/EmailWrapper/reducer.js +23 -0
  182. package/v2Containers/EmailWrapper/sagas.js +11 -0
  183. package/v2Containers/EmailWrapper/selectors.js +25 -0
  184. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  185. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  186. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  187. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  188. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  189. package/v2Containers/LanguageProvider/actions.js +17 -0
  190. package/v2Containers/LanguageProvider/constants.js +8 -0
  191. package/v2Containers/LanguageProvider/index.js +46 -0
  192. package/v2Containers/LanguageProvider/reducer.js +30 -0
  193. package/v2Containers/LanguageProvider/selectors.js +20 -0
  194. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  195. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  196. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  197. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  198. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  199. package/v2Containers/Line/Create/actions.js +90 -0
  200. package/v2Containers/Line/Create/constants.js +39 -0
  201. package/v2Containers/Line/Create/index.js +822 -0
  202. package/v2Containers/Line/Create/messages.js +173 -0
  203. package/v2Containers/Line/Create/reducer.js +99 -0
  204. package/v2Containers/Line/Create/sagas.js +107 -0
  205. package/v2Containers/Line/Create/selectors.js +36 -0
  206. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  207. package/v2Containers/Line/Edit/actions.js +79 -0
  208. package/v2Containers/Line/Edit/constants.js +27 -0
  209. package/v2Containers/Line/Edit/index.js +1050 -0
  210. package/v2Containers/Line/Edit/messages.js +157 -0
  211. package/v2Containers/Line/Edit/reducer.js +83 -0
  212. package/v2Containers/Line/Edit/sagas.js +81 -0
  213. package/v2Containers/Line/Edit/selectors.js +29 -0
  214. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  215. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  216. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  217. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  218. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  219. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  220. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  221. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  222. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  223. package/v2Containers/Login/index.js +106 -0
  224. package/v2Containers/Login/messages.js +21 -0
  225. package/v2Containers/Login/selectors.js +25 -0
  226. package/v2Containers/Login/tests/index.test.js +10 -0
  227. package/v2Containers/Login/tests/sagas.test.js +15 -0
  228. package/v2Containers/Login/tests/selectors.test.js +10 -0
  229. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  230. package/v2Containers/MobilePush/Create/actions.js +52 -0
  231. package/v2Containers/MobilePush/Create/constants.js +24 -0
  232. package/v2Containers/MobilePush/Create/index.js +1759 -0
  233. package/v2Containers/MobilePush/Create/messages.js +237 -0
  234. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  235. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  236. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  237. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  238. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  239. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  240. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  241. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  242. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  243. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  244. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  245. package/v2Containers/MobilePush/Edit/index.js +1851 -0
  246. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  247. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  248. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  249. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  250. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  251. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  252. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  253. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  254. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  255. package/v2Containers/MobilePush/commonMethods.js +249 -0
  256. package/v2Containers/MobilePush/eventsMap.js +127 -0
  257. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  258. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  259. package/v2Containers/MobilepushWrapper/index.js +136 -0
  260. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  261. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  262. package/v2Containers/NotFoundPage/index.js +25 -0
  263. package/v2Containers/NotFoundPage/messages.js +13 -0
  264. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  265. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  266. package/v2Containers/Sms/Create/actions.js +27 -0
  267. package/v2Containers/Sms/Create/constants.js +16 -0
  268. package/v2Containers/Sms/Create/index.js +1017 -0
  269. package/v2Containers/Sms/Create/messages.js +85 -0
  270. package/v2Containers/Sms/Create/reducer.js +41 -0
  271. package/v2Containers/Sms/Create/sagas.js +35 -0
  272. package/v2Containers/Sms/Create/selectors.js +28 -0
  273. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  274. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  275. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  276. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  277. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  278. package/v2Containers/Sms/Edit/actions.js +45 -0
  279. package/v2Containers/Sms/Edit/constants.js +18 -0
  280. package/v2Containers/Sms/Edit/index.js +1018 -0
  281. package/v2Containers/Sms/Edit/messages.js +89 -0
  282. package/v2Containers/Sms/Edit/reducer.js +52 -0
  283. package/v2Containers/Sms/Edit/sagas.js +50 -0
  284. package/v2Containers/Sms/Edit/selectors.js +32 -0
  285. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  286. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  287. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  288. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  289. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  290. package/v2Containers/Sms/initialSchema.js +281 -0
  291. package/v2Containers/TagList/_tagList.scss +8 -0
  292. package/v2Containers/TagList/actions.js +15 -0
  293. package/v2Containers/TagList/constants.js +7 -0
  294. package/v2Containers/TagList/index.js +236 -0
  295. package/v2Containers/TagList/messages.js +13 -0
  296. package/v2Containers/TagList/reducer.js +23 -0
  297. package/v2Containers/TagList/sagas.js +11 -0
  298. package/v2Containers/TagList/selectors.js +25 -0
  299. package/v2Containers/TagList/tests/actions.test.js +18 -0
  300. package/v2Containers/TagList/tests/index.test.js +10 -0
  301. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  302. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  303. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  304. package/v2Containers/Templates/_templates.scss +349 -0
  305. package/v2Containers/Templates/actions.js +110 -0
  306. package/v2Containers/Templates/constants.js +45 -0
  307. package/v2Containers/Templates/index.js +1725 -0
  308. package/v2Containers/Templates/messages.js +278 -0
  309. package/v2Containers/Templates/reducer.js +142 -0
  310. package/v2Containers/Templates/sagas.js +180 -0
  311. package/v2Containers/Templates/selectors.js +68 -0
  312. package/v2Containers/Templates/tests/actions.test.js +18 -0
  313. package/v2Containers/Templates/tests/index.test.js +10 -0
  314. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  315. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  316. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  317. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  318. package/v2Containers/TemplatesV2/actions.js +16 -0
  319. package/v2Containers/TemplatesV2/constants.js +10 -0
  320. package/v2Containers/TemplatesV2/index.js +217 -0
  321. package/v2Containers/TemplatesV2/messages.js +29 -0
  322. package/v2Containers/TemplatesV2/selectors.js +25 -0
  323. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  324. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  325. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  326. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  327. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  328. package/v2Containers/TestPage/constants.js +7 -0
  329. package/v2Containers/TestPage/index.js +31 -0
  330. package/v2Containers/TestPage/messages.js +13 -0
  331. package/v2Containers/TestPage/reducer.js +21 -0
  332. package/v2Containers/TestPage/sagas.js +11 -0
  333. package/v2Containers/Testv2/actions.js +15 -0
  334. package/v2Containers/Testv2/constants.js +7 -0
  335. package/v2Containers/Testv2/index.js +47 -0
  336. package/v2Containers/Testv2/messages.js +13 -0
  337. package/v2Containers/Testv2/reducer.js +23 -0
  338. package/v2Containers/Testv2/sagas.js +11 -0
  339. package/v2Containers/Testv2/selectors.js +25 -0
  340. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  341. package/v2Containers/Testv2/tests/index.test.js +10 -0
  342. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  343. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  344. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  345. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  346. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  347. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  348. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  349. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  350. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  351. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  352. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  354. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  355. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  356. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  357. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  392. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  393. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  394. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  395. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -0,0 +1,1050 @@
1
+
2
+ /*
3
+ *
4
+ * Create
5
+ *
6
+ */
7
+
8
+ import PropTypes from 'prop-types';
9
+
10
+ import React from 'react';
11
+ import {bindActionCreators} from "redux";
12
+ import { connect } from 'react-redux';
13
+ import { Row, Col, Spin, Breadcrumb, notification } from 'antd';
14
+ import { createStructuredSelector } from 'reselect';
15
+ import { injectIntl, intlShape } from 'react-intl';
16
+ import _ from 'lodash';
17
+ import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse} from "../../MobilePush/Edit/selectors";
18
+ import {makeSelectMetaEntities, setInjectedTags} from "../../Cap/selectors";
19
+ import {getMessageObject} from "../../../utils/messageUtils";
20
+ import FormBuilder from '../../../components/FormBuilder';
21
+ import * as globalActions from "../../Cap/actions";
22
+ import * as actions from "../../MobilePush/Edit/actions";
23
+ import * as templatesActions from "../../Templates/actions";
24
+ import {makeSelectTemplates} from "../../Templates/selectors";
25
+ import messages from './messages';
26
+ import './_lineEdit.scss';
27
+ import callNativeEvent from '../../../utils/callNativeEvent';
28
+
29
+ const BreadcrumbItem = Breadcrumb.Item;
30
+
31
+ export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
32
+ constructor(props) {
33
+ super(props);
34
+ const map = {
35
+ "template-name": {
36
+ onChange: this.onTemplateNameChange,
37
+ },
38
+ "discard-button": {
39
+ discardValues: this.discardValues,
40
+ },
41
+ "cancel-button": {
42
+ cancelTemplate: this.cancelTemplate,
43
+ },
44
+ "save-button": {
45
+ saveFormData: this.saveFormData,
46
+ },
47
+ "message-editor": {
48
+ onChange: this.onTemplateContentChange,
49
+ },
50
+ "message-editor2": {
51
+ onChange: this.onTemplateContentChange,
52
+ },
53
+ "message-tagList": {
54
+ onTagSelect: this.onTagSelect,
55
+ },
56
+ "message-tagList2": {
57
+ onTagSelect: this.onTagSelect,
58
+ },
59
+ "title-tagList": {
60
+ onTagSelect: this.onTagSelect,
61
+ },
62
+ "title-tagList2": {
63
+ onTagSelect: this.onTagSelect,
64
+ },
65
+ "pane": {
66
+ onTabChange: this.onTabChange,
67
+ },
68
+ "image-upload": {
69
+ onUpload: this.uploadImage,
70
+ },
71
+ "line-template": {
72
+ onSelect: this.onTemplateChange,
73
+ },
74
+ };
75
+ this.state = {
76
+ formData: {},
77
+ tabCount: 1,
78
+ schema: {},
79
+ currentTab: 1,
80
+ editData: {},
81
+ loading: false,
82
+ isFormValid: true,
83
+ injectedTags: {},
84
+ showModal: false,
85
+ eventsMap: map,
86
+ modalContent: {title: "Alert", body: this.props.intl.formatMessage(messages['template not configured,']), type: 'confirm'},
87
+ };
88
+ }
89
+ componentWillMount() {
90
+ console.log('edit mounting line');
91
+ if (this.props.location.query.type !== 'embedded') {
92
+ const type = this.props.location.query.type;
93
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
94
+ this.props.router.push({
95
+ pathname: `/line/`,
96
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
97
+ });
98
+ } else {
99
+ const query = {
100
+ layout: 'LINE',
101
+ type: 'LAYOUT',
102
+ };
103
+ this.props.globalActions.fetchSchemaForEntity(query);
104
+ }
105
+ }
106
+
107
+ componentDidMount() {
108
+ window.addEventListener("message", this.handleFrameTasks);
109
+ const type = this.props.location.query.type;
110
+ if (type === 'embedded') {
111
+ const response = {
112
+ action: 'startTemplateCreation',
113
+ };
114
+ parent.postMessage(JSON.stringify(response), '*');
115
+ }
116
+ if (!_.isEmpty(this.state.schema)) {
117
+ this.injectEvents(this.state.schema);
118
+ }
119
+ if (this.props.location.query && typeof this.props.location.query.module === 'undefined') { // when this containers is imported from creatives library
120
+ if (this.props.params.id) {
121
+ this.props.actions.getTemplateDetails(this.props.params.id);
122
+ } else {
123
+ this.props.actions.setTemplateDetails(this.props.templateData);
124
+ }
125
+ }
126
+ }
127
+
128
+ componentWillReceiveProps(nextProps) {
129
+ if (nextProps.isGetFormData) {
130
+ nextProps.getFormLibraryData(this.getFormData());
131
+ }
132
+ const params = {
133
+ name: '',
134
+ sortBy: 'Most Recent',
135
+ };
136
+ this.props.actions.getLineTemplatesList('line', params);
137
+
138
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.fullSchema)) {
139
+ this.setState({fullSchema: nextProps.metaEntities.layouts[0].definition, schema: nextProps.location.query.module === 'loyalty' ? nextProps.metaEntities.layouts[0].definition.textSchema : {}}, () => {
140
+ if (nextProps.location.query.module !== 'loyalty') {
141
+ this.props.actions.getTemplateDetails(this.props.params.id);
142
+ }
143
+ });
144
+ if (this.props.location.query.type === 'embedded') {
145
+ this.showNext();
146
+ }
147
+ }
148
+
149
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && nextProps.Edit.lineTemplates && !_.isEqual(nextProps.Edit.lineTemplates, this.props.Edit.lineTemplates)) { //used inloyalty
150
+ if (nextProps.location.query.type === 'embedded' && nextProps.location.query.module === 'loyalty') {
151
+ this.setTemplateOptions(nextProps.Edit.lineTemplates);
152
+ }
153
+ }
154
+ if (nextProps.templateDetails && nextProps.templateDetails.name && _.isEmpty(this.state.editData) && (this.props.location.query.type !== 'embedded' || (!_.isEmpty(this.state.fullSchema)))) {
155
+ this.props = nextProps;
156
+ const mode = nextProps.templateDetails.definition ? nextProps.templateDetails.definition.mode : nextProps.templateDetails.mode;
157
+ const schema = mode === "text" ? this.state.fullSchema.textSchema : this.state.fullSchema.imageSchema;
158
+ this.setEditState(nextProps.templateDetails, schema);
159
+ const query = {
160
+ layout: 'line',
161
+ type: 'TAG',
162
+ context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
163
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
164
+ };
165
+ if (this.props.getDefaultTags) {
166
+ query.context = this.props.getDefaultTags;
167
+ }
168
+ this.props.globalActions.fetchSchemaForEntity(query);
169
+ }
170
+ if (nextProps.Edit.uploadedAssetData) {
171
+ const formData = _.cloneDeep(this.state.formData);
172
+ formData[this.state.currentTab - 1].image = nextProps.Edit.uploadedAssetData.metaInfo.public_url;
173
+ this.setState({formData});
174
+ this.props.actions.clearAsset();
175
+ }
176
+ if (nextProps.Edit.iosCtasData) {
177
+ this.setState({iosCtasData: nextProps.Edit.iosCtasData});
178
+ }
179
+ if (nextProps.Edit.editResponse && nextProps.Edit.editResponse.templateId) {
180
+ console.log('reseting schema');
181
+ this.resetSchema();
182
+ this.setState({
183
+ formData: {},
184
+ tabCount: 1,
185
+ currentTab: 1,
186
+ editData: {},
187
+ });
188
+ const message = getMessageObject('success', this.props.intl.formatMessage(messages['MOBILEPUSH Template Edited Successfully']), true);
189
+ this.props.globalActions.addMessageToQueue(message);
190
+ this.props.actions.clearEditResponse();
191
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
192
+ const type = this.props.location.query.type;
193
+ this.props.router.push({
194
+ pathname: `/line/`,
195
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
196
+ });
197
+ }
198
+
199
+ if (nextProps.Edit.editTemplateError && !_.isEqual(nextProps.Edit.editTemplateError, this.props.Edit.editTemplateError)) {
200
+ const message = getMessageObject('error', (nextProps.Edit.editTemplateErrorMessage && nextProps.Edit.editTemplateErrorMessage !== '') ? nextProps.Edit.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
201
+ this.props.globalActions.addMessageToQueue(message);
202
+ }
203
+ }
204
+
205
+ componentWillUnmount() {
206
+ this.props.actions.clearData();
207
+ window.removeEventListener("message", this.handleFrameTasks);
208
+ }
209
+
210
+ onTemplateChange = (isEvent, formData) => {
211
+ _.forEach(this.props.Edit.lineTemplates, (template) => {
212
+ if (template._id === formData['line-template']) {
213
+ this.setState({editData: {}, formData: {}}, () => {
214
+ this.props.actions.setSelectedTemplate(template);
215
+ });
216
+ }
217
+ });
218
+ };
219
+
220
+ onFormDataChange = (formData, tabCount, currentTab) => {
221
+ console.log('Form data changed is ', formData, tabCount, currentTab);
222
+ const newFormData = _.cloneDeep(formData);
223
+ if (newFormData[this.state.currentTab - 1] && newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`]) {
224
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].name;
225
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[0].buttonText;
226
+ delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
227
+ if (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1]) {
228
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1].buttonText;
229
+ }
230
+ }
231
+ if (newFormData["line-accounts"] !== this.state.formData["line-accounts"]) {
232
+ this.setMobilePushAccountOptions(this.props.Edit.weCrmAccounts, newFormData["line-accounts"]);
233
+ delete newFormData['line-template'];
234
+ delete newFormData['template-name'];
235
+ if (!_.isEmpty(newFormData[0])) {
236
+ delete newFormData[0];
237
+ }
238
+ if (!_.isEmpty(newFormData[1])) {
239
+ delete newFormData[1];
240
+ }
241
+ }
242
+ if (this.state.isSchemaChanged) {
243
+ this.setState({isSchemaChanged: false});
244
+ }
245
+ this.setState({formData: newFormData, tabCount});
246
+ if (currentTab) {
247
+ this.setState({currentTab});
248
+ }
249
+ };
250
+
251
+ onTabChange = (data) => {
252
+ console.log('inside parent ontabchange', data, this.state);
253
+ this.setState({currentTab: data});
254
+ };
255
+
256
+ onTagSelect = (data, currentTab, srcComp) => {
257
+ console.log('parent data tag', data, currentTab);
258
+ const editorId = srcComp.target;
259
+ this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
260
+ document.getElementById(editorId).focus();
261
+ };
262
+ onModalCancel = () => {
263
+ if (this.state.modalContent && this.state.modalContent.show) {
264
+ this.setState({modalContent: {...this.state.modalContent, show: false}});
265
+ }
266
+ };
267
+ setTemplateOptions = (lineTemplates) => {
268
+ const templateOptions = [];
269
+ let selectedTemplate = {};
270
+ if (!_.isEmpty(lineTemplates)) {
271
+ _.forEach(lineTemplates, (template) => {
272
+ templateOptions.push({
273
+ key: template._id,
274
+ label: template.name,
275
+ value: template._id,
276
+ });
277
+ if (this.state.formData['line-template'] && template._id === this.state.formData['line-template']) {
278
+ selectedTemplate = template;
279
+ }
280
+ });
281
+ }
282
+ this.setState({templateOptions}, () => {
283
+ if (!_.isEmpty(selectedTemplate)) {
284
+ this.props.actions.setSelectedTemplate(selectedTemplate);
285
+ }
286
+ if (!_.isEmpty(this.state.schema)) {
287
+ this.injectEvents(this.state.schema);
288
+ }
289
+ });
290
+ };
291
+ setMobilePushAccountOptions = (accounts, newAccountId) => {
292
+ let accId = newAccountId || this.props.location.query.account_id;
293
+ if (this.props.location.query.module !== "loyalty") {
294
+ accId = Number(accId);
295
+ }
296
+ const formData = _.cloneDeep(this.state.formData);
297
+ let selectedAccount = {};
298
+ if (accId) {
299
+ _.forEach(accounts, (account) => {
300
+ let acccountId = account.id;
301
+ if (this.props.location.query.module === "loyalty" && typeof accId === 'string') {
302
+ acccountId = account.sourceAccountIdentifier;
303
+ }
304
+ if (acccountId === accId) {
305
+ this.props.templatesActions.setWeChatAccount(account);
306
+ selectedAccount = account;
307
+ formData['line-accounts'] = account.id;
308
+ if (this.props.location.query.account_id) {
309
+ formData['line-template'] = this.props.params.id;
310
+ }
311
+ }
312
+ });
313
+ } else {
314
+ selectedAccount = accounts[0];
315
+ formData['line-accounts'] = accounts[0].id;
316
+ }
317
+ this.props.actions.setWeChatAccount(selectedAccount);
318
+ this.setState({formData, accountsOptions: accounts.map((acc) => ({key: acc.id, label: acc.name, value: acc.id}))});
319
+ };
320
+
321
+ getTransformedData = (formData) => {
322
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
323
+ const obj = _.cloneDeep(this.state.editData);
324
+ obj.versions = {
325
+ base: {},
326
+ };
327
+ obj.name = formData['template-name'];
328
+ obj.definition = {
329
+ accountId: selectedWeChatAccount.id,
330
+ licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
331
+ mode: this.props.Edit.templateDetails.mode,
332
+ };
333
+ const android = {};
334
+ Object.keys(formData[0]).forEach((data) => {
335
+ if (!!formData[0][data] && data !== "tabKey") {
336
+ android[data] = formData[0][data];
337
+ }
338
+ });
339
+ const ios = {};
340
+ Object.keys(formData[1]).forEach((data) => {
341
+ if (!!formData[1][data] && data !== "tabKey") {
342
+ ios[data] = formData[1][data];
343
+ }
344
+ });
345
+ obj.versions.base = {};
346
+ delete android.base;
347
+ if (!_.isEmpty(android)) {
348
+ obj.versions.base.ANDROID = {
349
+ luid: "{{luid}}",
350
+ cuid: "{{cuid}}",
351
+ communicationId: "{{communicationId}}",
352
+ title: android['message-title'],
353
+ message: android['message-editor'],
354
+ expandableDetails: {
355
+ style: "BIG_TEXT",
356
+ message: android['message-editor'],
357
+ },
358
+ custom: _.map(android, (field, key) => {
359
+ if (key.indexOf('custom-value') > -1) {
360
+ return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select', ''), value: field} : undefined;
361
+ }
362
+ return undefined;
363
+ }).filter((custom) => custom),
364
+ };
365
+ }
366
+ if (android['cta-deeplink'] && android['cta-deeplink'] !== "") {
367
+ obj.versions.base.ANDROID.cta = {
368
+ type: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
369
+ actionLink: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? android['cta-deeplink-select'] : android['cta-deeplink-text'],
370
+ deepLinkName: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? this.getLinkName(android['cta-deeplink-select']) : undefined,
371
+ };
372
+ if (this.props.location.query.type === 'embedded') {
373
+ delete obj.versions.base.ANDROID.cta.deepLinkName;
374
+ }
375
+ }
376
+ if (!_.isEmpty(ios)) {
377
+ obj.versions.base.IOS = {
378
+ luid: "{{luid}}",
379
+ cuid: "{{cuid}}",
380
+ communicationId: "{{communicationId}}",
381
+ title: ios['message-title2'],
382
+ message: ios['message-editor2'],
383
+ expandableDetails: {
384
+ style: "BIG_TEXT",
385
+ message: ios['message-title2'],
386
+ ctas: [
387
+
388
+ ],
389
+ categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
390
+ },
391
+ custom: _.map(ios, (field, key) => {
392
+ if (key.indexOf('custom-value') > -1) {
393
+ return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink2-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select2', ''), value: field} : undefined;
394
+ }
395
+ return undefined;
396
+ }).filter((custom) => custom),
397
+ };
398
+ }
399
+ if (ios['cta-deeplink2'] && ios['cta-deeplink2'] !== "") {
400
+ obj.versions.base.IOS.cta = {
401
+ type: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
402
+ actionLink: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? ios['cta-deeplink2-select'] : ios['cta-deeplink2-text'],
403
+ deepLinkName: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? this.getLinkName(ios['cta-deeplink2-select']) : undefined,
404
+ };
405
+ if (this.props.location.query.type === 'embedded') {
406
+ delete obj.versions.base.IOS.cta.deepLinkName;
407
+ }
408
+ }
409
+ const imageLink = android.image;
410
+ if (imageLink) {
411
+ obj.versions.base.ANDROID.expandableDetails.image = imageLink;
412
+ obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
413
+ }
414
+ if (obj.versions.base.ANDROID && obj.versions.base.ANDROID.cta) {
415
+ if (obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
416
+ const params = _.map(android, (field, key) => {
417
+ let actionLink;
418
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
419
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
420
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
421
+ }
422
+ return actionLink;
423
+ }).filter((actionLink) => actionLink);
424
+ if (params.length) {
425
+ obj.versions.base.ANDROID.cta.actionLink = `${obj.versions.base.ANDROID.cta.actionLink}?${params.join('&')}`;
426
+ }
427
+ }
428
+ }
429
+ const secondaryCta1 = !!android["cta-deeplink-secondary-cta-0-select"] || !!android['secondary-cta-0-label'];
430
+ const secondaryCta2 = !!android['cta-deeplink-secondary-cta-1-select'] || !!android['secondary-cta-1-label'];
431
+ if (secondaryCta1 || secondaryCta2 ) {
432
+ obj.versions.base.ANDROID.expandableDetails.ctas = [];
433
+ if (secondaryCta1) {
434
+ const cta = {
435
+ actionText: android['secondary-cta-0-label'],
436
+ type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
437
+ actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
438
+ seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
439
+ };
440
+ if (this.props.location.query.type === 'embedded') {
441
+ delete cta.seccdeepLinkName;
442
+ }
443
+ obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
444
+ if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
445
+ const params = _.map(android, (field, key) => {
446
+ let actionLink;
447
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
448
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
449
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
450
+ }
451
+ return actionLink;
452
+ }).filter((actionLink) => actionLink);
453
+ if (params.length) {
454
+ obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
455
+ }
456
+ }
457
+ }
458
+ if (secondaryCta2) {
459
+ obj.versions.base.ANDROID.expandableDetails.ctas.push({
460
+ actionText: android['secondary-cta-1-label'],
461
+ type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
462
+ actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
463
+ seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
464
+ });
465
+ if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
466
+ const params = _.map(android, (field, key) => {
467
+ let actionLink;
468
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
469
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
470
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
471
+ }
472
+ return actionLink;
473
+ }).filter((actionLink) => actionLink);
474
+ if (params.length) {
475
+ obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
476
+ }
477
+ }
478
+ }
479
+ }
480
+ const imageLinkIos = ios.image;
481
+ if (imageLinkIos) {
482
+ obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
483
+ obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
484
+ }
485
+ if (obj.versions.base.IOS && obj.versions.base.IOS.cta) {
486
+ if (obj.versions.base.IOS.cta.type === "DEEP_LINK") {
487
+ const params = _.map(ios, (field, key) => {
488
+ let actionLink;
489
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
490
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
491
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
492
+ }
493
+ return actionLink;
494
+ }).filter((actionLink) => actionLink);
495
+ if (params.length) {
496
+ obj.versions.base.IOS.cta.actionLink = `${obj.versions.base.IOS.cta.actionLink}?${params.join('&')}`;
497
+ }
498
+ }
499
+ }
500
+ const secondaryCtaIos = !!ios['cta-deeplink-secondary-cta-1-select'] || !!ios['secondary-cta-1-label'];
501
+
502
+ if (secondaryCtaIos) {
503
+ obj.versions.base.IOS.expandableDetails.ctas = [];
504
+ const cta = {
505
+ actionText: ios['secondary-cta-1-label'],
506
+ actionLabel: ios['secondary-cta-1-action'],
507
+ actionLabel2: ios['secondary-cta-1-action2'],
508
+ type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
509
+ actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text2']),
510
+ ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
511
+ templateCtaId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].ctaTemplateDetails[0].id : undefined,
512
+ };
513
+ if (this.props.location.query.type === 'embedded') {
514
+ delete cta.ioscdeepLinkName;
515
+ }
516
+ obj.versions.base.IOS.expandableDetails.ctas.push(cta);
517
+ if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
518
+ const params = _.map(ios, (field, key) => {
519
+ let actionLink;
520
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
521
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
522
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
523
+ }
524
+ return actionLink;
525
+ }).filter((actionLink) => actionLink);
526
+ if (params.length) {
527
+ obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
528
+ }
529
+ }
530
+ }
531
+ return obj;
532
+ };
533
+
534
+ setFormValidity = (isFormValid) => {
535
+ this.setState({isFormValid});
536
+ };
537
+
538
+ getMappedEvent = (id, event) => {
539
+ const map = this.state.eventsMap;
540
+ if (!map[id] || !map[id][event]) {
541
+ console.log(`error map[id] ${map[id]}` );
542
+ }
543
+ return map[id][event];
544
+ };
545
+
546
+ getCurrentWindow = (e) => {
547
+ console.log('in line create', e);
548
+ const response = {
549
+ action: e.action,
550
+ value: 'edit',
551
+ direction: e.value,
552
+ };
553
+ parent.postMessage(JSON.stringify(response), '*');
554
+ };
555
+
556
+ getFormData = (e) => {
557
+ console.log('posting final result', this.state.formData);
558
+ const response = {
559
+ action: "getFormData",
560
+ value: this.getTransformedData(this.state.formData),
561
+ validity: this.state.isFormValid,
562
+ };
563
+ console.log('GetForm Data ', response);
564
+ this.setState({checkValidation: true});
565
+ if (e) {
566
+ e.source.postMessage(JSON.stringify(response), e.origin);
567
+ }
568
+ return response;
569
+ };
570
+
571
+
572
+ setEditState(data, schema) {
573
+ console.log('Test 1234', data, schema);
574
+ const tabCount = Object.keys(data.versions.base).length;
575
+ const formData = {};
576
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === "loyalty") {
577
+ formData["line-accounts"] = this.state.formData["line-accounts"];
578
+ formData['line-template'] = this.state.formData['line-template'];
579
+ }
580
+ formData['template-name'] = data.name;
581
+ const androidData = data.versions.base.ANDROID;
582
+ const iosData = data.versions.base.IOS;
583
+ const android = {};
584
+ android[`message-title`] = androidData ? androidData.title : '';
585
+ android['message-editor'] = androidData ? androidData.message : '';
586
+ if (data.mode === "image") {
587
+ android.image = "";
588
+ }
589
+ formData[0] = android;
590
+ const ios = {};
591
+ ios[`message-title2`] = iosData ? iosData.title : '';
592
+ ios['message-editor2'] = iosData ? iosData.message : '';
593
+ if (data.mode === "image") {
594
+ ios.image = "";
595
+ }
596
+ if (iosData) {
597
+ if (iosData.cta) {
598
+ ios['cta-deeplink2'] = iosData.cta.type === "DEEP_LINK" ? "Deeplink" : "External Link";
599
+ if (iosData.cta.type === "DEEP_LINK") {
600
+ ios['cta-deeplink2-select'] = iosData ? iosData.cta.actionLink : '';
601
+ } else {
602
+ ios['cta-deeplink2-text'] = iosData ? iosData.cta.actionLink : '';
603
+ }
604
+ if (iosData.cta.type === "DEEP_LINK") {
605
+ const link = ios['cta-deeplink2-select'].split('?')[0];
606
+ let params = ios['cta-deeplink2-select'].split('?');
607
+ if (params[1]) {
608
+ params = params[1].split('&');
609
+ _.forEach(params, (param) => {
610
+ ios[`custom-value-${param.split('=')[0]}-cta-deeplink2-select`] = param.split('=')[1];
611
+ });
612
+ }
613
+ ios['cta-deeplink2-select'] = link;
614
+ }
615
+ }
616
+ if (iosData.expandableDetails && iosData.expandableDetails.image) {
617
+ ios.image = iosData.expandableDetails.image;
618
+ }
619
+ if (iosData.expandableDetails && iosData.expandableDetails.ctas && iosData.expandableDetails.ctas.length) {
620
+ if (iosData.expandableDetails.ctas[0].type) {
621
+ ios['cta-deeplink-secondary-cta-1'] = iosData.expandableDetails.ctas[0].type === "DEEP_LINK" ? "Deeplink" : "External Link";
622
+ }
623
+ if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK") {
624
+ ios['cta-deeplink-secondary-cta-1-select2'] = iosData.expandableDetails.ctas[0].actionLink;
625
+ } else {
626
+ ios['cta-deeplink-secondary-cta-1-text2'] = iosData.expandableDetails.ctas[0].actionLink;
627
+ }
628
+ ios['secondary-cta-1-label'] = iosData.expandableDetails.ctas[0].actionText;
629
+ if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK" && ios['cta-deeplink-secondary-cta-1-select2']) {
630
+ const link = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[0];
631
+ const paramsIos = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1] && ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1].split('&');
632
+ ios['cta-deeplink-secondary-cta-1-select2'] = link;
633
+ _.forEach(paramsIos, (param) => {
634
+ ios[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select2`] = param.split('=')[1];
635
+ });
636
+ }
637
+ ios['secondary-cta-1-action'] = iosData.expandableDetails.ctas[0].actionLabel;
638
+ if (iosData.expandableDetails.ctas[0].actionLabel2) {
639
+ ios['secondary-cta-1-action2'] = iosData.expandableDetails.ctas[0].actionLabel2;
640
+ }
641
+ }
642
+ }
643
+ formData[1] = ios;
644
+ formData.base = formData[0];
645
+ formData[0].base = true;
646
+ console.log('form data after discarding ', formData);
647
+ this.getSchemaForFormData(formData, schema);
648
+ this.setState({tabCount, formData, editData: data, currentTab: 1});
649
+ }
650
+
651
+ getSchemaForFormData = (formData, inputSchema) => {
652
+ const schema = inputSchema;
653
+ this.setState({schema, isSchemaChanged: true});
654
+ this.injectEvents(schema);
655
+ };
656
+
657
+ setModalContent = (type) => {
658
+ if (type === 'ios') {
659
+ const modalContent = {
660
+ title: "Alert",
661
+ body: "Android template is not configured. Save without Android template",
662
+ type: 'confirm',
663
+ id: 'ios',
664
+ };
665
+ this.setState({modalContent, showModal: true});
666
+ } else if (type === 'android') {
667
+ const modalContent = {
668
+ title: "Alert",
669
+ body: "IOS template is not configured, Save without IOS template",
670
+ type: 'confirm',
671
+ id: 'android',
672
+ };
673
+ this.setState({modalContent, showModal: true});
674
+ }
675
+ };
676
+
677
+ openNotificationWithIcon = (type, message) => {
678
+ const dur = (type === 'error' || type === 'warning') ? null : 5;
679
+ notification[type]({
680
+ message: (`${type.toUpperCase()} ! ! ! `),
681
+ description: message, //'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
682
+ duration: dur,
683
+ });
684
+ };
685
+
686
+ handleCancelModal = () => {
687
+ this.setState({showModal: false});
688
+ };
689
+
690
+ insertAtCursor = (field, myValue) => {
691
+ //IE support
692
+ const myField = field;
693
+ if (document.selection) {
694
+ myField.focus();
695
+ const sel = document.selection.createRange();
696
+ sel.text = myValue;
697
+ } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
698
+ const startPos = myField.selectionStart;
699
+ const endPos = myField.selectionEnd;
700
+ myField.value = myField.value.substring(0, startPos)
701
+ + myValue
702
+ + myField.value.substring(endPos, myField.value.length);
703
+ myField.selectionStart = startPos + myValue.length;
704
+ myField.selectionEnd = startPos + myValue.length;
705
+ } else {
706
+ myField.value += myValue;
707
+ }
708
+ const event = new Event('input', { bubbles: true });
709
+ callNativeEvent({field, value: myField.value, event});
710
+ };
711
+
712
+ selectCtaIos = (selectedConfig) => {
713
+ this.showSelectedIosCta(null, null, null, selectedConfig);
714
+ };
715
+
716
+ uploadImage = (data) => {
717
+ if (data.fileParams.error) {
718
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 5mb']), true);
719
+ this.props.globalActions.addMessageToQueue(message);
720
+ } else {
721
+ const name = data.file.name.split('.');
722
+ const blob = data.file.slice(0, -1, 'image');
723
+ const newFile = new File([blob], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
724
+ this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
725
+ }
726
+ };
727
+
728
+ startTemplateCreation = (data) => {
729
+ console.log('startTemplateCreation', data);
730
+ if (!data.edit) {
731
+ this.setState({injectedTags: data.tags});
732
+ this.props.globalActions.setInjectedTags(data.tags);
733
+ }
734
+ };
735
+
736
+ discardValues = () => {
737
+ console.log('discarding', this.props.Edit);
738
+ this.resetSchema();
739
+ this.setState({
740
+ formData: {},
741
+ tabCount: 1,
742
+ currentTab: 1,
743
+ editData: {},
744
+ }, () => {
745
+ const schema = this.props.Edit.templateDetails.mode === "image" ? this.state.fullSchema.imageSchema : this.state.fullSchema.textSchema;
746
+ this.setEditState(this.props.Edit.templateDetails, schema);
747
+ });
748
+ };
749
+
750
+ resetSchema = () => {
751
+ this.setState({ schema: this.state.initialState ? this.state.initialState : this.state.schema});
752
+ };
753
+
754
+ showNext = () => {
755
+ const response = {
756
+ action: "showNext",
757
+ value: true,
758
+ };
759
+ parent.postMessage(JSON.stringify(response), '*');
760
+ };
761
+
762
+ moveToTemplates = () => {
763
+ console.log('in move to Templates');
764
+ const modalContent = {
765
+ title: "Alert",
766
+ body: "Do you really want to go back? All your temporary changes will be lost!",
767
+ type: 'confirm',
768
+ id: 'template-back-confirm-modal',
769
+ show: true,
770
+ };
771
+ this.setState({modalContent, showModal: true});
772
+ };
773
+
774
+ injectSections = (sections) => {
775
+ _.forEach(sections, (section) => {
776
+ let temp = section;
777
+ if (temp.type === 'col-label') {
778
+ temp = this.injectColLabelSection(temp);
779
+ } else if (section.type === 'multicols') {
780
+ temp = this.injectMultiColSection(temp);
781
+ } else if (section.type === 'parent') {
782
+ temp = this.injectSections(temp.childSections);
783
+ }
784
+ });
785
+ return sections;
786
+ };
787
+ injectMultiColSection = (section) => {
788
+ _.forEach(section.inputFields, (inputField) => {
789
+ _.forEach(inputField.cols, (col) => {
790
+ const temp = col;
791
+ if (temp.type === 'popover') {
792
+ temp.content.sections = this.injectSections(temp.content.sections);
793
+ temp.value.sections = this.injectSections(temp.value.sections);
794
+ return true;
795
+ }
796
+ temp.injectedEvents = {};
797
+ temp.className = temp.className ? temp.className : '';
798
+ if (this.props.location.query.type === 'embedded' && (temp.type === "div" || temp.type === "icon" || temp.type === "tag-list") && (temp.supportedEvents)) {
799
+ temp.className = `${temp.className} hide`;
800
+ }
801
+ if (this.props.location.query.type === 'embedded' && (temp.type === "input" || temp.type === "textarea" || temp.type === "radioGroup")) {
802
+ temp.className = `${temp.className} disabled`;
803
+ temp.disabled = true;
804
+ }
805
+ if (this.props.location.query.type === 'embedded' && temp.id === "line-template" ) {
806
+ temp.options = this.state.templateOptions ? this.state.templateOptions : [];
807
+ }
808
+ if (this.props.location.query.type === 'embedded' && temp.id === "line-accounts" ) {
809
+ temp.options = this.state.templateOptions ? this.state.accountsOptions : [];
810
+ }
811
+ if (temp.id === "mobile-push-preview" && this.props.Templates.selectedWeChatAccount && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
812
+ temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
813
+ }
814
+ _.forEach(col.supportedEvents, (event) => {
815
+ console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
816
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
817
+ });
818
+ return true;
819
+ });
820
+ });
821
+ _.forEach(section.actionFields, (actionField) => {
822
+ _.forEach(actionField.cols, (col) => {
823
+ const temp = col;
824
+ temp.disabled = this.props.location.query.type === 'embedded';
825
+ if (temp.type === 'popover') {
826
+ temp.content.sections = this.injectSections(temp.content.sections);
827
+ temp.value.sections = this.injectSections(temp.value.sections);
828
+ return true;
829
+ }
830
+ temp.injectedEvents = {};
831
+ _.forEach(col.supportedEvents, (event) => {
832
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
833
+ });
834
+ return true;
835
+ });
836
+ });
837
+ return section;
838
+ };
839
+
840
+ saveFormData = (formData) => {
841
+ console.log('Saving form data', formData, this.state.tabCount);
842
+ const obj = this.getTransformedData(formData);
843
+ console.log('obj', obj);
844
+ this.props.actions.editTemplate(obj);
845
+ };
846
+
847
+ handleFrameTasks = (e) => {
848
+ // console.log('data listened to is', e.data);
849
+ const type = e.data;
850
+ console.log('data type', typeof type);
851
+ if (typeof type === 'object') {
852
+ // console.log('received something', type);
853
+ const action = type.action;
854
+ switch (action) {
855
+ case "startTemplateCreation":
856
+ this.startTemplateCreation(type.value);
857
+ break;
858
+ case "startLoading":
859
+ this.startLoading(type.edit);
860
+ break;
861
+ case "getCurrentWindow":
862
+ this.getCurrentWindow(type);
863
+ break;
864
+ default:
865
+ break;
866
+ }
867
+ } else {
868
+ switch (type) {
869
+ case "getFormData":
870
+ this.getFormData(e);
871
+ break;
872
+ case "startTemplateCreation":
873
+ console.log('Starting to create template');
874
+ //this.getFormData(e);
875
+ break;
876
+ case "moveToTemplates":
877
+ console.log('moving to templates');
878
+ this.moveToTemplates();
879
+ break;
880
+ case "validateContent":
881
+ console.log('validating Content');
882
+ this.validateContent(e);
883
+ break;
884
+ default:
885
+ break;
886
+ }
887
+ }
888
+ };
889
+
890
+ cancelTemplate = () => {
891
+ const type = this.props.location.query.type;
892
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
893
+ this.props.router.push({
894
+ pathname: `/line/`,
895
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
896
+ });
897
+ };
898
+
899
+ injectContainer = (container) => {
900
+ const temp = container;
901
+ if (temp.type === 'tabs') {
902
+ temp.injectedEvents = {};
903
+ _.forEach(temp.supportedEvents, (event) => {
904
+ temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
905
+ });
906
+ _.forEach(temp.panes, (pane) => {
907
+ const tempPane = pane;
908
+ tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
909
+ tempPane.sections = this.injectSections(tempPane.sections);
910
+ });
911
+ }
912
+ return temp;
913
+ };
914
+
915
+ injectEvents = (schema) => {
916
+ const temp = schema;
917
+ if (this.injectSections) {
918
+ temp.standalone.sections = this.injectSections(temp.standalone.sections);
919
+ }
920
+ _.forEach(temp.containers, (container) => {
921
+ let tempContainer = container;
922
+ tempContainer = this.injectContainer(tempContainer);
923
+ return tempContainer;
924
+ });
925
+ console.log('final injected schema', schema);
926
+ this.setState({schema}, () => {
927
+ this.removeStandAlone();
928
+ });
929
+ return schema;
930
+ };
931
+
932
+ removeStandAlone = () => {
933
+ const schema = _.cloneDeep(this.state.schema);
934
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
935
+ if (schema.standalone.sections.length === 2) {
936
+ schema.standalone.sections.splice(0, 1);
937
+ }
938
+ } else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') {
939
+ delete schema.standalone;
940
+ } else {
941
+ schema.standalone.sections.splice(1, 1);
942
+ }
943
+ this.setState({ schema });
944
+ };
945
+
946
+ handleOnTagsContextChange = (data) => {
947
+ console.log('parent tags context', data);
948
+ const query = {
949
+ layout: 'line',
950
+ type: 'TAG',
951
+ context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
952
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
953
+ };
954
+ this.props.globalActions.fetchSchemaForEntity(query);
955
+ };
956
+
957
+ render() {
958
+ const schema = this.state.schema;
959
+ let tipText = this.props.Edit && ("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) ? 'Getting template details...' : '';
960
+ tipText = this.props.Edit && ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress) ? 'Saving Template...' : '';
961
+ const spinning = this.props.Edit.fetchingDefaultTemplates || this.props.Edit.assetUploading || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
962
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
963
+ if (this.props.supportedTags) {
964
+ tags = this.props.supportedTags;
965
+ }
966
+ return (
967
+ <div>
968
+ <Spin tip={tipText} spinning={spinning}>
969
+ {<Row style={{marginBottom: '16px', marginLeft: '-40px'}}>
970
+ <Col offset={1}>
971
+ {this.props.location.query.type !== "embedded" &&
972
+ <Breadcrumb>
973
+ <BreadcrumbItem>Campaigns</BreadcrumbItem>
974
+ <BreadcrumbItem>Creatives</BreadcrumbItem>
975
+ <BreadcrumbItem>Mobile Push</BreadcrumbItem>
976
+ </Breadcrumb>
977
+ }
978
+ </Col>
979
+ </Row>}
980
+ <Row>
981
+ <Col>
982
+ <FormBuilder
983
+ schema={schema}
984
+ onSubmit={this.saveFormData}
985
+ onChange={this.onFormDataChange}
986
+ formData={_.cloneDeep(this.state.formData)}
987
+ currentTab={this.state.currentTab}
988
+ parent={this}
989
+ location={this.props.location}
990
+ isEdit
991
+ tabCount={2}
992
+ iosCtasData={this.state.iosCtasData}
993
+ tags={tags}
994
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
995
+ onFormValidityChange={this.setFormValidity}
996
+ usingTabContainer
997
+ checkValidation={this.state.checkValidation}
998
+ onContextChange={this.handleOnTagsContextChange}
999
+ showModal={this.state.showModal}
1000
+ iframeParent={parent}
1001
+ router={this.props.router}
1002
+ isSchemaChanged={this.state.isSchemaChanged}
1003
+ handleCancelModal={this.handleCancelModal}
1004
+ modal={this.state.modalContent}
1005
+ setModalContent={this.setModalContent}
1006
+ />
1007
+ </Col>
1008
+ </Row>
1009
+ </Spin>
1010
+ </div>
1011
+ );
1012
+ }
1013
+ }
1014
+
1015
+ Edit.propTypes = {
1016
+ actions: PropTypes.object.isRequired,
1017
+ Edit: PropTypes.object,
1018
+ params: PropTypes.object,
1019
+ router: PropTypes.object,
1020
+ location: PropTypes.object,
1021
+ globalActions: PropTypes.object,
1022
+ templatesActions: PropTypes.object,
1023
+ Templates: PropTypes.object,
1024
+ metaEntities: PropTypes.object,
1025
+ templateDetails: PropTypes.object,
1026
+ intl: intlShape.isRequired,
1027
+ templateData: PropTypes.object,
1028
+ getDefaultTags: PropTypes.string,
1029
+ supportedTags: PropTypes.array,
1030
+ injectedTags: PropTypes.object,
1031
+ };
1032
+
1033
+ const mapStateToProps = createStructuredSelector({
1034
+ Edit: makeSelectEdit(),
1035
+ editResponse: makeSelectEditResponse(),
1036
+ templateDetails: makeSelectTemplateDetailsResponse(),
1037
+ metaEntities: makeSelectMetaEntities(),
1038
+ Templates: makeSelectTemplates(),
1039
+ injectedTags: setInjectedTags(),
1040
+ });
1041
+
1042
+ function mapDispatchToProps(dispatch) {
1043
+ return {
1044
+ actions: bindActionCreators(actions, dispatch),
1045
+ globalActions: bindActionCreators(globalActions, dispatch),
1046
+ templatesActions: bindActionCreators(templatesActions, dispatch),
1047
+ };
1048
+ }
1049
+
1050
+ export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(Edit));