@capillarytech/creatives-library 2.0.69 → 2.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/FormBuilder/index.js +25 -10
  4. package/components/Header/index.js +3 -1
  5. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  6. package/components/TemplatePreview/index.js +45 -51
  7. package/components/TemplatePreview/messages.js +1 -1
  8. package/containers/Cap/actions.js +0 -5
  9. package/containers/Cap/reducer.js +1 -1
  10. package/containers/Cap/selectors.js +0 -13
  11. package/containers/Ebill/index.js +1 -2
  12. package/containers/Email/_email.scss +1 -0
  13. package/containers/Email/actions.js +3 -8
  14. package/containers/Email/constants.js +0 -1
  15. package/containers/Email/index.js +947 -322
  16. package/containers/Email/reducer.js +0 -3
  17. package/containers/Email/sagas.js +6 -3
  18. package/containers/Email/selectors.js +1 -4
  19. package/containers/Line/Create/index.js +1 -2
  20. package/containers/Line/Edit/_lineEdit.scss +4 -0
  21. package/containers/Line/Edit/index.js +1 -3
  22. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  23. package/containers/MobilePush/Create/actions.js +0 -6
  24. package/containers/MobilePush/Create/constants.js +0 -1
  25. package/containers/MobilePush/Create/index.js +1133 -628
  26. package/containers/MobilePush/Create/messages.js +1 -5
  27. package/containers/MobilePush/Create/reducer.js +0 -2
  28. package/containers/MobilePush/Create/selectors.js +3 -3
  29. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  30. package/containers/MobilePush/Edit/index.js +1127 -393
  31. package/containers/MobilePush/Edit/messages.js +0 -4
  32. package/containers/MobilePush/Edit/reducer.js +1 -2
  33. package/containers/MobilePush/Edit/selectors.js +3 -6
  34. package/containers/Sms/Create/_smsCreate.scss +2 -1
  35. package/containers/Sms/Create/actions.js +4 -4
  36. package/containers/Sms/Create/index.js +570 -102
  37. package/containers/Sms/Create/sagas.js +2 -1
  38. package/containers/Sms/Edit/actions.js +5 -10
  39. package/containers/Sms/Edit/constants.js +0 -1
  40. package/containers/Sms/Edit/index.js +548 -103
  41. package/containers/Sms/Edit/reducer.js +0 -2
  42. package/containers/Sms/Edit/sagas.js +3 -1
  43. package/containers/TagList/index.js +3 -3
  44. package/containers/Templates/actions.js +1 -3
  45. package/containers/Templates/index.js +299 -268
  46. package/containers/Templates/messages.js +90 -122
  47. package/containers/Templates/reducer.js +3 -3
  48. package/containers/Templates/sagas.js +1 -5
  49. package/containers/Templates/selectors.js +1 -41
  50. package/containers/WeChat/MapTemplates/index.js +3 -4
  51. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  52. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  53. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  54. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  55. package/index.js +31 -31
  56. package/initialState.js +6 -0
  57. package/package.json +3 -3
  58. package/routes.js +24 -19
  59. package/services/api.js +6 -2
  60. package/services/getSchema.js +18 -0
  61. package/v2Containers/App/actions.js +7 -0
  62. package/v2Containers/App/constants.js +3 -0
  63. package/v2Containers/App/reducer.js +19 -0
  64. package/v2Containers/App/sagas.js +26 -0
  65. package/v2Containers/App/selectors.js +25 -0
  66. package/v2Containers/App/tests/actions.test.js +18 -0
  67. package/v2Containers/App/tests/reducer.test.js +9 -0
  68. package/v2Containers/App/tests/sagas.test.js +15 -0
  69. package/v2Containers/App/tests/selectors.test.js +10 -0
  70. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  71. package/v2Containers/Assets/Gallery/actions.js +37 -0
  72. package/v2Containers/Assets/Gallery/constants.js +23 -0
  73. package/v2Containers/Assets/Gallery/index.js +479 -0
  74. package/v2Containers/Assets/Gallery/messages.js +97 -0
  75. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  76. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  77. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  78. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  79. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  80. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  81. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  82. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  83. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  84. package/v2Containers/CallTask/_callTask.scss +5 -0
  85. package/v2Containers/CallTask/actions.js +15 -0
  86. package/v2Containers/CallTask/constants.js +7 -0
  87. package/v2Containers/CallTask/index.js +141 -0
  88. package/v2Containers/CallTask/messages.js +21 -0
  89. package/v2Containers/CallTask/reducer.js +23 -0
  90. package/v2Containers/CallTask/sagas.js +11 -0
  91. package/v2Containers/CallTask/selectors.js +25 -0
  92. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  93. package/v2Containers/CallTask/tests/index.test.js +10 -0
  94. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  95. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  96. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  97. package/v2Containers/Cap/actions.js +64 -0
  98. package/v2Containers/Cap/constants.js +24 -0
  99. package/v2Containers/Cap/index.js +349 -0
  100. package/v2Containers/Cap/messsages.js +63 -0
  101. package/v2Containers/Cap/reducer.js +111 -0
  102. package/v2Containers/Cap/sagas.js +143 -0
  103. package/v2Containers/Cap/selectors.js +85 -0
  104. package/v2Containers/Cap/tests/index.test.js +16 -0
  105. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  106. package/v2Containers/ChannelTemplates/actions.js +20 -0
  107. package/v2Containers/ChannelTemplates/constants.js +8 -0
  108. package/v2Containers/ChannelTemplates/index.js +48 -0
  109. package/v2Containers/ChannelTemplates/messages.js +13 -0
  110. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  111. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  112. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  113. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  114. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  115. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  116. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  117. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  118. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  119. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  120. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  121. package/v2Containers/CreativesContainer/actions.js +27 -0
  122. package/v2Containers/CreativesContainer/constants.js +16 -0
  123. package/v2Containers/CreativesContainer/index.js +483 -0
  124. package/v2Containers/CreativesContainer/index.scss +27 -0
  125. package/v2Containers/CreativesContainer/messages.js +293 -0
  126. package/v2Containers/CreativesContainer/reducer.js +29 -0
  127. package/v2Containers/CreativesContainer/sagas.js +11 -0
  128. package/v2Containers/CreativesContainer/selectors.js +30 -0
  129. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  130. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  131. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  132. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  133. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  134. package/v2Containers/Dashboard/actions.js +15 -0
  135. package/v2Containers/Dashboard/constants.js +7 -0
  136. package/v2Containers/Dashboard/index.js +54 -0
  137. package/v2Containers/Dashboard/messages.js +13 -0
  138. package/v2Containers/Dashboard/reducer.js +21 -0
  139. package/v2Containers/Dashboard/sagas.js +11 -0
  140. package/v2Containers/Dashboard/selectors.js +25 -0
  141. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  142. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  143. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  144. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  145. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  146. package/v2Containers/Ebill/_ebill.scss +5 -0
  147. package/v2Containers/Ebill/actions.js +43 -0
  148. package/v2Containers/Ebill/constants.js +20 -0
  149. package/v2Containers/Ebill/index.js +1261 -0
  150. package/v2Containers/Ebill/messages.js +73 -0
  151. package/v2Containers/Ebill/reducer.js +72 -0
  152. package/v2Containers/Ebill/sagas.js +65 -0
  153. package/v2Containers/Ebill/selectors.js +25 -0
  154. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  155. package/v2Containers/Ebill/tests/index.test.js +10 -0
  156. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  157. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  158. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  159. package/v2Containers/Email/_email.scss +140 -0
  160. package/v2Containers/Email/actions.js +86 -0
  161. package/v2Containers/Email/constants.js +37 -0
  162. package/v2Containers/Email/index.js +2703 -0
  163. package/v2Containers/Email/initialSchema.js +540 -0
  164. package/v2Containers/Email/messages.js +237 -0
  165. package/v2Containers/Email/reducer.js +147 -0
  166. package/v2Containers/Email/sagas.js +133 -0
  167. package/v2Containers/Email/selectors.js +34 -0
  168. package/v2Containers/Email/tests/actions.test.js +18 -0
  169. package/v2Containers/Email/tests/index.test.js +10 -0
  170. package/v2Containers/Email/tests/reducer.test.js +9 -0
  171. package/v2Containers/Email/tests/sagas.test.js +15 -0
  172. package/v2Containers/Email/tests/selectors.test.js +10 -0
  173. package/v2Containers/EmailWrapper/actions.js +15 -0
  174. package/v2Containers/EmailWrapper/constants.js +7 -0
  175. package/v2Containers/EmailWrapper/index.js +258 -0
  176. package/v2Containers/EmailWrapper/messages.js +57 -0
  177. package/v2Containers/EmailWrapper/reducer.js +23 -0
  178. package/v2Containers/EmailWrapper/sagas.js +11 -0
  179. package/v2Containers/EmailWrapper/selectors.js +25 -0
  180. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  181. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  182. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  183. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  184. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  185. package/v2Containers/LanguageProvider/actions.js +17 -0
  186. package/v2Containers/LanguageProvider/constants.js +8 -0
  187. package/v2Containers/LanguageProvider/index.js +46 -0
  188. package/v2Containers/LanguageProvider/reducer.js +30 -0
  189. package/v2Containers/LanguageProvider/selectors.js +20 -0
  190. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  191. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  192. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  193. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  194. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  195. package/v2Containers/Line/Create/actions.js +90 -0
  196. package/v2Containers/Line/Create/constants.js +39 -0
  197. package/v2Containers/Line/Create/index.js +822 -0
  198. package/v2Containers/Line/Create/messages.js +173 -0
  199. package/v2Containers/Line/Create/reducer.js +99 -0
  200. package/v2Containers/Line/Create/sagas.js +107 -0
  201. package/v2Containers/Line/Create/selectors.js +36 -0
  202. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  203. package/v2Containers/Line/Edit/actions.js +79 -0
  204. package/v2Containers/Line/Edit/constants.js +27 -0
  205. package/v2Containers/Line/Edit/index.js +1050 -0
  206. package/v2Containers/Line/Edit/messages.js +157 -0
  207. package/v2Containers/Line/Edit/reducer.js +83 -0
  208. package/v2Containers/Line/Edit/sagas.js +81 -0
  209. package/v2Containers/Line/Edit/selectors.js +29 -0
  210. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  211. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  212. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  213. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  214. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  215. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  216. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  217. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  218. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  219. package/v2Containers/Login/index.js +106 -0
  220. package/v2Containers/Login/messages.js +21 -0
  221. package/v2Containers/Login/selectors.js +25 -0
  222. package/v2Containers/Login/tests/index.test.js +10 -0
  223. package/v2Containers/Login/tests/sagas.test.js +15 -0
  224. package/v2Containers/Login/tests/selectors.test.js +10 -0
  225. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  226. package/v2Containers/MobilePush/Create/actions.js +52 -0
  227. package/v2Containers/MobilePush/Create/constants.js +24 -0
  228. package/v2Containers/MobilePush/Create/index.js +1759 -0
  229. package/v2Containers/MobilePush/Create/messages.js +237 -0
  230. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  231. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  232. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  233. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  234. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  235. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  236. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  237. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  238. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  239. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  240. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  241. package/v2Containers/MobilePush/Edit/index.js +1846 -0
  242. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  243. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  244. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  245. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  246. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  247. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  248. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  249. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  250. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  251. package/v2Containers/MobilePush/commonMethods.js +249 -0
  252. package/v2Containers/MobilePush/eventsMap.js +127 -0
  253. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  254. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  255. package/v2Containers/MobilepushWrapper/index.js +136 -0
  256. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  257. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  258. package/v2Containers/NotFoundPage/index.js +25 -0
  259. package/v2Containers/NotFoundPage/messages.js +13 -0
  260. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  261. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  262. package/v2Containers/Sms/Create/actions.js +27 -0
  263. package/v2Containers/Sms/Create/constants.js +16 -0
  264. package/v2Containers/Sms/Create/index.js +1017 -0
  265. package/v2Containers/Sms/Create/messages.js +85 -0
  266. package/v2Containers/Sms/Create/reducer.js +41 -0
  267. package/v2Containers/Sms/Create/sagas.js +35 -0
  268. package/v2Containers/Sms/Create/selectors.js +28 -0
  269. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  270. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  271. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  272. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  273. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  274. package/v2Containers/Sms/Edit/actions.js +45 -0
  275. package/v2Containers/Sms/Edit/constants.js +18 -0
  276. package/v2Containers/Sms/Edit/index.js +1018 -0
  277. package/v2Containers/Sms/Edit/messages.js +89 -0
  278. package/v2Containers/Sms/Edit/reducer.js +52 -0
  279. package/v2Containers/Sms/Edit/sagas.js +50 -0
  280. package/v2Containers/Sms/Edit/selectors.js +32 -0
  281. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  282. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  283. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  284. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  285. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  286. package/v2Containers/Sms/initialSchema.js +281 -0
  287. package/v2Containers/TagList/_tagList.scss +8 -0
  288. package/v2Containers/TagList/actions.js +15 -0
  289. package/v2Containers/TagList/constants.js +7 -0
  290. package/v2Containers/TagList/index.js +236 -0
  291. package/v2Containers/TagList/messages.js +13 -0
  292. package/v2Containers/TagList/reducer.js +23 -0
  293. package/v2Containers/TagList/sagas.js +11 -0
  294. package/v2Containers/TagList/selectors.js +25 -0
  295. package/v2Containers/TagList/tests/actions.test.js +18 -0
  296. package/v2Containers/TagList/tests/index.test.js +10 -0
  297. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  298. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  299. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  300. package/v2Containers/Templates/_templates.scss +349 -0
  301. package/v2Containers/Templates/actions.js +110 -0
  302. package/v2Containers/Templates/constants.js +45 -0
  303. package/v2Containers/Templates/index.js +1682 -0
  304. package/v2Containers/Templates/messages.js +273 -0
  305. package/v2Containers/Templates/reducer.js +142 -0
  306. package/v2Containers/Templates/sagas.js +180 -0
  307. package/v2Containers/Templates/selectors.js +68 -0
  308. package/v2Containers/Templates/tests/actions.test.js +18 -0
  309. package/v2Containers/Templates/tests/index.test.js +10 -0
  310. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  311. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  312. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  313. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  314. package/v2Containers/TemplatesV2/actions.js +16 -0
  315. package/v2Containers/TemplatesV2/constants.js +10 -0
  316. package/v2Containers/TemplatesV2/index.js +217 -0
  317. package/v2Containers/TemplatesV2/messages.js +29 -0
  318. package/v2Containers/TemplatesV2/selectors.js +25 -0
  319. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  320. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  321. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  322. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  323. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  324. package/v2Containers/TestPage/constants.js +7 -0
  325. package/v2Containers/TestPage/index.js +31 -0
  326. package/v2Containers/TestPage/messages.js +13 -0
  327. package/v2Containers/TestPage/reducer.js +21 -0
  328. package/v2Containers/TestPage/sagas.js +11 -0
  329. package/v2Containers/Testv2/actions.js +15 -0
  330. package/v2Containers/Testv2/constants.js +7 -0
  331. package/v2Containers/Testv2/index.js +47 -0
  332. package/v2Containers/Testv2/messages.js +13 -0
  333. package/v2Containers/Testv2/reducer.js +23 -0
  334. package/v2Containers/Testv2/sagas.js +11 -0
  335. package/v2Containers/Testv2/selectors.js +25 -0
  336. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  337. package/v2Containers/Testv2/tests/index.test.js +10 -0
  338. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  339. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  340. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  341. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  342. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  343. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  344. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  345. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  346. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  347. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  348. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  349. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  350. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  351. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  352. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  354. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  355. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  356. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  357. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -10,33 +10,142 @@ import React from 'react';
