@capillarytech/creatives-library 2.0.70 → 2.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/EmailMobilePreview/index.scss +0 -1
  4. package/components/EmailPreviewV2/_emailPreviewV2.scss +4 -1
  5. package/components/EmailPreviewV2/index.js +1 -1
  6. package/components/FormBuilder/index.js +25 -10
  7. package/components/Header/index.js +3 -1
  8. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  9. package/components/TemplatePreview/index.js +45 -51
  10. package/components/TemplatePreview/messages.js +1 -1
  11. package/config/app.js +1 -0
  12. package/containers/Cap/actions.js +0 -5
  13. package/containers/Cap/reducer.js +1 -1
  14. package/containers/Cap/selectors.js +0 -13
  15. package/containers/Ebill/index.js +1 -2
  16. package/containers/Email/_email.scss +1 -0
  17. package/containers/Email/actions.js +3 -8
  18. package/containers/Email/constants.js +0 -1
  19. package/containers/Email/index.js +947 -322
  20. package/containers/Email/reducer.js +0 -3
  21. package/containers/Email/sagas.js +6 -3
  22. package/containers/Email/selectors.js +1 -4
  23. package/containers/Line/Create/index.js +1 -2
  24. package/containers/Line/Edit/_lineEdit.scss +4 -0
  25. package/containers/Line/Edit/index.js +1 -3
  26. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  27. package/containers/MobilePush/Create/actions.js +0 -6
  28. package/containers/MobilePush/Create/constants.js +0 -1
  29. package/containers/MobilePush/Create/index.js +1133 -628
  30. package/containers/MobilePush/Create/messages.js +1 -5
  31. package/containers/MobilePush/Create/reducer.js +0 -2
  32. package/containers/MobilePush/Create/selectors.js +3 -3
  33. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  34. package/containers/MobilePush/Edit/index.js +1127 -393
  35. package/containers/MobilePush/Edit/messages.js +0 -4
  36. package/containers/MobilePush/Edit/reducer.js +1 -2
  37. package/containers/MobilePush/Edit/selectors.js +3 -6
  38. package/containers/Sms/Create/_smsCreate.scss +2 -1
  39. package/containers/Sms/Create/actions.js +4 -4
  40. package/containers/Sms/Create/index.js +570 -102
  41. package/containers/Sms/Create/sagas.js +2 -1
  42. package/containers/Sms/Edit/actions.js +5 -10
  43. package/containers/Sms/Edit/constants.js +0 -1
  44. package/containers/Sms/Edit/index.js +548 -103
  45. package/containers/Sms/Edit/reducer.js +0 -2
  46. package/containers/Sms/Edit/sagas.js +3 -1
  47. package/containers/TagList/index.js +3 -3
  48. package/containers/Templates/actions.js +1 -3
  49. package/containers/Templates/index.js +299 -268
  50. package/containers/Templates/messages.js +90 -122
  51. package/containers/Templates/reducer.js +3 -3
  52. package/containers/Templates/sagas.js +1 -5
  53. package/containers/Templates/selectors.js +1 -41
  54. package/containers/WeChat/MapTemplates/index.js +3 -4
  55. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  56. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  57. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  58. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  59. package/index.js +31 -31
  60. package/initialState.js +6 -0
  61. package/package.json +3 -3
  62. package/routes.js +24 -19
  63. package/services/api.js +6 -2
  64. package/services/getSchema.js +18 -0
  65. package/v2Containers/App/actions.js +7 -0
  66. package/v2Containers/App/constants.js +3 -0
  67. package/v2Containers/App/reducer.js +19 -0
  68. package/v2Containers/App/sagas.js +26 -0
  69. package/v2Containers/App/selectors.js +25 -0
  70. package/v2Containers/App/tests/actions.test.js +18 -0
  71. package/v2Containers/App/tests/reducer.test.js +9 -0
  72. package/v2Containers/App/tests/sagas.test.js +15 -0
  73. package/v2Containers/App/tests/selectors.test.js +10 -0
  74. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  75. package/v2Containers/Assets/Gallery/actions.js +37 -0
  76. package/v2Containers/Assets/Gallery/constants.js +23 -0
  77. package/v2Containers/Assets/Gallery/index.js +479 -0
  78. package/v2Containers/Assets/Gallery/messages.js +97 -0
  79. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  80. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  81. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  82. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  83. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  84. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  85. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  86. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  87. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  88. package/v2Containers/CallTask/_callTask.scss +5 -0
  89. package/v2Containers/CallTask/actions.js +15 -0
  90. package/v2Containers/CallTask/constants.js +7 -0
  91. package/v2Containers/CallTask/index.js +141 -0
  92. package/v2Containers/CallTask/messages.js +21 -0
  93. package/v2Containers/CallTask/reducer.js +23 -0
  94. package/v2Containers/CallTask/sagas.js +11 -0
  95. package/v2Containers/CallTask/selectors.js +25 -0
  96. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  97. package/v2Containers/CallTask/tests/index.test.js +10 -0
  98. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  99. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  100. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  101. package/v2Containers/Cap/actions.js +64 -0
  102. package/v2Containers/Cap/constants.js +24 -0
  103. package/v2Containers/Cap/index.js +349 -0
  104. package/v2Containers/Cap/messsages.js +63 -0
  105. package/v2Containers/Cap/reducer.js +111 -0
  106. package/v2Containers/Cap/sagas.js +143 -0
  107. package/v2Containers/Cap/selectors.js +85 -0
  108. package/v2Containers/Cap/tests/index.test.js +16 -0
  109. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  110. package/v2Containers/ChannelTemplates/actions.js +20 -0
  111. package/v2Containers/ChannelTemplates/constants.js +8 -0
  112. package/v2Containers/ChannelTemplates/index.js +48 -0
  113. package/v2Containers/ChannelTemplates/messages.js +13 -0
  114. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  115. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  116. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  117. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  118. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  119. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  120. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  121. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  122. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  123. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  124. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  125. package/v2Containers/CreativesContainer/actions.js +27 -0
  126. package/v2Containers/CreativesContainer/constants.js +16 -0
  127. package/v2Containers/CreativesContainer/index.js +483 -0
  128. package/v2Containers/CreativesContainer/index.scss +27 -0
  129. package/v2Containers/CreativesContainer/messages.js +293 -0
  130. package/v2Containers/CreativesContainer/reducer.js +29 -0
  131. package/v2Containers/CreativesContainer/sagas.js +11 -0
  132. package/v2Containers/CreativesContainer/selectors.js +30 -0
  133. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  134. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  135. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  136. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  137. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  138. package/v2Containers/Dashboard/actions.js +15 -0
  139. package/v2Containers/Dashboard/constants.js +7 -0
  140. package/v2Containers/Dashboard/index.js +54 -0
  141. package/v2Containers/Dashboard/messages.js +13 -0
  142. package/v2Containers/Dashboard/reducer.js +21 -0
  143. package/v2Containers/Dashboard/sagas.js +11 -0
  144. package/v2Containers/Dashboard/selectors.js +25 -0
  145. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  146. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  147. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  148. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  149. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  150. package/v2Containers/Ebill/_ebill.scss +5 -0
  151. package/v2Containers/Ebill/actions.js +43 -0
  152. package/v2Containers/Ebill/constants.js +20 -0
  153. package/v2Containers/Ebill/index.js +1261 -0
  154. package/v2Containers/Ebill/messages.js +73 -0
  155. package/v2Containers/Ebill/reducer.js +72 -0
  156. package/v2Containers/Ebill/sagas.js +65 -0
  157. package/v2Containers/Ebill/selectors.js +25 -0
  158. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  159. package/v2Containers/Ebill/tests/index.test.js +10 -0
  160. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  161. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  162. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  163. package/v2Containers/Email/_email.scss +140 -0
  164. package/v2Containers/Email/actions.js +86 -0
  165. package/v2Containers/Email/constants.js +37 -0
  166. package/v2Containers/Email/index.js +2703 -0
  167. package/v2Containers/Email/initialSchema.js +540 -0
  168. package/v2Containers/Email/messages.js +237 -0
  169. package/v2Containers/Email/reducer.js +147 -0
  170. package/v2Containers/Email/sagas.js +133 -0
  171. package/v2Containers/Email/selectors.js +34 -0
  172. package/v2Containers/Email/tests/actions.test.js +18 -0
  173. package/v2Containers/Email/tests/index.test.js +10 -0
  174. package/v2Containers/Email/tests/reducer.test.js +9 -0
  175. package/v2Containers/Email/tests/sagas.test.js +15 -0
  176. package/v2Containers/Email/tests/selectors.test.js +10 -0
  177. package/v2Containers/EmailWrapper/actions.js +15 -0
  178. package/v2Containers/EmailWrapper/constants.js +7 -0
  179. package/v2Containers/EmailWrapper/index.js +258 -0
  180. package/v2Containers/EmailWrapper/messages.js +57 -0
  181. package/v2Containers/EmailWrapper/reducer.js +23 -0
  182. package/v2Containers/EmailWrapper/sagas.js +11 -0
  183. package/v2Containers/EmailWrapper/selectors.js +25 -0
  184. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  185. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  186. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  187. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  188. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  189. package/v2Containers/LanguageProvider/actions.js +17 -0
  190. package/v2Containers/LanguageProvider/constants.js +8 -0
  191. package/v2Containers/LanguageProvider/index.js +46 -0
  192. package/v2Containers/LanguageProvider/reducer.js +30 -0
  193. package/v2Containers/LanguageProvider/selectors.js +20 -0
  194. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  195. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  196. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  197. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  198. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  199. package/v2Containers/Line/Create/actions.js +90 -0
  200. package/v2Containers/Line/Create/constants.js +39 -0
  201. package/v2Containers/Line/Create/index.js +822 -0
  202. package/v2Containers/Line/Create/messages.js +173 -0
  203. package/v2Containers/Line/Create/reducer.js +99 -0
  204. package/v2Containers/Line/Create/sagas.js +107 -0
  205. package/v2Containers/Line/Create/selectors.js +36 -0
  206. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  207. package/v2Containers/Line/Edit/actions.js +79 -0
  208. package/v2Containers/Line/Edit/constants.js +27 -0
  209. package/v2Containers/Line/Edit/index.js +1050 -0
  210. package/v2Containers/Line/Edit/messages.js +157 -0
  211. package/v2Containers/Line/Edit/reducer.js +83 -0
  212. package/v2Containers/Line/Edit/sagas.js +81 -0
  213. package/v2Containers/Line/Edit/selectors.js +29 -0
  214. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  215. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  216. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  217. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  218. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  219. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  220. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  221. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  222. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  223. package/v2Containers/Login/index.js +106 -0
  224. package/v2Containers/Login/messages.js +21 -0
  225. package/v2Containers/Login/selectors.js +25 -0
  226. package/v2Containers/Login/tests/index.test.js +10 -0
  227. package/v2Containers/Login/tests/sagas.test.js +15 -0
  228. package/v2Containers/Login/tests/selectors.test.js +10 -0
  229. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  230. package/v2Containers/MobilePush/Create/actions.js +52 -0
  231. package/v2Containers/MobilePush/Create/constants.js +24 -0
  232. package/v2Containers/MobilePush/Create/index.js +1759 -0
  233. package/v2Containers/MobilePush/Create/messages.js +237 -0
  234. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  235. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  236. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  237. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  238. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  239. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  240. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  241. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  242. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  243. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  244. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  245. package/v2Containers/MobilePush/Edit/index.js +1851 -0
  246. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  247. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  248. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  249. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  250. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  251. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  252. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  253. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  254. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  255. package/v2Containers/MobilePush/commonMethods.js +249 -0
  256. package/v2Containers/MobilePush/eventsMap.js +127 -0
  257. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  258. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  259. package/v2Containers/MobilepushWrapper/index.js +136 -0
  260. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  261. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  262. package/v2Containers/NotFoundPage/index.js +25 -0
  263. package/v2Containers/NotFoundPage/messages.js +13 -0
  264. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  265. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  266. package/v2Containers/Sms/Create/actions.js +27 -0
  267. package/v2Containers/Sms/Create/constants.js +16 -0
  268. package/v2Containers/Sms/Create/index.js +1017 -0
  269. package/v2Containers/Sms/Create/messages.js +85 -0
  270. package/v2Containers/Sms/Create/reducer.js +41 -0
  271. package/v2Containers/Sms/Create/sagas.js +35 -0
  272. package/v2Containers/Sms/Create/selectors.js +28 -0
  273. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  274. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  275. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  276. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  277. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  278. package/v2Containers/Sms/Edit/actions.js +45 -0
  279. package/v2Containers/Sms/Edit/constants.js +18 -0
  280. package/v2Containers/Sms/Edit/index.js +1018 -0
  281. package/v2Containers/Sms/Edit/messages.js +89 -0
  282. package/v2Containers/Sms/Edit/reducer.js +52 -0
  283. package/v2Containers/Sms/Edit/sagas.js +50 -0
  284. package/v2Containers/Sms/Edit/selectors.js +32 -0
  285. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  286. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  287. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  288. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  289. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  290. package/v2Containers/Sms/initialSchema.js +281 -0
  291. package/v2Containers/TagList/_tagList.scss +8 -0
  292. package/v2Containers/TagList/actions.js +15 -0
  293. package/v2Containers/TagList/constants.js +7 -0
  294. package/v2Containers/TagList/index.js +236 -0
  295. package/v2Containers/TagList/messages.js +13 -0
  296. package/v2Containers/TagList/reducer.js +23 -0
  297. package/v2Containers/TagList/sagas.js +11 -0
  298. package/v2Containers/TagList/selectors.js +25 -0
  299. package/v2Containers/TagList/tests/actions.test.js +18 -0
  300. package/v2Containers/TagList/tests/index.test.js +10 -0
  301. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  302. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  303. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  304. package/v2Containers/Templates/_templates.scss +349 -0
  305. package/v2Containers/Templates/actions.js +110 -0
  306. package/v2Containers/Templates/constants.js +45 -0
  307. package/v2Containers/Templates/index.js +1725 -0
  308. package/v2Containers/Templates/messages.js +278 -0
  309. package/v2Containers/Templates/reducer.js +142 -0
  310. package/v2Containers/Templates/sagas.js +180 -0
  311. package/v2Containers/Templates/selectors.js +68 -0
  312. package/v2Containers/Templates/tests/actions.test.js +18 -0
  313. package/v2Containers/Templates/tests/index.test.js +10 -0
  314. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  315. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  316. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  317. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  318. package/v2Containers/TemplatesV2/actions.js +16 -0
  319. package/v2Containers/TemplatesV2/constants.js +10 -0
  320. package/v2Containers/TemplatesV2/index.js +217 -0
  321. package/v2Containers/TemplatesV2/messages.js +29 -0
  322. package/v2Containers/TemplatesV2/selectors.js +25 -0
  323. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  324. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  325. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  326. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  327. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  328. package/v2Containers/TestPage/constants.js +7 -0
  329. package/v2Containers/TestPage/index.js +31 -0
  330. package/v2Containers/TestPage/messages.js +13 -0
  331. package/v2Containers/TestPage/reducer.js +21 -0
  332. package/v2Containers/TestPage/sagas.js +11 -0
  333. package/v2Containers/Testv2/actions.js +15 -0
  334. package/v2Containers/Testv2/constants.js +7 -0
  335. package/v2Containers/Testv2/index.js +47 -0
  336. package/v2Containers/Testv2/messages.js +13 -0
  337. package/v2Containers/Testv2/reducer.js +23 -0
  338. package/v2Containers/Testv2/sagas.js +11 -0
  339. package/v2Containers/Testv2/selectors.js +25 -0
  340. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  341. package/v2Containers/Testv2/tests/index.test.js +10 -0
  342. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  343. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  344. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  345. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  346. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  347. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  348. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  349. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  350. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  351. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  352. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  354. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  355. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  356. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  357. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  392. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  393. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  394. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  395. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -12,12 +12,10 @@ import {bindActionCreators} from "redux";
