@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,1759 @@
1
+ /*
2
+ *
3
+ * Create
4
+ *
5
+ */
6
+
7
+ import PropTypes from 'prop-types';
8
+
9
+ import React from 'react';
10
+ import { connect } from 'react-redux';
11
+ import { bindActionCreators } from 'redux';
12
+ import { notification } from 'antd';
13
+ import {get, set, filter, isEmpty, map, forEach, uniqueId, cloneDeep, isEqual, findIndex} from 'lodash';
14
+ import { createStructuredSelector } from 'reselect';
15
+ import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
16
+ import styled from 'styled-components';
17
+ import { CapSlideBox, CapHeader, CapTable, CapLink, CapRow, CapColumn, CapIcons, CapSpin} from '@capillarytech/cap-ui-library';
18
+ import { makeSelectCreate, makeSelectCreateResponse, makeSelectIosCta } from './selectors';
19
+ import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
20
+ import * as globalActions from '../../../containers/Cap/actions';
21
+ import FormBuilder from '../../../components/FormBuilder';
22
+ import './_mobilePushCreate.scss';
23
+ import * as actions from './actions';
24
+
25
+ import {getMessageObject} from '../../../utils/messageUtils';
26
+ import { makeSelectTemplates } from '../../Templates/selectors';
27
+ import messages from './messages';
28
+ import callNativeEvent from '../../../utils/callNativeEvent';
29
+ import getEventsMap from '../eventsMap';
30
+
31
+ const PrefixWrapper = styled.div`
32
+ margin-right: 16px;
33
+ `;
34
+ export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
35
+ constructor(props) {
36
+ super(props);
37
+ const eventsMap = getEventsMap(this);
38
+ if (this.props.Templates.selectedWeChatAccount) {
39
+ this.state = {
40
+ formData: {},
41
+ tabCount: 1,
42
+ currentTab: 1,
43
+ loading: false,
44
+ isFormValid: true,
45
+ tabKey: '',
46
+ checkValidation: false,
47
+ schema: {},
48
+ eventsMap,
49
+ errorData: {},
50
+ displayProps: {},
51
+ modalContent: {title: "Alert", body: "template not configured,", type: 'confirm'},
52
+ injectedTags: {},
53
+ };
54
+ }
55
+ }
56
+ componentWillMount = () => {
57
+ if (this.props.route.name === 'view') {
58
+ this.setState({loading: false});
59
+ this.removeStandAlone();
60
+ }
61
+ if (this.props.params.mode) {
62
+ this.setState({mode: this.props.params.mode});
63
+ }
64
+ if (!this.props.Templates.selectedWeChatAccount) {
65
+ const type = this.props.location.query.type;
66
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
67
+ this.props.router.push({
68
+ pathname: `/MOBILEPUSH/`,
69
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
70
+ });
71
+ }
72
+ };
73
+
74
+ componentDidMount = () => {
75
+ const query = {
76
+ layout: 'MOBILEPUSH',
77
+ type: 'LAYOUT',
78
+ version: "v2",
79
+ };
80
+ this.props.globalActions.fetchSchemaForEntity(query);
81
+ };
82
+ componentWillReceiveProps = (nextProps) => {
83
+ if (nextProps.isGetFormData && !this.props.isFullMode) {
84
+ nextProps.getFormLibraryData(this.getFormData());
85
+ } else if (nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
86
+ this.startValidation();
87
+ }
88
+ if (nextProps.Create.uploadedAssetData) {
89
+ const formData = cloneDeep(this.state.formData);
90
+ formData[this.state.currentTab - 1].image = nextProps.Create.uploadedAssetData.metaInfo.public_url;
91
+ this.setState({formData});
92
+ this.props.actions.clearAsset();
93
+ }
94
+ if (nextProps.createResponse && nextProps.createResponse.templateId) {
95
+ this.discardValues();
96
+ const message = getMessageObject('success', this.props.intl.formatMessage(messages["Mobile Push Template Created Successfully"]), true);
97
+ this.props.globalActions.addMessageToQueue(message);
98
+ this.props.actions.clearCreateResponse();
99
+ const type = this.props.location.query.type;
100
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
101
+ this.props.router.push({
102
+ pathname: `/mobilepush/`,
103
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
104
+ });
105
+ }
106
+ if (nextProps.params.mode) {
107
+ this.setState({mode: nextProps.params.mode});
108
+ }
109
+ if (nextProps.Create.createTemplateError && !isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
110
+ const message = getMessageObject('error', (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
111
+ this.props.globalActions.addMessageToQueue(message);
112
+ }
113
+ if (nextProps.iosCtasData) {
114
+ this.setState({showIosCtaTable: true});
115
+ }
116
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && isEmpty(this.state.schema)) {
117
+ const schema = this.props.params.mode === "text" ? nextProps.metaEntities.layouts[0].definition.textSchema : nextProps.metaEntities.layouts[0].definition.imageSchema;
118
+ const isAndroidSupported = get(this, "props.Templates.selectedWeChatAccount.configs.android") === '1';
119
+ const isIosSupported = get(this, "props.Templates.selectedWeChatAccount.configs.ios") === '1';
120
+ if (!isAndroidSupported) {
121
+ const androidField = get(schema, "containers[0].panes[0]");
122
+ androidField.isSupported = false;
123
+ this.setState({currentTab: 2});
124
+ set(schema, "containers[0].panes[0]", androidField);
125
+ }
126
+ if (!isIosSupported) {
127
+ const iosField = get(schema, "containers[0].panes[1]");
128
+ iosField.isSupported = false;
129
+
130
+ set(schema, "containers[0].panes[1]", iosField);
131
+ }
132
+ schema.standalone.sections.splice(1, 1);
133
+ this.injectEvents(schema);
134
+ const query = {
135
+ layout: 'mobilepush',
136
+ type: 'TAG',
137
+ context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
138
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
139
+ };
140
+ if (this.props.getDefaultTags) {
141
+ query.context = this.props.getDefaultTags;
142
+ }
143
+ this.props.globalActions.fetchSchemaForEntity(query);
144
+ }
145
+ };
146
+ componentWillUnmount = () => {
147
+ this.props.actions.resetStore();
148
+ window.removeEventListener("message", this.handleFrameTasks);
149
+ };
150
+ onTemplateChange = () => {
151
+
152
+ };
153
+
154
+ onFormDataChange = (formData, tabCount) => {
155
+ const newFormData = cloneDeep(formData);
156
+ const {templateCta} = this.state;
157
+ if (!isEmpty(templateCta)) {
158
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta.name;
159
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta.ctaTemplateDetails[0].buttonText;
160
+ delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
161
+ if (templateCta.ctaTemplateDetails[1]) {
162
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta.ctaTemplateDetails[1].buttonText;
163
+ }
164
+ }
165
+
166
+ // copy content code
167
+ // if (newFormData[0]['copy-iphone-content'] === "") {
168
+ //
169
+ // if(!!formData[1]['message-editor2'] && !!formData[1]['message-title2']){
170
+ // dispplayProps[0]['copy-iphone-content'] = true;
171
+ // }
172
+ // } else {
173
+ // if(formData[1]['message-editor2'] === "" || formData[1]['message-title2'] === ""){
174
+ // newFormData[0]['copy-iphone-content'] = "";
175
+ // }
176
+ // }
177
+ // if (newFormData[1]['copy-android-content'] === "") {
178
+ //
179
+ // if(!!formData[0]['message-editor'] && !!formData[0]['message-title']){
180
+ // newFormData[1]['copy-android-content'] = true;
181
+ // }
182
+ // } else {
183
+ // if(formData[0]['message-editor'] === "" || formData[0]['message-title'] === ""){
184
+ // newFormData[1]['copy-android-content'] = "";
185
+ // }
186
+ // }
187
+ if (this.props.isFullMode && this.props.defaultData && isEmpty(formData['template-name'])) {
188
+ newFormData['template-name'] = get(this.props, "defaultData['template-name']");
189
+ }
190
+ this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged}, () => {
191
+ if (this.props.isFullMode) {
192
+ this.props.showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
193
+ }
194
+ });
195
+ };
196
+
197
+ onTagSelect = (data, currentTab, srcComp) => {
198
+ const editorId = srcComp.target;
199
+ this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
200
+ document.getElementById(editorId).focus();
201
+ };
202
+
203
+ onTabChange = (data) => {
204
+ this.setState({currentTab: data});
205
+ };
206
+ onTemplateNameChange = () => {
207
+ // console.log('Template name changed to ', name);
208
+ };
209
+
210
+
211
+ onLinkTypeChange = (eventTriggered, formData, field) => {
212
+ let schema = cloneDeep(this.state.schema);
213
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
214
+ forEach(inputFields, (inputField, fieldIndex) => {
215
+ if (inputField) {
216
+ forEach(inputField.cols, (col) => {
217
+ if (col.id === field.id) {
218
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
219
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
220
+ const deeplinkValue = formData[this.state.currentTab - 1][field.id];
221
+ const componentIndex = fieldIndex + 1;
222
+ const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
223
+ if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === inputFields.length - 1 || inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
224
+ const row = {
225
+ rowClassName: 'mobile-push-row',
226
+ id: 'cta-deeplink-select-section',
227
+ cols: [
228
+
229
+ {
230
+ id: inputId,
231
+ placeholder: "Select DeepLink",
232
+ type: "select", //Resembles component to be used
233
+ options: deepLinkOptions,
234
+ metaType: "text",
235
+ datatype: "string",
236
+ errorMessage: "Select a deeplink",
237
+ required: true,
238
+ fluid: true,
239
+ width: 18,
240
+ offset: 1,
241
+ style: {
242
+ width: '100%',
243
+
244
+ marginBottom: '16px',
245
+ },
246
+ styling: "semantic",
247
+ order: 1,
248
+ customComponent: false,
249
+ supportedEvents: [
250
+ 'onSelect',
251
+ ],
252
+ },
253
+ ],
254
+ };
255
+ if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-external-link") {
256
+ inputFields[componentIndex] = row;
257
+ } else {
258
+ inputFields.splice(componentIndex, 0, row);
259
+ }
260
+ } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
261
+ const row = {
262
+ rowClassName: 'mobile-push-row',
263
+ id: 'cta-external-link',
264
+ cols: [
265
+
266
+ {
267
+ id: inputId,
268
+ placeholder: "External Link",
269
+ type: "input", //Resembles component to be used
270
+ metaType: "text",
271
+ datatype: "string",
272
+ errorMessage: "External Link cannot be empty",
273
+ required: true,
274
+ fluid: true,
275
+ width: 18,
276
+ offset: 1,
277
+ style: {
278
+ width: '100%',
279
+
280
+ marginBottom: '16px',
281
+ },
282
+ styling: "semantic",
283
+ order: 1,
284
+ customComponent: false,
285
+ standalone: false,
286
+ },
287
+ ],
288
+ };
289
+ if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-deeplink-select-section") {
290
+ inputFields[componentIndex] = row;
291
+ if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
292
+ inputFields.splice(componentIndex + 1, 1);
293
+ }
294
+ if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
295
+ let configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][`${col.id}-select`]);
296
+ if (configkeys[0]) {
297
+ configkeys = configkeys[0].keys;
298
+ }
299
+ if (configkeys.length) {
300
+ //inputFields = inputFields.slice(0, componentIndex + 1).concat(inputFields.slice( componentIndex + 1 + configkeys.length, inputFields.length));
301
+
302
+ inputFields.splice(componentIndex + 1, configkeys.length);
303
+ }
304
+ }
305
+ } else {
306
+ inputFields.splice(componentIndex, 0, row);
307
+ }
308
+ }
309
+ }
310
+ });
311
+ }
312
+ });
313
+ schema = set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
314
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
315
+ this.injectEvents(schema);
316
+ };
317
+ onTemplateContentChange = () => {
318
+
319
+ };
320
+ onModalCancel = () => {
321
+ if (this.state.modalContent && this.state.modalContent.show) {
322
+ this.setState({modalContent: {...this.state.modalContent, show: false}});
323
+ }
324
+ };
325
+ getLinkName = (link) => {
326
+ const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
327
+ const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
328
+ const deepLinkOptions = filter(JSON.parse(deeplinks), (l) => l.link === link);
329
+ if (deepLinkOptions[0]) {
330
+ return deepLinkOptions[0].name;
331
+ }
332
+ return undefined;
333
+ };
334
+
335
+ getMappedEvent = (id, event) => {
336
+ const eventsMap = this.state.eventsMap;
337
+ return eventsMap[id][event];
338
+ };
339
+ getCurrentWindow = (e) => {
340
+ const response = {
341
+ action: e.action,
342
+ value: 'edit',
343
+ direction: e.value,
344
+ };
345
+ parent.postMessage(JSON.stringify(response), '*');
346
+ };
347
+ getFormData = (e) => {
348
+ const templateData = this.getTransformedData(this.state.formData);
349
+ const response = {
350
+ action: "getFormData",
351
+ value: templateData,
352
+ validity: this.state.isFormValid,
353
+ type: templateData.type,
354
+ };
355
+ this.setState({checkValidation: true});
356
+ if (e) {
357
+ e.source.postMessage(JSON.stringify(response), e.origin);
358
+ }
359
+ return response;
360
+ };
361
+ setFormValidity = (isFormValid) => {
362
+ this.setState({isFormValid});
363
+ };
364
+ getTransformedData = (formData) => {
365
+ const obj = {};
366
+ obj.versions = {
367
+ base: {},
368
+ };
369
+ obj.type = 'MOBILEPUSH';
370
+ obj.name = formData['template-name'];
371
+ obj.definition = {
372
+ accountId: this.props.Templates.selectedWeChatAccount.id,
373
+ mode: this.props.params.mode,
374
+ };
375
+ const android = {};
376
+ Object.keys(formData[0]).forEach((data) => {
377
+ if (!!formData[0][data] && data !== "tabKey") {
378
+ android[data] = formData[0][data];
379
+ }
380
+ });
381
+ const ios = {};
382
+ Object.keys(formData[1]).forEach((data) => {
383
+ if (!!formData[1][data] && data !== "tabKey") {
384
+ ios[data] = formData[1][data];
385
+ }
386
+ });
387
+ obj.versions.base = {};
388
+ delete android.base;
389
+ if (!isEmpty(android)) {
390
+ obj.versions.base.ANDROID = {
391
+ luid: "{{luid}}",
392
+ cuid: "{{cuid}}",
393
+ communicationId: "{{communicationId}}",
394
+ title: android['message-title'],
395
+ message: android['message-editor'],
396
+ expandableDetails: {
397
+ style: "BIG_TEXT",
398
+ message: android['message-editor'],
399
+ },
400
+ custom: map(android, (field, key) => {
401
+ if (key.indexOf('custom-value') > -1) {
402
+ 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;
403
+ }
404
+ return undefined;
405
+ }).filter((custom) => custom),
406
+ };
407
+ obj.name = isEmpty(obj.name) ? android['message-title'] : obj.name;
408
+ }
409
+ if (android['cta-deeplink'] && android['cta-deeplink'] !== "") {
410
+ obj.versions.base.ANDROID.cta = {
411
+ type: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
412
+ actionLink: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? android['cta-deeplink-select'] : android['cta-deeplink-text'],
413
+ deepLinkName: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? this.getLinkName(android['cta-deeplink-select']) : undefined,
414
+ };
415
+ if (this.props.location.query.type === 'embedded') {
416
+ delete obj.versions.base.ANDROID.cta.deepLinkName;
417
+ }
418
+ }
419
+ if (!isEmpty(ios)) {
420
+ obj.versions.base.IOS = {
421
+ luid: "{{luid}}",
422
+ cuid: "{{cuid}}",
423
+ communicationId: "{{communicationId}}",
424
+ title: ios['message-title2'],
425
+ message: ios['message-editor2'],
426
+ expandableDetails: {
427
+ style: "BIG_TEXT",
428
+ message: ios['message-title2'],
429
+ ctas: [
430
+ ],
431
+ categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
432
+ },
433
+ custom: map(ios, (field, key) => {
434
+ if (key.indexOf('custom-value') > -1) {
435
+ 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;
436
+ }
437
+ return undefined;
438
+ }).filter((custom) => custom),
439
+ };
440
+ obj.name = isEmpty(obj.name) ? ios['message-title2'] : obj.name;
441
+ }
442
+ if (ios['cta-deeplink2'] && ios['cta-deeplink2'] !== "") {
443
+ obj.versions.base.IOS.cta = {
444
+ type: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
445
+ actionLink: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? ios['cta-deeplink2-select'] : ios['cta-deeplink2-text'],
446
+ deepLinkName: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? this.getLinkName(ios['cta-deeplink2-select']) : undefined,
447
+ };
448
+ if (this.props.location.query.type === 'embedded') {
449
+ delete obj.versions.base.IOS.cta.deepLinkName;
450
+ }
451
+ }
452
+ if (obj.versions.base.ANDROID) {
453
+ if (obj.versions.base.ANDROID.cta && obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
454
+ const params = map(android, (field, key) => {
455
+ let actionLink;
456
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
457
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
458
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
459
+ }
460
+ return actionLink;
461
+ }).filter((actionLink) => actionLink);
462
+ if (params.length) {
463
+ obj.versions.base.ANDROID.cta.actionLink = `${obj.versions.base.ANDROID.cta.actionLink}?${params.join('&')}`;
464
+ }
465
+ }
466
+ const secondaryCta1 = !!android["cta-deeplink-secondary-cta-0-select"] || !!android['secondary-cta-0-label'];
467
+ const secondaryCta2 = !!android['cta-deeplink-secondary-cta-1-select'] || !!android['secondary-cta-1-label'];
468
+ const imageLink = android.image;
469
+ if (imageLink) {
470
+ obj.versions.base.ANDROID.expandableDetails.image = imageLink;
471
+ obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
472
+ }
473
+ if (secondaryCta1 || secondaryCta2 ) {
474
+ obj.versions.base.ANDROID.expandableDetails.ctas = [];
475
+ if (secondaryCta1) {
476
+ const cta = {
477
+ actionText: android['secondary-cta-0-label'],
478
+ type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
479
+ actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
480
+ seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
481
+ };
482
+ if (this.props.location.query.type === 'embedded') {
483
+ delete cta.seccdeepLinkName;
484
+ }
485
+ obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
486
+ if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
487
+ const params = map(android, (field, key) => {
488
+ let actionLink;
489
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
490
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
491
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
492
+ }
493
+ return actionLink;
494
+ }).filter((actionLink) => actionLink);
495
+ if (params.length) {
496
+ 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('&')}`;
497
+ }
498
+ }
499
+ }
500
+ if (secondaryCta2) {
501
+ const cta = {
502
+ actionText: android['secondary-cta-1-label'],
503
+ type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
504
+ actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
505
+ seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
506
+ };
507
+ if (this.props.location.query.type === 'embedded') {
508
+ delete cta.seccdeepLinkName;
509
+ }
510
+ obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
511
+ if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
512
+ const params = map(android, (field, key) => {
513
+ let actionLink;
514
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
515
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
516
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
517
+ }
518
+ return actionLink;
519
+ }).filter((actionLink) => actionLink);
520
+ if (params.length) {
521
+ 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('&')}`;
522
+ }
523
+ }
524
+ }
525
+ }
526
+ }
527
+ if (obj.versions.base.IOS) {
528
+ if (obj.versions.base.IOS.cta && obj.versions.base.IOS.cta.type === "DEEP_LINK") {
529
+ const params = map(ios, (field, key) => {
530
+ let actionLink;
531
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
532
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
533
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
534
+ }
535
+ return actionLink;
536
+ }).filter((actionLink) => actionLink);
537
+ if (params.length) {
538
+ obj.versions.base.IOS.cta.actionLink = `${obj.versions.base.IOS.cta.actionLink}?${params.join('&')}`;
539
+ }
540
+ }
541
+ const imageLinkIos = ios.image;
542
+ const secondaryCtaIos = !!ios['cta-deeplink-secondary-cta-1-select'] || !!ios['secondary-cta-1-label'];
543
+ if (imageLinkIos) {
544
+ obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
545
+ obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
546
+ }
547
+ if (secondaryCtaIos) {
548
+ obj.versions.base.IOS.expandableDetails.ctas = [];
549
+ const templateCtaId = get(this.state, "templateCta.ctaTemplateDetails[0].id");
550
+ const cta = {
551
+ actionText: ios['secondary-cta-1-label'],
552
+ actionLabel: ios['secondary-cta-1-action'],
553
+ actionLabel2: ios['secondary-cta-1-action2'],
554
+ type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
555
+ 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-select']) : ios['cta-deeplink-secondary-cta-1-text']),
556
+ ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
557
+ templateCtaId,
558
+ };
559
+ if (this.props.location.query.type === 'embedded') {
560
+ delete cta.ioscdeepLinkName;
561
+ }
562
+ obj.versions.base.IOS.expandableDetails.ctas.push(cta);
563
+ if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
564
+ const params = map(ios, (field, key) => {
565
+ let actionLink;
566
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
567
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
568
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
569
+ }
570
+ return actionLink;
571
+ }).filter((actionLink) => actionLink);
572
+ if (params.length) {
573
+ 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('&')}`;
574
+ }
575
+ }
576
+ }
577
+ }
578
+ return obj;
579
+ };
580
+
581
+ setModalContent = (type) => {
582
+ if (type === 'ios') {
583
+ const modalContent = {
584
+ title: "Alert",
585
+ body: "Android template is not configured. Save without Android template",
586
+ type: 'confirm',
587
+ id: 'ios',
588
+ };
589
+ this.setState({modalContent, showModal: true});
590
+ } else if (type === 'android') {
591
+ const modalContent = {
592
+ title: "Alert",
593
+ body: "IOS template is not configured, Save without IOS template",
594
+ type: 'confirm',
595
+ id: 'android',
596
+ };
597
+ this.setState({modalContent, showModal: true});
598
+ }
599
+ }
600
+ stopValidation = () => {
601
+ this.setState({startValidation: false});
602
+ }
603
+ startValidation = () => {
604
+ this.setState({startValidation: true});
605
+ }
606
+ openNotificationWithIcon = (type, message) => {
607
+ const dur = (type === 'error' || type === 'warning') ? null : 5;
608
+ notification[type]({
609
+ message: (`${type.toUpperCase()} ! ! ! `),
610
+ description: message, //'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
611
+ duration: dur,
612
+ });
613
+ }
614
+
615
+ handleCancelModal = () => {
616
+ this.setState({showModal: false});
617
+ };
618
+
619
+ moveToTemplates = () => {
620
+ const modalContent = {
621
+ title: "Alert",
622
+ body: this.props.intl.formatMessage(messages["Do you really want to go back? All your temporary changes will be lost!"]),
623
+ type: 'confirm',
624
+ id: 'template-back-confirm-modal',
625
+ show: true,
626
+ };
627
+ this.setState({modalContent, showModal: true});
628
+ };
629
+
630
+ cancelTemplate = () => {
631
+ const type = this.props.location.query.type;
632
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
633
+ this.props.router.push({
634
+ pathname: `/MOBILEPUSH/`,
635
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
636
+ });
637
+ };
638
+
639
+ injectEvents = (schema) => {
640
+ const temp = schema;
641
+ if (temp.standalone) {
642
+ temp.standalone.sections = this.injectSections(temp.standalone.sections);
643
+ }
644
+ forEach(temp.containers, (container) => {
645
+ let tempContainer = container;
646
+ tempContainer = this.injectContainer(tempContainer);
647
+ return tempContainer;
648
+ });
649
+
650
+ this.setState({schema, isSchemaChanged: true}, () => {
651
+ this.removeStandAlone();
652
+ });
653
+ return schema;
654
+ };
655
+
656
+ injectContainer = (container) => {
657
+ const temp = container;
658
+ if (temp.type === 'tabs') {
659
+ temp.injectedEvents = {};
660
+ forEach(temp.supportedEvents, (event) => {
661
+ temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
662
+ });
663
+ forEach(temp.panes, (pane) => {
664
+ const tempPane = pane;
665
+ tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
666
+ tempPane.sections = this.injectSections(tempPane.sections);
667
+ });
668
+ }
669
+ return temp;
670
+ };
671
+
672
+ injectMultiColSection = (section) => {
673
+ forEach(section.inputFields, (inputField) => {
674
+ forEach(inputField.cols, (col) => {
675
+ const temp = col;
676
+ if (temp.type === 'popover') {
677
+ temp.content.sections = this.injectSections(temp.content.sections);
678
+ temp.value.sections = this.injectSections(temp.value.sections);
679
+ return true;
680
+ }
681
+ if (temp.id === "discard-button") {
682
+ temp.colStyle = {...temp.colStyle, display: 'none'};
683
+ }
684
+ if (temp.id === "cancel-button") {
685
+ temp.offset = 11;
686
+ }
687
+ if (temp.id === "mobile-push-preview") {
688
+ temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
689
+ }
690
+ temp.injectedEvents = {};
691
+
692
+ forEach(col.supportedEvents, (event) => {
693
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
694
+ });
695
+ return true;
696
+ });
697
+ });
698
+ forEach(section.actionFields, (actionField) => {
699
+ forEach(actionField.cols, (col) => {
700
+ const temp = col;
701
+ if (temp.type === 'popover') {
702
+ temp.content.sections = this.injectSections(temp.content.sections);
703
+ temp.value.sections = this.injectSections(temp.value.sections);
704
+ return true;
705
+ }
706
+ temp.injectedEvents = {};
707
+ forEach(col.supportedEvents, (event) => {
708
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
709
+ });
710
+ return true;
711
+ });
712
+ });
713
+ return section;
714
+ };
715
+
716
+ injectColLabelSection = (section) => {
717
+ forEach(section.inputFields, (inputField) => {
718
+ const temp = inputField;
719
+ if (temp.type === 'popover') {
720
+ temp.content.sections = this.injectSections(temp.content.sections);
721
+ temp.value.sections = this.injectSections(temp.value.sections);
722
+ return true;
723
+ }
724
+ temp.injectedEvents = {};
725
+ forEach(inputField.supportedEvents, (event) => {
726
+ temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
727
+ });
728
+ return true;
729
+ });
730
+ forEach(section.actionFields, (actionField) => {
731
+ const temp = actionField;
732
+ if (temp.type === 'popover') {
733
+ temp.content.sections = this.injectSections(temp.content.sections);
734
+ temp.value.sections = this.injectSections(temp.value.sections);
735
+ return true;
736
+ }
737
+ temp.injectedEvents = {};
738
+ forEach(actionField.supportedEvents, (event) => {
739
+ temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
740
+ });
741
+ return true;
742
+ });
743
+ return section;
744
+ };
745
+
746
+ injectSections = (sections) => {
747
+ forEach(sections, (section) => {
748
+ let temp = section;
749
+ if (temp.type === 'col-label') {
750
+ temp = this.injectColLabelSection(temp);
751
+ } else if (section.type === 'multicols') {
752
+ temp = this.injectMultiColSection(temp);
753
+ } else if (section.type === 'parent') {
754
+ temp = this.injectSections(temp.childSections);
755
+ }
756
+ });
757
+ return sections;
758
+ };
759
+
760
+ injectParentSection = (section) => {
761
+ forEach(section.childSections, (childSection) => {
762
+ let temp = childSection;
763
+ if (temp.type === 'col-label') {
764
+ temp = this.injectColLabelSection(temp);
765
+ } else if (section.type === 'multicols') {
766
+ temp = this.injectMultiColSection(temp);
767
+ } else if (section.type === 'parent') {
768
+ temp = this.injectParentSection(temp);
769
+ }
770
+ });
771
+ return section;
772
+ };
773
+ insertAtCursor = (field, myValue) => {
774
+ //IE support
775
+ const myField = field;
776
+ if (document.selection) {
777
+ myField.focus();
778
+ const sel = document.selection.createRange();
779
+ sel.text = myValue;
780
+ } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
781
+ const startPos = myField.selectionStart;
782
+ const endPos = myField.selectionEnd;
783
+ myField.value = myField.value.substring(0, startPos)
784
+ + myValue
785
+ + myField.value.substring(endPos, myField.value.length);
786
+ myField.selectionStart = startPos + myValue.length;
787
+ myField.selectionEnd = startPos + myValue.length;
788
+ } else {
789
+ myField.value += myValue;
790
+ }
791
+ const event = new Event('input', { bubbles: true });
792
+ callNativeEvent({field, value: myField.value, event});
793
+ };
794
+
795
+ startTemplateCreation = (data) => {
796
+ const content = data.content;
797
+ const id = uniqueId();
798
+ const tempData = {
799
+ 'message-editor': content,
800
+ 'base': true,
801
+ 'tabKey': id,
802
+ };
803
+ const formData = {};
804
+ formData[0] = tempData;
805
+ formData.base = tempData;
806
+ this.setState({formData, loading: false});
807
+ if (data.tags) {
808
+ this.props.globalActions.setInjectedTags(data.tags);
809
+ }
810
+ };
811
+
812
+ startLoading = (ifEdit) => {
813
+ if (ifEdit) {
814
+ this.setState({loading: true});
815
+ }
816
+ };
817
+
818
+ handleFrameTasks = (e) => {
819
+ const type = e.data;
820
+
821
+ if (typeof type === 'object') {
822
+ const action = type.action;
823
+ switch (action) {
824
+ case "startTemplateCreation":
825
+ this.startTemplateCreation(type.value);
826
+ break;
827
+ case "startLoading":
828
+ this.startLoading(type.edit);
829
+ break;
830
+ case "getCurrentWindow":
831
+ this.getCurrentWindow(type);
832
+ break;
833
+ default:
834
+ break;
835
+ }
836
+ } else {
837
+ switch (type) {
838
+ case "getFormData":
839
+ this.getFormData(e);
840
+ break;
841
+ case "startTemplateCreation":
842
+
843
+ //this.getFormData(e);
844
+ break;
845
+ case "moveToTemplates":
846
+
847
+ this.moveToTemplates();
848
+ break;
849
+ case "validateContent":
850
+
851
+ this.validateContent(e);
852
+ break;
853
+ default:
854
+ break;
855
+ }
856
+ }
857
+ };
858
+
859
+ removeStandAlone = () => {
860
+ const schema = cloneDeep(this.state.schema);
861
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
862
+ schema.standalone.sections.splice(0, 1);
863
+ } else if ((this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') || this.props.isFullMode) {
864
+ delete schema.standalone;
865
+ } else {
866
+ schema.standalone.sections.splice(1, 1);
867
+ }
868
+ this.setState({ schema });
869
+ };
870
+
871
+ validateContent = (e) => {
872
+ const response = {
873
+ action: "validateContent",
874
+ value: this.state.isFormValid,
875
+ };
876
+ e.source.postMessage(JSON.stringify(response), e.origin);
877
+ };
878
+
879
+ discardValues = () => {
880
+ this.resetSchema();
881
+ this.resetState();
882
+ };
883
+
884
+ resetState = () => {
885
+ this.setState({
886
+ formData: {},
887
+ tabCount: 1,
888
+ currentTab: 1,
889
+ });
890
+ };
891
+ resetSchema = () => {
892
+ this.setState({ schema: this.state.initialState ? this.state.initialState : this.state.schema});
893
+ };
894
+ showNext = () => {
895
+ const response = {
896
+ action: "showNext",
897
+ value: true,
898
+ };
899
+ parent.postMessage(JSON.stringify(response), '*');
900
+ };
901
+ copyContent = () => {
902
+
903
+ };
904
+ addSecondoryCtaIos = (flag, formData, schemaField) => {
905
+ const id = schemaField.id;
906
+ if (formData[this.state.currentTab - 1][id]) {
907
+ if (!this.props.iosCtasData) {
908
+ this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
909
+ } else {
910
+ this.deleteSecondaryCtaIos(() => { // oncick of change
911
+ this.setState({showIosCtaTable: true});
912
+ });
913
+ }
914
+ } else {
915
+ const schema = cloneDeep(this.state.schema);
916
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
917
+ forEach(inputFields, (inputField, fieldIndex) => {
918
+ forEach(inputField.cols, (col) => {
919
+ if (col.id === id) {
920
+ const indexOfNextField = inputFields.length;
921
+ const deleteCount = indexOfNextField - fieldIndex;
922
+ const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputField.length)];
923
+ set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
924
+ this.setState({schema});
925
+ }
926
+ });
927
+ });
928
+ }
929
+ };
930
+ showSelectedIosCta = (selectedConfig) => {
931
+ const currentTab = this.state.currentTab;
932
+ const schema = cloneDeep(this.state.schema);
933
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
934
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
935
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
936
+ forEach(inputFields, (inputField, fieldIndex) => {
937
+ forEach(inputField.cols, (col) => {
938
+ if (col.id === "add-sec-cta-ios") {
939
+ const inputId = `secondary-cta-${currentTab - 1}`;
940
+
941
+ inputFields.splice(fieldIndex + 1, 0, {
942
+ rowClassName: 'mobile-push-row',
943
+ cols: [
944
+ {
945
+ id: `${inputId}-action-display`,
946
+ metaType: "label",
947
+ value: <CapRow>
948
+ <CapColumn span={18}>
949
+ <CapHeader
950
+ title={this.state.templateCta.name}
951
+ description={get(this.state, "templateCta.ctaTemplateDetails[0].buttonText")}
952
+ size={"label"}/>
953
+ </CapColumn>
954
+ <CapColumn span={6}>
955
+ <CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
956
+ </CapColumn>
957
+ </CapRow>,
958
+ primitive: true,
959
+ dynamicTab: false,
960
+ type: "div",
961
+ width: 18,
962
+ offset: 1,
963
+ },
964
+ {
965
+ id: `${inputId}-action`,
966
+ metaType: "label",
967
+ value: "",
968
+ primitive: true,
969
+ dynamicTab: false,
970
+ type: "div",
971
+ width: 8,
972
+ offset: 0,
973
+ style: {
974
+ display: 'none',
975
+ },
976
+ },
977
+ {
978
+ id: `${inputId}-action2`,
979
+ metaType: "label",
980
+ value: "",
981
+ primitive: true,
982
+ dynamicTab: false,
983
+ type: "div",
984
+ width: 8,
985
+ offset: 0,
986
+ style: {display: 'none'},
987
+ },
988
+
989
+ ],
990
+ });
991
+ if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
992
+ inputFields.splice(fieldIndex + 2, 0, {
993
+ rowClassName: "mobile-push-row",
994
+ cols: [
995
+
996
+ {
997
+ id: `cta-deeplink-${inputId}`,
998
+ type: "radioGroup", //Resembles component to be used
999
+ metaType: "text",
1000
+ datatype: "string",
1001
+ options: ["Deeplink", "External Link"],
1002
+ inductiveText: ["A page within mobile app", "An external web page"],
1003
+ value: "Deeplink",
1004
+ required: true,
1005
+ width: 18,
1006
+ offset: 1,
1007
+ errorMessage: "Please select link type",
1008
+ fluid: true,
1009
+
1010
+ styling: "semantic",
1011
+ order: 1,
1012
+ supportedEvents: ["onChange"],
1013
+ customComponent: false,
1014
+ },
1015
+ ],
1016
+ });
1017
+ inputFields.splice(fieldIndex + 3, 0, {
1018
+ rowClassName: 'mobile-push-row',
1019
+ id: 'cta-deeplink-select-section',
1020
+ cols: [
1021
+
1022
+ {
1023
+ id: `cta-deeplink-${inputId}-select2`,
1024
+ placeholder: "Select DeepLink",
1025
+ type: "select", //Resembles component to be used
1026
+ options: deepLinkOptions,
1027
+ metaType: "text",
1028
+ datatype: "string",
1029
+ errorMessage: "Select a deeplink",
1030
+ required: true,
1031
+ fluid: true,
1032
+ width: 18,
1033
+ offset: 1,
1034
+ style: {
1035
+ width: '100%',
1036
+ marginBottom: '16px',
1037
+ },
1038
+ styling: "semantic",
1039
+ order: 1,
1040
+ customComponent: false,
1041
+ supportedEvents: [
1042
+ 'onSelect',
1043
+ ],
1044
+ },
1045
+ ],
1046
+ });
1047
+ }
1048
+ }
1049
+ });
1050
+ });
1051
+ // set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
1052
+
1053
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1054
+ this.injectEvents(schema);
1055
+ };
1056
+ addPrimaryCta = (flag, formData, schemaField) => {
1057
+ const id = schemaField.id;
1058
+ const schema = cloneDeep(this.state.schema);
1059
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1060
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1061
+ // const eventsMap = cloneDeep(this.state.eventsMap);
1062
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1063
+ forEach(inputFields, (inputField, fieldIndex) => {
1064
+ forEach(inputField.cols, (col) => {
1065
+ const colId = col.id;
1066
+ if (colId === id) {
1067
+ if (formData[this.state.currentTab - 1][id]) { // add primary cta
1068
+ inputFields.splice(fieldIndex + 1, 0, {
1069
+ rowClassName: 'mobile-push-row',
1070
+ cols: [
1071
+ {
1072
+ id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}`,
1073
+ type: "radioGroup", //Resembles component to be used
1074
+ metaType: "text",
1075
+ datatype: "string",
1076
+ options: ["Deeplink", "External Link"],
1077
+ inductiveText: ["A page within mobile app", "An external web page"],
1078
+ value: "Deeplink",
1079
+ required: true,
1080
+ width: 18,
1081
+ offset: 1,
1082
+ errorMessage: "Please select link type",
1083
+ fluid: true,
1084
+ styling: "semantic",
1085
+ order: 1,
1086
+ customComponent: false,
1087
+ supportedEvents: ["onChange"],
1088
+ },
1089
+
1090
+ ],
1091
+ });
1092
+ inputFields.splice(fieldIndex + 2, 0, {
1093
+ rowClassName: 'mobile-push-row',
1094
+ id: 'cta-deeplink-select-section',
1095
+ cols: [
1096
+
1097
+ {
1098
+ id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-select`,
1099
+ placeholder: "Select DeepLink",
1100
+ type: "select", //Resembles component to be used
1101
+ options: deepLinkOptions,
1102
+ metaType: "text",
1103
+ datatype: "string",
1104
+ required: true,
1105
+ errorMessage: "Select a deeplink",
1106
+ fluid: true,
1107
+ width: 18,
1108
+ offset: 1,
1109
+ style: {
1110
+ width: '100%',
1111
+
1112
+
1113
+ marginBottom: '16px',
1114
+ },
1115
+ styling: "semantic",
1116
+ order: 1,
1117
+ customComponent: false,
1118
+ supportedEvents: [
1119
+ 'onSelect',
1120
+ ],
1121
+ },
1122
+ ],
1123
+ });
1124
+ } else { // remove existing primary cta cuz primary cta is unchecked
1125
+ const identifier = (this.state.currentTab - 1) ? 'add-sec-cta-ios' : 'add-sec-cta';
1126
+ const indexOfNextField = findIndex(inputFields, {identifier});
1127
+ const deleteCount = indexOfNextField - fieldIndex;
1128
+ const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1129
+ set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1130
+ }
1131
+ }
1132
+ });
1133
+ });
1134
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true, formData}, () => this.injectEvents(schema));
1135
+ };
1136
+ addSecondoryCta = (flag, formData, schemaField) => {
1137
+ const id = schemaField.id;
1138
+ const schema = cloneDeep(this.state.schema);
1139
+ const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
1140
+ const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1141
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1142
+ // const eventsMap = cloneDeep(this.state.eventsMap);
1143
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1144
+ forEach(inputFields, (inputField, fieldIndex) => {
1145
+ forEach(inputField.cols, (col) => {
1146
+ if (col.id === id) {
1147
+ if (formData[this.state.currentTab - 1][id]) {
1148
+ const inputId = `secondary-cta-${col.fieldsCount}`;
1149
+ inputFields.splice(fieldIndex + 1, 0, {
1150
+ rowClassName: 'mobile-push-row',
1151
+ cols: [
1152
+
1153
+ {
1154
+ id: `${inputId}-label`,
1155
+ label: "Button label",
1156
+ type: "input", //Resembles component to be used
1157
+ metaType: "text",
1158
+ datatype: "string",
1159
+ required: true,
1160
+ width: 18,
1161
+ offset: 1,
1162
+ placeholder: "Enter CTA Label here",
1163
+ fluid: true,
1164
+ styling: "semantic",
1165
+ order: 1,
1166
+ customComponent: false,
1167
+ errorMessage: "CTA label cannot be empty.",
1168
+ },
1169
+
1170
+ ],
1171
+ });
1172
+ inputFields.splice(fieldIndex + 2, 0, {
1173
+ rowClassName: 'mobile-push-row',
1174
+ cols: [
1175
+
1176
+ {
1177
+ id: `cta-deeplink-${inputId}`,
1178
+ type: "radioGroup", //Resembles component to be used
1179
+ metaType: "text",
1180
+ datatype: "string",
1181
+ options: ["Deeplink", "External Link"],
1182
+ inductiveText: ["A page within mobile app", "An external web page"],
1183
+ value: "Deeplink",
1184
+ required: true,
1185
+ width: 18,
1186
+ offset: 1,
1187
+ errorMessage: "Please select link type",
1188
+ fluid: true,
1189
+ styling: "semantic",
1190
+ order: 1,
1191
+
1192
+ customComponent: false,
1193
+ supportedEvents: ["onChange"],
1194
+ },
1195
+ ],
1196
+ });
1197
+ inputFields.splice(fieldIndex + 3, 0, {
1198
+ rowClassName: 'mobile-push-row',
1199
+ id: 'cta-deeplink-select-section',
1200
+ cols: [
1201
+
1202
+
1203
+ {
1204
+ id: `cta-deeplink-${inputId}-select`,
1205
+ placeholder: "Select DeepLink",
1206
+ type: "select", //Resembles component to be used
1207
+ options: deepLinkOptions,
1208
+ errorMessage: "Select a deeplink",
1209
+ metaType: "text",
1210
+ datatype: "string",
1211
+ required: true,
1212
+ fluid: true,
1213
+ width: 18,
1214
+ offset: 1,
1215
+ style: {
1216
+ width: '100%',
1217
+ marginBottom: '16px',
1218
+ },
1219
+ styling: "semantic",
1220
+ order: 1,
1221
+ customComponent: false,
1222
+ supportedEvents: [
1223
+ 'onSelect',
1224
+ ],
1225
+ },
1226
+ ],
1227
+ });
1228
+
1229
+ // eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
1230
+ } else {
1231
+ const identifier = id === "add-sec-cta" ? 'add-sec-cta-2' : null;
1232
+ const indexOfNextField = identifier ? findIndex(inputFields, {identifier}) : inputFields.length;
1233
+ const deleteCount = indexOfNextField - fieldIndex;
1234
+ const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1235
+ set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1236
+ }
1237
+ }
1238
+ });
1239
+ });
1240
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, () => { this.injectEvents(schema); });
1241
+ };
1242
+ copyIphoneContent = () => {
1243
+ const formData = cloneDeep(this.state.formData);
1244
+ if (!!formData[1]['message-title2'] && !!formData[1]['message-editor2']) {
1245
+ formData[0]['message-title'] = formData[1]['message-title2'];
1246
+ formData[0]['message-editor'] = formData[1]['message-editor2'];
1247
+ this.setState({formData});
1248
+ } else {
1249
+ this.openNotificationWithIcon('warning', "Cannot copy empty field values.");
1250
+ }
1251
+ };
1252
+ copyAndroidContent = () => {
1253
+ const formData = cloneDeep(this.state.formData);
1254
+ if (!!formData[0]['message-title'] && !!formData[0]['message-editor']) {
1255
+ formData[1]['message-title2'] = formData[0]['message-title'];
1256
+ formData[1]['message-editor2'] = formData[0]['message-editor'];
1257
+ this.setState({formData});
1258
+ } else {
1259
+ this.openNotificationWithIcon('warning', "Cannot copy empty field values.");
1260
+ }
1261
+ };
1262
+ uploadImage = (data) => {
1263
+ if (data.fileParams.error) {
1264
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages["File size cannot be more than 5mb"]), true);
1265
+ this.props.globalActions.addMessageToQueue(message);
1266
+ } else {
1267
+ const name = data.file.name.split('.');
1268
+ const blob = data.file.slice(0, -1, 'image');
1269
+ const newFile = new File([blob], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
1270
+ this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
1271
+ }
1272
+ };
1273
+ selectCtaIos = (selectedConfig) => {
1274
+ this.showSelectedIosCta(selectedConfig);
1275
+ };
1276
+
1277
+ showCtaKeys = (eventTriggered, formData, field) => {
1278
+ const schema = cloneDeep(this.state.schema);
1279
+ const eventsMap = cloneDeep(this.state.eventsMap);
1280
+ forEach(schema.containers, (container) => {
1281
+ forEach(container.panes, (pane) => {
1282
+ forEach(pane.sections, (section) => {
1283
+ forEach(section.childSections, (childeSection) => {
1284
+ forEach(childeSection.childSections, (child) => {
1285
+ const formChaild = child;
1286
+ if (child.type === 'multicols') {
1287
+ forEach(child.inputFields, (inputField, fieldIndex) => {
1288
+ forEach(inputField.cols, (col) => {
1289
+ if (col.id === field.id) {
1290
+ const formDataKey = col.id.replace("-show-keys", "");
1291
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1292
+ let keys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][formDataKey]) : [];
1293
+ if (keys[0]) {
1294
+ keys = keys[0].keys;
1295
+ }
1296
+ let rows = map(keys, (key) => {
1297
+ const row = {
1298
+ rowClassName: 'mobile-push-row',
1299
+ id: 'cta-deeplink-keys',
1300
+ cols: [
1301
+
1302
+
1303
+ {
1304
+ id: `custom-value-${key}-${col.id}`,
1305
+ label: key.replace('_', " "),
1306
+ type: "input", //Resembles component to be used
1307
+ metaType: "text",
1308
+ datatype: "string",
1309
+ required: true,
1310
+ width: 18,
1311
+ offset: 1,
1312
+ placeholder: `Please input ${key.replace('_', " ")} here .`,
1313
+ fluid: true,
1314
+ styling: "semantic",
1315
+ order: 1,
1316
+ customComponent: false,
1317
+ errorMessage: "value cannot be empty.",
1318
+ },
1319
+ ],
1320
+ };
1321
+ //eventsMap[`custome-${key}`] = {"onChange": this.onMessageTitleChange};
1322
+ return row;
1323
+ // formChaild.inputFields[fieldIndex + index] = field;
1324
+ });
1325
+
1326
+
1327
+ const configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === this.state.formData[this.state.currentTab - 1][field.id]);
1328
+ if (configkeys.length) {
1329
+ const options = configkeys[0].keys;
1330
+ formChaild.inputFields = formChaild.inputFields.slice(0, fieldIndex + 1).concat(formChaild.inputFields.slice( fieldIndex + options.length + 1, formChaild.inputFields.length));
1331
+ // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1332
+ // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1333
+ }
1334
+ if (formChaild.inputFields[fieldIndex + 1] && formChaild.inputFields[fieldIndex + 1].id === "cta-deeplink-keys") {
1335
+ rows = formChaild.inputFields.slice(0, fieldIndex + 1).concat(rows).concat(formChaild.inputFields.slice(fieldIndex + 1, formChaild.inputFields.length));
1336
+ formChaild.inputFields = rows;
1337
+ } else {
1338
+ rows = formChaild.inputFields.slice(0, fieldIndex + 1).concat(rows).concat(formChaild.inputFields.slice(fieldIndex + 1, formChaild.inputFields.length));
1339
+ formChaild.inputFields = rows;
1340
+ }
1341
+ }
1342
+ });
1343
+ });
1344
+ }
1345
+ });
1346
+ });
1347
+ });
1348
+ });
1349
+ });
1350
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, eventsMap, isSchemaChanged: true});
1351
+ this.injectEvents(schema);
1352
+ };
1353
+ saveFormData = (formData) => {
1354
+ const obj = this.getTransformedData(formData);
1355
+
1356
+ this.props.actions.createTemplate(obj);
1357
+ };
1358
+ deleteSecondaryCtaIos = (callback) => {
1359
+ const schema = cloneDeep(this.state.schema);
1360
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1361
+ forEach(inputFields, (inputField, fieldIndex) => {
1362
+ if (inputField) {
1363
+ forEach(inputField.cols, (col) => {
1364
+ if (col.id === "add-sec-cta-ios") {
1365
+ inputFields.splice(fieldIndex + 1, inputFields.length);
1366
+ }
1367
+ });
1368
+ }
1369
+ });
1370
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, callback);
1371
+ this.injectEvents(schema);
1372
+ };
1373
+ deletePrimaryCTA = (event) => {
1374
+ const id = event.currentTarget.id;
1375
+ const schema = cloneDeep(this.state.schema);
1376
+ // const eventsMap = cloneDeep(this.state.eventsMap);
1377
+ const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1378
+ const formData = cloneDeep(this.state.formData);
1379
+ const self = this;
1380
+ forEach(schema.containers, (container) => {
1381
+ forEach(container.panes, (pane) => {
1382
+ forEach(pane.sections, (section) => {
1383
+ forEach(section.childSections, (childeSection) => {
1384
+ forEach(childeSection.childSections, (formChild) => {
1385
+ const child = formChild;
1386
+ if (child.type === 'multicols') {
1387
+ forEach(child.inputFields, (inputField, fieldIndex) => {
1388
+ if (inputField) {
1389
+ forEach(inputField.cols, (col) => {
1390
+ if (col.id === id) {
1391
+ child.inputFields.splice(fieldIndex, 1);
1392
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1393
+ child.inputFields.splice(fieldIndex, 1);
1394
+ }
1395
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1396
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1397
+ const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1398
+ if (configkeys.length) {
1399
+ const options = configkeys[0].keys;
1400
+ child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1401
+ delete formData[self.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1402
+ delete formData[self.state.currentTab - 1][`${id.replace('-delete', '')}`];
1403
+ } else {
1404
+ child.inputFields.splice(fieldIndex, 1);
1405
+ }
1406
+ }
1407
+ child.inputFields.splice(fieldIndex, 0, {
1408
+ cols: [
1409
+ {
1410
+ id: `${this.state.currentTab === 1 ? "add-pri-cta" : "add-pri-cta-ios"}`,
1411
+ metaType: "label",
1412
+ value: "Add Primary CTA",
1413
+ primitive: true,
1414
+ dynamicTab: false,
1415
+ type: "div",
1416
+ style: {
1417
+ backgroundColor: 'white',
1418
+ textAlign: 'left',
1419
+ color: '#2673D7',
1420
+
1421
+ cursor: 'pointer',
1422
+ },
1423
+ offset: 0,
1424
+ onlyDisplay: true,
1425
+ colStyle: {
1426
+ flex: 1,
1427
+ },
1428
+ submitAction: "addPrimaryCta",
1429
+ supportedEvents: ["addPrimaryCta"],
1430
+ },
1431
+ ],
1432
+ });
1433
+ }
1434
+ });
1435
+ }
1436
+ });
1437
+ }
1438
+ });
1439
+ });
1440
+ });
1441
+ });
1442
+ });
1443
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1444
+ this.injectEvents(schema);
1445
+ };
1446
+
1447
+ deleteSecondaryCTA = (event) => {
1448
+ const id = event.currentTarget.id;
1449
+ if (id === "secondary-cta-0-delete") {
1450
+ const secCta2 = document.getElementById("secondary-cta-1-delete");
1451
+ if (secCta2) {
1452
+ const modalContent = {title: "Alert", body: this.props.intl.formatMessage(messages["Please delete second Secondary cta First"]), type: 'info', show: true, onCancel: this.onModalCancel};
1453
+ this.setState({modalContent, showModal: true});
1454
+ return;
1455
+ }
1456
+ }
1457
+ const schema = cloneDeep(this.state.schema);
1458
+ // const eventsMap = cloneDeep(this.state.eventsMap);
1459
+ const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1460
+ const formData = cloneDeep(this.state.formData);
1461
+ const device = this.state.currentTab === 1 ? 'android' : 'ios';
1462
+ forEach(schema.containers, (container) => {
1463
+ forEach(container.panes, (pane) => {
1464
+ forEach(pane.sections, (section) => {
1465
+ forEach(section.childSections, (childeSection) => {
1466
+ forEach(childeSection.childSections, (formChild) => {
1467
+ const child = formChild;
1468
+ if (child.type === 'multicols') {
1469
+ forEach(child.inputFields, (inputField, fieldIndex) => {
1470
+ if (inputField) {
1471
+ forEach(inputField.cols, (col) => {
1472
+ if (col.id === id) {
1473
+ if (device === 'ios') {
1474
+ child.inputFields.splice(fieldIndex, 3);
1475
+ } else {
1476
+ child.inputFields.splice(fieldIndex, 2);
1477
+ }
1478
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1479
+ child.inputFields.splice(fieldIndex, 1);
1480
+ }
1481
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1482
+ const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
1483
+ const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1484
+ const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1485
+ if (configkeys.length) {
1486
+ const options = configkeys[0].keys;
1487
+ child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1488
+ } else {
1489
+ child.inputFields.splice(fieldIndex, 1);
1490
+ }
1491
+ }
1492
+ if (device === 'ios') {
1493
+ child.inputFields[fieldIndex] = {
1494
+ cols: [
1495
+ {
1496
+ id: "add-sec-cta-ios",
1497
+ metaType: "label",
1498
+ value: "Add Secondary CTA",
1499
+ primitive: true,
1500
+ dynamicTab: false,
1501
+ type: "div",
1502
+ style: {
1503
+ backgroundColor: 'white',
1504
+ textAlign: 'left',
1505
+ color: '#2673D7',
1506
+
1507
+ cursor: 'pointer',
1508
+ },
1509
+ offset: 0,
1510
+ onlyDisplay: true,
1511
+ colStyle: {
1512
+ flex: 1,
1513
+ },
1514
+ submitAction: "addSecondaryCtaIos",
1515
+ supportedEvents: ["addSecondaryCtaIos"],
1516
+ },
1517
+ ],
1518
+ };
1519
+ } else {
1520
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].cols[0] && child.inputFields[fieldIndex].cols[0].id === "add-sec-cta") {
1521
+ child.inputFields[fieldIndex] = {
1522
+ cols: [
1523
+ {
1524
+ id: "add-sec-cta",
1525
+ metaType: "label",
1526
+ value: "Add Secondary CTA",
1527
+ primitive: true,
1528
+ dynamicTab: false,
1529
+ type: "div",
1530
+ style: {
1531
+ backgroundColor: 'white',
1532
+ textAlign: 'left',
1533
+ color: '#2673D7',
1534
+
1535
+ cursor: 'pointer',
1536
+ },
1537
+ offset: 0,
1538
+ onlyDisplay: true,
1539
+ colStyle: {
1540
+ flex: 1,
1541
+ },
1542
+ submitAction: "addSecondaryCta",
1543
+ supportedEvents: ['addSecondaryCta'],
1544
+ fieldsLimit: 2,
1545
+ fieldsCount: 0,
1546
+ },
1547
+ ],
1548
+ };
1549
+ }
1550
+ if (id === "secondary-cta-1-delete" || child.inputFields[fieldIndex].cols[0].id === "cta-label" || child.inputFields[fieldIndex].cols[0].id === "secondary-cta-1-space") {
1551
+ let nextFieldIndex = fieldIndex;
1552
+ if (id === "secondary-cta-1-delete" || child.inputFields[fieldIndex].cols[0].id === "secondary-cta-1-space") {
1553
+ nextFieldIndex = child.inputFields.length;
1554
+ }
1555
+ child.inputFields[nextFieldIndex] = {
1556
+ cols: [
1557
+ {
1558
+ id: "add-sec-cta",
1559
+ metaType: "label",
1560
+ value: "Add Another CTA",
1561
+ primitive: true,
1562
+ dynamicTab: false,
1563
+ type: "div",
1564
+ style: {
1565
+ backgroundColor: 'white',
1566
+ textAlign: 'left',
1567
+ color: '#2673D7',
1568
+
1569
+ cursor: 'pointer',
1570
+ },
1571
+ offset: 0,
1572
+ onlyDisplay: true,
1573
+ colStyle: {
1574
+ flex: 1,
1575
+ },
1576
+ submitAction: "addSecondaryCta",
1577
+ supportedEvents: ['addSecondaryCta'],
1578
+ fieldsLimit: 2,
1579
+ fieldsCount: 1,
1580
+ },
1581
+ ],
1582
+ };
1583
+ }
1584
+ }
1585
+ }
1586
+ });
1587
+ }
1588
+ });
1589
+ }
1590
+ });
1591
+ });
1592
+ });
1593
+ });
1594
+ });
1595
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1596
+ this.injectEvents(schema);
1597
+ };
1598
+ handleOnTagsContextChange = (data) => {
1599
+ const query = {
1600
+ layout: 'mobilepush',
1601
+ type: 'TAG',
1602
+ context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
1603
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
1604
+ };
1605
+ this.props.globalActions.fetchSchemaForEntity(query);
1606
+ };
1607
+ handleClose = () => {
1608
+ const formData = cloneDeep(this.state.formData);
1609
+ formData[this.state.currentTab - 1]['add-sec-cta-ios'] = false;
1610
+ this.setState({showIosCtaTable: false, formData});
1611
+ }
1612
+ render() {
1613
+ let tipText = this.props.Create.createTemplateInProgress ? "Saving Template..." : "";
1614
+ let loading = this.props.Create.createTemplateInProgress ? this.props.Create.createTemplateInProgress : false;
1615
+ if (this.props.Create.assetUploading) {
1616
+ tipText = "Uploading Image...";
1617
+ loading = true;
1618
+ }
1619
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
1620
+ if (this.props.supportedTags) {
1621
+ tags = this.props.supportedTags; // if get default tags is not present and supported tags is present use that inlbrary mode
1622
+ }
1623
+ return (
1624
+ <div className="creatives-mobilepush-create">
1625
+ <CapSpin tip={tipText} spinning={loading}>
1626
+ <CapRow>
1627
+ <CapColumn>
1628
+ <FormBuilder
1629
+ key={"form builder"}
1630
+ schema={this.state.schema}
1631
+ onSubmit={this.saveFormData}
1632
+ onChange={this.onFormDataChange}
1633
+ currentTab={this.state.currentTab}
1634
+ parent={this}
1635
+ formData={cloneDeep(this.state.formData)}
1636
+ location={this.props.location}
1637
+ tags={tags}
1638
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
1639
+ onFormValidityChange={this.setFormValidity}
1640
+ usingTabContainer
1641
+ checkValidation={this.state.checkValidation}
1642
+ iosCtasData={this.state.iosCtasData}
1643
+ tabKey={this.state.tabKey}
1644
+ tabCount={2}
1645
+ showModal={this.state.showModal}
1646
+ isSchemaChanged={this.state.isSchemaChanged}
1647
+ modal={this.state.modalContent}
1648
+ handleCancelModal={this.handleCancelModal}
1649
+ iframeParent={parent}
1650
+ router={this.props.router}
1651
+ onContextChange={this.handleOnTagsContextChange}
1652
+ setModalContent={this.setModalContent}
1653
+ startValidation={this.state.startValidation}
1654
+ stopValidation={this.stopValidation}
1655
+ />
1656
+ </CapColumn>
1657
+ {this.props.iosCtasData && this.state.showIosCtaTable &&
1658
+ <CapSlideBox
1659
+ size="size-l"
1660
+ header={<CapHeader
1661
+ title={<FormattedMessage {...messages.selectActionButton} />}
1662
+ prefix={
1663
+ <PrefixWrapper>
1664
+ <CapIcons.backIcon onClick={this.handleClose} />
1665
+ </PrefixWrapper>
1666
+ }
1667
+
1668
+ />}
1669
+ content={<CapTable
1670
+ rowSelection={{
1671
+ type: 'radio',
1672
+ onSelect: (record) => {
1673
+ this.setState({templateCta: record, showIosCtaTable: false}, () => this.selectCtaIos(record));
1674
+ },
1675
+ }}
1676
+ dataSource={this.props.iosCtasData} columns={[
1677
+ {
1678
+ title: "Name and Description",
1679
+ dataIndex: "name",
1680
+ key: "name",
1681
+ width: 200,
1682
+ render: (text, record) => (
1683
+ <div>
1684
+ <div>{record.name}</div>
1685
+ <div>{record.description}</div>
1686
+ </div>),
1687
+ },
1688
+ {
1689
+ title: "Button 1",
1690
+ dataIndex: "description",
1691
+ key: "button1",
1692
+ width: 100,
1693
+ render: (text, record) => (
1694
+ <div>
1695
+ {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
1696
+ </div>),
1697
+ },
1698
+ {
1699
+ title: "Button 2",
1700
+ dataIndex: "description",
1701
+ key: "button2",
1702
+ width: 100,
1703
+ render: (text, record) => (
1704
+ <div>
1705
+ {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
1706
+ </div>
1707
+ ),
1708
+ },
1709
+ ]}
1710
+ />}
1711
+ show={this.state.showIosCtaTable}
1712
+ handleClose={this.handleClose}
1713
+ />
1714
+ }
1715
+
1716
+ </CapRow>
1717
+ </CapSpin>
1718
+ </div>
1719
+ );
1720
+ }
1721
+ }
1722
+
1723
+ Create.propTypes = {
1724
+ actions: PropTypes.object.isRequired,
1725
+ isFullMode: PropTypes.bool,
1726
+ Create: PropTypes.object,
1727
+ router: PropTypes.object,
1728
+ location: PropTypes.object,
1729
+ route: PropTypes.object,
1730
+ globalActions: PropTypes.object,
1731
+ metaEntities: PropTypes.object,
1732
+ params: PropTypes.object,
1733
+ Templates: PropTypes.object,
1734
+ intl: intlShape.isRequired,
1735
+ supportedTags: PropTypes.array,
1736
+ getDefaultTags: PropTypes.string,
1737
+ iosCtasData: PropTypes.array,
1738
+ injectedTags: PropTypes.object,
1739
+ defaultData: PropTypes.object,
1740
+ showTemplateName: PropTypes.func,
1741
+ };
1742
+
1743
+ const mapStateToProps = createStructuredSelector({
1744
+ Create: makeSelectCreate(),
1745
+ createResponse: makeSelectCreateResponse(),
1746
+ metaEntities: makeSelectMetaEntities(),
1747
+ Templates: makeSelectTemplates(),
1748
+ iosCtasData: makeSelectIosCta(),
1749
+ injectedTags: setInjectedTags(),
1750
+ });
1751
+
1752
+ function mapDispatchToProps(dispatch) {
1753
+ return {
1754
+ actions: bindActionCreators(actions, dispatch),
1755
+ globalActions: bindActionCreators(globalActions, dispatch),
1756
+ };
1757
+ }
1758
+
1759
+ export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(Create));