10
10
  import { connect } from 'react-redux';
11
11
  import { bindActionCreators } from 'redux';
12
12
  import { Row, Col, Spin, Breadcrumb, notification } from 'antd';
13
- import {get, set, filter, isEmpty, map, forEach, uniqueId, cloneDeep, isEqual, findIndex} from 'lodash';
13
+ import _ from 'lodash';
14
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} from '@capillarytech/cap-ui-library';
18
- import { makeSelectCreate, makeSelectCreateResponse, makeSelectIosCta } from './selectors';
15
+ import { injectIntl, intlShape } from 'react-intl';
16
+ import { makeSelectCreate, makeSelectCreateResponse } from './selectors';
19
17
  import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
20
18
  import * as globalActions from '../../../containers/Cap/actions';
21
19
  import FormBuilder from '../../../components/FormBuilder';
22
20
  import './_mobilePushCreate.scss';
23
21
  import * as actions from './actions';
24
-
25
22
  import {getMessageObject} from '../../../utils/messageUtils';
26
23
  import { makeSelectTemplates } from '../../Templates/selectors';
27
24
  import messages from './messages';
28
- import callNativeEvent from '../../../utils/callNativeEvent';
29
- import getEventsMap from '../eventsMap';
30
25
  const BreadcrumbItem = Breadcrumb.Item;
31
-
32
- const PrefixWrapper = styled.div`
33
- margin-right: 16px;
34
- `;
35
26
  export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