12
12
  import { connect } from 'react-redux';
13
13
  import { Row, Col, Spin, Breadcrumb, notification } from 'antd';
14
14
  import { createStructuredSelector } from 'reselect';
15
- import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
16
- import _, {get, findIndex, set, forEach, cloneDeep} from 'lodash';
17
- import { CapSlideBox, CapHeader, CapTable, CapLink, CapRow, CapColumn, CapIcons} from '@capillarytech/cap-ui-library';
18
- import styled from 'styled-components';
19
- import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse, makeSelectIosCta} from "./selectors";
20
- import {makeSelectMetaEntities, setInjectedTags, isLoadingMetaEntities} from "../../Cap/selectors";
15
+ import { injectIntl, intlShape } from 'react-intl';
16
+ import _ from 'lodash';
17
+ import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse} from "../../MobilePush/Edit/selectors";
18
+ import {makeSelectMetaEntities, setInjectedTags} from "../../Cap/selectors";
21
19
  import {getMessageObject} from "../../../utils/messageUtils";
22
20
  import FormBuilder from '../../../components/FormBuilder';
23
21
  import * as globalActions from "../../Cap/actions";
@@ -26,20 +24,128 @@ import * as templatesActions from "../../Templates/actions";
26
24
  import {makeSelectTemplates} from "../../Templates/selectors";
27
25
  import messages from './messages';
28
26
  import './_mobilePushCreate.scss';
29
- import callNativeEvent from '../../../utils/callNativeEvent';
30
27
  import {makeSelectCreate} from "../Create/selectors";
31
-
32
- import getEventsMap from '../eventsMap';
33
- import {getPrimaryCtaFields, getSecondaryCtaFields, getLinkTypeFields} from '../commonMethods';
34
28
  const BreadcrumbItem = Breadcrumb.Item;
35
29
 
36
- const PrefixWrapper = styled.div`
37
- margin-right: 16px;
38
- `;
39
30
  export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