36
27
  constructor(props) {
37
28
  super(props);
38
- const eventsMap = getEventsMap(this);
39
29
  if (this.props.Templates.selectedWeChatAccount) {
30
+ const map = {
31
+ "template-name": {
32
+ onChange: this.onTemplateNameChange,
33
+ },
34
+ "cta-deeplink-secondary-cta-0": {
35
+ onChange: this.onLinkTypeChange,
36
+ },
37
+ "cta-deeplink-secondary-cta-1": {
38
+ onChange: this.onLinkTypeChange,
39
+ },
40
+ "cta-deeplink-secondary-cta-12": {
41
+ onChange: this.onLinkTypeChange,
42
+ },
43
+ "cta-deeplink-delete": {
44
+ onDelete: this.deletePrimaryCTA,
45
+ },
46
+ "cta-deeplink2-delete": {
47
+ onDelete: this.deletePrimaryCTA,
48
+ },
49
+ "secondary-cta-0-delete": {
50
+ onDelete: this.deleteSecondaryCTA,
51
+ },
52
+ "secondary-cta-1-delete": {
53
+ onDelete: this.deleteSecondaryCTA,
54
+ },
55
+ "secondary-cta-1-delete-ios": {
56
+ onDelete: this.deleteSecondaryCtaIos,
57
+ },
58
+ "discard-button": {
59
+ discardValues: this.discardValues,
60
+ },
61
+ "cancel-button": {
62
+ cancelTemplate: this.cancelTemplate,
63
+ },
64
+ "copy-android-content": {
65
+ onClick: this.copyAndroidContent,
66
+ },
67
+ "copy-iphone-content": {
68
+ onClick: this.copyIphoneContent,
69
+ },
70
+ "save-button": {
71
+ saveFormData: this.saveFormData,
72
+ },
73
+ "message-editor": {
74
+ onChange: this.onTemplateContentChange,
75
+ },
76
+ "message-editor2": {
77
+ onChange: this.onTemplateContentChange,
78
+ },
79
+ "message-tagList": {
80
+ onTagSelect: this.onTagSelect,
81
+ },
82
+ "message-tagList2": {
83
+ onTagSelect: this.onTagSelect,
84
+ },
85
+ "title-tagList": {
86
+ onTagSelect: this.onTagSelect,
87
+ },
88
+ "title-tagList2": {
89
+ onTagSelect: this.onTagSelect,
90
+ },
91
+ "pane": {
92
+ onTabChange: this.onTabChange,
93
+ },
94
+ "cta-deeplink": {
95
+ onChange: this.onLinkTypeChange,
96
+ },
97
+ "cta-deeplink2": {
98
+ onChange: this.onLinkTypeChange,
99
+ },
100
+ "cta-deeplink-secondary-cta-1-select": {
101
+ onSelect: this.showCtaKeys,
102
+ },
103
+ "cta-deeplink-secondary-cta-0-select": {
104
+ onSelect: this.showCtaKeys,
105
+ },
106
+ "cta-deeplink-secondary-cta-1-select2": {
107
+ onSelect: this.showCtaKeys,
108
+ },
109
+ "cta-deeplink-select": {
110
+ onSelect: this.showCtaKeys,
111
+ },
112
+ "cta-deeplink2-select": {
113
+ onSelect: this.showCtaKeys,
114
+ },
115
+ "add-pri-cta": {
116
+ addPrimaryCta: this.addPrimaryCta,
117
+ },
118
+ "add-pri-cta-ios": {
119
+ addPrimaryCta: this.addPrimaryCta,
120
+ },
121
+ "add-sec-cta": {
122
+ addSecondaryCta: this.addSecondoryCta,
123
+ },
124
+ "add-sec-cta-ios": {
125
+ addSecondaryCtaIos: this.addSecondoryCtaIos,
126
+ },
127
+ "image-upload-android": {
128
+ onUpload: this.uploadImage,
129
+ },
130
+ "image-upload-ios": {
131
+ onUpload: this.uploadImage,
132
+ },
133
+ "secondary-cta-1-table": {
134
+ onRowClick: this.selectCtaIos,
135
+ },
136
+ "cta-deeplink-select-show-keys": {
137
+ onShowCtaKeys: this.showCtaKeys,
138
+ },
139
+ "cta-deeplink-secondary-cta-0-select-show-keys": {
140
+ onShowCtaKeys: this.showCtaKeys,
141
+ },
142
+ "cta-deeplink-secondary-cta-1-select-show-keys": {
143
+ onShowCtaKeys: this.showCtaKeys,
144
+ },
145
+ "wechat-template": {
146
+ onSelect: this.onTemplateChange,
147
+ },
148
+ };
40
149
  this.state = {
41
150
  formData: {},
42
151
  tabCount: 1,
@@ -46,7 +155,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
46
155
  tabKey: '',
47
156
  checkValidation: false,
48
157
  schema: {},
49
- eventsMap,
158
+ eventsMap: map,
50
159
  errorData: {},
51
160
  displayProps: {},
52
161
  modalContent: {title: "Alert", body: "template not configured,", type: 'confirm'},
@@ -73,26 +182,35 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
73
182
  };
74
183
 
75
184
  componentDidMount = () => {
185
+ console.log('added listener create,', this.props);
76
186
  const query = {
77
187
  layout: 'MOBILEPUSH',
78
188
  type: 'LAYOUT',
79
- version: "v2",
80
189
  };
81
190
  this.props.globalActions.fetchSchemaForEntity(query);
82
191
  window.addEventListener("message", this.handleFrameTasks);
192
+ const type = this.props.location.query.type;
193
+ if (type === 'embedded') {
194
+ const response = {
195
+ action: 'startTemplateCreation',
196
+ };
197
+ parent.postMessage(JSON.stringify(response), '*');
198
+ }
83
199
  };
84
200
 
85
201
  componentWillReceiveProps = (nextProps) => {
202
+ console.log('recieved props ', nextProps, nextProps.Create, this.props.Create);
86
203
  if (nextProps.isGetFormData) {
87
204
  nextProps.getFormLibraryData(this.getFormData());
88
205
  }
89
206
  if (nextProps.Create.uploadedAssetData) {
90
- const formData = cloneDeep(this.state.formData);
207
+ const formData = _.cloneDeep(this.state.formData);
91
208
  formData[this.state.currentTab - 1].image = nextProps.Create.uploadedAssetData.metaInfo.public_url;
92
209
  this.setState({formData});
93
210
  this.props.actions.clearAsset();
94
211
  }
95
212
  if (nextProps.createResponse && nextProps.createResponse.templateId) {
213
+ console.log('create response', nextProps.createResponse);
96
214
  this.discardValues();
97
215
  const message = getMessageObject('success', this.props.intl.formatMessage(messages["Mobile Push Template Created Successfully"]), true);
98
216
  this.props.globalActions.addMessageToQueue(message);
@@ -107,29 +225,16 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
107
225
  if (nextProps.params.mode) {
108
226
  this.setState({mode: nextProps.params.mode});
109
227
  }
110
- if (nextProps.Create.createTemplateError && !isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
228
+ if (nextProps.Create.createTemplateError && !_.isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
111
229
  const message = getMessageObject('error', (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
112
230
  this.props.globalActions.addMessageToQueue(message);
113
231
  }
114
- if (nextProps.iosCtasData) {
115
- this.setState({showIosCtaTable: true});
232
+ if (nextProps.Create.iosCtasData) {
233
+ this.setState({iosCtasData: nextProps.Create.iosCtasData});
116
234
  }
117
- if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && isEmpty(this.state.schema)) {
235
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
236
+ console.log('final schema is**', nextProps.metaEntities.layouts[0].definition);
118
237
  const schema = this.props.params.mode === "text" ? nextProps.metaEntities.layouts[0].definition.textSchema : nextProps.metaEntities.layouts[0].definition.imageSchema;
119
- const isAndroidSupported = get(this, "props.Templates.selectedWeChatAccount.configs.android") === '1';
120
- const isIosSupported = get(this, "props.Templates.selectedWeChatAccount.configs.ios") === '1';
121
- if (!isAndroidSupported) {
122
- const androidField = get(schema, "containers[0].panes[0]");
123
- androidField.isSupported = false;
124
- this.setState({currentTab: 2});
125
- set(schema, "containers[0].panes[0]", androidField);
126
- }
127
- if (!isIosSupported) {
128
- const iosField = get(schema, "containers[0].panes[1]");
129
- iosField.isSupported = false;
130
-
131
- set(schema, "containers[0].panes[1]", iosField);
132
- }
133
238
  schema.standalone.sections.splice(1, 1);
134
239
  this.injectEvents(schema);
135
240
  const query = {
@@ -148,25 +253,27 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
148
253
  }
149
254
  };
150
255
  componentWillUnmount = () => {
151
- this.props.actions.resetStore();
256
+ console.log('removed listener create');
152
257
  window.removeEventListener("message", this.handleFrameTasks);
153
258
  };
154
259
  onTemplateChange = () => {
155
260
 
156
261
  };
157
262
 
158
- onFormDataChange = (formData, tabCount) => {
159
- const newFormData = cloneDeep(formData);
160
- const {templateCta} = this.state;
161
- if (!isEmpty(templateCta)) {
162
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta.name;
163
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta.ctaTemplateDetails[0].buttonText;
263
+ onFormDataChange = (formData, tabCount, currentTab) => {
264
+ console.log('Form data changed is ', formData, tabCount, currentTab);
265
+ const newFormData = _.cloneDeep(formData);
266
+ if (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`]) {
267
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].name;
268
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[0].buttonText;
164
269
  delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
165
- if (templateCta.ctaTemplateDetails[1]) {
166
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta.ctaTemplateDetails[1].buttonText;
270
+ if (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1]) {
271
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1].buttonText;
167
272
  }
168
273
  }
169
-
274
+ if (this.state.isSchemaChanged) {
275
+ this.setState({isSchemaChanged: false});
276
+ }
170
277
  // copy content code
171
278
  // if (newFormData[0]['copy-iphone-content'] === "") {
172
279
  //
@@ -188,16 +295,18 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
188
295
  // newFormData[1]['copy-android-content'] = "";
189
296
  // }
190
297
  // }
191
- this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged});
298
+ this.setState({formData: newFormData, tabCount});
192
299
  };
193
300
 
194
301
  onTagSelect = (data, currentTab, srcComp) => {
302
+ console.log('parent data tag', data, currentTab);
195
303
  const editorId = srcComp.target;
196
304
  this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
197
305
  document.getElementById(editorId).focus();
198
306
  };
199
307
 
200
308
  onTabChange = (data) => {
309
+ console.log('inside parent ontabchange', data, this.state);
201
310
  this.setState({currentTab: data});
202
311
  };
203
312
  onTemplateNameChange = (name) => {
@@ -206,113 +315,148 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
206
315
 
207
316
 
208
317
  onLinkTypeChange = (eventTriggered, formData, field) => {
209
- let schema = cloneDeep(this.state.schema);
210
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
211
- forEach(inputFields, (inputField, fieldIndex) => {
212
- if (inputField) {
213
- forEach(inputField.cols, (col) => {
214
- if (col.id === field.id) {
215
- const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
216
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
217
- const deeplinkValue = formData[this.state.currentTab - 1][field.id];
218
- const componentIndex = fieldIndex + 1;
219
- const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
220
- if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === inputFields.length - 1 || inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
221
- const row = {
222
- rowClassName: 'mobile-push-row',
223
- id: 'cta-deeplink-select-section',
224
- cols: [
225
-
226
- {
227
- id: inputId,
228
- placeholder: "Select DeepLink",
229
- type: "select", //Resembles component to be used
230
- options: deepLinkOptions,
231
- metaType: "text",
232
- datatype: "string",
233
- errorMessage: "Select a deeplink",
234
- required: true,
235
- fluid: true,
236
- width: 18,
237
- offset: 1,
238
- style: {
239
- width: '100%',
240
-
241
- marginBottom: '16px',
242
- },
243
- styling: "semantic",
244
- order: 1,
245
- customComponent: false,
246
- supportedEvents: [
247
- 'onSelect',
248
- ],
249
- },
250
- ],
251
- };
252
- if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-external-link") {
253
- inputFields[componentIndex] = row;
254
- } else {
255
- inputFields.splice(componentIndex, 0, row);
256
- }
257
- } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
258
- const row = {
259
- rowClassName: 'mobile-push-row',
260
- id: 'cta-external-link',
261
- cols: [
262
-
263
- {
264
- id: inputId,
265
- placeholder: "External Link",
266
- type: "input", //Resembles component to be used
267
- metaType: "text",
268
- datatype: "string",
269
- errorMessage: "External Link cannot be empty",
270
- required: true,
271
- fluid: true,
272
- width: 18,
273
- offset: 1,
274
- style: {
275
- width: '100%',
276
-
277
- marginBottom: '16px',
278
- },
279
- styling: "semantic",
280
- order: 1,
281
- customComponent: false,
282
- standalone: false,
283
- },
284
- ],
285
- };
286
- if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-deeplink-select-section") {
287
- inputFields[componentIndex] = row;
288
- if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
289
- inputFields.splice(componentIndex + 1, 1);
290
- }
291
- if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
292
- let configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][`${col.id}-select`]);
293
- if (configkeys[0]) {
294
- configkeys = configkeys[0].keys;
295
- }
296
- if (configkeys.length) {
297
- //inputFields = inputFields.slice(0, componentIndex + 1).concat(inputFields.slice( componentIndex + 1 + configkeys.length, inputFields.length));
298
-
299
- inputFields.splice(componentIndex + 1, configkeys.length);
318
+ const schema = _.cloneDeep(this.state.schema);
319
+ _.forEach(schema.containers, (container) => {
320
+ _.forEach(container.panes, (pane, paneIndex) => {
321
+ _.forEach(pane.sections, (section) => {
322
+ _.forEach(section.childSections, (childeSection) => {
323
+ _.forEach(childeSection.childSections, (child) => {
324
+ const formChaild = child;
325
+ if (child.type === 'multicols') {
326
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
327
+ if (inputField) {
328
+ _.forEach(inputField.cols, (col) => {
329
+ if (col.id === field.id && paneIndex === this.state.currentTab - 1) {
330
+ console.log(child, fieldIndex, this.state.formData);
331
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
332
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
333
+ const deeplinkValue = formData[this.state.currentTab - 1][field.id];
334
+ const componentIndex = fieldIndex + 1;
335
+ const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
336
+ if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === child.inputFields.length - 1 || child.inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
337
+ const row = {
338
+ rowClassName: 'mobile-push-row',
339
+ id: 'cta-deeplink-select-section',
340
+ cols: [
341
+ {
342
+ id: "cta-label",
343
+ metaType: "label",
344
+ value: "",
345
+ primitive: true,
346
+ dynamicTab: false,
347
+ type: "div",
348
+ width: 4,
349
+ onlyDisplay: true,
350
+ colStyle: {
351
+ flex: 1,
352
+ },
353
+ },
354
+ {
355
+ id: inputId,
356
+ placeholder: "Select DeepLink",
357
+ type: "select", //Resembles component to be used
358
+ options: deepLinkOptions,
359
+ metaType: "text",
360
+ datatype: "string",
361
+ errorMessage: "Select a deeplink",
362
+ required: true,
363
+ fluid: true,
364
+ width: 19,
365
+ style: {
366
+ fontSize: '14px',
367
+ fontFamily: 'open-sans',
368
+ fontStyle: 'normal',
369
+ // fontWeight: 600,
370
+ marginBottom: '16px',
371
+ },
372
+ styling: "semantic",
373
+ order: 1,
374
+ customComponent: false,
375
+ supportedEvents: [
376
+ 'onSelect',
377
+ ],
378
+ },
379
+ ],
380
+ };
381
+ if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-external-link") {
382
+ formChaild.inputFields[componentIndex] = row;
383
+ } else {
384
+ formChaild.inputFields.splice(componentIndex, 0, row);
385
+ }
386
+ } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
387
+ const row = {
388
+ rowClassName: 'mobile-push-row',
389
+ id: 'cta-external-link',
390
+ cols: [
391
+ {
392
+ id: "cta-label",
393
+ metaType: "label",
394
+ value: "",
395
+ primitive: true,
396
+ dynamicTab: false,
397
+ type: "div",
398
+ width: 4,
399
+ offset: 0,
400
+ onlyDisplay: true,
401
+ },
402
+ {
403
+ id: inputId,
404
+ placeholder: "External Link",
405
+ type: "input", //Resembles component to be used
406
+ metaType: "text",
407
+ datatype: "string",
408
+ errorMessage: "External Link cannot be empty",
409
+ required: true,
410
+ fluid: true,
411
+ width: 19,
412
+ style: {
413
+ fontSize: '14px',
414
+ fontFamily: 'open-sans',
415
+ fontStyle: 'normal',
416
+ // fontWeight: 600,
417
+ marginBottom: '16px',
418
+ },
419
+ styling: "semantic",
420
+ order: 1,
421
+ offSet: 4,
422
+ customComponent: false,
423
+ standalone: false,
424
+ },
425
+ ],
426
+ };
427
+ if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-deeplink-select-section") {
428
+ formChaild.inputFields[componentIndex] = row;
429
+ if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
430
+ formChaild.inputFields.splice(componentIndex + 1, 1);
431
+ }
432
+ if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
433
+ let configkeys = _.filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][`${col.id}-select`]);
434
+ if (configkeys[0]) {
435
+ configkeys = configkeys[0].keys;
436
+ }
437
+ if (configkeys.length) {
438
+ formChaild.inputFields = formChaild.inputFields.slice(0, componentIndex + 1).concat(formChaild.inputFields.slice( componentIndex + 1 + configkeys.length, formChaild.inputFields.length));
439
+ }
440
+ }
441
+ } else {
442
+ formChaild.inputFields.splice(componentIndex, 0, row);
443
+ }
444
+ }
445
+ }
446
+ });
300
447
  }
301
- }
302
- } else {
303
- inputFields.splice(componentIndex, 0, row);
448
+ });
304
449
  }
305
- }
306
- }
450
+ });
451
+ });
307
452
  });
308
- }
453
+ });
309
454
  });
310
- schema = set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
311
455
  this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
312
456
  this.injectEvents(schema);
313
457
  };
314
- onTemplateContentChange = () => {
315
-
458
+ onTemplateContentChange = (content) => {
459
+ console.log('Template content changed to ', content);
316
460
  };
317
461
  onModalCancel = () => {
318
462
  if (this.state.modalContent && this.state.modalContent.show) {
@@ -322,7 +466,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
322
466
  getLinkName = (link) => {
323
467
  const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
324
468
  const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
325
- const deepLinkOptions = filter(JSON.parse(deeplinks), (l) => l.link === link);
469
+ const deepLinkOptions = _.filter(JSON.parse(deeplinks), (l) => l.link === link);
326
470
  if (deepLinkOptions[0]) {
327
471
  return deepLinkOptions[0].name;
328
472
  }
@@ -330,8 +474,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
330
474
  };
331
475
 
332
476
  getMappedEvent = (id, event) => {
333
- const eventsMap = this.state.eventsMap;
334
- return eventsMap[id][event];
477
+ const map = this.state.eventsMap;
478
+ if (!map[id] || !map[id][event]) {
479
+ console.log(`error map[id] ${map[id]}` );
480
+ }
481
+ return map[id][event];
335
482
  };
336
483
  getCurrentWindow = (e) => {
337
484
  const response = {
@@ -342,12 +489,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
342
489
  parent.postMessage(JSON.stringify(response), '*');
343
490
  };
344
491
  getFormData = (e) => {
345
- const templateData = this.getTransformedData(this.state.formData);
492
+ console.log('posting final result', this.state.formData);
346
493
  const response = {
347
494
  action: "getFormData",
348
- value: templateData,
495
+ value: this.getTransformedData(this.state.formData),
349
496
  validity: this.state.isFormValid,
350
- type: templateData.type,
351
497
  };
352
498
  this.setState({checkValidation: true});
353
499
  if (e) {
@@ -383,7 +529,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
383
529
  });
384
530
  obj.versions.base = {};
385
531
  delete android.base;
386
- if (!isEmpty(android)) {
532
+ if (!_.isEmpty(android)) {
387
533
  obj.versions.base.ANDROID = {
388
534
  luid: "{{luid}}",
389
535
  cuid: "{{cuid}}",
@@ -394,14 +540,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
394
540
  style: "BIG_TEXT",
395
541
  message: android['message-editor'],
396
542
  },
397
- custom: map(android, (field, key) => {
543
+ custom: _.map(android, (field, key) => {
398
544
  if (key.indexOf('custom-value') > -1) {
399
545
  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;
400
546
  }
401
547
  return undefined;
402
548
  }).filter((custom) => custom),
403
549
  };
404
- obj.name = isEmpty(obj.name) ? android['message-title'] : obj.name;
405
550
  }
406
551
  if (android['cta-deeplink'] && android['cta-deeplink'] !== "") {
407
552
  obj.versions.base.ANDROID.cta = {
@@ -413,7 +558,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
413
558
  delete obj.versions.base.ANDROID.cta.deepLinkName;
414
559
  }
415
560
  }
416
- if (!isEmpty(ios)) {
561
+ if (!_.isEmpty(ios)) {
417
562
  obj.versions.base.IOS = {
418
563
  luid: "{{luid}}",
419
564
  cuid: "{{cuid}}",
@@ -427,14 +572,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
427
572
  ],
428
573
  categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
429
574
  },
430
- custom: map(ios, (field, key) => {
575
+ custom: _.map(ios, (field, key) => {
431
576
  if (key.indexOf('custom-value') > -1) {
432
577
  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;
433
578
  }
434
579
  return undefined;
435
580
  }).filter((custom) => custom),
436
581
  };
437
- obj.name = isEmpty(obj.name) ? ios['message-title2'] : obj.name;
438
582
  }
439
583
  if (ios['cta-deeplink2'] && ios['cta-deeplink2'] !== "") {
440
584
  obj.versions.base.IOS.cta = {
@@ -448,7 +592,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
448
592
  }
449
593
  if (obj.versions.base.ANDROID) {
450
594
  if (obj.versions.base.ANDROID.cta && obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
451
- const params = map(android, (field, key) => {
595
+ const params = _.map(android, (field, key) => {
452
596
  let actionLink;
453
597
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
454
598
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
@@ -481,7 +625,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
481
625
  }
482
626
  obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
483
627
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
484
- const params = map(android, (field, key) => {
628
+ const params = _.map(android, (field, key) => {
485
629
  let actionLink;
486
630
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
487
631
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
@@ -506,7 +650,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
506
650
  }
507
651
  obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
508
652
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
509
- const params = map(android, (field, key) => {
653
+ const params = _.map(android, (field, key) => {
510
654
  let actionLink;
511
655
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
512
656
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
@@ -523,7 +667,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
523
667
  }
524
668
  if (obj.versions.base.IOS) {
525
669
  if (obj.versions.base.IOS.cta && obj.versions.base.IOS.cta.type === "DEEP_LINK") {
526
- const params = map(ios, (field, key) => {
670
+ const params = _.map(ios, (field, key) => {
527
671
  let actionLink;
528
672
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
529
673
  const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
@@ -543,7 +687,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
543
687
  }
544
688
  if (secondaryCtaIos) {
545
689
  obj.versions.base.IOS.expandableDetails.ctas = [];
546
- const templateCtaId = get(this.state, "templateCta.ctaTemplateDetails[0].id");
547
690
  const cta = {
548
691
  actionText: ios['secondary-cta-1-label'],
549
692
  actionLabel: ios['secondary-cta-1-action'],
@@ -551,14 +694,14 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
551
694
  type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
552
695
  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']),
553
696
  ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
554
- templateCtaId,
697
+ templateCtaId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].ctaTemplateDetails[0].id : undefined,
555
698
  };
556
699
  if (this.props.location.query.type === 'embedded') {
557
700
  delete cta.ioscdeepLinkName;
558
701
  }
559
702
  obj.versions.base.IOS.expandableDetails.ctas.push(cta);
560
703
  if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
561
- const params = map(ios, (field, key) => {
704
+ const params = _.map(ios, (field, key) => {
562
705
  let actionLink;
563
706
  if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
564
707
  const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
@@ -609,6 +752,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
609
752
  };
610
753
 
611
754
  moveToTemplates = () => {
755
+ console.log('in move to Templates');
612
756
  const modalContent = {
613
757
  title: "Alert",
614
758
  body: this.props.intl.formatMessage(messages["Do you really want to go back? All your temporary changes will be lost!"]),
@@ -633,12 +777,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
633
777
  if (temp.standalone) {
634
778
  temp.standalone.sections = this.injectSections(temp.standalone.sections);
635
779
  }
636
- forEach(temp.containers, (container) => {
780
+ _.forEach(temp.containers, (container) => {
637
781
  let tempContainer = container;
638
782
  tempContainer = this.injectContainer(tempContainer);
639
783
  return tempContainer;
640
784
  });
641
-
785
+ console.log('final injected schema', schema);
642
786
  this.setState({schema, isSchemaChanged: true}, () => {
643
787
  this.removeStandAlone();
644
788
  });
@@ -649,10 +793,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
649
793
  const temp = container;
650
794
  if (temp.type === 'tabs') {
651
795
  temp.injectedEvents = {};
652
- forEach(temp.supportedEvents, (event) => {
796
+ _.forEach(temp.supportedEvents, (event) => {
653
797
  temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
654
798
  });
655
- forEach(temp.panes, (pane) => {
799
+ _.forEach(temp.panes, (pane) => {
656
800
  const tempPane = pane;
657
801
  tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
658
802
  tempPane.sections = this.injectSections(tempPane.sections);
@@ -662,8 +806,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
662
806
  };
663
807
 
664
808
  injectMultiColSection = (section) => {
665
- forEach(section.inputFields, (inputField) => {
666
- forEach(inputField.cols, (col) => {
809
+ _.forEach(section.inputFields, (inputField) => {
810
+ _.forEach(inputField.cols, (col) => {
667
811
  const temp = col;
668
812
  if (temp.type === 'popover') {
669
813
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -681,14 +825,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
681
825
  }
682
826
  temp.injectedEvents = {};
683
827
 
684
- forEach(col.supportedEvents, (event) => {
828
+ _.forEach(col.supportedEvents, (event) => {
829
+ console.log('injected event for ', col, event);
685
830
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
686
831
  });
687
832
  return true;
688
833
  });
689
834
  });
690
- forEach(section.actionFields, (actionField) => {
691
- forEach(actionField.cols, (col) => {
835
+ _.forEach(section.actionFields, (actionField) => {
836
+ _.forEach(actionField.cols, (col) => {
692
837
  const temp = col;
693
838
  if (temp.type === 'popover') {
694
839
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -696,7 +841,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
696
841
  return true;
697
842
  }
698
843
  temp.injectedEvents = {};
699
- forEach(col.supportedEvents, (event) => {
844
+ _.forEach(col.supportedEvents, (event) => {
700
845
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
701
846
  });
702
847
  return true;
@@ -706,7 +851,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
706
851
  };
707
852
 
708
853
  injectColLabelSection = (section) => {
709
- forEach(section.inputFields, (inputField) => {
854
+ _.forEach(section.inputFields, (inputField) => {
710
855
  const temp = inputField;
711
856
  if (temp.type === 'popover') {
712
857
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -714,12 +859,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
714
859
  return true;
715
860
  }
716
861
  temp.injectedEvents = {};
717
- forEach(inputField.supportedEvents, (event) => {
862
+ _.forEach(inputField.supportedEvents, (event) => {
718
863
  temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
719
864
  });
720
865
  return true;
721
866
  });
722
- forEach(section.actionFields, (actionField) => {
867
+ _.forEach(section.actionFields, (actionField) => {
723
868
  const temp = actionField;
724
869
  if (temp.type === 'popover') {
725
870
  temp.content.sections = this.injectSections(temp.content.sections);
@@ -727,7 +872,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
727
872
  return true;
728
873
  }
729
874
  temp.injectedEvents = {};
730
- forEach(actionField.supportedEvents, (event) => {
875
+ _.forEach(actionField.supportedEvents, (event) => {
731
876
  temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
732
877
  });
733
878
  return true;
@@ -736,7 +881,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
736
881
  };
737
882
 
738
883
  injectSections = (sections) => {
739
- forEach(sections, (section) => {
884
+ _.forEach(sections, (section) => {
740
885
  let temp = section;
741
886
  if (temp.type === 'col-label') {
742
887
  temp = this.injectColLabelSection(temp);
@@ -750,7 +895,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
750
895
  };
751
896
 
752
897
  injectParentSection = (section) => {
753
- forEach(section.childSections, (childSection) => {
898
+ _.forEach(section.childSections, (childSection) => {
754
899
  let temp = childSection;
755
900
  if (temp.type === 'col-label') {
756
901
  temp = this.injectColLabelSection(temp);
@@ -781,12 +926,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
781
926
  myField.value += myValue;
782
927
  }
783
928
  const event = new Event('input', { bubbles: true });
784
- callNativeEvent({field, value: myField.value, event});
929
+ myField.dispatchEvent(event);
785
930
  };
786
931
 
787
932
  startTemplateCreation = (data) => {
933
+ console.log('startTemplateCreation', data);
788
934
  const content = data.content;
789
- const id = uniqueId();
935
+ const id = _.uniqueId();
790
936
  const tempData = {
791
937
  'message-editor': content,
792
938
  'base': true,
@@ -796,18 +942,24 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
796
942
  formData[0] = tempData;
797
943
  formData.base = tempData;
798
944
  this.setState({formData, loading: false});
945
+ if (data.tags) {
946
+ this.props.globalActions.setInjectedTags(data.tags);
947
+ }
799
948
  };
800
949
 
801
950
  startLoading = (ifEdit) => {
951
+ console.log('startLoading', ifEdit);
802
952
  if (ifEdit) {
803
953
  this.setState({loading: true});
804
954
  }
805
955
  };
806
956
 
807
957
  handleFrameTasks = (e) => {
958
+ console.log('data listened to is', e.data);
808
959
  const type = e.data;
809
-
960
+ console.log('data type', typeof type);
810
961
  if (typeof type === 'object') {
962
+ console.log('received something', type);
811
963
  const action = type.action;
812
964
  switch (action) {
813
965
  case "startTemplateCreation":
@@ -828,15 +980,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
828
980
  this.getFormData(e);
829
981
  break;
830
982
  case "startTemplateCreation":
831
-
983
+ console.log('Starting to create template');
832
984
  //this.getFormData(e);
833
985
  break;
834
986
  case "moveToTemplates":
835
-
987
+ console.log('moving to templates');
836
988
  this.moveToTemplates();
837
989
  break;
838
990
  case "validateContent":
839
-
991
+ console.log('validating Content');
840
992
  this.validateContent(e);
841
993
  break;
842
994
  default:
@@ -846,7 +998,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
846
998
  };
847
999
 
848
1000
  removeStandAlone = () => {
849
- const schema = cloneDeep(this.state.schema);
1001
+ const schema = _.cloneDeep(this.state.schema);
850
1002
  if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
851
1003
  schema.standalone.sections.splice(0, 1);
852
1004
  } else if (this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') {
@@ -858,6 +1010,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
858
1010
  };
859
1011
 
860
1012
  validateContent = (e) => {
1013
+ console.log('posting final validation result', this.state.isFormValid);
861
1014
  const response = {
862
1015
  action: "validateContent",
863
1016
  value: this.state.isFormValid,
@@ -890,347 +1043,643 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
890
1043
  copyContent = () => {
891
1044
 
892
1045
  };
893
- addSecondoryCtaIos = (flag, formData, schemaField) => {
894
- const id = schemaField.id;
895
- if (formData[this.state.currentTab - 1][id]) {
896
- if (!this.props.iosCtasData) {
897
- this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
898
- } else {
899
- this.deleteSecondaryCtaIos(() => { // oncick of change
900
- this.setState({showIosCtaTable: true});
901
- });
902
- }
903
- } else {
904
- const schema = cloneDeep(this.state.schema);
905
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
906
- forEach(inputFields, (inputField, fieldIndex) => {
907
- forEach(inputField.cols, (col) => {
908
- if (col.id === id) {
909
- const indexOfNextField = inputFields.length;
910
- const deleteCount = indexOfNextField - fieldIndex;
911
- const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputField.length)];
912
- set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
913
- this.setState({schema});
914
- }
1046
+ addSecondoryCtaIos = (ev) => {
1047
+ const id = ev.target.id;
1048
+ const schema = _.cloneDeep(this.state.schema);
1049
+ _.forEach(schema.containers, (container) => {
1050
+ _.forEach(container.panes, (pane, paneIndex) => {
1051
+ _.forEach(pane.sections, (section) => {
1052
+ _.forEach(section.childSections, (childeSection) => {
1053
+ _.forEach(childeSection.childSections, (child) => {
1054
+ if (child.type === 'multicols') {
1055
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1056
+ _.forEach(inputField.cols, (col) => {
1057
+ const colId = (paneIndex + 1) > 1 ? col.id + (paneIndex + 1) : col.id;
1058
+ if (colId === id) {
1059
+ const inputId = `secondary-cta-${paneIndex}`;
1060
+ console.log(child.inputFields, fieldIndex);
1061
+ child.inputFields.splice(fieldIndex, 1, {
1062
+ rowClassName: 'mobile-push-row',
1063
+ cols: [
1064
+ {
1065
+ id: `${inputId}-label`,
1066
+ metaType: "label",
1067
+ value: "Secondary CTA",
1068
+ primitive: true,
1069
+ dynamicTab: false,
1070
+ type: "div",
1071
+ width: 4,
1072
+ style: {
1073
+ backgroundColor: 'white',
1074
+ textAlign: 'left',
1075
+ color: '#333333',
1076
+ lineHeight: '24px',
1077
+ fontSize: '14px',
1078
+ fontFamily: 'open-sans',
1079
+ fontStyle: 'normal',
1080
+ paddingTop: '8px',
1081
+ },
1082
+ offset: 0,
1083
+ onlyDisplay: true,
1084
+ colStyle: {
1085
+ flex: 1,
1086
+ },
1087
+ },
1088
+ {
1089
+ id: `${inputId}-table`,
1090
+ type: "table", //Resembles component to be used
1091
+ metaType: "text",
1092
+ datatype: "string",
1093
+ pagination: false,
1094
+ columns: [
1095
+ {
1096
+ title: "Name and Description",
1097
+ dataIndex: "name",
1098
+ key: "name",
1099
+ width: 200,
1100
+ render: (text, record) => (
1101
+ <div>
1102
+ <div>{record.name}</div>
1103
+ <div>{record.description}</div>
1104
+ </div>),
1105
+ },
1106
+ {
1107
+ title: "Button 1",
1108
+ dataIndex: "description",
1109
+ key: "button1",
1110
+ width: 100,
1111
+ render: (text, record) => (
1112
+ <div>
1113
+ {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
1114
+ </div>),
1115
+ },
1116
+ {
1117
+ title: "Button 2",
1118
+ dataIndex: "description",
1119
+ key: "button2",
1120
+ width: 100,
1121
+ render: (text, record) => (
1122
+ <div>
1123
+ {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
1124
+ </div>
1125
+ ),
1126
+ },
1127
+ ],
1128
+ required: true,
1129
+ width: 16,
1130
+ fluid: true,
1131
+ styling: "semantic",
1132
+ order: 1,
1133
+ customComponent: false,
1134
+ supportedEvents: ["onRowClick"],
1135
+ },
1136
+ ],
1137
+ });
1138
+
1139
+ const colField = col;
1140
+ colField.value = "Add Another CTA";
1141
+ colField.fieldsCount += 1;
1142
+ if (col.fieldsCount === col.fieldsLimit) {
1143
+ child.inputFields.pop();
1144
+ }
1145
+ }
1146
+ });
1147
+ });
1148
+ }
1149
+ });
1150
+ });
915
1151
  });
916
1152
  });
917
- }
1153
+ });
1154
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1155
+ this.injectEvents(schema);
1156
+ this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
918
1157
  };
919
1158
  showSelectedIosCta = (selectedConfig) => {
920
1159
  const currentTab = this.state.currentTab;
921
- const schema = cloneDeep(this.state.schema);
1160
+ const schema = _.cloneDeep(this.state.schema);
922
1161
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
923
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
924
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
925
- forEach(inputFields, (inputField, fieldIndex) => {
926
- forEach(inputField.cols, (col) => {
927
- if (col.id === "add-sec-cta-ios") {
928
- const inputId = `secondary-cta-${currentTab - 1}`;
929
-
930
- inputFields.splice(fieldIndex + 1, 0, {
931
- rowClassName: 'mobile-push-row',
932
- cols: [
933
- {
934
- id: `${inputId}-action-display`,
935
- metaType: "label",
936
- value: <CapRow>
937
- <CapColumn span={18}>
938
- <CapHeader
939
- title={this.state.templateCta.name}
940
- description={get(this.state, "templateCta.ctaTemplateDetails[0].buttonText")}
941
- size={"label"}/>
942
- </CapColumn>
943
- <CapColumn span={6}>
944
- <CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
945
- </CapColumn>
946
- </CapRow>,
947
- primitive: true,
948
- dynamicTab: false,
949
- type: "div",
950
- width: 18,
951
- offset: 1,
952
- },
953
- {
954
- id: `${inputId}-action`,
955
- metaType: "label",
956
- value: "",
957
- primitive: true,
958
- dynamicTab: false,
959
- type: "div",
960
- width: 8,
961
- offset: 0,
962
- style: {
963
- display: 'none',
964
- },
965
- },
966
- {
967
- id: `${inputId}-action2`,
968
- metaType: "label",
969
- value: "",
970
- primitive: true,
971
- dynamicTab: false,
972
- type: "div",
973
- width: 8,
974
- offset: 0,
975
- style: {display: 'none'},
976
- },
977
-
978
- ],
979
- });
980
- if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
981
- inputFields.splice(fieldIndex + 2, 0, {
982
- rowClassName: "mobile-push-row",
983
- cols: [
984
-
985
- {
986
- id: `cta-deeplink-${inputId}`,
987
- type: "radioGroup", //Resembles component to be used
988
- metaType: "text",
989
- datatype: "string",
990
- options: ["Deeplink", "External Link"],
991
- inductiveText: ["A page within mobile app", "An external web page"],
992
- value: "Deeplink",
993
- required: true,
994
- width: 18,
995
- offset: 1,
996
- errorMessage: "Please select link type",
997
- fluid: true,
998
-
999
- styling: "semantic",
1000
- order: 1,
1001
- supportedEvents: ["onChange"],
1002
- customComponent: false,
1003
- },
1004
- ],
1005
- });
1006
- inputFields.splice(fieldIndex + 3, 0, {
1007
- rowClassName: 'mobile-push-row',
1008
- id: 'cta-deeplink-select-section',
1009
- cols: [
1010
-
1011
- {
1012
- id: `cta-deeplink-${inputId}-select2`,
1013
- placeholder: "Select DeepLink",
1014
- type: "select", //Resembles component to be used
1015
- options: deepLinkOptions,
1016
- metaType: "text",
1017
- datatype: "string",
1018
- errorMessage: "Select a deeplink",
1019
- required: true,
1020
- fluid: true,
1021
- width: 18,
1022
- offset: 1,
1023
- style: {
1024
- width: '100%',
1025
- marginBottom: '16px',
1026
- },
1027
- styling: "semantic",
1028
- order: 1,
1029
- customComponent: false,
1030
- supportedEvents: [
1031
- 'onSelect',
1032
- ],
1033
- },
1034
- ],
1162
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1163
+ _.forEach(schema.containers, (container) => {
1164
+ _.forEach(container.panes, (pane, paneIndex) => {
1165
+ _.forEach(pane.sections, (section) => {
1166
+ _.forEach(section.childSections, (childeSection) => {
1167
+ _.forEach(childeSection.childSections, (child) => {
1168
+ const formChaild = child;
1169
+ if (child.type === 'multicols') {
1170
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1171
+ _.forEach(inputField.cols, (col) => {
1172
+ if (col.id.indexOf(`secondary-cta-${currentTab - 1}-table`) > -1) {
1173
+ console.log(child, fieldIndex, this.state.formData);
1174
+ const inputId = `secondary-cta-${paneIndex}`;
1175
+
1176
+ formChaild.inputFields[fieldIndex] = {
1177
+ rowClassName: 'mobile-push-row',
1178
+ cols: [
1179
+ {
1180
+ id: `${inputId}-action-label`,
1181
+ metaType: "label",
1182
+ value: "Secondary CTA",
1183
+ primitive: true,
1184
+ dynamicTab: false,
1185
+ type: "div",
1186
+ width: 4,
1187
+ style: {
1188
+ backgroundColor: 'white',
1189
+ textAlign: 'left',
1190
+ color: '#333333',
1191
+ lineHeight: '24px',
1192
+ fontSize: '14px',
1193
+ fontFamily: 'open-sans',
1194
+ fontStyle: 'normal',
1195
+ paddingTop: '8px',
1196
+ },
1197
+ offset: 0,
1198
+ onlyDisplay: true,
1199
+ colStyle: {
1200
+ flex: 1,
1201
+ },
1202
+ },
1203
+ {
1204
+ id: `${inputId}-label`,
1205
+ metaType: "label",
1206
+ value: "",
1207
+ primitive: true,
1208
+ dynamicTab: false,
1209
+ type: "div",
1210
+ width: 16,
1211
+ style: {
1212
+ backgroundColor: 'white',
1213
+ textAlign: 'left',
1214
+ color: '#333333',
1215
+ lineHeight: '24px',
1216
+ fontSize: '14px',
1217
+ fontFamily: 'open-sans',
1218
+ fontStyle: 'normal',
1219
+ paddingTop: '8px',
1220
+ },
1221
+ offset: 0,
1222
+ colStyle: {
1223
+ flex: 1,
1224
+ },
1225
+ },
1226
+ {
1227
+ id: `${inputId}-delete-ios`,
1228
+ type: "icon",
1229
+ value: 'delete',
1230
+ width: 4,
1231
+ submitAction: "onDelete",
1232
+ supportedEvents: ["onDelete"],
1233
+ },
1234
+ ],
1235
+ };
1236
+ formChaild.inputFields[fieldIndex + 1] = {
1237
+ rowClassName: 'mobile-push-row',
1238
+ cols: [
1239
+ {
1240
+ id: `${inputId}-action-label-empty`,
1241
+ metaType: "label",
1242
+ value: "",
1243
+ primitive: true,
1244
+ dynamicTab: false,
1245
+ type: "div",
1246
+ width: 4,
1247
+ onlyDisplay: true,
1248
+ colStyle: {
1249
+ flex: 1,
1250
+ },
1251
+ },
1252
+ {
1253
+ id: `${inputId}-action`,
1254
+ metaType: "label",
1255
+ value: "",
1256
+ primitive: true,
1257
+ dynamicTab: false,
1258
+ type: "div",
1259
+ width: 8,
1260
+ offset: 0,
1261
+ },
1262
+ {
1263
+ id: `${inputId}-action2`,
1264
+ metaType: "label",
1265
+ value: "",
1266
+ primitive: true,
1267
+ dynamicTab: false,
1268
+ type: "div",
1269
+ width: 8,
1270
+ offset: 0,
1271
+ style: {display: 'none'},
1272
+ },
1273
+ ],
1274
+ };
1275
+ if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
1276
+ formChaild.inputFields[fieldIndex + 2] = {
1277
+ rowClassName: "mobile-push-row",
1278
+ cols: [
1279
+ {
1280
+ id: `${inputId}-action-label-empty`,
1281
+ metaType: "label",
1282
+ value: "",
1283
+ primitive: true,
1284
+ dynamicTab: false,
1285
+ type: "div",
1286
+ width: 4,
1287
+ offset: 0,
1288
+ onlyDisplay: true,
1289
+ },
1290
+ {
1291
+ id: `cta-deeplink-${inputId}`,
1292
+ type: "radioGroup", //Resembles component to be used
1293
+ metaType: "text",
1294
+ datatype: "string",
1295
+ options: ["Deeplink", "External Link"],
1296
+ value: "Deeplink",
1297
+ required: true,
1298
+ width: 16,
1299
+ offSet: 4,
1300
+ errorMessage: "Please select link type",
1301
+ fluid: true,
1302
+ style: {
1303
+ fontFamily: 'open-sans',
1304
+ fontSize: '14px',
1305
+ lineHeight: '24px',
1306
+ },
1307
+ styling: "semantic",
1308
+ order: 1,
1309
+ supportedEvents: ["onChange"],
1310
+ customComponent: false,
1311
+ },
1312
+ ],
1313
+ };
1314
+ formChaild.inputFields[fieldIndex + 3] = {
1315
+ rowClassName: 'mobile-push-row',
1316
+ id: 'cta-deeplink-select-section',
1317
+ cols: [
1318
+ {
1319
+ id: "cta-label",
1320
+ metaType: "label",
1321
+ value: "",
1322
+ primitive: true,
1323
+ dynamicTab: false,
1324
+ type: "div",
1325
+ width: 4,
1326
+ onlyDisplay: true,
1327
+ colStyle: {
1328
+ flex: 1,
1329
+ },
1330
+ },
1331
+ {
1332
+ id: `cta-deeplink-${inputId}-select2`,
1333
+ placeholder: "Select DeepLink",
1334
+ type: "select", //Resembles component to be used
1335
+ options: deepLinkOptions,
1336
+ metaType: "text",
1337
+ datatype: "string",
1338
+ errorMessage: "Select a deeplink",
1339
+ required: true,
1340
+ fluid: true,
1341
+ width: 19,
1342
+ style: {
1343
+ fontSize: '14px',
1344
+ fontFamily: 'open-sans',
1345
+ fontStyle: 'normal',
1346
+ // fontWeight: 600,
1347
+ marginBottom: '16px',
1348
+ },
1349
+ styling: "semantic",
1350
+ order: 1,
1351
+ customComponent: false,
1352
+ supportedEvents: [
1353
+ 'onSelect',
1354
+ ],
1355
+ },
1356
+ ],
1357
+ };
1358
+ }
1359
+ }
1360
+ });
1361
+ });
1362
+ }
1035
1363
  });
1036
- }
1037
- }
1364
+ });
1365
+ });
1038
1366
  });
1039
1367
  });
1040
- // set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, inputFields);
1041
-
1042
1368
  this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1043
1369
  this.injectEvents(schema);
1044
1370
  };
1045
- addPrimaryCta = (flag, formData, schemaField) => {
1046
- const id = schemaField.id;
1047
- const schema = cloneDeep(this.state.schema);
1371
+ addPrimaryCta = (ev) => {
1372
+ const id = ev.target.id;
1373
+ const schema = _.cloneDeep(this.state.schema);
1048
1374
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1049
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1050
- // const eventsMap = cloneDeep(this.state.eventsMap);
1051
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1052
- forEach(inputFields, (inputField, fieldIndex) => {
1053
- forEach(inputField.cols, (col) => {
1054
- const colId = col.id;
1055
- if (colId === id) {
1056
- if (formData[this.state.currentTab - 1][id]) { // add primary cta
1057
- inputFields.splice(fieldIndex + 1, 0, {
1058
- rowClassName: 'mobile-push-row',
1059
- cols: [
1060
- {
1061
- id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}`,
1062
- type: "radioGroup", //Resembles component to be used
1063
- metaType: "text",
1064
- datatype: "string",
1065
- options: ["Deeplink", "External Link"],
1066
- inductiveText: ["A page within mobile app", "An external web page"],
1067
- value: "Deeplink",
1068
- required: true,
1069
- width: 18,
1070
- offset: 1,
1071
- errorMessage: "Please select link type",
1072
- fluid: true,
1073
- styling: "semantic",
1074
- order: 1,
1075
- customComponent: false,
1076
- supportedEvents: ["onChange"],
1077
- },
1078
-
1079
- ],
1080
- });
1081
- inputFields.splice(fieldIndex + 2, 0, {
1082
- rowClassName: 'mobile-push-row',
1083
- id: 'cta-deeplink-select-section',
1084
- cols: [
1085
-
1086
- {
1087
- id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-select`,
1088
- placeholder: "Select DeepLink",
1089
- type: "select", //Resembles component to be used
1090
- options: deepLinkOptions,
1091
- metaType: "text",
1092
- datatype: "string",
1093
- required: true,
1094
- errorMessage: "Select a deeplink",
1095
- fluid: true,
1096
- width: 18,
1097
- offset: 1,
1098
- style: {
1099
- width: '100%',
1100
-
1101
-
1102
- marginBottom: '16px',
1103
- },
1104
- styling: "semantic",
1105
- order: 1,
1106
- customComponent: false,
1107
- supportedEvents: [
1108
- 'onSelect',
1109
- ],
1110
- },
1111
- ],
1375
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1376
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1377
+ _.forEach(schema.containers, (container) => {
1378
+ _.forEach(container.panes, (pane) => {
1379
+ _.forEach(pane.sections, (section) => {
1380
+ _.forEach(section.childSections, (childeSection) => {
1381
+ _.forEach(childeSection.childSections, (child) => {
1382
+ if (child.type === 'multicols') {
1383
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1384
+ _.forEach(inputField.cols, (col) => {
1385
+ const colId = `${col.id}${this.state.currentTab > 1 ? this.state.currentTab : ''}`;
1386
+ if (colId === id) {
1387
+ console.log(child.inputFields, fieldIndex);
1388
+ child.inputFields.splice(fieldIndex, 1, {
1389
+ rowClassName: 'mobile-push-row',
1390
+ cols: [
1391
+ {
1392
+ id: "cta-label",
1393
+ metaType: "label",
1394
+ value: "Primary CTA",
1395
+ primitive: true,
1396
+ dynamicTab: false,
1397
+ type: "div",
1398
+ width: 4,
1399
+ style: {
1400
+ backgroundColor: 'white',
1401
+ textAlign: 'left',
1402
+ color: '#333333',
1403
+ lineHeight: '24px',
1404
+ fontSize: '14px',
1405
+ fontFamily: 'open-sans',
1406
+ fontStyle: 'normal',
1407
+ },
1408
+ offset: 0,
1409
+ onlyDisplay: true,
1410
+ colStyle: {
1411
+ flex: 1,
1412
+ },
1413
+ },
1414
+ {
1415
+ id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}`,
1416
+ type: "radioGroup", //Resembles component to be used
1417
+ metaType: "text",
1418
+ datatype: "string",
1419
+ options: ["Deeplink", "External Link"],
1420
+ value: "Deeplink",
1421
+ required: true,
1422
+ width: 18,
1423
+ errorMessage: "Please select link type",
1424
+ fluid: true,
1425
+ styling: "semantic",
1426
+ order: 1,
1427
+ customComponent: false,
1428
+ supportedEvents: ["onChange"],
1429
+ },
1430
+ {
1431
+ id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-delete`,
1432
+ type: "icon",
1433
+ value: 'delete',
1434
+ width: 1,
1435
+ submitAction: "onDelete",
1436
+ supportedEvents: ["onDelete"],
1437
+ },
1438
+ ],
1439
+ });
1440
+ child.inputFields.splice(fieldIndex + 1, 0, {
1441
+ rowClassName: 'mobile-push-row',
1442
+ id: 'cta-deeplink-select-section',
1443
+ cols: [
1444
+ {
1445
+ id: "cta-label",
1446
+ metaType: "label",
1447
+ value: "",
1448
+ primitive: true,
1449
+ dynamicTab: false,
1450
+ type: "div",
1451
+ width: 4,
1452
+ onlyDisplay: true,
1453
+ colStyle: {
1454
+ flex: 1,
1455
+ },
1456
+ },
1457
+ {
1458
+ id: `cta-deeplink${this.state.currentTab > 1 ? this.state.currentTab : ''}-select`,
1459
+ placeholder: "Select DeepLink",
1460
+ type: "select", //Resembles component to be used
1461
+ options: deepLinkOptions,
1462
+ metaType: "text",
1463
+ datatype: "string",
1464
+ required: true,
1465
+ errorMessage: "Select a deeplink",
1466
+ fluid: true,
1467
+ width: 19,
1468
+ style: {
1469
+ fontSize: '14px',
1470
+ fontFamily: 'open-sans',
1471
+ fontStyle: 'normal',
1472
+ // fontWeight: 600,
1473
+ marginBottom: '16px',
1474
+ },
1475
+ styling: "semantic",
1476
+ order: 1,
1477
+ customComponent: false,
1478
+ supportedEvents: [
1479
+ 'onSelect',
1480
+ ],
1481
+ },
1482
+ ],
1483
+ });
1484
+ }
1485
+ });
1486
+ });
1487
+ }
1112
1488
  });
1113
- } else { // remove existing primary cta cuz primary cta is unchecked
1114
- const identifier = (this.state.currentTab - 1) ? 'add-sec-cta-ios' : 'add-sec-cta';
1115
- const indexOfNextField = findIndex(inputFields, {identifier});
1116
- const deleteCount = indexOfNextField - fieldIndex;
1117
- const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1118
- set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1119
- }
1120
- }
1489
+ });
1490
+ });
1121
1491
  });
1122
1492
  });
1123
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true, formData}, () => this.injectEvents(schema));
1493
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1494
+ this.injectEvents(schema);
1124
1495
  };
1125
- addSecondoryCta = (flag, formData, schemaField) => {
1126
- const id = schemaField.id;
1127
- const schema = cloneDeep(this.state.schema);
1496
+ addSecondoryCta = (ev) => {
1497
+ const id = ev.target.id;
1498
+ const schema = _.cloneDeep(this.state.schema);
1128
1499
  const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
1129
1500
  const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1130
- const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1131
- // const eventsMap = cloneDeep(this.state.eventsMap);
1132
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1133
- forEach(inputFields, (inputField, fieldIndex) => {
1134
- forEach(inputField.cols, (col) => {
1135
- if (col.id === id) {
1136
- if (formData[this.state.currentTab - 1][id]) {
1137
- const inputId = `secondary-cta-${col.fieldsCount}`;
1138
- inputFields.splice(fieldIndex + 1, 0, {
1139
- rowClassName: 'mobile-push-row',
1140
- cols: [
1141
-
1142
- {
1143
- id: `${inputId}-label`,
1144
- label: "Button label",
1145
- type: "input", //Resembles component to be used
1146
- metaType: "text",
1147
- datatype: "string",
1148
- required: true,
1149
- width: 18,
1150
- offset: 1,
1151
- placeholder: "Enter CTA Label here",
1152
- fluid: true,
1153
- styling: "semantic",
1154
- order: 1,
1155
- customComponent: false,
1156
- errorMessage: "CTA label cannot be empty.",
1157
- },
1158
-
1159
- ],
1160
- });
1161
- inputFields.splice(fieldIndex + 2, 0, {
1162
- rowClassName: 'mobile-push-row',
1163
- cols: [
1164
-
1165
- {
1166
- id: `cta-deeplink-${inputId}`,
1167
- type: "radioGroup", //Resembles component to be used
1168
- metaType: "text",
1169
- datatype: "string",
1170
- options: ["Deeplink", "External Link"],
1171
- inductiveText: ["A page within mobile app", "An external web page"],
1172
- value: "Deeplink",
1173
- required: true,
1174
- width: 18,
1175
- offset: 1,
1176
- errorMessage: "Please select link type",
1177
- fluid: true,
1178
- styling: "semantic",
1179
- order: 1,
1180
-
1181
- customComponent: false,
1182
- supportedEvents: ["onChange"],
1183
- },
1184
- ],
1185
- });
1186
- inputFields.splice(fieldIndex + 3, 0, {
1187
- rowClassName: 'mobile-push-row',
1188
- id: 'cta-deeplink-select-section',
1189
- cols: [
1190
-
1191
-
1192
- {
1193
- id: `cta-deeplink-${inputId}-select`,
1194
- placeholder: "Select DeepLink",
1195
- type: "select", //Resembles component to be used
1196
- options: deepLinkOptions,
1197
- errorMessage: "Select a deeplink",
1198
- metaType: "text",
1199
- datatype: "string",
1200
- required: true,
1201
- fluid: true,
1202
- width: 18,
1203
- offset: 1,
1204
- style: {
1205
- width: '100%',
1206
- marginBottom: '16px',
1207
- },
1208
- styling: "semantic",
1209
- order: 1,
1210
- customComponent: false,
1211
- supportedEvents: [
1212
- 'onSelect',
1213
- ],
1214
- },
1215
- ],
1501
+ const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? _.map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1502
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1503
+ _.forEach(schema.containers, (container) => {
1504
+ _.forEach(container.panes, (pane) => {
1505
+ _.forEach(pane.sections, (section) => {
1506
+ _.forEach(section.childSections, (childeSection) => {
1507
+ _.forEach(childeSection.childSections, (child) => {
1508
+ if (child.type === 'multicols') {
1509
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1510
+ _.forEach(inputField.cols, (col) => {
1511
+ if (col.id === id) {
1512
+ if (col.fieldsCount < col.fieldsLimit) {
1513
+ const inputId = `secondary-cta-${col.fieldsCount}`;
1514
+ console.log(child.inputFields, fieldIndex);
1515
+ child.inputFields.splice(fieldIndex, 0, {
1516
+ rowClassName: 'mobile-push-row',
1517
+ cols: [
1518
+ {
1519
+ id: `${inputId}-space`,
1520
+ metaType: "label",
1521
+ value: "Secondary CTA",
1522
+ primitive: true,
1523
+ dynamicTab: false,
1524
+ type: "div",
1525
+ width: 4,
1526
+ style: {
1527
+ backgroundColor: 'white',
1528
+ textAlign: 'left',
1529
+ color: '#333333',
1530
+ lineHeight: '24px',
1531
+ fontSize: '14px',
1532
+ fontFamily: 'open-sans',
1533
+ fontStyle: 'normal',
1534
+ paddingTop: '8px',
1535
+ },
1536
+ offset: 0,
1537
+ onlyDisplay: true,
1538
+ colStyle: {
1539
+ flex: 1,
1540
+ },
1541
+ },
1542
+ {
1543
+ id: `${inputId}-label`,
1544
+ label: "link",
1545
+ type: "input", //Resembles component to be used
1546
+ metaType: "text",
1547
+ datatype: "string",
1548
+ required: true,
1549
+ width: 18,
1550
+ offset: 4,
1551
+ placeholder: "Enter CTA Label here",
1552
+ fluid: true,
1553
+ styling: "semantic",
1554
+ order: 1,
1555
+ customComponent: false,
1556
+ errorMessage: "CTA label cannot be empty.",
1557
+ },
1558
+ {
1559
+ id: `${inputId}-delete`,
1560
+ type: "icon",
1561
+ value: 'delete',
1562
+ width: 1,
1563
+ submitAction: "onDelete",
1564
+ supportedEvents: ["onDelete"],
1565
+ },
1566
+ ],
1567
+ });
1568
+ child.inputFields.splice(fieldIndex + 1, 0, {
1569
+ rowClassName: 'mobile-push-row',
1570
+ cols: [
1571
+ {
1572
+ id: `${inputId}-label-space`,
1573
+ metaType: "label",
1574
+ value: "",
1575
+ primitive: true,
1576
+ dynamicTab: false,
1577
+ type: "div",
1578
+ width: 4,
1579
+ style: {
1580
+ backgroundColor: 'white',
1581
+ textAlign: 'left',
1582
+ color: '#333333',
1583
+ lineHeight: '24px',
1584
+ fontSize: '14px',
1585
+ fontFamily: 'open-sans',
1586
+ fontStyle: 'normal',
1587
+ paddingTop: '8px',
1588
+ },
1589
+ offset: 0,
1590
+ onlyDisplay: true,
1591
+ colStyle: {
1592
+ flex: 1,
1593
+ },
1594
+ },
1595
+ {
1596
+ id: `cta-deeplink-${inputId}`,
1597
+ type: "radioGroup", //Resembles component to be used
1598
+ metaType: "text",
1599
+ datatype: "string",
1600
+ options: ["Deeplink", "External Link"],
1601
+ value: "Deeplink",
1602
+ required: true,
1603
+ width: 16,
1604
+ errorMessage: "Please select link type",
1605
+ fluid: true,
1606
+ styling: "semantic",
1607
+ order: 1,
1608
+ style: {
1609
+ lineHeight: '24px',
1610
+ fontSize: '14px',
1611
+ },
1612
+ customComponent: false,
1613
+ supportedEvents: ["onChange"],
1614
+ },
1615
+ ],
1616
+ });
1617
+ child.inputFields.splice(fieldIndex + 2, 0, {
1618
+ rowClassName: 'mobile-push-row',
1619
+ id: 'cta-deeplink-select-section',
1620
+ cols: [
1621
+ {
1622
+ id: "cta-label",
1623
+ metaType: "label",
1624
+ value: "",
1625
+ primitive: true,
1626
+ dynamicTab: false,
1627
+ type: "div",
1628
+ width: 4,
1629
+ onlyDisplay: true,
1630
+ colStyle: {
1631
+ flex: 1,
1632
+ },
1633
+ },
1634
+ {
1635
+ id: `cta-deeplink-${inputId}-select`,
1636
+ placeholder: "Select DeepLink",
1637
+ type: "select", //Resembles component to be used
1638
+ options: deepLinkOptions,
1639
+ errorMessage: "Select a deeplink",
1640
+ metaType: "text",
1641
+ datatype: "string",
1642
+ required: true,
1643
+ fluid: true,
1644
+ width: 19,
1645
+ style: {
1646
+ fontSize: '14px',
1647
+ fontFamily: 'open-sans',
1648
+ fontStyle: 'normal',
1649
+ // fontWeight: 600,
1650
+ marginBottom: '16px',
1651
+ },
1652
+ styling: "semantic",
1653
+ order: 1,
1654
+ customComponent: false,
1655
+ supportedEvents: [
1656
+ 'onSelect',
1657
+ ],
1658
+ },
1659
+ ],
1660
+ });
1661
+ const colField = col;
1662
+ colField.value = "Add Another CTA";
1663
+ colField.fieldsCount += 1;
1664
+ if (col.fieldsCount === col.fieldsLimit) {
1665
+ child.inputFields.pop();
1666
+ }
1667
+ // eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
1668
+ }
1669
+ }
1670
+ });
1671
+ });
1672
+ }
1216
1673
  });
1217
-
1218
- // eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
1219
- } else {
1220
- const identifier = id === "add-sec-cta" ? 'add-sec-cta-2' : null;
1221
- const indexOfNextField = identifier ? findIndex(inputFields, {identifier}) : inputFields.length;
1222
- const deleteCount = indexOfNextField - fieldIndex;
1223
- const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1224
- set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1225
- }
1226
- }
1674
+ });
1675
+ });
1227
1676
  });
1228
1677
  });
1229
1678
  this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1230
1679
  this.injectEvents(schema);
1231
1680
  };
1232
1681
  copyIphoneContent = () => {
1233
- const formData = cloneDeep(this.state.formData);
1682
+ const formData = _.cloneDeep(this.state.formData);
1234
1683
  if (!!formData[1]['message-title2'] && !!formData[1]['message-editor2']) {
1235
1684
  formData[0]['message-title'] = formData[1]['message-title2'];
1236
1685
  formData[0]['message-editor'] = formData[1]['message-editor2'];
@@ -1240,7 +1689,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1240
1689
  }
1241
1690
  };
1242
1691
  copyAndroidContent = () => {
1243
- const formData = cloneDeep(this.state.formData);
1692
+ const formData = _.cloneDeep(this.state.formData);
1244
1693
  if (!!formData[0]['message-title'] && !!formData[0]['message-editor']) {
1245
1694
  formData[1]['message-title2'] = formData[0]['message-title'];
1246
1695
  formData[1]['message-editor2'] = formData[0]['message-editor'];
@@ -1265,40 +1714,76 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1265
1714
  };
1266
1715
 
1267
1716
  showCtaKeys = (eventTriggered, formData, field) => {
1268
- const schema = cloneDeep(this.state.schema);
1269
- const eventsMap = cloneDeep(this.state.eventsMap);
1270
- forEach(schema.containers, (container) => {
1271
- forEach(container.panes, (pane) => {
1272
- forEach(pane.sections, (section) => {
1273
- forEach(section.childSections, (childeSection) => {
1274
- forEach(childeSection.childSections, (child) => {
1717
+ console.log(this.props.Templates);
1718
+ const schema = _.cloneDeep(this.state.schema);
1719
+ const eventsMap = _.cloneDeep(this.state.eventsMap);
1720
+ _.forEach(schema.containers, (container) => {
1721
+ _.forEach(container.panes, (pane) => {
1722
+ _.forEach(pane.sections, (section) => {
1723
+ _.forEach(section.childSections, (childeSection) => {
1724
+ _.forEach(childeSection.childSections, (child) => {
1275
1725
  const formChaild = child;
1276
1726
  if (child.type === 'multicols') {
1277
- forEach(child.inputFields, (inputField, fieldIndex) => {
1278
- forEach(inputField.cols, (col) => {
1727
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1728
+ _.forEach(inputField.cols, (col) => {
1279
1729
  if (col.id === field.id) {
1280
1730
  const formDataKey = col.id.replace("-show-keys", "");
1281
1731
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1282
- let keys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][formDataKey]) : [];
1732
+ let keys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][formDataKey]) : [];
1283
1733
  if (keys[0]) {
1284
1734
  keys = keys[0].keys;
1285
1735
  }
1286
- let rows = map(keys, (key) => {
1736
+ let rows = _.map(keys, (key) => {
1287
1737
  const row = {
1288
1738
  rowClassName: 'mobile-push-row',
1289
1739
  id: 'cta-deeplink-keys',
1290
1740
  cols: [
1291
-
1292
-
1741
+ {
1742
+ id: `${key}-space`,
1743
+ metaType: "label",
1744
+ value: "",
1745
+ primitive: true,
1746
+ dynamicTab: false,
1747
+ type: "div",
1748
+ width: 4,
1749
+ offset: 0,
1750
+ onlyDisplay: true,
1751
+ colStyle: {
1752
+ flex: 1,
1753
+ },
1754
+ },
1755
+ {
1756
+ id: `${key}-label`,
1757
+ metaType: "label",
1758
+ value: key.replace('_', " "),
1759
+ primitive: true,
1760
+ dynamicTab: false,
1761
+ type: "div",
1762
+ width: 5,
1763
+ style: {
1764
+ backgroundColor: 'white',
1765
+ textAlign: 'left',
1766
+ lineHeight: '24px',
1767
+ fontSize: '14px',
1768
+ fontFamily: 'open-sans',
1769
+ fontStyle: 'normal',
1770
+ cursor: 'pointer',
1771
+ paddingTop: '8px',
1772
+ },
1773
+ offset: 0,
1774
+ onlyDisplay: true,
1775
+ colStyle: {
1776
+ flex: 1,
1777
+ },
1778
+ },
1293
1779
  {
1294
1780
  id: `custom-value-${key}-${col.id}`,
1295
- label: key.replace('_', " "),
1781
+ label: "value",
1296
1782
  type: "input", //Resembles component to be used
1297
1783
  metaType: "text",
1298
1784
  datatype: "string",
1299
1785
  required: true,
1300
- width: 18,
1301
- offset: 1,
1786
+ width: 14,
1302
1787
  placeholder: `Please input ${key.replace('_', " ")} here .`,
1303
1788
  fluid: true,
1304
1789
  styling: "semantic",
@@ -1312,9 +1797,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1312
1797
  return row;
1313
1798
  // formChaild.inputFields[fieldIndex + index] = field;
1314
1799
  });
1315
-
1316
-
1317
- const configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === this.state.formData[this.state.currentTab - 1][field.id]);
1800
+ console.log(formChaild);
1801
+ console.log("this in getctakeys", this);
1802
+ const configkeys = _.filter(JSON.parse(deeplinks), (dl) => dl.link === this.state.formData[this.state.currentTab - 1][field.id]);
1318
1803
  if (configkeys.length) {
1319
1804
  const options = configkeys[0].keys;
1320
1805
  formChaild.inputFields = formChaild.inputFields.slice(0, fieldIndex + 1).concat(formChaild.inputFields.slice( fieldIndex + options.length + 1, formChaild.inputFields.length));
@@ -1341,42 +1826,109 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1341
1826
  this.injectEvents(schema);
1342
1827
  };
1343
1828
  saveFormData = (formData) => {
1829
+ console.log('Saving form data', formData, this.state.tabCount);
1344
1830
  const obj = this.getTransformedData(formData);
1345
-
1831
+ console.log('obj', obj);
1346
1832
  this.props.actions.createTemplate(obj);
1347
1833
  };
1348
- deleteSecondaryCtaIos = (callback) => {
1349
- const schema = cloneDeep(this.state.schema);
1350
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1351
- forEach(inputFields, (inputField, fieldIndex) => {
1352
- if (inputField) {
1353
- forEach(inputField.cols, (col) => {
1354
- if (col.id === "add-sec-cta-ios") {
1355
- inputFields.splice(fieldIndex + 1, inputFields.length);
1356
- }
1834
+ deleteSecondaryCtaIos = (event) => {
1835
+ const id = event.currentTarget.id;
1836
+ const schema = _.cloneDeep(this.state.schema);
1837
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1838
+ const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1839
+ const formData = _.cloneDeep(this.state.formData);
1840
+ const self = this;
1841
+ const device = this.state.currentTab === 1 ? 'android' : 'ios';
1842
+ _.forEach(schema.containers, (container) => {
1843
+ _.forEach(container.panes, (pane) => {
1844
+ _.forEach(pane.sections, (section) => {
1845
+ _.forEach(section.childSections, (childeSection) => {
1846
+ _.forEach(childeSection.childSections, (formChild) => {
1847
+ const child = formChild;
1848
+ if (child.type === 'multicols') {
1849
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1850
+ if (inputField) {
1851
+ _.forEach(inputField.cols, (col) => {
1852
+ if (col.id === id) {
1853
+ child.inputFields.splice(fieldIndex, 3);
1854
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1855
+ child.inputFields.splice(fieldIndex, 1);
1856
+ }
1857
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1858
+ const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1859
+ const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1860
+ if (configkeys.length) {
1861
+ const options = configkeys[0].keys;
1862
+ child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1863
+ delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1864
+ delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1865
+ } else {
1866
+ child.inputFields.splice(fieldIndex, 1);
1867
+ }
1868
+ }
1869
+ if (device === 'ios') {
1870
+ child.inputFields[fieldIndex] = {
1871
+ cols: [
1872
+ {
1873
+ id: "add-sec-cta-ios",
1874
+ metaType: "label",
1875
+ value: "Add Secondary CTA",
1876
+ primitive: true,
1877
+ dynamicTab: false,
1878
+ type: "div",
1879
+ style: {
1880
+ backgroundColor: 'white',
1881
+ textAlign: 'left',
1882
+ color: '#2673D7',
1883
+ lineHeight: '24px',
1884
+ marginTop: '16px',
1885
+ fontSize: '14px',
1886
+ fontWeight: '600',
1887
+ fontFamily: 'open-sans',
1888
+ fontStyle: 'normal',
1889
+ cursor: 'pointer',
1890
+ },
1891
+ offset: 0,
1892
+ onlyDisplay: true,
1893
+ colStyle: {
1894
+ flex: 1,
1895
+ },
1896
+ submitAction: "addSecondaryCtaIos",
1897
+ supportedEvents: ["addSecondaryCtaIos"],
1898
+ },
1899
+ ],
1900
+ };
1901
+ }
1902
+ }
1903
+ });
1904
+ }
1905
+ });
1906
+ }
1907
+ });
1908
+ });
1357
1909
  });
1358
- }
1910
+ });
1359
1911
  });
1360
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, callback);
1912
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1361
1913
  this.injectEvents(schema);
1362
1914
  };
1363
1915
  deletePrimaryCTA = (event) => {
1364
1916
  const id = event.currentTarget.id;
1365
- const schema = cloneDeep(this.state.schema);
1366
- // const eventsMap = cloneDeep(this.state.eventsMap);
1917
+ const schema = _.cloneDeep(this.state.schema);
1918
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1367
1919
  const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1368
- const formData = cloneDeep(this.state.formData);
1920
+ const formData = _.cloneDeep(this.state.formData);
1369
1921
  const self = this;
1370
- forEach(schema.containers, (container) => {
1371
- forEach(container.panes, (pane) => {
1372
- forEach(pane.sections, (section) => {
1373
- forEach(section.childSections, (childeSection) => {
1374
- forEach(childeSection.childSections, (formChild) => {
1922
+ _.forEach(schema.containers, (container) => {
1923
+ _.forEach(container.panes, (pane) => {
1924
+ _.forEach(pane.sections, (section) => {
1925
+ _.forEach(section.childSections, (childeSection) => {
1926
+ _.forEach(childeSection.childSections, (formChild) => {
1375
1927
  const child = formChild;
1376
1928
  if (child.type === 'multicols') {
1377
- forEach(child.inputFields, (inputField, fieldIndex) => {
1929
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1378
1930
  if (inputField) {
1379
- forEach(inputField.cols, (col) => {
1931
+ _.forEach(inputField.cols, (col) => {
1380
1932
  if (col.id === id) {
1381
1933
  child.inputFields.splice(fieldIndex, 1);
1382
1934
  if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
@@ -1384,7 +1936,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1384
1936
  }
1385
1937
  if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1386
1938
  const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1387
- const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1939
+ const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1388
1940
  if (configkeys.length) {
1389
1941
  const options = configkeys[0].keys;
1390
1942
  child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
@@ -1407,7 +1959,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1407
1959
  backgroundColor: 'white',
1408
1960
  textAlign: 'left',
1409
1961
  color: '#2673D7',
1410
-
1962
+ lineHeight: '24px',
1963
+ fontSize: '14px',
1964
+ fontWeight: '600',
1965
+ fontFamily: 'open-sans',
1966
+ fontStyle: 'normal',
1411
1967
  cursor: 'pointer',
1412
1968
  },
1413
1969
  offset: 0,
@@ -1444,21 +2000,21 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1444
2000
  return;
1445
2001
  }
1446
2002
  }
1447
- const schema = cloneDeep(this.state.schema);
1448
- // const eventsMap = cloneDeep(this.state.eventsMap);
2003
+ const schema = _.cloneDeep(this.state.schema);
2004
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1449
2005
  const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1450
- const formData = cloneDeep(this.state.formData);
2006
+ const formData = _.cloneDeep(this.state.formData);
1451
2007
  const device = this.state.currentTab === 1 ? 'android' : 'ios';
1452
- forEach(schema.containers, (container) => {
1453
- forEach(container.panes, (pane) => {
1454
- forEach(pane.sections, (section) => {
1455
- forEach(section.childSections, (childeSection) => {
1456
- forEach(childeSection.childSections, (formChild) => {
2008
+ _.forEach(schema.containers, (container) => {
2009
+ _.forEach(container.panes, (pane) => {
2010
+ _.forEach(pane.sections, (section) => {
2011
+ _.forEach(section.childSections, (childeSection) => {
2012
+ _.forEach(childeSection.childSections, (formChild) => {
1457
2013
  const child = formChild;
1458
2014
  if (child.type === 'multicols') {
1459
- forEach(child.inputFields, (inputField, fieldIndex) => {
2015
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1460
2016
  if (inputField) {
1461
- forEach(inputField.cols, (col) => {
2017
+ _.forEach(inputField.cols, (col) => {
1462
2018
  if (col.id === id) {
1463
2019
  if (device === 'ios') {
1464
2020
  child.inputFields.splice(fieldIndex, 3);
@@ -1471,7 +2027,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1471
2027
  if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1472
2028
  const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
1473
2029
  const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
1474
- const configkeys = this.props.Templates.selectedWeChatAccount ? filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
2030
+ const configkeys = this.props.Templates.selectedWeChatAccount ? _.filter(JSON.parse(deeplinks), (dl) => dl.link === selectedDeeplink) : [];
1475
2031
  if (configkeys.length) {
1476
2032
  const options = configkeys[0].keys;
1477
2033
  child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
@@ -1493,7 +2049,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1493
2049
  backgroundColor: 'white',
1494
2050
  textAlign: 'left',
1495
2051
  color: '#2673D7',
1496
-
2052
+ lineHeight: '24px',
2053
+ fontSize: '14px',
2054
+ marginTop: '16px',
2055
+ fontWeight: '600',
2056
+ fontFamily: 'open-sans',
2057
+ fontStyle: 'normal',
1497
2058
  cursor: 'pointer',
1498
2059
  },
1499
2060
  offset: 0,
@@ -1521,7 +2082,12 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1521
2082
  backgroundColor: 'white',
1522
2083
  textAlign: 'left',
1523
2084
  color: '#2673D7',
1524
-
2085
+ lineHeight: '24px',
2086
+ fontSize: '14px',
2087
+ fontWeight: '600',
2088
+ marginTop: '16px',
2089
+ fontFamily: 'open-sans',
2090
+ fontStyle: 'normal',
1525
2091
  cursor: 'pointer',
1526
2092
  },
1527
2093
  offset: 0,
@@ -1555,7 +2121,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1555
2121
  backgroundColor: 'white',
1556
2122
  textAlign: 'left',
1557
2123
  color: '#2673D7',
1558
-
2124
+ lineHeight: '24px',
2125
+ fontSize: '14px',
2126
+ fontWeight: '600',
2127
+ fontFamily: 'open-sans',
2128
+ fontStyle: 'normal',
1559
2129
  cursor: 'pointer',
1560
2130
  },
1561
2131
  offset: 0,
@@ -1586,6 +2156,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1586
2156
  this.injectEvents(schema);
1587
2157
  };
1588
2158
  handleOnTagsContextChange = (data) => {
2159
+ console.log('parent tags context', data);
1589
2160
  const query = {
1590
2161
  layout: 'mobilepush',
1591
2162
  type: 'TAG',
@@ -1594,11 +2165,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1594
2165
  };
1595
2166
  this.props.globalActions.fetchSchemaForEntity(query);
1596
2167
  };
1597
- handleClose = () => {
1598
- const formData = cloneDeep(this.state.formData);
1599
- formData[this.state.currentTab - 1]['add-sec-cta-ios'] = false;
1600
- this.setState({showIosCtaTable: false, formData});
1601
- }
1602
2168
  render() {
1603
2169
  let tipText = this.props.Create.createTemplateInProgress ? "Saving Template..." : "";
1604
2170
  let loading = this.props.Create.createTemplateInProgress ? this.props.Create.createTemplateInProgress : false;
@@ -1633,13 +2199,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1633
2199
  onChange={this.onFormDataChange}
1634
2200
  currentTab={this.state.currentTab}
1635
2201
  parent={this}
1636
- formData={cloneDeep(this.state.formData)}
2202
+ formData={_.cloneDeep(this.state.formData)}
1637
2203
  location={this.props.location}
1638
2204
  tags={tags}
1639
2205
  injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
1640
2206
  onFormValidityChange={this.setFormValidity}
1641
2207
  usingTabContainer
1642
- checkValidation={this.state.checkValidation}
2208
+ checkValidation={false}
1643
2209
  iosCtasData={this.state.iosCtasData}
1644
2210
  tabKey={this.state.tabKey}
1645
2211
  tabCount={2}
@@ -1653,65 +2219,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1653
2219
  setModalContent={this.setModalContent}
1654
2220
  />
1655
2221
  </Col>
1656
- {this.props.iosCtasData && this.state.showIosCtaTable &&
1657
- <CapSlideBox
1658
- size="size-l"
1659
- header={<CapHeader
1660
- title={<FormattedMessage {...messages.selectActionButton} />}
1661
- prefix={
1662
- <PrefixWrapper>
1663
- <CapIcons.backIcon onClick={this.handleClose} />
1664
- </PrefixWrapper>
1665
- }
1666
-
1667
- />}
1668
- content={<CapTable
1669
- rowSelection={{
1670
- type: 'radio',
1671
- onSelect: (record) => {
1672
- this.setState({templateCta: record, showIosCtaTable: false}, () => this.selectCtaIos(record));
1673
- },
1674
- }}
1675
- dataSource={this.props.iosCtasData} columns={[
1676
- {
1677
- title: "Name and Description",
1678
- dataIndex: "name",
1679
- key: "name",
1680
- width: 200,
1681
- render: (text, record) => (
1682
- <div>
1683
- <div>{record.name}</div>
1684
- <div>{record.description}</div>
1685
- </div>),
1686
- },
1687
- {
1688
- title: "Button 1",
1689
- dataIndex: "description",
1690
- key: "button1",
1691
- width: 100,
1692
- render: (text, record) => (
1693
- <div>
1694
- {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
1695
- </div>),
1696
- },
1697
- {
1698
- title: "Button 2",
1699
- dataIndex: "description",
1700
- key: "button2",
1701
- width: 100,
1702
- render: (text, record) => (
1703
- <div>
1704
- {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
1705
- </div>
1706
- ),
1707
- },
1708
- ]}
1709
- />}
1710
- show={this.state.showIosCtaTable}
1711
- handleClose={this.handleClose}
1712
- />
1713
- }
1714
-
1715
2222
  </Row>
1716
2223
  </Spin>
1717
2224
  </div>
@@ -1732,7 +2239,6 @@ Create.propTypes = {
1732
2239
  intl: intlShape.isRequired,
1733
2240
  supportedTags: PropTypes.array,
1734
2241
  getDefaultTags: PropTypes.string,
1735
- iosCtasData: PropTypes.array,
1736
2242
  injectedTags: PropTypes.object,
1737
2243
  };
1738
2244
 
@@ -1741,7 +2247,6 @@ const mapStateToProps = createStructuredSelector({
1741
2247
  createResponse: makeSelectCreateResponse(),
1742
2248
  metaEntities: makeSelectMetaEntities(),
1743
2249
  Templates: makeSelectTemplates(),
1744
- iosCtasData: makeSelectIosCta(),
1745
2250
  injectedTags: setInjectedTags(),
1746
2251
  });
1747
2252