40
31
  constructor(props) {
41
32
  super(props);
42
- const eventsMap = getEventsMap(this);
33
+ const map = {
34
+ "template-name": {
35
+ onChange: this.onTemplateNameChange,
36
+ },
37
+ "cta-deeplink-secondary-cta-0": {
38
+ onChange: this.onLinkTypeChange,
39
+ },
40
+ "cta-deeplink-secondary-cta-1": {
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-1-select2": {
104
+ onSelect: this.showCtaKeys,
105
+ },
106
+ "cta-deeplink-secondary-cta-0-select": {
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
+ "mobilepush-template": {
146
+ onSelect: this.onTemplateChange,
147
+ },
148
+ };
43
149
  this.state = {
44
150
  formData: {},
45
151
  tabCount: 1,
@@ -50,12 +156,9 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
50
156
  isFormValid: true,
51
157
  injectedTags: {},
52
158
  showModal: false,
53
- eventsMap,
159
+ eventsMap: map,
54
160
  modalContent: {title: "Alert", body: this.props.intl.formatMessage(messages['template not configured,']), type: 'confirm'},
55
161
  };
56
- this.getPrimaryCtaFields = getPrimaryCtaFields.bind(this);
57
- this.getSecondaryCtaFields = getSecondaryCtaFields.bind(this);
58
- this.getLinkTypeFields = getLinkTypeFields.bind(this);
59
162
  }
60
163
  componentWillMount() {
61
164
  console.log('edit mounting');
@@ -71,7 +174,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
71
174
  const query = {
72
175
  layout: 'MOBILEPUSH',
73
176
  type: 'LAYOUT',
74
- version: "v2",
75
177
  };
76
178
  this.props.globalActions.fetchSchemaForEntity(query);
77
179
  console.log(this.props.params);
@@ -82,14 +184,20 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
82
184
  if (!_.isEmpty(this.state.schema)) {
83
185
  this.injectEvents(this.state.schema);
84
186
  }
85
- if (this.props.location.query && (typeof this.props.location.query.module === 'undefined' || this.props.isFullMode === false)) { // when this containers is imported from creatives library
86
- const templateId = get(this, "props.params.id");
87
- if (templateId) {
88
- this.props.actions.getTemplateDetails(templateId);
187
+ if (this.props.location.query && typeof this.props.location.query.module === 'undefined') { // when this containers is imported from creatives library
188
+ if (this.props.params.id) {
189
+ this.props.actions.getTemplateDetails(this.props.params.id);
89
190
  } else {
90
191
  this.props.actions.setTemplateDetails(this.props.templateData);
91
192
  }
92
193
  }
194
+ const type = this.props.location.query.type;
195
+ if (type === 'embedded') {
196
+ const response = {
197
+ action: 'startTemplateCreation',
198
+ };
199
+ parent.postMessage(JSON.stringify(response), '*');
200
+ }
93
201
  }
94
202
  componentWillReceiveProps(nextProps) {
95
203
  if (nextProps.isGetFormData) {
@@ -110,12 +218,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
110
218
  }
111
219
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.fullSchema)) {
112
220
  this.setState({fullSchema: nextProps.metaEntities.layouts[0].definition, schema: (nextProps.location.query.module === 'loyalty') ? nextProps.metaEntities.layouts[0].definition.textSchema : {}}, () => {
113
- const templateId = get(this, "props.params.id");
114
- if (nextProps.location.query.module !== 'loyalty' && templateId && templateId !== 'temp') {
115
- this.props.actions.getTemplateDetails(templateId);
221
+ if (nextProps.location.query.module !== 'loyalty' && this.props.params.id !== 'temp') {
222
+ this.props.actions.getTemplateDetails(this.props.params.id);
116
223
  }
117
224
  const type = this.props.location.query.type;
118
- if (type === 'embedded' && templateId === 'temp' && _.isEmpty(this.state.formData)) { // when his.props.params.id is temp that means mobile push template content will be passed from post message from parent with startTemplateCreation action
225
+ if (type === 'embedded' && this.props.params.id === 'temp' && _.isEmpty(this.state.formData)) { // when his.props.params.id is temp that means mobile push template content will be passed from post message from parent with startTemplateCreation action
119
226
  const response = {
120
227
  action: 'startTemplateCreation',
121
228
  };
@@ -132,24 +239,10 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
132
239
  this.setTemplateOptions(nextProps.Edit.mobilepushTemplates);
133
240
  }
134
241
  }
135
- if (!_.isEmpty(nextProps.templateDetails) && _.isEmpty(this.state.editData) && !_.isEmpty(this.state.fullSchema) && selectedWeChatAccount && (this.props.location.query.type !== 'embedded' || this.props.isFullMode === false)) {
242
+ if (nextProps.templateDetails && nextProps.templateDetails.name && _.isEmpty(this.state.editData) && (this.props.location.query.type !== 'embedded' || (!_.isEmpty(this.state.fullSchema) && selectedWeChatAccount))) {
136
243
  this.props = nextProps;
137
244
  const mode = nextProps.templateDetails.definition ? nextProps.templateDetails.definition.mode : nextProps.templateDetails.mode;
138
245
  const schema = mode === "text" ? this.state.fullSchema.textSchema : this.state.fullSchema.imageSchema;
139
- const isAndroidSupported = get(this, "props.Templates.selectedWeChatAccount.configs.android") === '1';
140
- const isIosSupported = get(this, "props.Templates.selectedWeChatAccount.configs.ios") === '1';
141
- if (!isAndroidSupported) {
142
- const androidField = get(schema, "containers[0].panes[0]");
143
- androidField.isSupported = false;
144
- this.setState({currentTab: 2});
145
- set(schema, "containers[0].panes[0]", androidField);
146
- }
147
- if (!isIosSupported) {
148
- const iosField = get(schema, "containers[0].panes[1]");
149
- iosField.isSupported = false;
150
-
151
- set(schema, "containers[0].panes[1]", iosField);
152
- }
153
246
  this.setEditState(nextProps.templateDetails, schema);
154
247
  this.getTags();
155
248
  }
@@ -159,8 +252,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
159
252
  this.setState({formData});
160
253
  this.props.actions.clearAsset();
161
254
  }
162
- if (nextProps.iosCtasData) {
163
- this.setState({showIosCtaTable: true});
255
+ if (nextProps.Edit.iosCtasData) {
256
+ this.setState({iosCtasData: nextProps.Edit.iosCtasData});
164
257
  }
165
258
  if (nextProps.Edit.editResponse && nextProps.Edit.editResponse.templateId) {
166
259
  console.log('reseting schema');
@@ -203,13 +296,12 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
203
296
  onFormDataChange = (formData, tabCount, currentTab) => {
204
297
  console.log('Form data changed is ', formData, tabCount, currentTab);
205
298
  const newFormData = _.cloneDeep(formData);
206
- const {templateCta} = this.state;
207
- if (!_.isEmpty(templateCta) && this.state.currentTab === 2) {
208
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta.name;
209
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta.ctaTemplateDetails[0].buttonText;
299
+ if (newFormData[this.state.currentTab - 1] && newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`]) {
300
+ 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;
301
+ 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;
210
302
  delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
211
- if (templateCta.ctaTemplateDetails[1]) {
212
- newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta.ctaTemplateDetails[1].buttonText;
303
+ if (newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-table`].ctaTemplateDetails[1]) {
304
+ 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;
213
305
  }
214
306
  }
215
307
  if (newFormData["mobilepush-accounts"] !== this.state.formData["mobilepush-accounts"]) {
@@ -232,23 +324,157 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
232
324
  }
233
325
  };
234
326
 
235
- onLinkTypeChange = (eventTriggered, formData, field, currentTab, inputSchema) => {
327
+ onLinkTypeChange = (eventTriggered, formData, field, tabIndex, inputSchema) => {
328
+ const currentTab = tabIndex || this.state.currentTab;
236
329
  const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
237
330
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
238
- const tabIndex = currentTab || this.state.currentTab;
239
- const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
240
- const id = field.id;
241
- const fieldIndex = findIndex(inputFields, {identifier: id});
242
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
243
- const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
244
- // let inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${id}-select` : `${id}-text`;
245
- // if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
246
- // inputId = `${inputId}${tabIndex || this.state.currentTab}`;
247
- // }
248
- const newInputFields = this.getLinkTypeFields({inputFieldsArgs: inputFields, fieldIndex, deepLinkOptions, formData, field});
249
- set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
250
-
251
- if (currentTab) { // identifying where ist called from setEditData or by event handler
331
+ _.forEach(schema.containers, (container) => {
332
+ _.forEach(container.panes, (pane, paneIndex) => {
333
+ _.forEach(pane.sections, (section) => {
334
+ _.forEach(section.childSections, (childeSection) => {
335
+ _.forEach(childeSection.childSections, (child) => {
336
+ const formChaild = child;
337
+ if (child.type === 'multicols') {
338
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
339
+ if (inputField) {
340
+ _.forEach(inputField.cols, (col) => {
341
+ if (col.id === field.id && currentTab === paneIndex + 1) {
342
+ console.log(child, fieldIndex, this.state.formData);
343
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
344
+ const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
345
+ const deeplinkValue = formData[currentTab - 1][field.id];
346
+ const componentIndex = fieldIndex + 1;
347
+ let inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${col.id}-select` : `${col.id}-text`;
348
+ if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
349
+ inputId = `${inputId}${tabIndex || this.state.currentTab}`;
350
+ }
351
+ if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === child.inputFields.length - 1 || child.inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
352
+ const row = {
353
+ rowClassName: 'mobile-push-row',
354
+ id: 'cta-deeplink-select-section',
355
+ cols: [
356
+ {
357
+ id: "cta-label",
358
+ metaType: "label",
359
+ value: "",
360
+ primitive: true,
361
+ dynamicTab: false,
362
+ type: "div",
363
+ width: 4,
364
+ onlyDisplay: true,
365
+ colStyle: {
366
+ flex: 1,
367
+ },
368
+ },
369
+ {
370
+ id: inputId,
371
+ placeholder: "Select DeepLink",
372
+ type: "select", //Resembles component to be used
373
+ options: deepLinkOptions,
374
+ errorMessage: "Select a deeplink",
375
+ metaType: "text",
376
+ datatype: "string",
377
+ required: true,
378
+ fluid: true,
379
+ width: 19,
380
+ style: {
381
+ fontSize: '14px',
382
+ fontFamily: 'open-sans',
383
+ fontStyle: 'normal',
384
+ // fontWeight: 600,
385
+ marginBottom: '16px',
386
+ },
387
+ styling: "semantic",
388
+ order: 1,
389
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
390
+ customComponent: false,
391
+ supportedEvents: [
392
+ 'onSelect',
393
+ ],
394
+ },
395
+ ],
396
+ };
397
+ if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-external-link") {
398
+ formChaild.inputFields[componentIndex] = row;
399
+ } else {
400
+ formChaild.inputFields.splice(componentIndex, 0, row);
401
+ }
402
+ } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
403
+ const row = {
404
+ rowClassName: 'mobile-push-row',
405
+ id: 'cta-external-link',
406
+ cols: [
407
+ {
408
+ id: "cta-label",
409
+ metaType: "label",
410
+ value: "",
411
+ primitive: true,
412
+ dynamicTab: false,
413
+ type: "div",
414
+ width: 4,
415
+ offset: 0,
416
+ onlyDisplay: true,
417
+ },
418
+ {
419
+ id: inputId,
420
+ placeholder: "External Link",
421
+ type: "input", //Resembles component to be used
422
+ metaType: "text",
423
+ datatype: "string",
424
+ errorMessage: "External Link cannot be empty.",
425
+ required: true,
426
+ fluid: true,
427
+ width: 19,
428
+ style: {
429
+ fontSize: '14px',
430
+ fontFamily: 'open-sans',
431
+ fontStyle: 'normal',
432
+ // fontWeight: 600,
433
+ marginBottom: '16px',
434
+ },
435
+ styling: "semantic",
436
+ order: 1,
437
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
438
+ offSet: 4,
439
+ customComponent: false,
440
+ standalone: false,
441
+ },
442
+ ],
443
+ };
444
+ if (!child.inputFields[fieldIndex + 1] || child.inputFields[componentIndex].id === "cta-deeplink-select-section") {
445
+ formChaild.inputFields[componentIndex] = row;
446
+ if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
447
+ formChaild.inputFields.splice(componentIndex + 1, 1);
448
+ }
449
+ if (child.inputFields[componentIndex + 1] && child.inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
450
+ const dataIndex = tabIndex || this.state.currentTab;
451
+ let selector = `${col.id}-select`;
452
+ if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
453
+ selector = `${selector}${tabIndex || this.state.currentTab}`;
454
+ }
455
+ let configkeys = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === formData[dataIndex - 1][selector]);
456
+ if (configkeys[0]) {
457
+ configkeys = configkeys[0].keys;
458
+ }
459
+ if (configkeys.length) {
460
+ formChaild.inputFields = formChaild.inputFields.slice(0, componentIndex + 1).concat(formChaild.inputFields.slice( componentIndex + 1 + configkeys.length, formChaild.inputFields.length));
461
+ }
462
+ }
463
+ } else {
464
+ formChaild.inputFields.splice(componentIndex, 0, row);
465
+ }
466
+ }
467
+ }
468
+ });
469
+ }
470
+ });
471
+ }
472
+ });
473
+ });
474
+ });
475
+ });
476
+ });
477
+ if (tabIndex) {
252
478
  return schema;
253
479
  }
254
480
  this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
@@ -351,7 +577,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
351
577
  licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
352
578
  };
353
579
  if (this.props.location.query && this.props.location.query.module !== 'dvs') {
354
- obj.definition.mode = this.props.Edit.templateDetails.mode || get(this, 'props.Edit.templateDetails.definition.mode');
580
+ obj.definition.mode = this.props.Edit.templateDetails.mode;
355
581
  }
356
582
  const android = {};
357
583
  Object.keys(formData[0]).forEach((data) => {
@@ -524,8 +750,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
524
750
 
525
751
  if (secondaryCtaIos) {
526
752
  obj.versions.base.IOS.expandableDetails.ctas = [];
527
- const templateCtaId = get(this.state, "templateCta.ctaTemplateDetails[0].id");
528
-
529
753
  const cta = {
530
754
  actionText: ios['secondary-cta-1-label'],
531
755
  actionLabel: ios['secondary-cta-1-action'],
@@ -533,7 +757,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
533
757
  type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
534
758
  actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text2']),
535
759
  ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
536
- templateCtaId,
760
+ templateCtaId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].ctaTemplateDetails[0].id : undefined,
537
761
  };
538
762
  if (this.props.location.query.type === 'embedded') {
539
763
  delete cta.ioscdeepLinkName;
@@ -573,7 +797,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
573
797
  getMappedEvent = (id, event) => {
574
798
  const map = this.state.eventsMap;
575
799
  if (!map[id] || !map[id][event]) {
576
- console.log(`error map[id] ${map[id]} ${id} ${event}` );
800
+ console.log(`error map[id] ${map[id]}` );
577
801
  }
578
802
  return map[id][event];
579
803
  };
@@ -678,7 +902,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
678
902
  }
679
903
  formData[0] = android;
680
904
  const ios = {};
681
- const templateCta = {};
682
905
  ios[`message-title2`] = iosData ? iosData.title : '';
683
906
  ios['message-editor2'] = iosData ? iosData.message : '';
684
907
  if (data.mode === "image") {
@@ -725,12 +948,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
725
948
  ios[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select2`] = param.split('=')[1];
726
949
  });
727
950
  }
728
- set(templateCta, "ctaTemplateDetails[0].buttonText", iosData.expandableDetails.ctas[0].actionLabel);
729
- set(templateCta, "name", iosData.expandableDetails.ctas[0].actionText);
730
- set(templateCta, "ctaTemplateDetails[0].id", iosData.expandableDetails.ctas[0].templateCtaId);
731
951
  ios['secondary-cta-1-action'] = iosData.expandableDetails.ctas[0].actionLabel;
732
952
  if (iosData.expandableDetails.ctas[0].actionLabel2) {
733
- set(templateCta, "ctaTemplateDetails[1].buttonText", iosData.expandableDetails.ctas[0].actionLabel2);
734
953
  ios['secondary-cta-1-action2'] = iosData.expandableDetails.ctas[0].actionLabel2;
735
954
  }
736
955
  }
@@ -741,51 +960,42 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
741
960
  // formData[0].tabKey = '1';
742
961
  // formData[1].tabKey = '2';
743
962
  console.log('form data after discarding ', formData);
744
- this.setState({templateCta}, () => {
745
- this.getSchemaForFormData(formData, schema);
746
- this.setState({tabCount, formData, editData: data, currentTab: 1});
747
- });
963
+ this.getSchemaForFormData(formData, schema);
964
+ this.setState({tabCount, formData, editData: data, currentTab: 1});
748
965
  }
749
966
 
750
- getSchemaForFormData = (formdata, inputSchema) => {
967
+ getSchemaForFormData = (formData, inputSchema) => {
751
968
  let schema = inputSchema;
752
- const formData = _.cloneDeep(formdata);
753
969
  if (!_.isEmpty(formData[0])) {
754
970
  if (formData[0]['cta-deeplink']) {
755
- formData[0]['add-pri-cta'] = true;
756
- schema = this.addPrimaryCta(null, formData, {id: 'add-pri-cta'}, schema, 1);
971
+ schema = this.addPrimaryCta(null, {id: 'add-pri-cta'}, schema, 1);
757
972
  schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink'}, 1, schema);
758
973
  schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-select'}, 1, schema);
759
974
  }
760
975
  if (formData[0]['cta-deeplink-secondary-cta-0']) {
761
- formData[0]['add-sec-cta'] = true;
762
- schema = this.addSecondoryCta(null, formData, {id: 'add-sec-cta'}, schema, 1);
976
+ schema = this.addSecondoryCta(null, {id: 'add-sec-cta'}, schema);
763
977
  schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-0'}, 1, schema);
764
978
  schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-0-select'}, 1, schema);
765
979
  }
766
980
  if (formData[0]['cta-deeplink-secondary-cta-1']) {
767
- formData[0]['add-sec-cta-2'] = true;
768
- schema = this.addSecondoryCta(null, formData, {id: 'add-sec-cta-2'}, schema, 1);
981
+ schema = this.addSecondoryCta(null, {id: 'add-sec-cta'}, schema);
769
982
  schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 1, schema);
770
983
  schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select'}, 1, schema);
771
984
  }
772
985
  }
773
986
  if (!_.isEmpty(formData[1])) {
774
987
  if (formData[1]['cta-deeplink2']) {
775
- formData[1]['add-pri-cta-ios'] = true;
776
- schema = this.addPrimaryCta(null, formData, {id: 'add-pri-cta-ios'}, schema, 2);
988
+ schema = this.addPrimaryCta(null, {id: 'add-pri-cta-ios'}, schema, 2);
777
989
  schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink2'}, 2, schema);
778
990
  schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink2-select'}, 2, schema);
779
991
  }
780
992
  if (formData[1]['secondary-cta-1-action']) {
781
- formData[1]['add-sec-cta-ios'] = true;
782
-
783
993
  schema = this.showSelectedIosCta(schema, {id: 'add-sec-cta-ios'}, 2, undefined, formData[1]['cta-deeplink-secondary-cta-1']);
784
994
  schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 2, schema);
785
995
  schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select2'}, 2, schema);
786
996
  }
787
997
  }
788
- this.setState({schema, isSchemaChanged: true, formData});
998
+ this.setState({schema, isSchemaChanged: true});
789
999
  this.injectEvents(schema);
790
1000
  };
791
1001
 
@@ -841,7 +1051,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
841
1051
  myField.value += myValue;
842
1052
  }
843
1053
  const event = new Event('input', { bubbles: true });
844
- callNativeEvent({field, value: myField.value, event});
1054
+ myField.dispatchEvent(event);
845
1055
  };
846
1056
 
847
1057
  selectCtaIos = (selectedConfig) => {
@@ -881,128 +1091,218 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
881
1091
  }
882
1092
  };
883
1093
 
884
- showSelectedIosCta = (inputSchema, field, tab, selectedConfig) => {
1094
+ showSelectedIosCta = (inputSchema, field, tab, selectedConfig, showDeeplink) => {
885
1095
  const currentTab = tab || this.state.currentTab;
886
1096
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
887
1097
  const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
888
1098
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
889
1099
  const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
890
1100
 
891
- const inputFields = get(schema, `containers[0].panes[${currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
892
- forEach(inputFields, (inputField, fieldIndex) => {
893
- forEach(inputField.cols, (col) => {
894
- if (col.id === "add-sec-cta-ios") {
895
- const inputId = `secondary-cta-${currentTab - 1}`;
896
- inputFields.splice(fieldIndex + 1, 0, {
897
- rowClassName: 'mobile-push-row',
898
- cols: [
899
- {
900
- id: `${inputId}-action-display`,
901
- metaType: "label",
902
- value: <CapRow>
903
- <CapColumn span={18}>
904
- <CapHeader
905
- title={this.state.templateCta.name}
906
- description={get(this.state, "templateCta.ctaTemplateDetails[0].buttonText")}
907
- size={"label"}/>
908
- </CapColumn>
909
- <CapColumn span={6}>
910
- <CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
911
- </CapColumn>
912
- </CapRow>,
913
- primitive: true,
914
- dynamicTab: false,
915
- type: "div",
916
- width: 18,
917
- offset: 1,
918
- },
919
- {
920
- id: `${inputId}-action`,
921
- metaType: "label",
922
- value: "",
923
- primitive: true,
924
- dynamicTab: false,
925
- type: "div",
926
- width: 8,
927
- offset: 0,
928
- style: {
929
- display: 'none',
930
- },
931
- },
932
- {
933
- id: `${inputId}-action2`,
934
- metaType: "label",
935
- value: "",
936
- primitive: true,
937
- dynamicTab: false,
938
- type: "div",
939
- width: 8,
940
- offset: 0,
941
- style: {display: 'none'},
942
- },
943
-
944
- ],
945
- });
946
- if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
947
- inputFields.splice(fieldIndex + 2, 0, {
948
- rowClassName: "mobile-push-row",
949
- identifier: `cta-deeplink-${inputId}`,
950
- cols: [
951
-
952
- {
953
- id: `cta-deeplink-${inputId}`,
954
- type: "radioGroup", //Resembles component to be used
955
- metaType: "text",
956
- datatype: "string",
957
- options: ["Deeplink", "External Link"],
958
- inductiveText: ["A page within mobile app", "An external web page"],
959
- value: "Deeplink",
960
- required: true,
961
- width: 18,
962
- offset: 1,
963
- errorMessage: "Please select link type",
964
- fluid: true,
965
-
966
- styling: "semantic",
967
- order: 1,
968
- supportedEvents: ["onChange"],
969
- customComponent: false,
970
- },
971
- ],
972
- });
973
- inputFields.splice(fieldIndex + 3, 0, {
974
- rowClassName: 'mobile-push-row',
975
- id: 'cta-deeplink-select-section',
976
- identifier: `cta-deeplink-${inputId}-select2`,
977
- cols: [
1101
+ _.forEach(schema.containers, (container) => {
1102
+ _.forEach(container.panes, (pane, paneIndex) => {
1103
+ _.forEach(pane.sections, (section) => {
1104
+ _.forEach(section.childSections, (childeSection) => {
1105
+ _.forEach(childeSection.childSections, (child) => {
1106
+ const formChaild = child;
1107
+ if (child.type === 'multicols') {
1108
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1109
+ _.forEach(inputField.cols, (col) => {
1110
+ if (col.id.indexOf(`secondary-cta-${currentTab - 1}-table`) > -1 || (field && field.id === col.id)) {
1111
+ console.log(child, fieldIndex, this.state.formData);
1112
+ const inputId = `secondary-cta-${paneIndex}`;
978
1113
 
979
- {
980
- id: `cta-deeplink-${inputId}-select2`,
981
- placeholder: "Select DeepLink",
982
- type: "select", //Resembles component to be used
983
- options: deepLinkOptions,
984
- metaType: "text",
985
- datatype: "string",
986
- errorMessage: "Select a deeplink",
987
- required: true,
988
- fluid: true,
989
- width: 18,
990
- offset: 1,
991
- style: {
992
- width: '100%',
993
- marginBottom: '16px',
994
- },
995
- styling: "semantic",
996
- order: 1,
997
- customComponent: false,
998
- supportedEvents: [
999
- 'onSelect',
1000
- ],
1001
- },
1002
- ],
1114
+ formChaild.inputFields[fieldIndex] = {
1115
+ rowClassName: 'mobile-push-row',
1116
+ cols: [
1117
+ {
1118
+ id: `${inputId}-action-label`,
1119
+ metaType: "label",
1120
+ value: "Secondary CTA",
1121
+ primitive: true,
1122
+ dynamicTab: false,
1123
+ type: "div",
1124
+ width: 4,
1125
+ style: {
1126
+ backgroundColor: 'white',
1127
+ textAlign: 'left',
1128
+ color: '#333333',
1129
+ lineHeight: '24px',
1130
+ fontSize: '14px',
1131
+ fontFamily: 'open-sans',
1132
+ fontStyle: 'normal',
1133
+ paddingTop: '8px',
1134
+ },
1135
+ offset: 0,
1136
+ onlyDisplay: true,
1137
+ colStyle: {
1138
+ flex: 1,
1139
+ },
1140
+ },
1141
+ {
1142
+ id: `${inputId}-label`,
1143
+ metaType: "label",
1144
+ value: "",
1145
+ primitive: true,
1146
+ dynamicTab: false,
1147
+ type: "div",
1148
+ width: 18,
1149
+ style: {
1150
+ backgroundColor: 'white',
1151
+ textAlign: 'left',
1152
+ color: '#333333',
1153
+ lineHeight: '24px',
1154
+ fontSize: '14px',
1155
+ fontFamily: 'open-sans',
1156
+ fontStyle: 'normal',
1157
+ paddingTop: '8px',
1158
+ },
1159
+ offset: 0,
1160
+ colStyle: {
1161
+ flex: 1,
1162
+ },
1163
+ },
1164
+ {
1165
+ id: `${inputId}-delete-ios`,
1166
+ type: "icon",
1167
+ value: 'delete',
1168
+ width: 1,
1169
+ submitAction: "onDelete",
1170
+ supportedEvents: ["onDelete"],
1171
+ },
1172
+ ],
1173
+ };
1174
+ formChaild.inputFields[fieldIndex + 1] = {
1175
+ rowClassName: 'mobile-push-row',
1176
+ cols: [
1177
+ {
1178
+ id: `${inputId}-action-label-empty`,
1179
+ metaType: "label",
1180
+ value: "",
1181
+ primitive: true,
1182
+ dynamicTab: false,
1183
+ type: "div",
1184
+ width: 4,
1185
+ colStyle: {
1186
+ flex: 1,
1187
+ },
1188
+ },
1189
+ {
1190
+ id: `${inputId}-action`,
1191
+ metaType: "label",
1192
+ value: "",
1193
+ primitive: true,
1194
+ dynamicTab: false,
1195
+ type: "div",
1196
+ width: 16,
1197
+ offset: 0,
1198
+ },
1199
+ {
1200
+ id: `${inputId}-action2`,
1201
+ metaType: "label",
1202
+ value: "",
1203
+ primitive: true,
1204
+ dynamicTab: false,
1205
+ type: "div",
1206
+ width: 8,
1207
+ offset: 0,
1208
+ style: {display: 'none'},
1209
+ },
1210
+ ],
1211
+ };
1212
+ let showDeeplinkOption = selectedConfig ? (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56") : true;
1213
+ if (!selectedConfig) {
1214
+ showDeeplinkOption = showDeeplink;
1215
+ }
1216
+ if (showDeeplinkOption) {
1217
+ formChaild.inputFields[fieldIndex + 2] = {
1218
+ rowClassName: "mobile-push-row",
1219
+ cols: [
1220
+ {
1221
+ id: `${inputId}-action-label-empty`,
1222
+ metaType: "label",
1223
+ value: "",
1224
+ primitive: true,
1225
+ dynamicTab: false,
1226
+ type: "div",
1227
+ width: 4,
1228
+ offset: 0,
1229
+ onlyDisplay: true,
1230
+ },
1231
+ {
1232
+ id: `cta-deeplink-${inputId}`,
1233
+ type: "radioGroup", //Resembles component to be used
1234
+ metaType: "text",
1235
+ datatype: "string",
1236
+ options: ["Deeplink", "External Link"],
1237
+ value: "Deeplink",
1238
+ required: true,
1239
+ width: 16,
1240
+ offSet: 4,
1241
+ fluid: true,
1242
+ style: {
1243
+ fontFamily: 'open-sans',
1244
+ fontSize: '14px',
1245
+ lineHeight: '24px',
1246
+ },
1247
+ styling: "semantic",
1248
+ order: 1,
1249
+ supportedEvents: ["onChange"],
1250
+ customComponent: false,
1251
+ },
1252
+ ],
1253
+ };
1254
+ formChaild.inputFields[fieldIndex + 3] = {
1255
+ rowClassName: 'mobile-push-row',
1256
+ id: 'cta-deeplink-select-section',
1257
+ cols: [
1258
+ {
1259
+ id: "cta-label",
1260
+ metaType: "label",
1261
+ value: "",
1262
+ primitive: true,
1263
+ dynamicTab: false,
1264
+ type: "div",
1265
+ width: 4,
1266
+ onlyDisplay: true,
1267
+ colStyle: {
1268
+ flex: 1,
1269
+ },
1270
+ },
1271
+ {
1272
+ id: `cta-deeplink-${inputId}-select2`,
1273
+ placeholder: "Select DeepLink",
1274
+ type: "select", //Resembles component to be used
1275
+ options: deepLinkOptions,
1276
+ errorMessage: "Select a deeplink",
1277
+ metaType: "text",
1278
+ datatype: "string",
1279
+ required: true,
1280
+ fluid: true,
1281
+ width: 19,
1282
+ style: {
1283
+ fontSize: '14px',
1284
+ fontFamily: 'open-sans',
1285
+ fontStyle: 'normal',
1286
+ // fontWeight: 600,
1287
+ marginBottom: '16px',
1288
+ },
1289
+ styling: "semantic",
1290
+ order: 1,
1291
+ customComponent: false,
1292
+ supportedEvents: [
1293
+ 'onSelect',
1294
+ ],
1295
+ },
1296
+ ],
1297
+ };
1298
+ }
1299
+ }
1300
+ });
1301
+ });
1302
+ }
1003
1303
  });
1004
- }
1005
- }
1304
+ });
1305
+ });
1006
1306
  });
1007
1307
  });
1008
1308
  if (!inputSchema) {
@@ -1096,19 +1396,98 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1096
1396
  this.injectEvents(schema);
1097
1397
  };
1098
1398
 
1099
- deleteSecondaryCtaIos = (callback) => {
1100
- const schema = cloneDeep(this.state.schema);
1101
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1102
- forEach(inputFields, (inputField, fieldIndex) => {
1103
- if (inputField) {
1104
- forEach(inputField.cols, (col) => {
1105
- if (col.id === "add-sec-cta-ios") {
1106
- inputFields.splice(fieldIndex + 1, inputFields.length);
1107
- }
1399
+ deleteSecondaryCtaIos = (event) => {
1400
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1401
+ const id = event.currentTarget.id;
1402
+ const schema = _.cloneDeep(this.state.schema);
1403
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1404
+ const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1405
+ const formData = _.cloneDeep(this.state.formData);
1406
+ const self = this;
1407
+ const device = this.state.currentTab === 1 ? 'android' : 'ios';
1408
+ _.forEach(schema.containers, (container) => {
1409
+ _.forEach(container.panes, (pane) => {
1410
+ _.forEach(pane.sections, (section) => {
1411
+ _.forEach(section.childSections, (childeSection) => {
1412
+ _.forEach(childeSection.childSections, (formChild) => {
1413
+ const child = formChild;
1414
+ if (child.type === 'multicols') {
1415
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1416
+ if (inputField) {
1417
+ _.forEach(inputField.cols, (col) => {
1418
+ if (col.id === id) {
1419
+ if (device === 'ios') {
1420
+ child.inputFields.splice(fieldIndex, 3);
1421
+ delete formData[self.state.currentTab - 1][`secondary-cta-1-action`];
1422
+ delete formData[self.state.currentTab - 1][`secondary-cta-1-action2`];
1423
+ delete formData[self.state.currentTab - 1][`secondary-cta-1-label`];
1424
+ delete formData[self.state.currentTab - 1][`cta-deeplink-secondary-cta-1`];
1425
+ }
1426
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1427
+ child.inputFields.splice(fieldIndex, 1);
1428
+ delete formData[self.state.currentTab - 1][`cta-deeplink-secondary-cta-1-text2`];
1429
+ }
1430
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1431
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1432
+ const configkeys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === selectedDeeplink) : [];
1433
+ if (configkeys.length) {
1434
+ const options = configkeys[0].keys;
1435
+ _.forEach(options, (opt) => {
1436
+ delete formData[this.state.currentTab - 1][`custom-value-${opt}2-cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1437
+ delete formData[this.state.currentTab - 1][`custom-value-${opt}-cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1438
+ });
1439
+ child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1440
+
1441
+ delete formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete-ios', 'select2')}`];
1442
+ } else {
1443
+ child.inputFields.splice(fieldIndex, 1);
1444
+ }
1445
+ }
1446
+ if (device === 'ios') {
1447
+ child.inputFields[fieldIndex] = {
1448
+ cols: [
1449
+ {
1450
+ id: "add-sec-cta-ios",
1451
+ metaType: "label",
1452
+ value: "Add Secondary CTA",
1453
+ primitive: true,
1454
+ dynamicTab: false,
1455
+ type: "div",
1456
+ style: {
1457
+ backgroundColor: 'white',
1458
+ textAlign: 'left',
1459
+ color: '#2673D7',
1460
+ lineHeight: '24px',
1461
+ fontSize: '14px',
1462
+ marginTop: '16px',
1463
+ fontWeight: '600',
1464
+ fontFamily: 'open-sans',
1465
+ fontStyle: 'normal',
1466
+ cursor: 'pointer',
1467
+ },
1468
+ offset: 0,
1469
+ onlyDisplay: true,
1470
+ colStyle: {
1471
+ flex: 1,
1472
+ },
1473
+ submitAction: "addSecondaryCtaIos",
1474
+ supportedEvents: ["addSecondaryCtaIos"],
1475
+ },
1476
+ ],
1477
+ };
1478
+ }
1479
+ }
1480
+ });
1481
+ }
1482
+ });
1483
+ }
1484
+ });
1485
+ });
1108
1486
  });
1109
- }
1487
+ });
1110
1488
  });
1111
- this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, callback);
1489
+
1490
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1112
1491
  this.injectEvents(schema);
1113
1492
  };
1114
1493
 
@@ -1300,6 +1679,9 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1300
1679
  this.setEditState(editData, this.state.schema);
1301
1680
  });
1302
1681
  }
1682
+ if (data.tags) {
1683
+ this.props.globalActions.setInjectedTags(data.tags);
1684
+ }
1303
1685
  };
1304
1686
  discardValues = () => {
1305
1687
  console.log('discarding', this.props.Edit);
@@ -1365,10 +1747,10 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1365
1747
  if (this.props.location.query.type === 'embedded' && ((temp.type === "tag-list" || temp.type === "div" || temp.type === "icon") && this.props.location.query.module !== "dvs") && (temp.supportedEvents)) {
1366
1748
  temp.className = `${temp.className} hide`;
1367
1749
  }
1368
- // if (this.props.location.query.type === 'embedded' && (temp.type === "input" || temp.type === "textarea" || temp.type === "radioGroup") && this.props.location.query.module !== "dvs") {
1369
- // temp.className = `${temp.className} disabled`;
1370
- // temp.disabled = true;
1371
- // }
1750
+ if (this.props.location.query.type === 'embedded' && (temp.type === "input" || temp.type === "textarea" || temp.type === "radioGroup") && this.props.location.query.module !== "dvs") {
1751
+ temp.className = `${temp.className} disabled`;
1752
+ temp.disabled = true;
1753
+ }
1372
1754
  if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-template" ) {
1373
1755
  temp.options = this.state.templateOptions ? this.state.templateOptions : [];
1374
1756
  }
@@ -1388,7 +1770,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1388
1770
  _.forEach(section.actionFields, (actionField) => {
1389
1771
  _.forEach(actionField.cols, (col) => {
1390
1772
  const temp = col;
1391
- // temp.disabled = this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs";
1773
+ temp.disabled = this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs";
1392
1774
  if (temp.type === 'popover') {
1393
1775
  temp.content.sections = this.injectSections(temp.content.sections);
1394
1776
  temp.value.sections = this.injectSections(temp.value.sections);
@@ -1467,49 +1849,114 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1467
1849
  const currentTab = tabIndex || this.state.currentTab;
1468
1850
  const schema = _.cloneDeep(schemaInput || this.state.schema);
1469
1851
  const eventsMap = _.cloneDeep(this.state.eventsMap);
1470
- let inputFields = get(schema, `containers[0].panes[${currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1471
- const {id} = field;
1472
- const fieldIndex = findIndex(inputFields, {identifier: id});
1473
- const formDataKey = id.replace("-show-keys", "");
1474
- const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1475
- let keys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === formData[currentTab - 1][formDataKey]) : [];
1476
- if (keys[0]) {
1477
- keys = keys[0].keys;
1478
- }
1479
- _.map(keys, (key, index) => {
1480
- const row = {
1481
- rowClassName: 'mobile-push-row',
1482
- id: 'cta-deeplink-keys',
1483
- cols: [
1484
- {
1485
- id: `custom-value-${key}-${id}`,
1486
- label: key.replace('_', " "),
1487
- type: "input", //Resembles component to be used
1488
- metaType: "text",
1489
- datatype: "string",
1490
- required: true,
1491
- width: 18,
1492
- offset: 1,
1493
- placeholder: `Please input ${key.replace('_', " ")}.`,
1494
- fluid: true,
1495
- styling: "semantic",
1496
- order: 1,
1497
- customComponent: false,
1498
- errorMessage: "value cannot be empty.",
1499
- },
1500
- ],
1501
- };
1502
- inputFields.splice(fieldIndex + index + 1, 0, row);
1852
+ _.forEach(schema.containers, (container) => {
1853
+ _.forEach(container.panes, (pane) => {
1854
+ _.forEach(pane.sections, (section) => {
1855
+ _.forEach(section.childSections, (childeSection) => {
1856
+ _.forEach(childeSection.childSections, (child) => {
1857
+ const formChaild = child;
1858
+ if (child.type === 'multicols') {
1859
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1860
+ _.forEach(inputField.cols, (col) => {
1861
+ if (col.id === field.id) {
1862
+ const formDataKey = col.id.replace("-show-keys", "");
1863
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1864
+ let keys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === formData[currentTab - 1][formDataKey]) : [];
1865
+ if (keys[0]) {
1866
+ keys = keys[0].keys;
1867
+ }
1868
+ let rows = _.map(keys, (key) => {
1869
+ const row = {
1870
+ rowClassName: 'mobile-push-row',
1871
+ id: 'cta-deeplink-keys',
1872
+ cols: [
1873
+ {
1874
+ id: `${key}-space`,
1875
+ metaType: "label",
1876
+ value: "",
1877
+ primitive: true,
1878
+ dynamicTab: false,
1879
+ type: "div",
1880
+ width: 4,
1881
+ offset: 0,
1882
+ onlyDisplay: true,
1883
+ colStyle: {
1884
+ flex: 1,
1885
+ },
1886
+ },
1887
+ {
1888
+ id: `${key}-label`,
1889
+ metaType: "label",
1890
+ value: key.replace('_', " "),
1891
+ primitive: true,
1892
+ dynamicTab: false,
1893
+ type: "div",
1894
+ width: 5,
1895
+ style: {
1896
+ backgroundColor: 'white',
1897
+ textAlign: 'left',
1898
+ lineHeight: '24px',
1899
+ fontSize: '14px',
1900
+ fontFamily: 'open-sans',
1901
+ fontStyle: 'normal',
1902
+ cursor: 'pointer',
1903
+ paddingTop: '8px',
1904
+ },
1905
+ offset: 0,
1906
+ onlyDisplay: true,
1907
+ colStyle: {
1908
+ flex: 1,
1909
+ },
1910
+ },
1911
+ {
1912
+ id: `custom-value-${key}-${col.id}`,
1913
+ label: "value",
1914
+ type: "input", //Resembles component to be used
1915
+ metaType: "text",
1916
+ datatype: "string",
1917
+ required: true,
1918
+ width: 14,
1919
+ placeholder: `Please input ${key.replace('_', " ")}.`,
1920
+ fluid: true,
1921
+ styling: "semantic",
1922
+ order: 1,
1923
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
1924
+ customComponent: false,
1925
+ errorMessage: "value cannot be empty.",
1926
+ },
1927
+ ],
1928
+ };
1929
+ //eventsMap[`custome-${key}`] = {"onChange": this.onMessageTitleChange};
1930
+ return row;
1931
+ // formChaild.inputFields[fieldIndex + index] = field;
1932
+ });
1933
+ console.log(formChaild);
1934
+ console.log("this in getctakeys", this);
1935
+ if (!tabIndex) { // removes the existing selected options keys so that newly selected options keys can be added.
1936
+ const configkeys = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === this.state.formData[currentTab - 1][field.id]);
1937
+ if (configkeys.length) {
1938
+ const options = configkeys[0].keys;
1939
+ formChaild.inputFields = formChaild.inputFields.slice(0, fieldIndex + 1).concat(formChaild.inputFields.slice(fieldIndex + options.length + 1, formChaild.inputFields.length));
1940
+ // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1941
+ // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1942
+ }
1943
+ }
1944
+ if (formChaild.inputFields[fieldIndex + 1] && formChaild.inputFields[fieldIndex + 1].id === "cta-deeplink-keys") {
1945
+ rows = formChaild.inputFields.slice(0, fieldIndex + 1).concat(rows).concat(formChaild.inputFields.slice(fieldIndex + 1, formChaild.inputFields.length));
1946
+ formChaild.inputFields = rows;
1947
+ } else {
1948
+ rows = formChaild.inputFields.slice(0, fieldIndex + 1).concat(rows).concat(formChaild.inputFields.slice(fieldIndex + 1, formChaild.inputFields.length));
1949
+ formChaild.inputFields = rows;
1950
+ }
1951
+ }
1952
+ });
1953
+ });
1954
+ }
1955
+ });
1956
+ });
1957
+ });
1958
+ });
1503
1959
  });
1504
- if (!tabIndex) { // removes the existing selected options keys so that newly selected options keys can be added.
1505
- const configkeys = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === this.state.formData[currentTab - 1][field.id]);
1506
- if (configkeys.length) {
1507
- const options = configkeys[0].keys;
1508
- inputFields = inputFields.slice(0, fieldIndex + 1).concat(inputFields.slice(fieldIndex + options.length + 1, inputFields.length));
1509
- // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1510
- // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1511
- }
1512
- }
1513
1960
  if (tabIndex) {
1514
1961
  return schema;
1515
1962
  }
@@ -1517,26 +1964,131 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1517
1964
  this.injectEvents(schema);
1518
1965
  return schema;
1519
1966
  };
1520
- addPrimaryCta = (flag, formData, field, inputSchema, currentTab) => {
1967
+ addPrimaryCta = (ev, field, inputSchema) => {
1521
1968
  const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1522
- const id = field.id;
1969
+ const id = field ? field.id : ev.target.id;
1523
1970
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1524
1971
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1525
1972
  const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1526
1973
  // const eventsMap = _.cloneDeep(this.state.eventsMap);
1527
- const tabIndex = currentTab || this.state.currentTab;
1528
- const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1529
- const fieldIndex = findIndex(inputFields, {identifier: id});
1530
- let newInputFields;
1531
- if (formData[tabIndex - 1][id]) {
1532
- newInputFields = this.getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions});
1533
- } else {
1534
- const identifier = (tabIndex - 1) ? 'add-sec-cta-ios' : 'add-sec-cta';
1535
- const indexOfNextField = findIndex(inputFields, {identifier});
1536
- const deleteCount = indexOfNextField - fieldIndex;
1537
- newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1538
- }
1539
- set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1974
+ _.forEach(schema.containers, (container) => {
1975
+ _.forEach(container.panes, (pane) => {
1976
+ _.forEach(pane.sections, (section) => {
1977
+ _.forEach(section.childSections, (childeSection) => {
1978
+ _.forEach(childeSection.childSections, (child) => {
1979
+ if (child.type === 'multicols') {
1980
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1981
+ _.forEach(inputField.cols, (col) => {
1982
+ const colId = `${col.id}${this.state.currentTab > 1 ? this.state.currentTab : ''}`;
1983
+ if (colId === id) {
1984
+ console.log(child.inputFields, fieldIndex);
1985
+ child.inputFields.splice(fieldIndex, 1, {
1986
+ rowClassName: 'mobile-push-row',
1987
+ cols: [
1988
+ {
1989
+ id: "cta-label",
1990
+ metaType: "label",
1991
+ value: "Primary CTA",
1992
+ primitive: true,
1993
+ dynamicTab: false,
1994
+ type: "div",
1995
+ width: 4,
1996
+ style: {
1997
+ backgroundColor: 'white',
1998
+ textAlign: 'left',
1999
+ color: '#333333',
2000
+ lineHeight: '24px',
2001
+ fontSize: '14px',
2002
+ fontFamily: 'open-sans',
2003
+ fontStyle: 'normal',
2004
+ },
2005
+ offset: 0,
2006
+ onlyDisplay: true,
2007
+ colStyle: {
2008
+ flex: 1,
2009
+ },
2010
+ },
2011
+ {
2012
+ id: `cta-deeplink${id === 'add-pri-cta' ? '' : 2}`,
2013
+ type: "radioGroup", //Resembles component to be used
2014
+ metaType: "text",
2015
+ datatype: "string",
2016
+ options: ["Deeplink", "External Link"],
2017
+ value: "Deeplink",
2018
+ required: true,
2019
+ width: 18,
2020
+ errorMessage: "Please select link type",
2021
+ fluid: true,
2022
+ styling: "semantic",
2023
+ order: 1,
2024
+ customComponent: false,
2025
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2026
+ supportedEvents: ["onChange"],
2027
+ },
2028
+ {
2029
+ id: `cta-deeplink${id === 'add-pri-cta' ? '' : 2}-delete`,
2030
+ type: "icon",
2031
+ value: 'delete',
2032
+ width: 1,
2033
+ submitAction: "onDelete",
2034
+ supportedEvents: ["onDelete"],
2035
+ },
2036
+ ],
2037
+ });
2038
+ child.inputFields.splice(fieldIndex + 1, 0, {
2039
+ rowClassName: 'mobile-push-row',
2040
+ id: 'cta-deeplink-select-section',
2041
+ cols: [
2042
+ {
2043
+ id: "cta-label",
2044
+ metaType: "label",
2045
+ value: "",
2046
+ primitive: true,
2047
+ dynamicTab: false,
2048
+ type: "div",
2049
+ width: 4,
2050
+ onlyDisplay: true,
2051
+ colStyle: {
2052
+ flex: 1,
2053
+ },
2054
+ },
2055
+ {
2056
+ id: `cta-deeplink${id === 'add-pri-cta' ? '' : 2}-select`,
2057
+ placeholder: "Select DeepLink",
2058
+ type: "select", //Resembles component to be used
2059
+ options: deepLinkOptions,
2060
+ errorMessage: "Select a deeplink",
2061
+ metaType: "text",
2062
+ datatype: "string",
2063
+ required: true,
2064
+ fluid: true,
2065
+ width: 19,
2066
+ style: {
2067
+ fontSize: '14px',
2068
+ fontFamily: 'open-sans',
2069
+ fontStyle: 'normal',
2070
+ // fontWeight: 600,
2071
+ marginBottom: '16px',
2072
+ },
2073
+ styling: "semantic",
2074
+ order: 1,
2075
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2076
+ customComponent: false,
2077
+ supportedEvents: [
2078
+ 'onSelect',
2079
+ ],
2080
+ },
2081
+ ],
2082
+ });
2083
+ }
2084
+ });
2085
+ });
2086
+ }
2087
+ });
2088
+ });
2089
+ });
2090
+ });
2091
+ });
1540
2092
  if (inputSchema) {
1541
2093
  return schema;
1542
2094
  }
@@ -1545,25 +2097,191 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1545
2097
  return schema;
1546
2098
  };
1547
2099
 
1548
- addSecondoryCta = (flag, formData, field, inputSchema, currentTab) => {
1549
- const id = field.id;
1550
- const tabIndex = currentTab || this.state.currentTab;
2100
+ addSecondoryCta = (ev, field, inputSchema) => {
2101
+ const id = field ? field.id : ev.target.id;
1551
2102
  const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1552
2103
  const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1553
2104
  const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1554
2105
  const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1555
- const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1556
- const fieldIndex = findIndex(inputFields, {identifier: id});
1557
- let newInputFields;
1558
- if (formData[tabIndex - 1][id]) {
1559
- newInputFields = this.getSecondaryCtaFields({inputFields, fieldIndex, deepLinkOptions});
1560
- } else {
1561
- const identifier = id === "add-sec-cta" ? 'add-sec-cta-2' : null;
1562
- const indexOfNextField = identifier ? findIndex(inputFields, {identifier}) : inputFields.length;
1563
- const deleteCount = indexOfNextField - fieldIndex;
1564
- newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1565
- }
1566
- set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
2106
+
2107
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
2108
+ _.forEach(schema.containers, (container) => {
2109
+ _.forEach(container.panes, (pane) => {
2110
+ _.forEach(pane.sections, (section) => {
2111
+ _.forEach(section.childSections, (childeSection) => {
2112
+ _.forEach(childeSection.childSections, (child) => {
2113
+ if (child.type === 'multicols') {
2114
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
2115
+ _.forEach(inputField.cols, (col) => {
2116
+ if (col.id === id) {
2117
+ if (col.fieldsCount < col.fieldsLimit) {
2118
+ const inputId = `secondary-cta-${col.fieldsCount}`;
2119
+ console.log(child.inputFields, fieldIndex);
2120
+ child.inputFields.splice(fieldIndex, 0, {
2121
+ rowClassName: 'mobile-push-row',
2122
+ cols: [
2123
+ {
2124
+ id: `${inputId}-space`,
2125
+ metaType: "label",
2126
+ value: "Secondary CTA",
2127
+ primitive: true,
2128
+ dynamicTab: false,
2129
+ type: "div",
2130
+ width: 4,
2131
+ style: {
2132
+ backgroundColor: 'white',
2133
+ textAlign: 'left',
2134
+ color: '#333333',
2135
+ lineHeight: '24px',
2136
+ fontSize: '14px',
2137
+ fontFamily: 'open-sans',
2138
+ fontStyle: 'normal',
2139
+ paddingTop: '8px',
2140
+ },
2141
+ offset: 0,
2142
+ onlyDisplay: true,
2143
+ colStyle: {
2144
+ flex: 1,
2145
+ },
2146
+ },
2147
+ {
2148
+ id: `${inputId}-label`,
2149
+ label: "link",
2150
+ type: "input", //Resembles component to be used
2151
+ metaType: "text",
2152
+ datatype: "string",
2153
+ required: true,
2154
+ width: 18,
2155
+ offset: 4,
2156
+ placeholder: "Enter CTA Label here",
2157
+ fluid: true,
2158
+ styling: "semantic",
2159
+ order: 1,
2160
+ customComponent: false,
2161
+ errorMessage: "CTA label cannot be empty.",
2162
+ },
2163
+ {
2164
+ id: `${inputId}-delete`,
2165
+ type: "icon",
2166
+ value: 'delete',
2167
+ width: 1,
2168
+ submitAction: "onDelete",
2169
+ supportedEvents: ["onDelete"],
2170
+ },
2171
+ ],
2172
+ });
2173
+ child.inputFields.splice(fieldIndex + 1, 0, {
2174
+ rowClassName: 'mobile-push-row',
2175
+ cols: [
2176
+ {
2177
+ id: `${inputId}-label-space`,
2178
+ metaType: "label",
2179
+ value: "",
2180
+ primitive: true,
2181
+ dynamicTab: false,
2182
+ type: "div",
2183
+ width: 4,
2184
+ style: {
2185
+ backgroundColor: 'white',
2186
+ textAlign: 'left',
2187
+ color: '#333333',
2188
+ lineHeight: '24px',
2189
+ fontSize: '14px',
2190
+ fontFamily: 'open-sans',
2191
+ fontStyle: 'normal',
2192
+ paddingTop: '8px',
2193
+ },
2194
+ offset: 0,
2195
+ onlyDisplay: true,
2196
+ colStyle: {
2197
+ flex: 1,
2198
+ },
2199
+ },
2200
+ {
2201
+ id: `cta-deeplink-${inputId}`,
2202
+ type: "radioGroup", //Resembles component to be used
2203
+ metaType: "text",
2204
+ datatype: "string",
2205
+ options: ["Deeplink", "External Link"],
2206
+ value: "Deeplink",
2207
+ required: true,
2208
+ width: 16,
2209
+ fluid: true,
2210
+ styling: "semantic",
2211
+ order: 1,
2212
+ style: {
2213
+ lineHeight: '24px',
2214
+ fontSize: '14px',
2215
+ },
2216
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2217
+ customComponent: false,
2218
+ supportedEvents: ["onChange"],
2219
+ },
2220
+ ],
2221
+ });
2222
+ child.inputFields.splice(fieldIndex + 2, 0, {
2223
+ rowClassName: 'mobile-push-row',
2224
+ id: 'cta-deeplink-select-section',
2225
+ cols: [
2226
+ {
2227
+ id: "cta-label",
2228
+ metaType: "label",
2229
+ value: "",
2230
+ primitive: true,
2231
+ dynamicTab: false,
2232
+ type: "div",
2233
+ width: 4,
2234
+ onlyDisplay: true,
2235
+ colStyle: {
2236
+ flex: 1,
2237
+ },
2238
+ },
2239
+ {
2240
+ id: `cta-deeplink-${inputId}-select`,
2241
+ placeholder: "Select DeepLink",
2242
+ type: "select", //Resembles component to be used
2243
+ options: deepLinkOptions,
2244
+ errorMessage: "Select a deeplink",
2245
+ metaType: "text",
2246
+ datatype: "string",
2247
+ required: true,
2248
+ fluid: true,
2249
+ width: 19,
2250
+ style: {
2251
+ fontSize: '14px',
2252
+ fontFamily: 'open-sans',
2253
+ fontStyle: 'normal',
2254
+ // fontWeight: 600,
2255
+ marginBottom: '16px',
2256
+ },
2257
+ styling: "semantic",
2258
+ order: 1,
2259
+ disabled: this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs",
2260
+ customComponent: false,
2261
+ supportedEvents: [
2262
+ 'onSelect',
2263
+ ],
2264
+ },
2265
+ ],
2266
+ });
2267
+
2268
+ const colField = col;
2269
+ colField.value = "Add Another CTA";
2270
+ colField.fieldsCount += 1;
2271
+ if (col.fieldsCount === col.fieldsLimit) {
2272
+ child.inputFields.pop();
2273
+ }
2274
+ // eventsMap[`cta-deeplink-${inputId}`] = {"onChange": this.onLinkTypeChange};
2275
+ }
2276
+ }
2277
+ });
2278
+ });
2279
+ }
2280
+ });
2281
+ });
2282
+ });
2283
+ });
2284
+ });
1567
2285
  if (inputSchema) {
1568
2286
  return schema;
1569
2287
  }
@@ -1572,41 +2290,120 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1572
2290
  return schema;
1573
2291
  };
1574
2292
 
1575
- addSecondoryCtaIos = (flag, formData, schemaField) => {
1576
- const id = schemaField.id;
1577
- if (formData[this.state.currentTab - 1][id]) {
1578
- const actionText = formData[this.state.currentTab - 1]['secondary-cta-1-action'];
1579
- if (!this.props.iosCtasData) {
1580
- if (!_.isEmpty(actionText)) {
1581
- this.deleteSecondaryCtaIos();
1582
- }
1583
- this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
1584
- } else {
1585
- this.deleteSecondaryCtaIos(() => { // oncick of change
1586
- this.setState({showIosCtaTable: true});
1587
- });
1588
- }
1589
- } else {
1590
- const schema = cloneDeep(this.state.schema);
1591
- const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1592
- forEach(inputFields, (inputField, fieldIndex) => {
1593
- forEach(inputField.cols, (col) => {
1594
- if (col.id === id) {
1595
- const indexOfNextField = inputFields.length;
1596
- const deleteCount = indexOfNextField - fieldIndex;
1597
- const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputField.length)];
1598
- set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1599
- this.setState({schema});
1600
- }
2293
+ addSecondoryCtaIos = (ev) => {
2294
+ const id = ev.target.id;
2295
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
2296
+ const schema = _.cloneDeep(this.state.schema);
2297
+ _.forEach(schema.containers, (container) => {
2298
+ _.forEach(container.panes, (pane, paneIndex) => {
2299
+ _.forEach(pane.sections, (section) => {
2300
+ _.forEach(section.childSections, (childeSection) => {
2301
+ _.forEach(childeSection.childSections, (child) => {
2302
+ if (child.type === 'multicols') {
2303
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
2304
+ _.forEach(inputField.cols, (col) => {
2305
+ const colId = (paneIndex + 1) > 1 ? col.id + (paneIndex + 1) : col.id;
2306
+ if (colId === id) {
2307
+ const inputId = `secondary-cta-${paneIndex}`;
2308
+ console.log(child.inputFields, fieldIndex);
2309
+ child.inputFields.splice(fieldIndex, 1, {
2310
+ rowClassName: 'mobile-push-row',
2311
+ cols: [
2312
+ {
2313
+ id: `${inputId}-label`,
2314
+ metaType: "label",
2315
+ value: "Secondary CTA",
2316
+ primitive: true,
2317
+ dynamicTab: false,
2318
+ type: "div",
2319
+ width: 4,
2320
+ style: {
2321
+ backgroundColor: 'white',
2322
+ textAlign: 'left',
2323
+ color: '#333333',
2324
+ lineHeight: '24px',
2325
+ fontSize: '14px',
2326
+ fontFamily: 'open-sans',
2327
+ fontStyle: 'normal',
2328
+ paddingTop: '8px',
2329
+ },
2330
+ offset: 0,
2331
+ onlyDisplay: true,
2332
+ colStyle: {
2333
+ flex: 1,
2334
+ },
2335
+ },
2336
+ {
2337
+ id: `${inputId}-table`,
2338
+ type: "table", //Resembles component to be used
2339
+ metaType: "text",
2340
+ datatype: "string",
2341
+ pagination: false,
2342
+ columns: [
2343
+ {
2344
+ title: "Name and Description",
2345
+ dataIndex: "name",
2346
+ key: "name",
2347
+ width: 200,
2348
+ render: (text, record) => (
2349
+ <div>
2350
+ <div>{record.name}</div>
2351
+ <div>{record.description}</div>
2352
+ </div>),
2353
+ },
2354
+ {
2355
+ title: "Button 1",
2356
+ dataIndex: "description",
2357
+ key: "button1",
2358
+ width: 100,
2359
+ render: (text, record) => (
2360
+ <div>
2361
+ {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
2362
+ </div>),
2363
+ },
2364
+ {
2365
+ title: "Button 2",
2366
+ dataIndex: "description",
2367
+ key: "button2",
2368
+ width: 100,
2369
+ render: (text, record) => (
2370
+ <div>
2371
+ {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
2372
+ </div>
2373
+ ),
2374
+ },
2375
+ ],
2376
+ required: true,
2377
+ width: 16,
2378
+ fluid: true,
2379
+ styling: "semantic",
2380
+ order: 1,
2381
+ customComponent: false,
2382
+ supportedEvents: ["onRowClick"],
2383
+ },
2384
+ ],
2385
+ });
2386
+
2387
+ const colField = col;
2388
+ colField.value = "Add Another CTA";
2389
+ colField.fieldsCount += 1;
2390
+ if (col.fieldsCount === col.fieldsLimit) {
2391
+ child.inputFields.pop();
2392
+ }
2393
+ }
2394
+ });
2395
+ });
2396
+ }
2397
+ });
2398
+ });
1601
2399
  });
1602
2400
  });
1603
- }
2401
+ });
2402
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
2403
+ this.injectEvents(schema);
2404
+ this.props.actions.getIosCtas(selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
1604
2405
  };
1605
- handleClose = () => {
1606
- const formData = cloneDeep(this.state.formData);
1607
- formData[this.state.currentTab - 1]['add-sec-cta-ios'] = false;
1608
- this.setState({showIosCtaTable: false, formData});
1609
- }
2406
+
1610
2407
  injectContainer = (container) => {
1611
2408
  const temp = container;
1612
2409
  if (temp.type === 'tabs') {
@@ -1668,7 +2465,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1668
2465
  let tipText = this.props.Edit && ("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) ? 'Getting template details...' : '';
1669
2466
  tipText = this.props.Edit && ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress) ? 'Saving Template...' : '';
1670
2467
  const loadingContentEdit = this.state.loadingContentEdit || (this.props.location.query.module === 'dvs' && _.isEmpty(this.state.schema));
1671
- const spinning = this.props.isLoadingMetaEntities || loadingContentEdit || this.props.Edit.fetchingDefaultTemplates || this.props.Edit.assetUploading || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
2468
+ const spinning = loadingContentEdit || this.props.Edit.fetchingDefaultTemplates || this.props.Edit.assetUploading || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
1672
2469
  let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
1673
2470
  if (this.props.supportedTags) {
1674
2471
  tags = this.props.supportedTags;
@@ -1689,7 +2486,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1689
2486
  </Row>}
1690
2487
  <Row>
1691
2488
  <Col>
1692
- {!this.props.isLoadingMetaEntities && <FormBuilder
2489
+ <FormBuilder
1693
2490
  schema={schema}
1694
2491
  onSubmit={this.saveFormData}
1695
2492
  onChange={this.onFormDataChange}
@@ -1713,66 +2510,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1713
2510
  handleCancelModal={this.handleCancelModal}
1714
2511
  modal={this.state.modalContent}
1715
2512
  setModalContent={this.setModalContent}
1716
- />}
1717
- </Col>
1718
- {this.props.iosCtasData && this.state.showIosCtaTable &&
1719
- <CapSlideBox
1720
- size="size-l"
1721
- header={<CapHeader
1722
- title={<FormattedMessage {...messages.selectActionButton} />}
1723
- prefix={
1724
- <PrefixWrapper>
1725
- <CapIcons.backIcon onClick={this.handleClose} />
1726
- </PrefixWrapper>
1727
- }
1728
-
1729
- />}
1730
- content={<CapTable
1731
- rowSelection={{
1732
- type: 'radio',
1733
- onSelect: (record) => {
1734
- this.setState({templateCta: record, showIosCtaTable: false}, () => this.selectCtaIos(record));
1735
- },
1736
- }}
1737
- dataSource={this.props.iosCtasData} columns={[
1738
- {
1739
- title: "Name and Description",
1740
- dataIndex: "name",
1741
- key: "name",
1742
- width: 200,
1743
- render: (text, record) => (
1744
- <div>
1745
- <div>{record.name}</div>
1746
- <div>{record.description}</div>
1747
- </div>),
1748
- },
1749
- {
1750
- title: "Button 1",
1751
- dataIndex: "description",
1752
- key: "button1",
1753
- width: 100,
1754
- render: (text, record) => (
1755
- <div>
1756
- {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
1757
- </div>),
1758
- },
1759
- {
1760
- title: "Button 2",
1761
- dataIndex: "description",
1762
- key: "button2",
1763
- width: 100,
1764
- render: (text, record) => (
1765
- <div>
1766
- {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
1767
- </div>
1768
- ),
1769
- },
1770
- ]}
1771
- />}
1772
- show={this.state.showIosCtaTable}
1773
- handleClose={this.handleClose}
1774
2513
  />
1775
- }
2514
+ </Col>
1776
2515
  </Row>
1777
2516
  </Spin>
1778
2517
  </div>
@@ -1795,9 +2534,6 @@ Edit.propTypes = {
1795
2534
  supportedTags: PropTypes.array,
1796
2535
  getDefaultTags: PropTypes.string,
1797
2536
  templateData: PropTypes.object,
1798
- isFullMode: PropTypes.bool,
1799
- iosCtasData: PropTypes.array,
1800
- isLoadingMetaEntities: PropTypes.bool,
1801
2537
  injectedTags: PropTypes.object,
1802
2538
  };
1803
2539
 
@@ -1808,8 +2544,6 @@ const mapStateToProps = createStructuredSelector({
1808
2544
  templateDetails: makeSelectTemplateDetailsResponse(),
1809
2545
  metaEntities: makeSelectMetaEntities(),
1810
2546
  Templates: makeSelectTemplates(),
1811
- iosCtasData: makeSelectIosCta(),
1812
- isLoadingMetaEntities: isLoadingMetaEntities(),
1813
2547
  injectedTags: setInjectedTags(),
1814
2548
  });
1815
2549