@capillarytech/creatives-library 2.0.70 → 2.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/EmailMobilePreview/index.scss +0 -1
  4. package/components/EmailPreviewV2/_emailPreviewV2.scss +4 -1
  5. package/components/EmailPreviewV2/index.js +1 -1
  6. package/components/FormBuilder/index.js +25 -10
  7. package/components/Header/index.js +3 -1
  8. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  9. package/components/TemplatePreview/index.js +45 -51
  10. package/components/TemplatePreview/messages.js +1 -1
  11. package/config/app.js +1 -0
  12. package/containers/Cap/actions.js +0 -5
  13. package/containers/Cap/reducer.js +1 -1
  14. package/containers/Cap/selectors.js +0 -13
  15. package/containers/Ebill/index.js +1 -2
  16. package/containers/Email/_email.scss +1 -0
  17. package/containers/Email/actions.js +3 -8
  18. package/containers/Email/constants.js +0 -1
  19. package/containers/Email/index.js +947 -322
  20. package/containers/Email/reducer.js +0 -3
  21. package/containers/Email/sagas.js +6 -3
  22. package/containers/Email/selectors.js +1 -4
  23. package/containers/Line/Create/index.js +1 -2
  24. package/containers/Line/Edit/_lineEdit.scss +4 -0
  25. package/containers/Line/Edit/index.js +1 -3
  26. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  27. package/containers/MobilePush/Create/actions.js +0 -6
  28. package/containers/MobilePush/Create/constants.js +0 -1
  29. package/containers/MobilePush/Create/index.js +1133 -628
  30. package/containers/MobilePush/Create/messages.js +1 -5
  31. package/containers/MobilePush/Create/reducer.js +0 -2
  32. package/containers/MobilePush/Create/selectors.js +3 -3
  33. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  34. package/containers/MobilePush/Edit/index.js +1127 -393
  35. package/containers/MobilePush/Edit/messages.js +0 -4
  36. package/containers/MobilePush/Edit/reducer.js +1 -2
  37. package/containers/MobilePush/Edit/selectors.js +3 -6
  38. package/containers/Sms/Create/_smsCreate.scss +2 -1
  39. package/containers/Sms/Create/actions.js +4 -4
  40. package/containers/Sms/Create/index.js +570 -102
  41. package/containers/Sms/Create/sagas.js +2 -1
  42. package/containers/Sms/Edit/actions.js +5 -10
  43. package/containers/Sms/Edit/constants.js +0 -1
  44. package/containers/Sms/Edit/index.js +548 -103
  45. package/containers/Sms/Edit/reducer.js +0 -2
  46. package/containers/Sms/Edit/sagas.js +3 -1
  47. package/containers/TagList/index.js +3 -3
  48. package/containers/Templates/actions.js +1 -3
  49. package/containers/Templates/index.js +299 -268
  50. package/containers/Templates/messages.js +90 -122
  51. package/containers/Templates/reducer.js +3 -3
  52. package/containers/Templates/sagas.js +1 -5
  53. package/containers/Templates/selectors.js +1 -41
  54. package/containers/WeChat/MapTemplates/index.js +3 -4
  55. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  56. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  57. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  58. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  59. package/index.js +31 -31
  60. package/initialState.js +6 -0
  61. package/package.json +3 -3
  62. package/routes.js +24 -19
  63. package/services/api.js +6 -2
  64. package/services/getSchema.js +18 -0
  65. package/v2Containers/App/actions.js +7 -0
  66. package/v2Containers/App/constants.js +3 -0
  67. package/v2Containers/App/reducer.js +19 -0
  68. package/v2Containers/App/sagas.js +26 -0
  69. package/v2Containers/App/selectors.js +25 -0
  70. package/v2Containers/App/tests/actions.test.js +18 -0
  71. package/v2Containers/App/tests/reducer.test.js +9 -0
  72. package/v2Containers/App/tests/sagas.test.js +15 -0
  73. package/v2Containers/App/tests/selectors.test.js +10 -0
  74. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  75. package/v2Containers/Assets/Gallery/actions.js +37 -0
  76. package/v2Containers/Assets/Gallery/constants.js +23 -0
  77. package/v2Containers/Assets/Gallery/index.js +479 -0
  78. package/v2Containers/Assets/Gallery/messages.js +97 -0
  79. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  80. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  81. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  82. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  83. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  84. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  85. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  86. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  87. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  88. package/v2Containers/CallTask/_callTask.scss +5 -0
  89. package/v2Containers/CallTask/actions.js +15 -0
  90. package/v2Containers/CallTask/constants.js +7 -0
  91. package/v2Containers/CallTask/index.js +141 -0
  92. package/v2Containers/CallTask/messages.js +21 -0
  93. package/v2Containers/CallTask/reducer.js +23 -0
  94. package/v2Containers/CallTask/sagas.js +11 -0
  95. package/v2Containers/CallTask/selectors.js +25 -0
  96. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  97. package/v2Containers/CallTask/tests/index.test.js +10 -0
  98. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  99. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  100. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  101. package/v2Containers/Cap/actions.js +64 -0
  102. package/v2Containers/Cap/constants.js +24 -0
  103. package/v2Containers/Cap/index.js +349 -0
  104. package/v2Containers/Cap/messsages.js +63 -0
  105. package/v2Containers/Cap/reducer.js +111 -0
  106. package/v2Containers/Cap/sagas.js +143 -0
  107. package/v2Containers/Cap/selectors.js +85 -0
  108. package/v2Containers/Cap/tests/index.test.js +16 -0
  109. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  110. package/v2Containers/ChannelTemplates/actions.js +20 -0
  111. package/v2Containers/ChannelTemplates/constants.js +8 -0
  112. package/v2Containers/ChannelTemplates/index.js +48 -0
  113. package/v2Containers/ChannelTemplates/messages.js +13 -0
  114. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  115. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  116. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  117. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  118. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  119. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  120. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  121. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  122. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  123. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  124. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  125. package/v2Containers/CreativesContainer/actions.js +27 -0
  126. package/v2Containers/CreativesContainer/constants.js +16 -0
  127. package/v2Containers/CreativesContainer/index.js +483 -0
  128. package/v2Containers/CreativesContainer/index.scss +27 -0
  129. package/v2Containers/CreativesContainer/messages.js +293 -0
  130. package/v2Containers/CreativesContainer/reducer.js +29 -0
  131. package/v2Containers/CreativesContainer/sagas.js +11 -0
  132. package/v2Containers/CreativesContainer/selectors.js +30 -0
  133. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  134. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  135. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  136. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  137. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  138. package/v2Containers/Dashboard/actions.js +15 -0
  139. package/v2Containers/Dashboard/constants.js +7 -0
  140. package/v2Containers/Dashboard/index.js +54 -0
  141. package/v2Containers/Dashboard/messages.js +13 -0
  142. package/v2Containers/Dashboard/reducer.js +21 -0
  143. package/v2Containers/Dashboard/sagas.js +11 -0
  144. package/v2Containers/Dashboard/selectors.js +25 -0
  145. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  146. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  147. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  148. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  149. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  150. package/v2Containers/Ebill/_ebill.scss +5 -0
  151. package/v2Containers/Ebill/actions.js +43 -0
  152. package/v2Containers/Ebill/constants.js +20 -0
  153. package/v2Containers/Ebill/index.js +1261 -0
  154. package/v2Containers/Ebill/messages.js +73 -0
  155. package/v2Containers/Ebill/reducer.js +72 -0
  156. package/v2Containers/Ebill/sagas.js +65 -0
  157. package/v2Containers/Ebill/selectors.js +25 -0
  158. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  159. package/v2Containers/Ebill/tests/index.test.js +10 -0
  160. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  161. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  162. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  163. package/v2Containers/Email/_email.scss +140 -0
  164. package/v2Containers/Email/actions.js +86 -0
  165. package/v2Containers/Email/constants.js +37 -0
  166. package/v2Containers/Email/index.js +2703 -0
  167. package/v2Containers/Email/initialSchema.js +540 -0
  168. package/v2Containers/Email/messages.js +237 -0
  169. package/v2Containers/Email/reducer.js +147 -0
  170. package/v2Containers/Email/sagas.js +133 -0
  171. package/v2Containers/Email/selectors.js +34 -0
  172. package/v2Containers/Email/tests/actions.test.js +18 -0
  173. package/v2Containers/Email/tests/index.test.js +10 -0
  174. package/v2Containers/Email/tests/reducer.test.js +9 -0
  175. package/v2Containers/Email/tests/sagas.test.js +15 -0
  176. package/v2Containers/Email/tests/selectors.test.js +10 -0
  177. package/v2Containers/EmailWrapper/actions.js +15 -0
  178. package/v2Containers/EmailWrapper/constants.js +7 -0
  179. package/v2Containers/EmailWrapper/index.js +258 -0
  180. package/v2Containers/EmailWrapper/messages.js +57 -0
  181. package/v2Containers/EmailWrapper/reducer.js +23 -0
  182. package/v2Containers/EmailWrapper/sagas.js +11 -0
  183. package/v2Containers/EmailWrapper/selectors.js +25 -0
  184. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  185. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  186. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  187. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  188. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  189. package/v2Containers/LanguageProvider/actions.js +17 -0
  190. package/v2Containers/LanguageProvider/constants.js +8 -0
  191. package/v2Containers/LanguageProvider/index.js +46 -0
  192. package/v2Containers/LanguageProvider/reducer.js +30 -0
  193. package/v2Containers/LanguageProvider/selectors.js +20 -0
  194. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  195. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  196. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  197. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  198. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  199. package/v2Containers/Line/Create/actions.js +90 -0
  200. package/v2Containers/Line/Create/constants.js +39 -0
  201. package/v2Containers/Line/Create/index.js +822 -0
  202. package/v2Containers/Line/Create/messages.js +173 -0
  203. package/v2Containers/Line/Create/reducer.js +99 -0
  204. package/v2Containers/Line/Create/sagas.js +107 -0
  205. package/v2Containers/Line/Create/selectors.js +36 -0
  206. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  207. package/v2Containers/Line/Edit/actions.js +79 -0
  208. package/v2Containers/Line/Edit/constants.js +27 -0
  209. package/v2Containers/Line/Edit/index.js +1050 -0
  210. package/v2Containers/Line/Edit/messages.js +157 -0
  211. package/v2Containers/Line/Edit/reducer.js +83 -0
  212. package/v2Containers/Line/Edit/sagas.js +81 -0
  213. package/v2Containers/Line/Edit/selectors.js +29 -0
  214. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  215. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  216. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  217. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  218. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  219. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  220. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  221. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  222. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  223. package/v2Containers/Login/index.js +106 -0
  224. package/v2Containers/Login/messages.js +21 -0
  225. package/v2Containers/Login/selectors.js +25 -0
  226. package/v2Containers/Login/tests/index.test.js +10 -0
  227. package/v2Containers/Login/tests/sagas.test.js +15 -0
  228. package/v2Containers/Login/tests/selectors.test.js +10 -0
  229. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  230. package/v2Containers/MobilePush/Create/actions.js +52 -0
  231. package/v2Containers/MobilePush/Create/constants.js +24 -0
  232. package/v2Containers/MobilePush/Create/index.js +1759 -0
  233. package/v2Containers/MobilePush/Create/messages.js +237 -0
  234. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  235. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  236. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  237. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  238. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  239. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  240. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  241. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  242. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  243. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  244. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  245. package/v2Containers/MobilePush/Edit/index.js +1851 -0
  246. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  247. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  248. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  249. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  250. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  251. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  252. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  253. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  254. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  255. package/v2Containers/MobilePush/commonMethods.js +249 -0
  256. package/v2Containers/MobilePush/eventsMap.js +127 -0
  257. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  258. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  259. package/v2Containers/MobilepushWrapper/index.js +136 -0
  260. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  261. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  262. package/v2Containers/NotFoundPage/index.js +25 -0
  263. package/v2Containers/NotFoundPage/messages.js +13 -0
  264. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  265. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  266. package/v2Containers/Sms/Create/actions.js +27 -0
  267. package/v2Containers/Sms/Create/constants.js +16 -0
  268. package/v2Containers/Sms/Create/index.js +1017 -0
  269. package/v2Containers/Sms/Create/messages.js +85 -0
  270. package/v2Containers/Sms/Create/reducer.js +41 -0
  271. package/v2Containers/Sms/Create/sagas.js +35 -0
  272. package/v2Containers/Sms/Create/selectors.js +28 -0
  273. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  274. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  275. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  276. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  277. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  278. package/v2Containers/Sms/Edit/actions.js +45 -0
  279. package/v2Containers/Sms/Edit/constants.js +18 -0
  280. package/v2Containers/Sms/Edit/index.js +1018 -0
  281. package/v2Containers/Sms/Edit/messages.js +89 -0
  282. package/v2Containers/Sms/Edit/reducer.js +52 -0
  283. package/v2Containers/Sms/Edit/sagas.js +50 -0
  284. package/v2Containers/Sms/Edit/selectors.js +32 -0
  285. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  286. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  287. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  288. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  289. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  290. package/v2Containers/Sms/initialSchema.js +281 -0
  291. package/v2Containers/TagList/_tagList.scss +8 -0
  292. package/v2Containers/TagList/actions.js +15 -0
  293. package/v2Containers/TagList/constants.js +7 -0
  294. package/v2Containers/TagList/index.js +236 -0
  295. package/v2Containers/TagList/messages.js +13 -0
  296. package/v2Containers/TagList/reducer.js +23 -0
  297. package/v2Containers/TagList/sagas.js +11 -0
  298. package/v2Containers/TagList/selectors.js +25 -0
  299. package/v2Containers/TagList/tests/actions.test.js +18 -0
  300. package/v2Containers/TagList/tests/index.test.js +10 -0
  301. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  302. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  303. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  304. package/v2Containers/Templates/_templates.scss +349 -0
  305. package/v2Containers/Templates/actions.js +110 -0
  306. package/v2Containers/Templates/constants.js +45 -0
  307. package/v2Containers/Templates/index.js +1725 -0
  308. package/v2Containers/Templates/messages.js +278 -0
  309. package/v2Containers/Templates/reducer.js +142 -0
  310. package/v2Containers/Templates/sagas.js +180 -0
  311. package/v2Containers/Templates/selectors.js +68 -0
  312. package/v2Containers/Templates/tests/actions.test.js +18 -0
  313. package/v2Containers/Templates/tests/index.test.js +10 -0
  314. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  315. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  316. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  317. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  318. package/v2Containers/TemplatesV2/actions.js +16 -0
  319. package/v2Containers/TemplatesV2/constants.js +10 -0
  320. package/v2Containers/TemplatesV2/index.js +217 -0
  321. package/v2Containers/TemplatesV2/messages.js +29 -0
  322. package/v2Containers/TemplatesV2/selectors.js +25 -0
  323. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  324. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  325. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  326. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  327. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  328. package/v2Containers/TestPage/constants.js +7 -0
  329. package/v2Containers/TestPage/index.js +31 -0
  330. package/v2Containers/TestPage/messages.js +13 -0
  331. package/v2Containers/TestPage/reducer.js +21 -0
  332. package/v2Containers/TestPage/sagas.js +11 -0
  333. package/v2Containers/Testv2/actions.js +15 -0
  334. package/v2Containers/Testv2/constants.js +7 -0
  335. package/v2Containers/Testv2/index.js +47 -0
  336. package/v2Containers/Testv2/messages.js +13 -0
  337. package/v2Containers/Testv2/reducer.js +23 -0
  338. package/v2Containers/Testv2/sagas.js +11 -0
  339. package/v2Containers/Testv2/selectors.js +25 -0
  340. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  341. package/v2Containers/Testv2/tests/index.test.js +10 -0
  342. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  343. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  344. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  345. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  346. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  347. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  348. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  349. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  350. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  351. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  352. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  354. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  355. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  356. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  357. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  392. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  393. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  394. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  395. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -0,0 +1,2703 @@
1
+ /*
2
+ *
3
+ * Email
4
+ *
5
+ */
6
+
7
+ import PropTypes from 'prop-types';
8
+
9
+ import React from 'react';
10
+ import { connect } from 'react-redux';
11
+ import { bindActionCreators } from 'redux';
12
+ import { Row, Col, Popover, Modal } from 'antd';
13
+ import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
14
+ import { CapButton, CapInput, CapSpin, CapSlideBox, CapCustomCard } from '@capillarytech/cap-ui-library';
15
+ import { createStructuredSelector } from 'reselect';
16
+ import _ from 'lodash';
17
+ import moment from "moment";
18
+ import FormBuilder from '../../components/FormBuilder';
19
+ import { makeSelectMetaEntities, selectCurrentOrgDetails, isLoadingMetaEntities, makeSelectAuthenticated, setInjectedTags } from '../Cap/selectors';
20
+ import * as actions from './actions';
21
+ import * as templatesActions from '../Templates/actions';
22
+ import * as globalActions from '../../containers/Cap/actions';
23
+ import { UserIsAuthenticated } from '../../utils/authWrapper';
24
+ import {makeSelectEmail} from './selectors';
25
+ import { makeSelectTemplates } from '../Templates/selectors';
26
+ import messages from './messages';
27
+ // import PageHeader from '../../components/PageHeader';
28
+ import './_email.scss';
29
+ import {getMessageObject} from '../../utils/messageUtils';
30
+ import EmailPreview from '../../components/EmailPreview';
31
+
32
+ import Pagination from '../../components/Pagination';
33
+ import * as creativesContainerActions from '../CreativesContainer/actions';
34
+ const {CapCustomCardList} = CapCustomCard;
35
+ export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
36
+ constructor(props) {
37
+ super(props);
38
+ this.state = {
39
+ loadingStatus: 0,
40
+ formData: {},
41
+ tabCount: 1,
42
+ currentTab: 1,
43
+ events: {
44
+ blur: this.onBlur,
45
+ afterPaste: this.afterPaste,
46
+ change: this.onChange,
47
+ },
48
+ isEdit: false,
49
+ schema: {},
50
+ loading: false,
51
+ isFormValid: true,
52
+ injectedTags: {},
53
+ checkValidation: false,
54
+ saveEdmDataMode: 'save',
55
+ tabKey: '',
56
+ showEmailPreview: false,
57
+ device: "desktop",
58
+ editorInstanse: undefined,
59
+ showImageSelectionBox: false,
60
+ isDragDrop: false,
61
+ showConfirmationModal: false,
62
+ modalContent: {title: "Alert", body: "Do you really want to delete this language?", type: 'confirm', id: 'email-language-delete-modal'},
63
+ showModal: false,
64
+ page: 1,
65
+ perPageLimit: 25,
66
+ totalCount: 0,
67
+ searchText: '',
68
+ saveCount: 0,
69
+ cmsDataCount: 0,
70
+ targetSaveCount: 0,
71
+ saveObj: {},
72
+ showEdmEmailTemplates: false,
73
+ editDataSet: false,
74
+ languageDataSet: false,
75
+ addLanguageType: '',
76
+ startValidation: false,
77
+ saveForm: false,
78
+ };
79
+
80
+ this.isTagLoaded = false;
81
+ this.edmEvent = undefined;
82
+ this.supportedLanguages = this.getSupportedLanguages(props);
83
+ this.map = {
84
+ "template-name": {
85
+ onChange: this.onTemplateNameChange,
86
+ },
87
+ "template-version": {
88
+ onSelect: this.handleVersionSelect,
89
+ addVersion: this.addVersion,
90
+ },
91
+ "preview-button": {
92
+ previewTemplate: this.toggleEmailPreview,
93
+ },
94
+ "cancel-button": {
95
+ cancelTemplate: this.cancelTemplate,
96
+ },
97
+ "save-button": {
98
+ saveFormData: this.saveFormData,
99
+ },
100
+ "sms-editor": {
101
+ onChange: this.onTemplateContentChange,
102
+ },
103
+ "tagList": {
104
+ onTagSelect: this.onTagSelect,
105
+ },
106
+ "unicode-validity": {
107
+ onChange: this.onTemplateNameChange,
108
+ },
109
+ "add-language-button": {
110
+ addLanguage: this.addLanguage,
111
+ },
112
+ "tab-header": {
113
+ onChange: this.onVersionNameChange,
114
+ },
115
+ "tab-options-popover": {
116
+ onTabOptionSelect: this.onTabOptionSelect,
117
+ },
118
+ "mark-final-version-label": {
119
+ markFinalVersion: this.markFinalVersion,
120
+ },
121
+ "duplicate-version-label": {
122
+ duplicateVersion: this.duplicateVersion,
123
+ },
124
+ "rename-version-label": {
125
+ renameVersion: this.renameVersion,
126
+ },
127
+ "delete-version-label": {
128
+ deleteVersion: this.deleteVersion,
129
+ },
130
+ "switch-editor-label": {
131
+ switchEditor: this.switchEditor,
132
+ },
133
+ "pane": {
134
+ onTabChange: this.onTabChange,
135
+ },
136
+ "insert-image": {
137
+ onImageSelect: this.onImageSelect,
138
+ },
139
+ "template-content": {
140
+ onContentChange: this.onChange,
141
+ getEditorInstanse: this.getEditorInstanse,
142
+ },
143
+ "delete-language-label": {
144
+ deleteLanguage: this.deleteLanguage,
145
+ },
146
+ };
147
+ }
148
+ componentWillMount() {
149
+ const formData = this.initFormData(this.props, true); //_.cloneDeep(this.state.formData);
150
+ const isEmpty = _.isEmpty(formData);
151
+ if (!isEmpty) {
152
+ formData['template-version-options'] = [
153
+ {
154
+ key: 'version 1',
155
+ label: 'Version 1',
156
+ value: 'version 1',
157
+ },
158
+ {
159
+ key: 'New Version',
160
+ label: 'New Version',
161
+ value: 'New Version',
162
+ },
163
+ ];
164
+ //
165
+ formData['template-version'] = "version 1";
166
+ }
167
+ // const formData = _.cloneDeep(this.state.formData);
168
+ if (this.props.params.id || (this.props.location.query.module === "library" && this.props.templateData && !_.isEmpty(this.props.templateData))) {
169
+ this.setState({isEdit: true}, () => {
170
+ if (this.props.params.id) {
171
+ this.props.actions.getTemplateDetails(this.props.params.id, 'email');
172
+ }
173
+ });
174
+ }
175
+ // formData[0] = {
176
+ // "template-content": (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''),
177
+ // };
178
+ // if (this.props.Templates.CmsSettings) {}
179
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
180
+ if (this.props.location.query.module === "library" && this.props.templateData) {
181
+ this.props.templatesActions.resetTemplateData();
182
+ }
183
+ if (!_.isEmpty(this.props.Templates.edmTemplate) && this.props.Templates.edmTemplate.versions.base.is_drag_drop) {
184
+ this.setState({isDragDrop: true});
185
+ if (this.props.params.id) {
186
+ this.props.actions.getCmsSetting('edm', this.props.Templates.edmTemplate.versions.base.drag_drop_id, 'open', undefined, isEdmSupport);
187
+ } else if (this.props.location.query.module !== "library" || (this.props.location.query.module === "library" && !this.props.templateData)) {
188
+ this.props.actions.getCmsSetting('edm', this.props.Templates.edmTemplate.versions.base.drag_drop_id, 'create', undefined, isEdmSupport);
189
+ }
190
+ }
191
+
192
+ this.setState({ content: (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''), formData}, () => {
193
+ // this.injectEvents(this.state.schema);
194
+ });
195
+
196
+ // setTimeout(() => {
197
+ // // this.getFormData();
198
+ // this.startTemplateCreation();
199
+ // }, 15000);
200
+ }
201
+
202
+ componentDidMount() {
203
+ const query = {
204
+ layout: 'EMAIL',
205
+ type: 'LAYOUT',
206
+ version: 'v2',
207
+ };
208
+ this.props.globalActions.fetchSchemaForEntity(query);
209
+ window.addEventListener("message", this.handleFrameTasks);
210
+ if (this.props.location.query.type === 'embedded') {
211
+ this.showNext();
212
+ }
213
+ }
214
+
215
+ componentWillReceiveProps(nextProps) {
216
+ // if (this.props.location.query.type === 'embedded') {
217
+ // this.showNext();
218
+ // }
219
+ if (this.state.languageDataSet && nextProps.Templates.selectedEmailLayout && nextProps.Templates.selectedEmailLayout !== '' && !_.isEqual(this.props.Templates.selectedEmailLayout, nextProps.Templates.selectedEmailLayout )) {
220
+ this.setNewLanguageContent(nextProps.Templates.selectedEmailLayout);
221
+ }
222
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
223
+ const newSchema = this.injectEvents(nextProps.metaEntities.layouts[0].definition);
224
+
225
+ this.setState({schema: newSchema, loadingStatus: this.state.loadingStatus + 1});
226
+ if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
227
+ const query = {
228
+ layout: 'EMAIL',
229
+ type: 'TAG',
230
+ context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
231
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
232
+ };
233
+ if (this.props.getDefaultTags) {
234
+ query.context = this.props.getDefaultTags;
235
+ }
236
+ if (_.isEmpty(this.props.metaEntities.tags)) {
237
+ this.props.globalActions.fetchSchemaForEntity(query);
238
+ }
239
+ }
240
+ setTimeout(() => {
241
+ this.showSubject();
242
+ }, 0);
243
+ }
244
+ if (nextProps.currentOrgDetails && nextProps.currentOrgDetails.basic_details && !_.isEmpty(nextProps.currentOrgDetails.basic_details) && _.isEmpty(this.state.formData)) {
245
+ const formData = this.initFormData(nextProps);
246
+ formData['template-version-options'] = [
247
+ {
248
+ key: 'version 1',
249
+ label: 'Version 1',
250
+ value: 'version 1',
251
+ },
252
+ {
253
+ key: 'New Version',
254
+ label: 'New Version',
255
+ value: 'New Version',
256
+ },
257
+ ];
258
+ //
259
+ formData['template-version'] = "version 1";
260
+ //const that = this;
261
+ this.setState({formData}, () => {
262
+ // setTimeout(() => {
263
+ // this.getFormData();
264
+ // that.startTemplateCreation();
265
+ // }, 15000);
266
+ });
267
+ } else if (nextProps.currentOrgDetails && nextProps.currentOrgDetails.basic_details) {
268
+ // this.injectEvents(this.state.schema);
269
+ const baseLanguage = nextProps.currentOrgDetails.basic_details.base_language;
270
+ if (this.state.formData[`${this.state.currentTab - 1}`] && _.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages)) {
271
+ const formData = _.cloneDeep(this.state.formData);
272
+ formData[`${this.state.currentTab - 1}`].selectedLanguages = [];
273
+ formData[`${this.state.currentTab - 1}`].selectedLanguages.push(baseLanguage);
274
+ formData.base.selectedLanguages = [];
275
+ formData.base.selectedLanguages.push(baseLanguage);
276
+ this.setState({formData});
277
+ }
278
+
279
+ if (!_.isEmpty(this.state.schema)) {
280
+ const schema = _.cloneDeep(this.state.schema);
281
+
282
+ const formData = _.cloneDeep(this.state.formData);
283
+ const container = schema.containers[0];
284
+ // const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
285
+ if (baseLanguage === formData[0].activeTab) {
286
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
287
+ } else {
288
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
289
+ }
290
+ this.setState({schema, loadingStatus: this.state.loadingStatus + 1});
291
+ }
292
+
293
+ //
294
+ // if (!this.isTagLoaded) {
295
+ // this.isTagLoaded = true;
296
+ // const query = {
297
+ // layout: 'EMAIL',
298
+ // type: 'TAG',
299
+ // context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
300
+ // embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
301
+ // };
302
+ // this.props.globalActions.fetchSchemaForEntity(query);
303
+ // }
304
+
305
+ if (this.state.isEdit && !this.state.editDataSet && !_.isEmpty(nextProps.Email.templateDetails) && !_.isEmpty(this.state.schema)) {
306
+ this.setState({editDataSet: true}, () => {
307
+ this.setEditData(nextProps.Email.templateDetails);
308
+ });
309
+ }
310
+ if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) && !this.props.params.id && !nextProps.isGetFormData) {
311
+ this.startTemplateCreation(nextProps.templateData);
312
+ }
313
+ if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
314
+ if (this.props.isFullMode) {
315
+ let triggerGetFormData = true;
316
+ let isEdmEditor = false;
317
+ const formData = this.state.formData;
318
+ _.forEach(formData[0].selectedLanguages, (language) => {
319
+ if (formData[0][language].is_drag_drop) {
320
+ isEdmEditor = true;
321
+ }
322
+ });
323
+ triggerGetFormData = isEdmEditor ? (!nextProps.Email.fetchingCmsData && _.isEmpty(nextProps.Email.cmsData)) : !nextProps.Email.createTemplateInProgress && _.isEmpty(nextProps.Email.createResponse); // if edm editor selected check for getCmsData call in progress or not before triggering save
324
+ if (triggerGetFormData) {
325
+ this.getFormData();
326
+ }
327
+ } else {
328
+ if (!_.isEmpty(this.props.Email.cmsData)) {
329
+ this.props.actions.resetCmsData();
330
+ }
331
+ this.getFormData();
332
+ }
333
+ }
334
+
335
+ if (!_.isEmpty(nextProps.Email.CmsSettings) && !_.isEqual(this.props.Email.CmsSettings, nextProps.Email.CmsSettings)) {
336
+ const apiLangId = nextProps.Email.CmsSettings.langId;
337
+ const langId = nextProps.Email.CmsSettings.langId !== "undefined" ? nextProps.Email.CmsSettings.langId : nextProps.currentOrgDetails.basic_details.base_language;
338
+
339
+ const formData = _.cloneDeep(this.state.formData);
340
+
341
+ const schema = _.cloneDeep(this.state.schema);
342
+ const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
343
+
344
+ const temp = schema.containers[this.state.currentTab - 1];
345
+ if (baseLanguage === langId && (apiLangId === "undefined" || apiLangId === formData[this.state.currentTab - 1].activeTab)) {
346
+ temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
347
+ } else if (apiLangId === "undefined" || apiLangId === formData[this.state.currentTab - 1].activeTab) {
348
+ temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
349
+ }
350
+
351
+ if (nextProps.Email.CmsSettings.isDragDrop) {
352
+ formData[`${this.state.currentTab - 1}`][langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
353
+ formData[`${this.state.currentTab - 1}`][langId][`drag_drop_id`] = this.getParameterByName("projectId", nextProps.Email.CmsSettings.url);
354
+ formData[`${this.state.currentTab - 1}`][langId][`is_drag_drop`] = true;
355
+ if (formData[`${this.state.currentTab - 1}`].base) {
356
+ formData.base[langId][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`] = nextProps.Email.CmsSettings.url;
357
+ formData.base[langId][`drag_drop_id`] = this.getParameterByName("projectId", nextProps.Email.CmsSettings.url);
358
+ formData.base[langId][`is_drag_drop`] = true;
359
+ }
360
+ _.forEach(temp.panes, (pane, index) => {
361
+ const tempPane = pane;
362
+ //
363
+ if (parseInt(index, 10) === parseInt(langIndex, 10)) {
364
+ //
365
+ tempPane.sections[0].inputFields[0].cols[1].colStyle = {display: ""};
366
+ tempPane.sections[0].inputFields[0].cols[0].colStyle = {display: "none"};
367
+ }
368
+ });
369
+
370
+ this.setState({schema, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1});
371
+ } else {
372
+ _.forEach(temp.panes, (pane, index) => {
373
+ const tempPane = pane;
374
+ if (parseInt(index, 10) === parseInt(langIndex, 10) ) {
375
+ tempPane.sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
376
+ tempPane.sections[0].inputFields[0].cols[0].colStyle = {display: ""};
377
+ }
378
+ });
379
+
380
+ this.setState({schema, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1});
381
+ let html = decodeURIComponent(nextProps.Email.CmsSettings.htmlContent);
382
+
383
+ html = html.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\\&quot;/g, '"');
384
+
385
+ formData[this.state.currentTab - 1][langId]["template-content"] = html;
386
+ if (window.CKEDITOR && apiLangId !== "undefined") {
387
+ const instanceName = `template-content${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`;
388
+
389
+ _.forEach(window.CKEDITOR.instances, (winInstance) => {
390
+ const tempInstance = winInstance;
391
+
392
+ if (winInstance.name === instanceName) {
393
+ tempInstance.setData(html);
394
+ } else if (winInstance.name.indexOf('editor') !== -1) {
395
+ tempInstance.setData(html);
396
+ }
397
+ });
398
+ }
399
+ }
400
+
401
+ this.setState({ formData }, () => {
402
+ this.hideEdmOptions(nextProps.Email.CmsSettings.isDragDrop);
403
+ });
404
+ }
405
+ if (nextProps.Email.createTemplateError && !_.isEqual(nextProps.Email.createTemplateError, this.props.Email.createTemplateError)) {
406
+ const message = getMessageObject('error', (nextProps.Email.createTemplateErrorMessage && nextProps.Email.createTemplateErrorMessage !== '') ? nextProps.Email.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
407
+ this.props.globalActions.addMessageToQueue(message);
408
+ }
409
+ if (!nextProps.Email.fetchingCmsData && !_.isEqual(nextProps.Email.cmsData, this.props.Email.cmsData) && !_.isEmpty(nextProps.Email.cmsData)) {
410
+ const formData = _.cloneDeep(this.state.formData);
411
+ if (nextProps.Email.langId && nextProps.Email.langId !== 'undefined') {
412
+ const langId = nextProps.Email.langId;
413
+ formData[`${this.state.currentTab - 1}`][langId]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
414
+ if (formData[`${this.state.currentTab - 1}`].base) {
415
+ formData.base[langId]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
416
+ }
417
+ } else if (this.state.gettingPreviewData) {
418
+ this.setState({gettingPreviewData: false});
419
+ formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
420
+ if (formData[`${this.state.currentTab - 1}`].base) {
421
+ formData.base[formData.base.activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
422
+ }
423
+ } else {
424
+ const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(formData[this.state.currentTab - 1].activeTab);
425
+ const instanceName = `template-content${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`;
426
+
427
+ _.forEach(window.CKEDITOR.instances, (winInstance) => {
428
+ const temp = winInstance;
429
+
430
+ if (winInstance.name === instanceName) {
431
+ temp.setData(decodeURIComponent(nextProps.Email.cmsData));
432
+ } else if (winInstance.name.indexOf('editor') !== -1) {
433
+ temp.setData(decodeURIComponent(nextProps.Email.cmsData));
434
+ }
435
+ });
436
+ formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
437
+ formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop = false;
438
+ formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id = "";
439
+ delete formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab].edmeditorsrc;
440
+ if (formData[`${this.state.currentTab - 1}`].base) {
441
+ formData.base[formData.base.activeTab]['template-content'] = decodeURIComponent(nextProps.Email.cmsData);
442
+ formData.base[formData.base.activeTab].is_drag_drop = false;
443
+ formData.base[formData.base.activeTab].drag_drop_id = "";
444
+ delete formData.base[formData.base.activeTab].edmeditorsrc;
445
+ }
446
+ }
447
+
448
+ this.setState({ formData }, () => {
449
+ if (nextProps.Email.langId) {
450
+ this.shouldStartValidation();
451
+ }
452
+ });
453
+ }
454
+
455
+ if ( !_.isEqual(nextProps.Email.uploadAssetSuccess, this.props.Email.uploadAssetSuccess) && nextProps.Email.uploadAssetSuccess) {
456
+ const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
457
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
458
+ if (isDragDrop && isEdmSupport) {
459
+ const evtData = JSON.parse(this.edmEvent.data);
460
+ if (evtData.action === 'editBackground') {
461
+ this.edmEvent.source.postMessage(JSON.stringify({
462
+ _dynId: JSON.parse(this.edmEvent.data)._dynId,
463
+ action: "setProps",
464
+ props: {
465
+ background: {
466
+ image: {
467
+ src: nextProps.Email.uploadedAssetData.metaInfo.secure_file_path,
468
+ },
469
+ },
470
+ },
471
+ }), "*");
472
+ } else if (evtData.action === 'edit') {
473
+ this.edmEvent.source.postMessage(JSON.stringify({
474
+ _dynId: JSON.parse(this.edmEvent.data)._dynId,
475
+ action: "setProps",
476
+ props: {
477
+ src: nextProps.Email.uploadedAssetData.metaInfo.secure_file_path,
478
+ },
479
+ }), "*");
480
+ }
481
+ this.edmEvent = undefined;
482
+ } else {
483
+ this.state.editorInstanse.insertHtml(`<img src='${nextProps.Email.uploadedAssetData.metaInfo.secure_file_path}' alt='Capillary Image'>`);
484
+ //this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, nextProps.Email.uploadedAssetData, true);
485
+ }
486
+ this.setState({showImageSelectionBox: false});
487
+ }
488
+
489
+ if ( !_.isEqual(nextProps.Email.assetUploading, this.props.Email.assetUploading) && !nextProps.Email.assetUploading && !nextProps.Email.uploadAssetSuccess) {
490
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages.assetUploadFailed), true);
491
+ this.props.globalActions.addMessageToQueue(message);
492
+ }
493
+
494
+ if (!_.isEqual(nextProps.currentOrgDetails.basic_details.supported_languages, this.props.currentOrgDetails.basic_details.supported_languages)) {
495
+ this.supportedLanguages = nextProps.currentOrgDetails.basic_details.supported_languages;
496
+ }
497
+
498
+ if (!nextProps.Email.fetchingAllAssets && !_.isEqual(nextProps.Email.fetchingAllAssets, this.props.Email.fetchingAllAssets) && !_.isEmpty(nextProps.Email.assetList) && nextProps.Email.assetList[0] && nextProps.Email.assetList[0].totalCount && this.state.totalCount === 0) {
499
+ this.setState({totalCount: nextProps.Email.assetList[0].totalCount});
500
+ }
501
+ }
502
+ }
503
+
504
+ componentWillUnmount() {
505
+ if (this.props.setIsLoadingContent) {
506
+ this.props.setIsLoadingContent(true); // setting isLoading of CreativesContainer so that slidebox foot can be hidden till content is loaded
507
+ }
508
+ this.resetStateValue();
509
+ window.removeEventListener("message", this.handleFrameTasks);
510
+ this.props.actions.clearStoreValues();
511
+ this.props.actions.clearCRUDResponse();
512
+ }
513
+
514
+ onFormDataChange = (updatedFormData, tabCount, currentTab) => {
515
+ // this.transformFormData(formData);
516
+ const formData = {...updatedFormData};
517
+ if (this.props.defaultData && _.isEmpty(formData['template-name']) && this.props.isFullMode) {
518
+ formData['template-name'] = _.get(this.props, "defaultData['template-name']");
519
+ }
520
+ this.setState({formData, tabCount, isSchemaChanged: false}, () => {
521
+ if (this.props.isFullMode) {
522
+ this.props.showTemplateName({formData, onFormDataChange: this.onFormDataChange});
523
+ }
524
+ });
525
+ if (currentTab) {
526
+ this.setState({currentTab});
527
+ }
528
+ //this.resetCkEditorInstance(currentTab, formData);
529
+ }
530
+
531
+ onChange = (evt) => {
532
+ const formData = _.cloneDeep(this.state.formData);
533
+
534
+ //if (evt.editor.name.indexOf('editor') === -1) {
535
+ // _.forEach(window.CKEDITOR.instances, (winInstance) => {
536
+ // const temp = winInstance;
537
+ // if (winInstance.name === evt.editor.name) {
538
+ //
539
+ // setTimeout(() => {
540
+ // //temp.name = id;
541
+ // }, 1000);
542
+ // //temp.name = id;
543
+ //
544
+ // }
545
+ // });
546
+ //}
547
+ if (!formData[this.state.currentTab - 1][formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop) {
548
+ formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab][`template-content`] = _.cloneDeep(evt.editor.getData());
549
+ if (formData[`${this.state.currentTab - 1}`].tabKey === formData.base.tabKey) {
550
+ formData.base[formData[`${this.state.currentTab - 1}`].activeTab][`template-content`] = _.cloneDeep(evt.editor.getData());
551
+ }
552
+
553
+ this.setState({formData, content: evt.editor.getData()}, () => {
554
+
555
+ });
556
+ }
557
+ }
558
+
559
+ onTabChange(data, formData) {
560
+ //this.resetCkEditorInstance(data, formData);
561
+ const schema = _.cloneDeep(this.state.schema);
562
+ const container = schema.containers[`${data - 1}`];
563
+ if (formData[`${data - 1}`][formData[`${data - 1}`].activeTab].is_drag_drop) {
564
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: ""};
565
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[2].style.display = "none";
566
+ } else {
567
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
568
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[2].style.display = "";
569
+ }
570
+ const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
571
+ if (baseLanguage === formData[`${data - 1}`].activeTab) {
572
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
573
+ } else {
574
+ container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
575
+ }
576
+ this.setState({currentTab: data, formData, schema, loadingStatus: this.state.loadingStatus + 1});
577
+ }
578
+
579
+ onTemplateNameChange = () => {
580
+
581
+ }
582
+
583
+ onTagSelect = (data) => {
584
+ const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
585
+ const formData = _.cloneDeep(this.state.formData);
586
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
587
+
588
+ if (isDragDrop && isEdmSupport) {
589
+ let msg = {};
590
+ if (data === "unsubscribe") {
591
+ const anchor = `<a href='{{${data}}}'>${data}</a>`;
592
+ msg = {
593
+ action: "InsertToCursor",
594
+ content: `${anchor}`,
595
+ };
596
+ } else {
597
+ msg = {
598
+ action: "InsertToCursor",
599
+ content: `{{${data}}}`,
600
+ };
601
+ }
602
+ const msgString = JSON.stringify(msg);
603
+ const langId = formData[this.state.currentTab - 1].activeTab;
604
+ const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
605
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
606
+ win.postMessage(msgString, '*');
607
+ } else {
608
+ if (data === "unsubscribe") {
609
+ const anchor = `<a href='{{${data}}}'>${data}</a>`;
610
+ this.state.editorInstanse.insertHtml(`${anchor}`);
611
+ } else {
612
+ this.state.editorInstanse.insertHtml(`{{${data}}}`);
613
+ }
614
+ //this.resetCkEditorInstance(currentTab, formData, true, data);
615
+ }
616
+ }
617
+
618
+ onImageSelect = () => {
619
+ this.setState({ showImageSelectionBox: true }, () => {
620
+ const params = {
621
+ name: this.state.searchText,
622
+ sortBy: 'Most Recent',
623
+ };
624
+ this.fetchAllAssets({params, resetPage: true});
625
+ // this.props.actions.getAllAssets("image", params);
626
+ });
627
+ }
628
+ onUpdateTemplateComplete = (createResponse) => {
629
+ if (createResponse && createResponse.templateId) {
630
+ // this.resetSchema();
631
+ let message;
632
+ if (this.state.isEdit) {
633
+ message = getMessageObject('success', this.props.intl.formatMessage(messages.emailEditSuccess), true);
634
+ } else {
635
+ message = getMessageObject('success', this.props.intl.formatMessage(messages.emailCreateSuccess), true);
636
+ }
637
+ this.props.globalActions.addMessageToQueue(message);
638
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
639
+ const type = this.props.location.query.type;
640
+ const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
641
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
642
+ if (this.props.isFullMode) {
643
+ const {versions, ...rest} = createResponse.templateId;
644
+ this.props.getFormSubscriptionData({ value: versions, ...rest, validity: true});
645
+ } else {
646
+ this.props.router.push({
647
+ pathname: `/email`,
648
+ query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport},
649
+ });
650
+ }
651
+ }
652
+ }
653
+
654
+ getSupportedLanguages = (props) => {
655
+ const {currentOrgDetails} = props;
656
+ let supportedLanguages = [];
657
+ if (!_.isEmpty(currentOrgDetails)) {
658
+ const {basic_details} = currentOrgDetails;
659
+ supportedLanguages = basic_details.supported_languages || [];
660
+ }
661
+ return supportedLanguages;
662
+ }
663
+ getValidationData = () => {
664
+ const that = this;
665
+ const formData = _.cloneDeep(this.state.formData);
666
+ if (!this.props.Email.fetchingCmsData) {
667
+ // checking wheather getCmsData in progress or not cuz getValidationData gets called multiple times from handleEdmSave
668
+ _.forEach(formData, (val, index) => {
669
+ if (!isNaN(index)) {
670
+ _.forEach(val.selectedLanguages, (language) => {
671
+ if (val[language].is_drag_drop) {
672
+ that.props.actions.getCmsData('edm', val[language].drag_drop_id, language);
673
+ }
674
+ });
675
+ }
676
+ });
677
+ }
678
+ }
679
+ setNewLanguageContent = (data) => {
680
+ const content = _.cloneDeep(data);
681
+ const formData = _.cloneDeep(this.state.formData);
682
+ const currentTab = this.state.currentTab - 1;
683
+ // const schema = _.cloneDeep(this.state.schema);
684
+
685
+ const currentTabData = formData[currentTab][this.state.settingLanguage.iso_code];
686
+ currentTabData.is_drag_drop = false;
687
+ currentTabData.drag_drop_id = "";
688
+ const newActiveTab = this.state.settingLanguage.iso_code;
689
+ currentTabData["template-content"] = content;
690
+ formData[currentTab].activeTab = newActiveTab;
691
+ if (currentTabData.edmeditorsrc) {
692
+ delete currentTabData.edmeditorsrc;
693
+ }
694
+ formData[currentTab].selectedLanguages.push(newActiveTab);
695
+
696
+ // this.setState({formData});
697
+ // const container = schema.containers[this.state.currentTab - 1];
698
+ // const temp = container;
699
+ // const langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(newActiveTab);
700
+ //
701
+ // temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
702
+ // temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
703
+ // temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
704
+ this.props.templatesActions.resetUploadData();
705
+ this.setState({formData, languageDataSet: false, addLanguageType: ''});
706
+ }
707
+
708
+ getParameterByName = (name, url) => {
709
+ const match = RegExp(`[?&]${name}=([^&]*)`).exec(url);
710
+ return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
711
+ }
712
+
713
+ getFormData = (e, value) => {
714
+ this.setState({getFormDataValue: value, gettingFormData: true}, () => {
715
+ this.saveValidationData();
716
+ });
717
+ //
718
+ // const response = {
719
+ // action: "getFormData",
720
+ // postAction: value || 'next',
721
+ // value: this.transformFormData(this.state.formData),
722
+ // validity: this.state.isFormValid,
723
+ // };
724
+ //
725
+ // this.setState({checkValidation: true});
726
+ // if (e) {
727
+ // e.source.postMessage(JSON.stringify(response), e.origin);
728
+ // }
729
+ // return response;
730
+ }
731
+
732
+ setFormValidity = (isFormValid) => {
733
+ this.setState({isFormValid, startValidation: false});
734
+ }
735
+
736
+ setEditData(editData) {
737
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
738
+ const formData = _.cloneDeep(this.state.formData);
739
+
740
+ const schema = (this.props.location.query.type === 'embedded') ? this.removeStandAlone(this.state.schema) : _.cloneDeep(this.state.schema);
741
+ const containers = _.cloneDeep(schema.containers.slice());
742
+ let tabKey = "";
743
+ let currentTab = _.cloneDeep(this.state.currentTab);
744
+ const isLanguageSupport = this.props.location.query.isLanguageSupport;
745
+ const type = this.props.location.query.type;
746
+
747
+ formData['template-name'] = editData.name;
748
+ formData['template-subject'] = _.get(editData, 'versions.base.subject');
749
+ formData.base = editData.versions.base;
750
+
751
+ _.forEach(editData.versions.history, (data1, index) => {
752
+ const data = _.cloneDeep(data1);
753
+ if (data !== null) {
754
+ if (index > 0 && (isLanguageSupport || this.props.location.query.type !== 'embedded')) {
755
+ const firstPane = _.cloneDeep(containers[0].panes[0]);
756
+ // schema.containers[this.state.currentTab - 1].isActive = false;
757
+ const sections = [];
758
+ // containers[0].isActive = true;
759
+ _.forEach(firstPane.sections, (section) => {
760
+ let sect = _.cloneDeep(section);
761
+
762
+ if (sect.type === 'col-label') {
763
+ sect = this.cloneColLabel(sect, index, true);
764
+ } else if (sect.type === 'multicols') {
765
+ sect = this.cloneMultiCol(sect, index, true);
766
+ } else if (sect.type === 'parent') {
767
+ sect = this.cloneParent(sect, index, true);
768
+ }
769
+
770
+ sections.push(sect);
771
+ return true;
772
+ });
773
+ firstPane.sections = sections;
774
+ containers[0].panes = [];
775
+ containers[0].panes.push(firstPane);
776
+ schema.containers.push(containers[0]);
777
+
778
+
779
+ // _.forEach(sections[0].inputFields[0].cols, (inputField) => {
780
+ // if (this.map[inputField.id] === undefined) {
781
+ // if (inputField.id.indexOf('template-content') > -1) {
782
+ // this.map[inputField.id] = this.map['template-content'];
783
+ // } else if (inputField.id.indexOf('edmeditor2') > -1) {
784
+ // this.map[inputField.id] = this.map.edmeditor2;
785
+ // }
786
+ // }
787
+ // });
788
+
789
+ const newVersionOption = formData['template-version-options'].pop();
790
+ formData['template-version-options'].push({
791
+ key: `version ${index + 1}`,
792
+ label: `Version ${index + 1}`,
793
+ value: `version ${index + 1}`,
794
+ });
795
+ formData['template-version-options'].push(newVersionOption);
796
+ }
797
+
798
+ // data.activeTab = this.props.currentOrgDetails.basic_details.base_language;
799
+ _.forEach((data.selectedLanguages), (language) => {
800
+ if (data.tabKey === data[language].tabKey) {
801
+ data.activeTab = language;
802
+ }
803
+ });
804
+ if (data.constructor === Object) {
805
+ if (data.tabKey === editData.versions.base.tabKey) {
806
+ tabKey = data.tabKey;
807
+ schema.containers[index].isActive = true;
808
+ formData['template-version'] = formData['template-version-options'][index].key;
809
+ currentTab = index + 1;
810
+ } else {
811
+ schema.containers[index].isActive = false;
812
+ }
813
+ // const isLanguageSupport = this.props.location.query.isLanguageSupport;
814
+
815
+ _.forEach(data.selectedLanguages, (lang, langIndex) => {
816
+ if ((type !== 'embedded' || (type === 'embedded' && isLanguageSupport === 'true')) && lang !== this.props.currentOrgDetails.basic_details.base_language) {
817
+ const tabContent = _.cloneDeep(containers[0].tabContent.sections[0]);
818
+ const tabContentSection = tabContent.inputFields[0].cols[0];
819
+ const panes = containers[0].panes.slice();
820
+ const firstPane = _.cloneDeep(panes[0]);
821
+ const sections = [];
822
+ _.forEach(firstPane.sections, (section) => {
823
+ let sect = _.cloneDeep(section);
824
+
825
+ if (sect.type === 'col-label') {
826
+ sect = this.cloneColLabel(sect, (langIndex + 1));
827
+ } else if (sect.type === 'multicols') {
828
+ sect = this.cloneMultiCol(sect, (langIndex + 1));
829
+ } else if (sect.type === 'parent') {
830
+ sect = this.cloneParent(sect, (langIndex + 1));
831
+ }
832
+
833
+ sections.push(sect);
834
+ return true;
835
+ });
836
+ //
837
+
838
+ this.map[`template-content${data.selectedLanguages.indexOf(lang) + 1}`] = this.map['template-content'];
839
+ tabContentSection.id = `${tabContentSection.id}${index + 1}`;
840
+ tabContentSection.value = `${data[lang].language}`;
841
+
842
+ firstPane.sections = sections;
843
+ firstPane.sectionsHeaders = [tabContent];
844
+
845
+ // panes.push(firstPane);
846
+
847
+ schema.containers[index].panes.push(firstPane);
848
+ } else if (lang !== this.props.currentOrgDetails.basic_details.base_language) {
849
+ delete data[lang];
850
+ data.selectedLanguages.splice(langIndex, 1);
851
+ }
852
+ });
853
+ }
854
+ if (data.base) {
855
+ formData.base = data;
856
+ }
857
+ formData[index] = data;
858
+ }
859
+ });
860
+
861
+ _.forEach(formData.base.selectedLanguages, (language) => {
862
+ if (formData.base.tabKey === formData.base[language].tabKey) {
863
+ formData.base.activeTab = language;
864
+ }
865
+ });
866
+
867
+
868
+ this.setState({ formData, schema, tabKey, currentTab, tabCount: editData.versions.history.length, loadingStatus: this.state.loadingStatus + 1 }, () => {
869
+ this.props.showTemplateName({formData, onFormDataChange: this.onFormDataChange});
870
+ _.forEach((editData.versions.base.selectedLanguages), (language) => {
871
+ // if (formData[this.state.currentTab - 1].tabKey === formData[this.state.currentTab - 1][language].tabKey) {
872
+ // formData[this.state.currentTab - 1].activeTab = language;
873
+ // }
874
+ // if (formData.base.tabKey === formData.base[language].tabKey) {
875
+ // formData.base.activeTab = language;
876
+ // }
877
+ if (language && editData.versions.base[language].is_drag_drop) {
878
+ this.props.actions.getCmsSetting('edm', editData.versions.base[language].drag_drop_id, 'open', language, isEdmSupport);
879
+ }
880
+ });
881
+
882
+ // this.resetCkEditorInstance(this.state.currentTab - 1, formData);
883
+ // this.setState({formData});
884
+ });
885
+ }
886
+
887
+ getMappedEvent = (id, event) => this.map[id][event]
888
+
889
+ getCurrentWindow = (e) => {
890
+ const response = {
891
+ action: e.action,
892
+ value: 'edit',
893
+ direction: e.value,
894
+ };
895
+ parent.postMessage(JSON.stringify(response), '*');
896
+ }
897
+
898
+ getEditorInstanse = () => {
899
+ window.CKEDITOR.on( 'instanceReady', ( event ) => {
900
+ this.setState({editorInstanse: event.editor});
901
+ event.editor.on( 'focus', () => {
902
+ this.setState({editorInstanse: event.editor});
903
+ });
904
+ });
905
+ //this.setState({editorInstanse: instance});
906
+ }
907
+
908
+ setModalContent = (type, data) => {
909
+ let modalContent = {};
910
+ if (type === 'delete-version') {
911
+ modalContent = {
912
+ title: "Alert",
913
+ body: "Do you really want to delete this version?",
914
+ type: 'confirm',
915
+ id: 'email-version-delete-modal',
916
+ };
917
+ } else if (type === 'delete-language') {
918
+ modalContent = {
919
+ title: "Alert",
920
+ body: "Do you really want to delete this language?",
921
+ type: 'confirm',
922
+ id: 'email-language-delete-modal',
923
+ };
924
+ } else if (type === 'add-language') {
925
+ const jsx = (
926
+ <div>
927
+ <div><CapButton type="secondary" style={{width: "100%", marginBottom: "8px"}} onClick={this.uploadFile}>Upload File</CapButton>
928
+ <input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
929
+ </div>
930
+ <div><CapButton type="secondary" style={{width: "100%", marginBottom: "8px"}} onClick={this.useEditor}>Use Editor</CapButton></div>
931
+ <div><CapButton type="secondary" style={{width: "100%", marginBottom: "8px"}} onClick={this.copyPrimaryLanguage}>Copy primary Language</CapButton></div>
932
+ </div>);
933
+ modalContent = {
934
+ title: "New Language",
935
+ type: "action",
936
+ jsx,
937
+ id: 'email-add-language-options',
938
+ };
939
+ this.setState({settingLanguage: data});
940
+ }
941
+ this.setState({ modalContent, showModal: true});
942
+ };
943
+
944
+ shouldStartValidation = () => {
945
+ this.setState((prevState) => ({ cmsDataCount: prevState.cmsDataCount + 1}), () => {
946
+ if (this.state.targetSaveCount === this.state.cmsDataCount) {
947
+ this.setState({startValidation: true});
948
+ }
949
+ });
950
+ }
951
+
952
+ stopValidation = () => {
953
+ this.setState({startValidation: false});
954
+ }
955
+ saveValidationData = () => {
956
+ let saveCount = 0;
957
+ this.setState({saveEdmDataMode: 'validation', saveCount: 0, cmsDataCount: 0}, () => {
958
+ _.forEach(this.state.formData, (newdata, index) => {
959
+ if (!isNaN(index)) {
960
+ _.forEach(newdata.selectedLanguages, (language) => {
961
+ if (newdata[language].is_drag_drop && ((parseInt(index, 10) + 1) === this.state.currentTab)) {
962
+ saveCount += 1;
963
+ }
964
+ });
965
+ }
966
+ });
967
+ if (saveCount === 0) {
968
+ this.setState({startValidation: true});
969
+ return;
970
+ }
971
+ this.setState({targetSaveCount: saveCount, mode: "save", saveCount: 0, cmsDataCount: 0}, () => {
972
+ const data = this.state.formData[this.state.currentTab - 1];
973
+ _.forEach(data.selectedLanguages, (language, langIndex) => {
974
+ if (data[language].is_drag_drop) {
975
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
976
+ win.postMessage("saveProject", '*');
977
+ }
978
+ });
979
+ });
980
+ });
981
+ }
982
+
983
+ resetStateValue = () => {
984
+ this.setState({
985
+ formData: {},
986
+ tabCount: 1,
987
+ currentTab: 1,
988
+ isEdit: false,
989
+ schema: {},
990
+ loading: false,
991
+ isFormValid: true,
992
+ injectedTags: {},
993
+ checkValidation: false,
994
+ tabKey: '',
995
+ showEmailPreview: false,
996
+ device: "desktop",
997
+ editorInstanse: undefined,
998
+ showImageSelectionBox: false,
999
+ isDragDrop: false,
1000
+ showConfirmationModal: false,
1001
+ modalContent: {title: "Alert", body: "Do you really want to delete this language?", type: 'confirm', id: 'email-language-delete-modal'},
1002
+ showModal: false,
1003
+ page: 1,
1004
+ perPageLimit: 25,
1005
+ totalCount: 0,
1006
+ searchText: '',
1007
+ saveCount: 0,
1008
+ targetSaveCount: 0,
1009
+ saveObj: {},
1010
+ showEdmEmailTemplates: false,
1011
+ editDataSet: false,
1012
+ }, () => {
1013
+
1014
+ });
1015
+ }
1016
+
1017
+ resetCkEditorInstance = (data, formData, onInsert, value, isImage) => {
1018
+ const currentLang = formData[`${data - 1}`].selectedLanguages.indexOf(formData[`${data - 1}`].activeTab);
1019
+ const langIndex = formData[`${data - 1}`].selectedLanguages.indexOf(formData[`${data - 1}`].activeTab);
1020
+ let instance1 = window.CKEDITOR.instances[`editor${currentLang + 1}`];
1021
+ const instanceArray = [];
1022
+ _.forEach(window.CKEDITOR.instances, (instance ) => {
1023
+ const name = instance.name;
1024
+ if (instance.status === "destroyed") {
1025
+ return;
1026
+ }
1027
+ let instanceIdx = 0;
1028
+ if (name.indexOf('template-content') > -1 && name !== 'template-content') {
1029
+ instanceIdx = parseInt(name.replace('template-content', ''), 10) - 1;
1030
+ const obj = {
1031
+ idx: instanceIdx,
1032
+ instance,
1033
+ };
1034
+ instanceArray.push(obj);
1035
+ } else {
1036
+ const obj = {
1037
+ idx: 0,
1038
+ instance,
1039
+ };
1040
+ instanceArray.push(obj);
1041
+ }
1042
+ });
1043
+
1044
+ instanceArray.sort( (a, b) => {
1045
+ const idxA = a.idx;
1046
+ const idxB = b.idx;
1047
+ if (idxA < idxB) {
1048
+ return -1;
1049
+ } else if (idxA > idxB) {
1050
+ return 1;
1051
+ }
1052
+ return 0;
1053
+ });
1054
+
1055
+ //instanceCount += 1;
1056
+ // if (instanceIdx === langIndex) {
1057
+ const instance = instanceArray[langIndex].instance;
1058
+
1059
+ instance1 = instance;
1060
+ this.setState({editorInstanse: instance1}, () => {
1061
+ if (onInsert && !isImage) {
1062
+ this.state.editorInstanse.insertHtml(`{{${value}}}`);
1063
+ } else if (onInsert) {
1064
+ this.state.editorInstanse.insertHtml(`<img src='${value.metaInfo.secure_file_path}' alt='Capillary Image'>`);
1065
+ }
1066
+ });
1067
+ }
1068
+
1069
+ uploadFile = () => {
1070
+ document.getElementById('filename').click();
1071
+ };
1072
+
1073
+ useEditor = () => {
1074
+ //this.toggleEdmEmailTemplateSelection();
1075
+ this.setState({addLanguageType: "useEditor"}, () => {
1076
+ this.setState({showModal: false}, () => {
1077
+ this.toggleEdmEmailTemplateSelection();
1078
+ });
1079
+ });
1080
+ }
1081
+
1082
+ copyPrimaryLanguage = () => {
1083
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
1084
+
1085
+ this.setState({addLanguageType: "copyPrimaryLanguage"}, () => {
1086
+ this.setState({showModal: false});
1087
+ const formData = _.cloneDeep(this.state.formData);
1088
+ const currentTab = this.state.currentTab - 1;
1089
+ const baseLanguage = this.props.currentOrgDetails.basic_details.base_language ? this.props.currentOrgDetails.basic_details.base_language : 'en';
1090
+ if (formData[currentTab][baseLanguage].is_drag_drop) {
1091
+ this.props.actions.getCmsSetting('edm', formData[currentTab][baseLanguage].drag_drop_id, 'duplicate', baseLanguage, isEdmSupport);
1092
+ }
1093
+ });
1094
+ }
1095
+
1096
+ handleFileUpload = (e, {files}) => {
1097
+ if (files.length === 0) {
1098
+ return;
1099
+ }
1100
+ const fileExtension = files[0].name.split('.').pop();
1101
+ const supportedZipFormats = ['zip'];
1102
+
1103
+ if (supportedZipFormats.indexOf(fileExtension.toLowerCase()) !== -1) {
1104
+ this.setState({ addLanguageType: "upload"}, () => {
1105
+ this.props.templatesActions.handleZipUpload(files[0]);
1106
+ document.getElementById("filename").value = "";
1107
+ this.setState({showModal: false});
1108
+ });
1109
+ } else if (fileExtension === 'html' || fileExtension === 'htm') {
1110
+ const reader = new FileReader();
1111
+ reader.onload = () => {
1112
+ this.setState({ addLanguageType: "upload"}, () => {
1113
+ const text = reader.result;
1114
+ this.props.templatesActions.handleHtmlUpload(text);
1115
+ document.getElementById("filename").value = "";
1116
+ this.setState({showModal: false});
1117
+ });
1118
+ };
1119
+ reader.readAsText(files[0]);
1120
+ } else {
1121
+ alert('Invalid file type added! Please Give a proper zip/html file');
1122
+ }
1123
+ };
1124
+
1125
+ uploadImages(e, {files}) {
1126
+ e.preventDefault();
1127
+ const _URL = window.URL || window.webkitURL;
1128
+ const file = files[0];
1129
+ const fileSize = (file.size / ( 1024 * 1024 ));
1130
+ if (fileSize > 5) {
1131
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages.uploadSizeError), true);
1132
+ this.props.globalActions.addMessageToQueue(message);
1133
+ document.getElementById("fileName").value = "";
1134
+ return;
1135
+ }
1136
+ const img = new Image();
1137
+ const that = this;
1138
+ img.src = _URL.createObjectURL(file);
1139
+ img.onload = function () {
1140
+ const fileParams = {
1141
+ width: this.width,
1142
+ height: this.height,
1143
+ };
1144
+ that.props.actions.uploadAsset(file, 'image', fileParams);
1145
+ that.handleImagePreviewClose();
1146
+ };
1147
+ }
1148
+
1149
+ fetchAllAssets = ({params, getNextPage, resetPage}) => {
1150
+ let queryParams = params;
1151
+ let page = this.state.page;
1152
+ if (!this.props.Email.fetchingAllAssets && (resetPage || (page === 1 && this.state.totalCount === 0) || page <= (this.state.totalCount / this.state.perPageLimit))) {
1153
+ if (getNextPage) {
1154
+ page += 1;
1155
+ }
1156
+ let totalCount = this.state.totalCount;
1157
+ if (resetPage) {
1158
+ page = 1;
1159
+ totalCount = 0;
1160
+ }
1161
+ if ((!params || _.isEmpty(params))) {
1162
+ queryParams = {
1163
+ sortBy: this.state.sortBy,
1164
+ };
1165
+ }
1166
+ if (this.state.searchText !== "") {
1167
+ queryParams = {...queryParams, name: this.state.searchText};
1168
+ }
1169
+ this.setState({page, totalCount}, () => {
1170
+ queryParams.page = page;
1171
+ queryParams.perPage = this.state.perPageLimit;
1172
+ this.props.actions.getAllAssets('image', queryParams);
1173
+ });
1174
+ }
1175
+ };
1176
+
1177
+ searchAsset = (value) => {
1178
+ this.setState({searchText: value}, () => {
1179
+ this.delay(() => {
1180
+ const params = {
1181
+ name: this.state.searchText,
1182
+ };
1183
+ if (this.state.sortBy) {
1184
+ params.sortBy = this.state.sortBy;
1185
+ }
1186
+ this.fetchAllAssets({params, resetPage: true});
1187
+ }, 1000);
1188
+ });
1189
+ }
1190
+
1191
+ delay = (callback, ms) => {
1192
+ clearTimeout(this.delayTimer);
1193
+ this.delayTimer = setTimeout(callback, ms);
1194
+ }
1195
+
1196
+ deleteLanguage = (passedData, val) => {
1197
+ const formData = _.cloneDeep(passedData);
1198
+
1199
+ const schema = _.cloneDeep(this.state.schema);
1200
+ schema.containers[this.state.currentTab - 1].panes.splice(val, 1);
1201
+ schema.containers[this.state.currentTab - 1].tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: "none"};
1202
+ //this.resetCkEditorInstance(this.state.currentTab, formData);
1203
+ this.setState({schema, formData, showModal: false});
1204
+ }
1205
+
1206
+ initFormData(props) {
1207
+ let newFormData = {};
1208
+ if (props.currentOrgDetails && props.currentOrgDetails.basic_details) {
1209
+ newFormData = {
1210
+ "0": {},
1211
+ "template-name": "",
1212
+ "base": {},
1213
+ };
1214
+ const baseData = {};
1215
+ const baseLanguage = props.currentOrgDetails.basic_details.base_language;
1216
+ this.supportedLanguages = this.getSupportedLanguages(props);
1217
+ const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})];
1218
+ baseData.activeTab = baseLanguage;
1219
+ baseData[languageObject.iso_code] = {};
1220
+ baseData[languageObject.iso_code].is_drag_drop = false;
1221
+ baseData[languageObject.iso_code].lang_id = languageObject.lang_id;
1222
+ baseData[languageObject.iso_code].iso_code = languageObject.iso_code;
1223
+ baseData[languageObject.iso_code].language = languageObject.language;
1224
+ baseData[languageObject.iso_code]["template-content"] = (props.Templates.selectedEmailLayout ? props.Templates.selectedEmailLayout : '');
1225
+ // if (this.state.isDragDrop) {
1226
+ baseData[languageObject.iso_code].drag_drop_id = "";//props.Templates.edmTemplate.versions.base.drag_drop_id;
1227
+ //}
1228
+ baseData.selectedLanguages = [baseLanguage];
1229
+ newFormData.base = baseData;
1230
+ newFormData[0] = baseData;
1231
+ newFormData[0].base = true;
1232
+ }
1233
+ this.props.templatesActions.resetUploadData();
1234
+ return newFormData;
1235
+ }
1236
+
1237
+ transformFormData = (formData) => {
1238
+ const newFormData = {
1239
+ base: {},
1240
+ secondary_templates: [],
1241
+ };
1242
+ // const baseData = {};
1243
+ _.forEach(formData.base, (content, index) => {
1244
+ if (content && content.constructor === Object) {
1245
+ const tmpData = {};
1246
+ if (_.isEmpty(content)) {
1247
+ return;
1248
+ }
1249
+ tmpData.html_content = content['template-content'];
1250
+ tmpData.is_drag_drop = content.is_drag_drop;
1251
+ tmpData.lang_id = content.lang_id;
1252
+ tmpData.iso_code = content.iso_code;
1253
+ tmpData.language = content.language;
1254
+ if (content.is_drag_drop) {
1255
+ tmpData.drag_drop_id = (content.drag_drop_id ? content.drag_drop_id : "");
1256
+ }
1257
+
1258
+ if (index === this.props.currentOrgDetails.basic_details.base_language) {
1259
+ newFormData.base = _.cloneDeep(tmpData);
1260
+ }
1261
+ newFormData.secondary_templates.push({template_data: tmpData});
1262
+ }
1263
+ });
1264
+ // if (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs" || this.props.location.query.module === "coupon_expiry" || this.props.location.query.module === "timeline" || this.props.location.query.module === "library")) {
1265
+ newFormData.base.subject = formData['template-subject'];
1266
+ // }
1267
+
1268
+
1269
+ return newFormData;
1270
+ }
1271
+
1272
+ handleFrameTasks = (e) => {
1273
+ const type = this.isValidJson(e.data) ? JSON.parse(e.data) : e.data;
1274
+
1275
+ if (typeof type === 'object') {
1276
+ const action = type.action;
1277
+ switch (action) {
1278
+ case "startTemplateCreation":
1279
+ this.startTemplateCreation(type.value);
1280
+ break;
1281
+ case "edit":
1282
+ this.edmEvent = e;
1283
+ if (type.elementJson.type === "IMAGE") {
1284
+ this.onImageSelect();
1285
+ }
1286
+ break;
1287
+ case "editBackground":
1288
+ this.edmEvent = e;
1289
+ if (type.elementJson.type === "BOX" || type.elementJson.type === "BUTTON" || type.elementJson.type === "GENERAL") {
1290
+ this.onImageSelect();
1291
+ }
1292
+ break;
1293
+ case "create":
1294
+ this.edmEvent = e;
1295
+ break;
1296
+ case "select":
1297
+ //this.edmEvent = e;
1298
+ break;
1299
+ case "startLoading":
1300
+ this.startLoading(type.edit);
1301
+ break;
1302
+ case "getCurrentWindow":
1303
+ this.getCurrentWindow(type);
1304
+ break;
1305
+ case "getFormData":
1306
+ this.getFormData(e, type.value);
1307
+ break;
1308
+ default:
1309
+ break;
1310
+ }
1311
+ } else {
1312
+ switch (type) {
1313
+ case "getFormData":
1314
+ this.getFormData(e);
1315
+ break;
1316
+ case "startTemplateCreation":
1317
+
1318
+ //this.getFormData(e);
1319
+ break;
1320
+ case "moveToTemplates":
1321
+
1322
+ this.moveToTemplates();
1323
+ break;
1324
+ case "validateContent":
1325
+
1326
+ this.validateContent(e);
1327
+ break;
1328
+ case "Save result: success":
1329
+ if (_.isEmpty(this.props.Email.cmsData)) {
1330
+ this.handleEdmSave();
1331
+ }
1332
+ break;
1333
+ case "JsonChanged":
1334
+ this.edmEvent = e;
1335
+ break;
1336
+ default:
1337
+ break;
1338
+ }
1339
+ }
1340
+ }
1341
+
1342
+ isValidJson = (str) => {
1343
+ try {
1344
+ JSON.parse(str);
1345
+ } catch (e) {
1346
+ return false;
1347
+ }
1348
+ return true;
1349
+ }
1350
+
1351
+ handleEdmSave = () => {
1352
+ if (this.state.mode === "save") {
1353
+ this.setState((prevState) => ({ saveCount: prevState.saveCount + 1}), () => {
1354
+ if (this.state.targetSaveCount === this.state.saveCount) {
1355
+ if (this.state.saveEdmDataMode === 'validation') {
1356
+ this.getValidationData();
1357
+ } else if (this.state.saveEdmDataMode === 'save') {
1358
+ this.props.actions.createTemplate(this.state.saveObj);
1359
+ }
1360
+ }
1361
+ });
1362
+ } else if (this.state.mode === 'preview' || this.state.mode === 'switchEditor') {
1363
+ this.props.actions.getCmsData('edm', this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id);
1364
+ if (this.state.mode === 'switchEditor') {
1365
+ let schema = _.cloneDeep(this.state.schema);
1366
+ const formData = _.cloneDeep(this.state.formData);
1367
+ _.forEach(schema.containers, (container, index) => {
1368
+ if (parseInt(index, 10) === (this.state.currentTab - 1)) {
1369
+ const temp = container;
1370
+ const langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(formData[`${this.state.currentTab - 1}`].activeTab);
1371
+
1372
+ temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
1373
+ temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
1374
+ temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
1375
+ }
1376
+ });
1377
+ schema = this.showInsertImageButton(schema);
1378
+
1379
+ this.setState({ schema, showConfirmationModal: false, isSchemaChanged: true }, () => {
1380
+ this.injectEvents(schema);
1381
+ });
1382
+ }
1383
+ }
1384
+ }
1385
+
1386
+ handleImagePreviewClose = () => {
1387
+ this.setState({ showImageSelectionBox: false });
1388
+ }
1389
+
1390
+ handleContentChange = (data) => {
1391
+ const formData = _.cloneDeep(this.state.formData);
1392
+ formData[this.state.currentTab][formData[this.state.currentTab - 1].activeTab]["template-content"] = data;
1393
+ this.setState({formData});
1394
+ }
1395
+
1396
+ handleOnHoverItem = (isHovering) => {
1397
+ if (!isHovering) {
1398
+ // const data = _.find(this.props.Email.assetList, {_id: id});
1399
+ //
1400
+ // if (data) {
1401
+ // if (this.state.isDragDrop) {
1402
+ //
1403
+ // } else {
1404
+ // this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.public_url}' alt='Capillary Image'>`);
1405
+ // }
1406
+ // }
1407
+ }
1408
+ }
1409
+
1410
+ hideEdmOptions = (isDragDrop) => {
1411
+ const schema = _.cloneDeep(this.state.schema);
1412
+ _.forEach(schema.containers, (container) => {
1413
+ if (container.isActive) {
1414
+ _.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
1415
+ if (containerInputFieldCol.id === 'insert-image') {
1416
+ const newContainerInputFieldCol = containerInputFieldCol;
1417
+ newContainerInputFieldCol.style.display = isDragDrop ? "none" : '';
1418
+ }
1419
+ if (containerInputFieldCol.id === 'tab-options-popover') {
1420
+ _.forEach(containerInputFieldCol.content.sections[0].inputFields, (tabPopoverSection) => {
1421
+ if (tabPopoverSection.cols[0].id === 'switch-editor-label') {
1422
+ const newTabPopoverSection = tabPopoverSection;
1423
+ newTabPopoverSection.cols[0].style.display = isDragDrop ? "" : 'none';
1424
+ }
1425
+ });
1426
+ }
1427
+ });
1428
+ }
1429
+ });
1430
+
1431
+ this.setState({schema, isSchemaChanged: true});
1432
+ }
1433
+
1434
+ showInsertImageButton = (passedSchema) => {
1435
+ const schema = passedSchema || _.cloneDeep(this.state.schema);
1436
+ _.forEach(schema.containers, (container) => {
1437
+ if (container.isActive) {
1438
+ _.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
1439
+ if (containerInputFieldCol.id === 'insert-image') {
1440
+ const newContainerInputFieldCol = containerInputFieldCol;
1441
+ newContainerInputFieldCol.style.display = "";
1442
+ }
1443
+ });
1444
+ }
1445
+ });
1446
+
1447
+ this.setState({schema, isSchemaChanged: true});
1448
+ }
1449
+
1450
+ showSubject = () => {
1451
+ const schema = _.cloneDeep(this.state.schema);
1452
+ if (schema.standalone) {
1453
+ if ((this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs" || this.props.location.query.module === "timeline" || this.props.location.query.module === "coupon_expiry" ||
1454
+ this.props.location.query.module === "library")) {
1455
+ _.set(schema, 'standalone.sections[0].inputFields[0].style.display', "" );
1456
+ _.set(schema, 'standalone.sections[0].inputFields[0].labelStyle.display', "");
1457
+ }
1458
+ this.setState({schema});
1459
+ }
1460
+ }
1461
+
1462
+ handleOnItemClick = (isSelected, id) => {
1463
+ const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
1464
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
1465
+ if (isSelected) {
1466
+ const data = _.find(this.props.Email.assetList, {_id: id});
1467
+
1468
+ if (data) {
1469
+ if (isDragDrop && isEdmSupport) {
1470
+ const evtData = JSON.parse(this.edmEvent.data);
1471
+ if (evtData.action === 'editBackground') {
1472
+ this.edmEvent.source.postMessage(JSON.stringify({
1473
+ _dynId: JSON.parse(this.edmEvent.data)._dynId,
1474
+ action: "setProps",
1475
+ props: {
1476
+ background: {
1477
+ image: {
1478
+ src: data.metaInfo.secure_file_path,
1479
+ },
1480
+ },
1481
+ },
1482
+ }), "*");
1483
+ } else if (evtData.action === 'edit') {
1484
+ this.edmEvent.source.postMessage(JSON.stringify({
1485
+ _dynId: JSON.parse(this.edmEvent.data)._dynId,
1486
+ action: "setProps",
1487
+ props: {
1488
+ src: data.metaInfo.secure_file_path,
1489
+ },
1490
+ }), "*");
1491
+ }
1492
+ this.edmEvent = undefined;
1493
+ } else {
1494
+ this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.secure_file_path}' alt='Capillary Image'>`);
1495
+ //this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, data, true);
1496
+ }
1497
+ }
1498
+ this.setState({ showImageSelectionBox: false });
1499
+ }
1500
+ }
1501
+
1502
+ toggleEmailPreview = () => {
1503
+ const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
1504
+ if (isDragDrop && !this.state.showEmailPreview) {
1505
+ const activeLangTab = this.state.formData[`${this.state.currentTab - 1}`].activeTab;
1506
+ const langIndex = this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
1507
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
1508
+ win.postMessage("saveProject", '*');
1509
+ this.setState({mode: "preview", gettingPreviewData: true});
1510
+ // this.setState({gettingPreviewData: true}, () => {
1511
+ // this.props.actions.getCmsData('edm', this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].drag_drop_id);
1512
+ // });
1513
+ } else if (this.state.showEmailPreview) {
1514
+ const formData = _.cloneDeep(this.state.formData);
1515
+ formData[`${this.state.currentTab - 1}`][formData[`${this.state.currentTab - 1}`].activeTab]['template-content'] = "";
1516
+ if (formData[`${this.state.currentTab - 1}`].base) {
1517
+ formData.base[formData.base.activeTab]['template-content'] = "";
1518
+ }
1519
+ }
1520
+ this.setState( (prevState) => ({ showEmailPreview: !prevState.showEmailPreview }));
1521
+ }
1522
+
1523
+ changePreviewDevice = (device) => {
1524
+ this.setState({ device });
1525
+ }
1526
+
1527
+ handleVersionSelect = (status, formData) => {
1528
+ const newFormData = _.cloneDeep(this.state.formData);
1529
+ const schema = _.cloneDeep(this.state.schema);
1530
+ const versionIndex = _.findIndex(formData['template-version-options'], {key: status});
1531
+ newFormData['template-version'] = formData['template-version-options'][versionIndex].key;
1532
+
1533
+ const newContainers = [];
1534
+ _.forEach(schema.containers, (container, index) => {
1535
+ const tmpContainer = _.cloneDeep(container);
1536
+ if (index === versionIndex) {
1537
+ tmpContainer.isActive = true;
1538
+ } else {
1539
+ tmpContainer.isActive = false;
1540
+ }
1541
+ newContainers.push(tmpContainer);
1542
+ });
1543
+ schema.containers = _.cloneDeep(newContainers);
1544
+ this.setState({formData: newFormData, schema, currentTab: (versionIndex + 1), isSchemaChanged: true});
1545
+ }
1546
+
1547
+ afterPaste = () => {
1548
+
1549
+ }
1550
+
1551
+ deleteVersion = (data, currentTab) => {
1552
+ if (this.state.tabCount === 1 || currentTab === 1) {
1553
+ return;
1554
+ }
1555
+ const schema = _.cloneDeep(this.state.schema);
1556
+ const formData = _.cloneDeep(this.state.formData);
1557
+ schema.containers.splice(`${currentTab - 1}`, 1);
1558
+ schema.containers[0].isActive = true;
1559
+ delete formData[`${currentTab - 1}`];
1560
+ formData['template-version-options'].splice(`${currentTab - 1}`, 1);
1561
+ formData['template-version'] = formData['template-version-options'][0].value;
1562
+
1563
+ this.setState({schema, tabCount: (this.state.tabCount - 1), currentTab: 1, isSchemaChanged: true, showModal: false});
1564
+ }
1565
+
1566
+ switchEditor = () => {
1567
+ this.setState({showConfirmationModal: true});
1568
+ }
1569
+
1570
+ renameVersion = () => {
1571
+
1572
+ }
1573
+
1574
+ markFinalVersion = () => {
1575
+ const message = getMessageObject('success', this.props.intl.formatMessage(messages["Template Marked as Final Successfully"]), true);
1576
+ this.props.globalActions.addMessageToQueue(message);
1577
+ }
1578
+
1579
+ duplicateVersion = (formData) => {
1580
+ this.setState({formData}, () => {
1581
+ this.addVersion(this.state.tabCount);
1582
+ });
1583
+ }
1584
+
1585
+ addVersion = () => {
1586
+ if (this.state.schema.containers.length === 5) {
1587
+ alert('You cant have more that 5 versions');
1588
+ return;
1589
+ }
1590
+
1591
+ const schema = _.cloneDeep(this.state.schema);
1592
+ const tabIndex = schema.containers.length + 1; //data + 1;
1593
+ const formData = _.cloneDeep(this.state.formData);
1594
+ const containers = _.cloneDeep(schema.containers.slice());
1595
+ const firstPane = _.cloneDeep(containers[0].panes[0]);
1596
+ const sections = [];
1597
+ containers[0].isActive = true;
1598
+ _.forEach(firstPane.sections, (section) => {
1599
+ let sect = _.cloneDeep(section);
1600
+
1601
+ if (sect.type === 'col-label') {
1602
+ sect = this.cloneColLabel(sect, tabIndex);
1603
+ } else if (sect.type === 'multicols') {
1604
+ sect = this.cloneMultiCol(sect, tabIndex);
1605
+ } else if (sect.type === 'parent') {
1606
+ sect = this.cloneParent(sect, tabIndex);
1607
+ }
1608
+
1609
+ sections.push(sect);
1610
+ return true;
1611
+ });
1612
+ firstPane.sections = sections;
1613
+ containers[0].panes = [];
1614
+ containers[0].panes.push(firstPane);
1615
+ schema.containers.push(containers[0]);
1616
+
1617
+ _.forEach(schema.containers, (container, index) => {
1618
+ schema.containers[index].isActive = ((index + 1) === this.state.currentTab);
1619
+ });
1620
+
1621
+
1622
+ _.forEach(sections[0].inputFields[0].cols, (inputField) => {
1623
+ if (this.map[inputField.id] === undefined) {
1624
+ if (inputField.id.indexOf('template-content') > -1) {
1625
+ this.map[inputField.id] = this.map['template-content'];
1626
+ } else if (inputField.id.indexOf('edmeditor2') > -1) {
1627
+ this.map[inputField.id] = this.map.edmeditor2;
1628
+ }
1629
+ }
1630
+ });
1631
+
1632
+ const newVersionOption = formData['template-version-options'].pop();
1633
+
1634
+ formData['template-version-options'].push({
1635
+ key: `version ${tabIndex}`,
1636
+ label: `Version ${tabIndex}`,
1637
+ value: `version ${tabIndex}`,
1638
+ });
1639
+ formData['template-version-options'].push(newVersionOption);
1640
+ formData['template-version'] = `version ${tabIndex}`;
1641
+
1642
+ if (schema) {
1643
+ this.setState({schema, formData, currentTab: (tabIndex), isSchemaChanged: true});
1644
+ }
1645
+ }
1646
+
1647
+ addLanguage = (tempLang, passedData, val, asyncLanguages) => {
1648
+ if (this.state.addLanguageType === "upload") {
1649
+ this.setState({languageDataSet: true}, () => {
1650
+ if (this.props.Templates.selectedEmailLayout && this.props.Templates.selectedEmailLayout !== '') {
1651
+ this.setNewLanguageContent(this.props.Templates.selectedEmailLayout);
1652
+ }
1653
+ });
1654
+ }
1655
+ let addLanguageLength = 1;
1656
+ if (asyncLanguages) {
1657
+ addLanguageLength = asyncLanguages.length;
1658
+ }
1659
+ let data = tempLang;
1660
+ let tabKey = '';
1661
+ let langTab = 0;
1662
+ const schema = _.cloneDeep(this.state.schema);
1663
+ const formData = _.cloneDeep(passedData);
1664
+ if (!_.isEmpty(schema)) {
1665
+ for (let idx = 0; idx < addLanguageLength; idx += 1) {
1666
+ let newActiveTab = this.state.settingLanguage ? this.state.settingLanguage.iso_code : 'en';
1667
+ if (asyncLanguages) {
1668
+ newActiveTab = asyncLanguages[idx].iso_code;
1669
+ data = asyncLanguages[idx];
1670
+ }
1671
+ langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(newActiveTab);
1672
+ if (langTab === -1) {
1673
+ formData[`${this.state.currentTab - 1}`].selectedLanguages.push(newActiveTab);
1674
+ langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(newActiveTab);
1675
+ }
1676
+ const selectedLanguage = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(data.iso_code);
1677
+ tabKey = formData[`${this.state.currentTab - 1}`][data.iso_code].tabKey;
1678
+ const tabIndex = (selectedLanguage) + 1;
1679
+ const containers = schema.containers.slice();
1680
+ const tabContent = _.cloneDeep(containers[0].tabContent.sections[0]);
1681
+ const tabContentSection = tabContent.inputFields[0].cols[0];
1682
+ const panes = containers[`${this.state.currentTab - 1}`].panes.slice();
1683
+ const firstPane = _.cloneDeep(panes[0]);
1684
+ const sections = [];
1685
+ _.forEach(firstPane.sections, (section) => {
1686
+ let sect = _.cloneDeep(section);
1687
+ if (sect.type === 'col-label') {
1688
+ sect = this.cloneColLabel(sect, tabIndex);
1689
+ } else if (sect.type === 'multicols') {
1690
+ sect = this.cloneMultiCol(sect, tabIndex);
1691
+ } else if (sect.type === 'parent') {
1692
+ sect = this.cloneParent(sect, tabIndex);
1693
+ }
1694
+ sections.push(sect);
1695
+ return true;
1696
+ });
1697
+ tabContentSection.id = `${tabContentSection.id}${tabIndex}`;
1698
+ tabContentSection.value = `${data.language}`;
1699
+ _.forEach(sections[0].inputFields[0].cols, (inputField) => {
1700
+ if (this.map[inputField.id] === undefined) {
1701
+ if (inputField.id.indexOf('template-content') > -1) {
1702
+ this.map[inputField.id] = this.map['template-content'];
1703
+ } else if (inputField.id.indexOf('edmeditor2') > -1) {
1704
+ this.map[inputField.id] = this.map.edmeditor2;
1705
+ }
1706
+ }
1707
+ });
1708
+ firstPane.sections = sections;
1709
+ firstPane.sectionsHeaders = [tabContent];
1710
+ // panes.push(firstPane);
1711
+ schema.containers[`${this.state.currentTab - 1}`].panes.push(firstPane);
1712
+ // schema.containers[0].tabContent.sections.push(tabContent);
1713
+ }
1714
+ //this.props.templatesActions.getEdmDefaultTemplates();
1715
+ const container = schema.containers[this.state.currentTab - 1];
1716
+ const temp = container;
1717
+ if (this.state.addLanguageType === "upload") {
1718
+ temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
1719
+ temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
1720
+ temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[3].cols[0].style = {display: "none"};
1721
+ }
1722
+ temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
1723
+ if (schema) {
1724
+ this.setState({schema, isSchemaChanged: true, tabKey});
1725
+ if (this.state.addLanguageType !== "upload") {
1726
+ this.setState({addLanguageType: ''});
1727
+ }
1728
+ //this.toggleEdmEmailTemplateSelection();
1729
+ }
1730
+ }
1731
+ }
1732
+
1733
+ openPreviewMode = (selectedAsset) => {
1734
+ const asset = selectedAsset;
1735
+ asset.showButtons = asset.showButtons ? !asset.showButtons : true;
1736
+ this.setState({selectedAsset: asset});
1737
+ }
1738
+
1739
+ cloneParent = (section, tabIndex, noSuffix) => {
1740
+ const parentsect = section;
1741
+ const childSectionsBeforeCloning = parentsect.childSections.slice();
1742
+ const childSections = [];
1743
+ _.forEach(childSectionsBeforeCloning, (childSection) => {
1744
+ let sect = {};
1745
+ if (childSection.type === 'col-label') {
1746
+ sect = this.cloneColLabel(childSection, tabIndex, noSuffix);
1747
+ } else if (childSection.type === 'multicols') {
1748
+ sect = this.cloneMultiCol(childSection, tabIndex, noSuffix);
1749
+ } else if (childSection.type === 'parent') {
1750
+ sect = this.cloneParent(childSection, tabIndex, noSuffix);
1751
+ }
1752
+
1753
+ childSections.push(sect);
1754
+ return true;
1755
+ });
1756
+
1757
+ parentsect.childSections = childSections;
1758
+
1759
+ return _.cloneDeep(parentsect);
1760
+ }
1761
+
1762
+ cloneColLabel = (sectionObj, tabIndex, noSuffix) => {
1763
+ const section = _.cloneDeep(sectionObj);
1764
+ const inputFields = _.forEach(section.inputFields, (inputField) => {
1765
+ const inputF = inputField;
1766
+ inputF.id = noSuffix ? `${inputField.id}` : `${inputField.id}${tabIndex}`;
1767
+ inputF.paneIndex = tabIndex;
1768
+ return inputF;
1769
+ });
1770
+ section.inputFields = inputFields;
1771
+
1772
+ return section;
1773
+ }
1774
+
1775
+ cloneMultiCol = (sectionObj, tabIndex, noSuffix) => {
1776
+ const section = _.cloneDeep(sectionObj);
1777
+ const inputFields = _.forEach(section.inputFields, (inputField) => {
1778
+ const inputF = inputField;
1779
+ const cols = _.forEach(inputF.cols, (col) => {
1780
+ const colTemp = col;
1781
+ colTemp.id = noSuffix ? `${col.id}` : `${col.id}${tabIndex}`;
1782
+ colTemp.paneIndex = tabIndex;
1783
+ return colTemp;
1784
+ });
1785
+ inputF.cols = cols;
1786
+ return inputF;
1787
+ });
1788
+ section.inputFields = inputFields;
1789
+
1790
+ return section;
1791
+ }
1792
+
1793
+ injectMessages = (elem) => {
1794
+ const temp = elem;
1795
+ if (temp.value && messages[temp.value]) {
1796
+ temp.value = this.props.intl.formatMessage(messages[temp.value]);
1797
+ }
1798
+ if (temp.label && messages[temp.label]) {
1799
+ temp.label = this.props.intl.formatMessage(messages[temp.label]);
1800
+ }
1801
+ if (temp.errorMessage && messages[temp.errorMessage]) {
1802
+ temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
1803
+ }
1804
+ if (temp.placeholder && messages[temp.placeholder]) {
1805
+ temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
1806
+ }
1807
+ return temp;
1808
+ }
1809
+
1810
+ showNext = () => {
1811
+ const response = {
1812
+ action: "showNext",
1813
+ value: true,
1814
+ };
1815
+ parent.postMessage(JSON.stringify(response), '*');
1816
+ }
1817
+
1818
+ moveToTemplates = () => {
1819
+ const modalContent = {
1820
+ title: "Alert",
1821
+ body: "Do you really want to go back? All your temporary changes will be lost!",
1822
+ type: 'confirm',
1823
+ id: 'template-back-confirm-modal',
1824
+ show: true,
1825
+ };
1826
+ this.setState({modalContent, showModal: true});
1827
+ }
1828
+
1829
+ cancelTemplate = () => {
1830
+ const type = this.props.location.query.type;
1831
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
1832
+ const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
1833
+ const isEdmSupport = this.props.location.query.isEdmSupport !== false || false;
1834
+ this.props.router.push({
1835
+ pathname: `/email/`,
1836
+ query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport},
1837
+ });
1838
+ }
1839
+
1840
+ selectAsset = (asset) => {
1841
+ this.state.editorInstanse.insertHtml(`<img src='${asset}' alt='Capillary Image'>`);
1842
+ }
1843
+
1844
+ prepareImageData() {
1845
+ const data = [];
1846
+ const assetList = this.props.Email.assetList;
1847
+ _.forEach(assetList, (asset) => {
1848
+ const tmpData = {};
1849
+ tmpData.id = asset._id;
1850
+ const updateDateTime = (moment().format('DD-MM-YYYY') === moment(asset.updatedAt).format('DD-MM-YYYY')) ? moment(asset.updatedAt).format('hh:mma') : moment(asset.updatedAt).format('DD-MM-YYYY');
1851
+ tmpData.content = (
1852
+ <div className="image-container">
1853
+ <img style={{width: '100%'}} src={asset.metaInfo.secure_file_path ? asset.metaInfo.secure_file_path : asset.metaInfo.public_url} alt={asset.name} />
1854
+ <div className={asset.showButtons ? 'overlay show-overlay' : 'overlay hide'}>
1855
+ <div>
1856
+ <CapButton type="secondary" className="select-button" onClick={(e) => this.selectAsset(e)}>
1857
+ <FormattedMessage {...messages.select} />
1858
+ </CapButton>
1859
+ </div>
1860
+ <div>
1861
+ {/* <CapButton type="cancel" className="preview-button" onClick={() => this.openEmbeddedPreviewMode(asset)}>
1862
+ <FormattedMessage {...messages.preview} />
1863
+ </CapButton> */}
1864
+ </div>
1865
+ </div>
1866
+ </div>
1867
+ );
1868
+ tmpData.footer = (
1869
+ <div className="card-footer-wrapper">
1870
+ <div className="card-title-container">
1871
+ <div className="card-title-wrapper">
1872
+ <p className="card-title" onClick={() => this.openPreviewMode(asset)}>{asset.name}</p>
1873
+ </div>
1874
+ <div className="more-icon-wrapper">
1875
+ <Popover
1876
+ placement="leftTop"
1877
+ content={<div style={{ cursor: 'pointer'}}><p onClick={() => this.deleteAsset(asset)}>
1878
+ <FormattedMessage {...messages.delete} />
1879
+ </p></div>} trigger="click">
1880
+ <i className="material-icons creative-icons">more_vert</i>
1881
+ </Popover>
1882
+ </div>
1883
+ </div>
1884
+ <p className="card-detail"><FormattedMessage {...messages.uploadedAt} />: {updateDateTime}</p>
1885
+ </div>
1886
+ );
1887
+ data.push(tmpData);
1888
+ });
1889
+ return data;
1890
+ }
1891
+
1892
+ injectEvents = (schema) => {
1893
+ const type = this.props.location.query.type;
1894
+
1895
+ let temp = _.cloneDeep(schema);
1896
+ temp.standalone.sections = this.injectSections(temp.standalone.sections);
1897
+ _.forEach(temp.containers, (container) => {
1898
+ let tempContainer = container;
1899
+ tempContainer = this.injectContainer(tempContainer);
1900
+ return tempContainer;
1901
+ });
1902
+
1903
+ // if (type !== "embedded" || (type === "embedded" && (this.props.location.query.isLanguageSupport === "false" || (this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === "true")))) {
1904
+ const ifLangSupported = this.props.location.query.isLanguageSupport === "true" || type !== "embedded";
1905
+ _.forEach(temp.containers, (container) => {
1906
+ if (container.isActive) {
1907
+ let hideLang = false;
1908
+ _.forEach(container.tabContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
1909
+ const tempEl = containerInputFieldCol;
1910
+ if (containerInputFieldCol.id === "tab-header") {
1911
+ const baseLanguage = this.props.currentOrgDetails && this.props.currentOrgDetails.basic_details && this.props.currentOrgDetails.basic_details.base_language && this.props.currentOrgDetails.basic_details.base_language !== "" ? this.props.currentOrgDetails.basic_details.base_language : 'en';
1912
+ const supportedLanguages = this.getSupportedLanguages(this.props);
1913
+ if (!supportedLanguages) {
1914
+ tempEl.value = 'English';
1915
+ return;
1916
+ }
1917
+ const langObject = supportedLanguages.find( (lang) => lang.iso_code === baseLanguage);
1918
+ if (langObject) {
1919
+ tempEl.value = langObject.language;
1920
+ } else {
1921
+ tempEl.value = 'English';
1922
+ }
1923
+ }
1924
+ });
1925
+ _.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
1926
+ if (hideLang && !ifLangSupported) {
1927
+ const newContainerInputFieldCol = containerInputFieldCol;
1928
+ hideLang = false;
1929
+ newContainerInputFieldCol.offset = 16;
1930
+ } else if (hideLang) {
1931
+ const newContainerInputFieldCol = containerInputFieldCol;
1932
+ hideLang = false;
1933
+ newContainerInputFieldCol.offset = 13;
1934
+ }
1935
+ if (containerInputFieldCol.id === 'add-language-button' && !ifLangSupported) {
1936
+ const newContainerInputFieldCol = containerInputFieldCol;
1937
+ if (newContainerInputFieldCol.colStyle.display !== "none") {
1938
+ newContainerInputFieldCol.colStyle.display = "none";
1939
+ }
1940
+ hideLang = true;
1941
+ } else if (containerInputFieldCol.id === 'add-language-button') {
1942
+ hideLang = true;
1943
+ }
1944
+ if (containerInputFieldCol.id === "mark-final-version-label") {
1945
+ const newContainerInputFieldCol = containerInputFieldCol;
1946
+ if (newContainerInputFieldCol.colStyle.display !== "none") {
1947
+ newContainerInputFieldCol.colStyle.display = "none";
1948
+ }
1949
+ }
1950
+ // if (containerInputFieldCol.id === "tab-options-popover") {
1951
+ // const newContainerInputFieldCol = containerInputFieldCol;
1952
+ // newContainerInputFieldCol.colStyle.display = "none";
1953
+ // }
1954
+ });
1955
+ }
1956
+ });
1957
+ _.forEach(temp.standalone.sections[1].inputFields[0].cols, (inputField) => {
1958
+ if (inputField.id === "template-version") {
1959
+ const iF = inputField;
1960
+ iF.colStyle = {};
1961
+ iF.colStyle.display = "none";
1962
+ }
1963
+ });
1964
+ //}
1965
+ temp = type === 'embedded' ? this.removeStandAlone(temp) : temp;
1966
+ this.setState({schema: temp, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1}, () => {
1967
+ if (type === 'embedded' && (this.props.route.name === 'EmailView' || (this.props.location.query.module && (this.props.location.query.module.toLowerCase() === 'loyalty' || this.props.location.query.module.toLowerCase() === 'dvs' || this.props.location.query.module.toLowerCase() === 'coupon_expiry' || this.props.location.query.module.toLowerCase() === 'timeline')))) {
1968
+ if ((this.props.route.name === "EmailEdit" || this.props.route.name === "EmailCreate") && (this.props.location.query.module === "dvs" || this.props.location.query.module.toLowerCase() === 'coupon_expiry')) {
1969
+ return;
1970
+ }
1971
+ const response = {
1972
+ action: 'startTemplateCreation',
1973
+ };
1974
+ parent.postMessage(JSON.stringify(response), '*');
1975
+ }
1976
+ });
1977
+ return temp;
1978
+ }
1979
+
1980
+ handleOnTagsContextChange = (data) => {
1981
+ const query = {
1982
+ layout: 'EMAIL',
1983
+ type: 'TAG',
1984
+ context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
1985
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
1986
+ };
1987
+ this.props.globalActions.fetchSchemaForEntity(query);
1988
+ }
1989
+
1990
+ removeStandAlone(schema) {
1991
+ const newSchema = _.cloneDeep(schema);
1992
+ delete newSchema.standalone;
1993
+ newSchema.standalone = {};
1994
+ newSchema.standalone.sections = [];
1995
+ if (this.props.location.query.type === 'embedded' && (this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs" || this.props.location.query.module === "coupon_expiry" || this.props.location.query.module === "timeline" ||
1996
+ this.props.location.query.module === "library")) {
1997
+ newSchema.standalone.sections.push(_.cloneDeep(schema.standalone.sections[0]));
1998
+ }
1999
+
2000
+ _.forEach(newSchema.containers, (container) => {
2001
+ const temp = container;
2002
+ if (temp.type === 'tabs') {
2003
+ // temp.tabBarExtraContent = {};
2004
+ // temp.tabBarExtraContent.sections = [];
2005
+ const basePane = _.cloneDeep(temp.panes[0]);
2006
+ _.forEach(temp.tabContent.sections, (section) => {
2007
+ _.forEach(section.inputFields, (inputField) => {
2008
+ if (section.type === 'multicols') {
2009
+ _.forEach(inputField.cols, (col, key) => {
2010
+ if (col.id === 'tab-options-popover') {
2011
+ inputField.cols.splice(key, 1);
2012
+ } else if (col.id === 'tab-header') {
2013
+ const tempCol = col;
2014
+ tempCol.style = {padding: '8px 0'};
2015
+ }
2016
+ });
2017
+ }
2018
+ });
2019
+ });
2020
+ _.forEach(temp.tabBarExtraContent.sections, (section) => {
2021
+ _.forEach(section.inputFields, (inputFields) => {
2022
+ if (section.type === "multicols") {
2023
+ _.forEach(inputFields.cols, (col) => {
2024
+ if ((col.id === "tab-options-popover" || col.id === "add-language-button") && this.props.location.query.type === 'embedded' && (this.props.location.query.module === "library")) {
2025
+ const colStyle = col.colStyle;
2026
+ colStyle.display = "none";
2027
+ }
2028
+ });
2029
+ }
2030
+ });
2031
+ });
2032
+ temp.panes = [];
2033
+ temp.panes.push(basePane);
2034
+ }
2035
+ });
2036
+ return newSchema;
2037
+ }
2038
+
2039
+ startTemplateCreation(data) {
2040
+ if (_.isEmpty(data)) {
2041
+ return;
2042
+ }
2043
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
2044
+
2045
+ //const data = {"base":{"subject":"deded","html_content":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> \t<title>Scheduled Report</title> \t<meta http-equiv=\"Content-Type\" content=\"text/html charset=UTF-8\"/> \t<style type=\"text/css\">.container-main p{line-height: 1.6;}@media screen and (max-width: 480px){a.brand{font-size: 35px;}}@media screen and (max-width: 480px){.container-main a{text-align: center;}a.brand{text-align: center;}}a.brand img{vertical-align: middle; padding: 0 8px 0 0; width: 250px;}@media screen and (max-width: 480px){a.brand img{width: 220px !important;}}@media screen and (max-width: 480px){.container-content{padding: 15px 20px; font-size: 12px !important;} .email-footer{font-size: 12px !important;}}.container-content table{border-collapse: collapse;}.container-content table tr td p{margin: 5px;}.container-content table tr td p span{font-weight: bold; padding: 0 3px 0 0;}@media screen and (max-width: 480px){a.btn-view-reports{margin: 25px auto 10px;}}a.btn-view-reports:hover{background: grey; color: #fff;}.email-footer p{text-align: center; font-size: 12px; color: grey;}.email-footer p a{color: blue; cursor: pointer;}.email-footer p a:hover{color: grey;} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table class=\"container-main\" style=\"background:#eeeeee; color:#000000; font-family:'Open Sans',sans-serif; font-size:16px; font-weight:400; margin:0 auto; max-width:978px; padding:15px; width:100%\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table class=\"email-header\" style=\"background:#ffffff; margin:0 0 5px; padding:17px 0; width:100%\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td style=\"width:100%\"><a class=\"brand\" href=\"#\" style=\"display: table; margin: 0 auto; text-decoration: none; font-size: 37px; color: grey;\"><img alt=\"Capillary Technologies\" src=\"https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/60221e2020ba572f6787.png\" /> </a></td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<div class=\"container-content\" style=\"background:#ffffff; padding:20px 35px\"> \t\t\t<p>Hi Ashish Karan,</p> \t\t\t<p>You&#39;ve received a new scheduled report. {{unsubscribe}}</p> \t\t\t<table> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Org Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>autotest1</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Scheduled Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>Schedule Test</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Time Period: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>1st Jan, 2017 to 24th Sep, 2017</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Report Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>redDart Report</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<p style=\"font-size:15px; margin-top:25px\">By clicking &quot;View Report&quot; you will be redirected to Capillary Analytics to view the automated report.</p> \t\t\t<a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91?snapshot=59c8bce750f4e75ec8b0d24c\" style=\"background: #009e0f; text-align: center; color: #fff; font-size: 16px; padding: 10px 25px; cursor: pointer; text-decoration: none; display: block; width: 120px; margin: 25px auto 15px;\" target=\"_blank\">View Report</a></div> \t\t\t<div class=\"email-footer\"> \t\t\t<p style=\"color:grey; font-size:12px; text-align:center\">You&#39;ve received this mail because you subscribed to Schedule Test schedule of redDart Report. <a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91/schedule/59c8bce750f4e75ec8b0d24c/unsubscribeSchedule\" style=\"color: blue; cursor: pointer;\" target=\"_blank\">Unsubscribe</a></p> \t\t\t<p><a href=\"http://capillarytech.com/privacy-policy/\" target=\"_blank\">Privacy Policy</a> | <a href=\"http://capillarytech.com/about-us/\" target=\"_blank\">About Capillary</a></p> \t\t\t</div> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","is_drag_drop":false,"drag_drop_id":null},"secondary_templates":[{"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":false,"drag_drop_id":null,"scope":null,"tag":null,"is_default":null,"html_content":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> \t<title>Scheduled Report</title> \t<meta http-equiv=\"Content-Type\" content=\"text/html charset=UTF-8\"/> \t<style type=\"text/css\">.container-main p{line-height: 1.6;}@media screen and (max-width: 480px){a.brand{font-size: 35px;}}@media screen and (max-width: 480px){.container-main a{text-align: center;}a.brand{text-align: center;}}a.brand img{vertical-align: middle; padding: 0 8px 0 0; width: 250px;}@media screen and (max-width: 480px){a.brand img{width: 220px !important;}}@media screen and (max-width: 480px){.container-content{padding: 15px 20px; font-size: 12px !important;} .email-footer{font-size: 12px !important;}}.container-content table{border-collapse: collapse;}.container-content table tr td p{margin: 5px;}.container-content table tr td p span{font-weight: bold; padding: 0 3px 0 0;}@media screen and (max-width: 480px){a.btn-view-reports{margin: 25px auto 10px;}}a.btn-view-reports:hover{background: grey; color: #fff;}.email-footer p{text-align: center; font-size: 12px; color: grey;}.email-footer p a{color: blue; cursor: pointer;}.email-footer p a:hover{color: grey;} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table class=\"container-main\" style=\"background:#eeeeee; color:#000000; font-family:'Open Sans',sans-serif; font-size:16px; font-weight:400; margin:0 auto; max-width:978px; padding:15px; width:100%\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table class=\"email-header\" style=\"background:#ffffff; margin:0 0 5px; padding:17px 0; width:100%\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td style=\"width:100%\"><a class=\"brand\" href=\"#\" style=\"display: table; margin: 0 auto; text-decoration: none; font-size: 37px; color: grey;\"><img alt=\"Capillary Technologies\" src=\"https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/60221e2020ba572f6787.png\" /> </a></td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<div class=\"container-content\" style=\"background:#ffffff; padding:20px 35px\"> \t\t\t<p>Hi Ashish Karan,</p> \t\t\t<p>You&#39;ve received a new scheduled report. {{unsubscribe}}</p> \t\t\t<table> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Org Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>autotest1</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Scheduled Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>Schedule Test</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Time Period: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>1st Jan, 2017 to 24th Sep, 2017</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Report Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>redDart Report</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<p style=\"font-size:15px; margin-top:25px\">By clicking &quot;View Report&quot; you will be redirected to Capillary Analytics to view the automated report.</p> \t\t\t<a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91?snapshot=59c8bce750f4e75ec8b0d24c\" style=\"background: #009e0f; text-align: center; color: #fff; font-size: 16px; padding: 10px 25px; cursor: pointer; text-decoration: none; display: block; width: 120px; margin: 25px auto 15px;\" target=\"_blank\">View Report</a></div> \t\t\t<div class=\"email-footer\"> \t\t\t<p style=\"color:grey; font-size:12px; text-align:center\">You&#39;ve received this mail because you subscribed to Schedule Test schedule of redDart Report. <a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91/schedule/59c8bce750f4e75ec8b0d24c/unsubscribeSchedule\" style=\"color: blue; cursor: pointer;\" target=\"_blank\">Unsubscribe</a></p> \t\t\t<p><a href=\"http://capillarytech.com/privacy-policy/\" target=\"_blank\">Privacy Policy</a> | <a href=\"http://capillarytech.com/about-us/\" target=\"_blank\">About Capillary</a></p> \t\t\t</div> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","secondary_template_id":"9500","is_base_template":1,"language_name":"English","language":"English","lang_id":"69"}],"edit":true,"tags":[]};
2046
+ // const data = {edit: true, "base":{"subject":"testsubject","html_content":"<html> <head> \t<meta charset=\"utf-8\" /> \t<title>Aster Secure</title> \t<style type=\"text/css\">#outlook a { padding: 0; } body { width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0;} .ExternalClass { width: 100%; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } #backgroundTable { margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; border: none; -ms-interpolation-mode: bicubic; } a img { border: none; } .image_fix { display: block; } p { margin: 0px 0px !important; } table td { border-collapse: collapse; } table { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; } table[class=full] { width: 100%; clear: both; } table[class=spacetable] { height: 176px; } table[class=spacetable1] { height: 431px; } table[class=spacetable2] { height: 50px; } table[class=spacetable3] { height: 55px; } \t @media only screen and (min-width: 320px) and (max-width: 540px) { a[href^=\"tel\"], a[href^=\"sms\"] { text-decoration: none; color: #ffffff; pointer-events: none; cursor: default; } .mobile_link a[href^=\"tel\"], .mobile_link a[href^=\"sms\"] { text-decoration: default; color: #ffffff !important; pointer-events: auto; cursor: default; } img[class=logo] { width: 132px!important; } img[class=shop] { width:53px!important; text-align: center!important; } table[class=innerlayer] { width: 300px !important; text-align: center; } img[class=spot] { width: 65px!important; } img[class=banner] { width: 290px !important; text-align: center; } img[class=banner1] { width: 229px!important; } img[class=click] { width:55px!important; } img[class=border] { width: 290px!important; } td[class=txtfont] { font-size:11px!important; height:50px!important; line-height: 15px!important; } \t span[class=txtfont] { font-size:9px!important; height:98px!important; line-height:23px!important; } \t td[class=txtfont1] { font-size:11px!important; height:40px!important; line-height: 14px!important; } img[class=left] { width:195px!important; } img[class=right] { width:46px!important; } \t \t td[class=txtfont3] { font-size:8px!important;} \ttd[class=txtfont2] { font-size:6px!important; line-height:9px!important; } td[class=txtbold] { font-size: 21px!important; } img[class=gap] { width:92px!important; } img[class=gap1] { width: 20px!important; } table[class=social] { width: 99% !important; } img[class=fb] { width:20px!important; } img[class=in] { width:21px!important; } img[class=tw] { width:20px!important; } img[class=pin] { width:41px!important; } \t img[class=and] { width:81px!important; } img[class=my] { width: 44px!important; } \t img[class=you] { width:21px!important; } img[class=store] { width:65px!important; } \t \t img[class=snap] { width:24px!important; } td[class=textlen] { height:52px!important; } \ttd[class=tdlen] \t{ \theight:35px!important;font-size: 10px !important; \t} \t\t\timg[class=a] { width: 42px!important; } \t\t\timg[class=b] { width: 22px!important; } \t\t\timg[class=c] { width: 72px!important; } \t\t\timg[class=d] { width: 50px!important; } \t\t\timg[class=e] { width: 56px!important; } \t\t\timg[class=f] { width: 56px!important; } \t\t\t} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table align=\"center\" bgcolor=\"#fff\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">Shop at Aster Pharmacy this month and You could be the next lucky winner!</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><a href=\"#\" style=\"pointer-events:none;\"><img class=\"banner\" src=\"https://s3-eu-west-1.amazonaws.com/fs.capillary.eu/intouch_creative_assets/890bdffee3b2322d8ec7.jpg\" style=\"border:none; display:block\" /></a></td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">To remove your email address from our mailing list , please click on {{unsubscribe}}</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","is_drag_drop":0,"drag_drop_id":null},"secondary_templates":[{"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":false,"drag_drop_id":null,"scope":null,"tag":null,"is_default":null,"html_content":"<html>\r\n<head>\r\n\t<meta charset=\"utf-8\" />\r\n\t<title>Aster Secure</title>\r\n\t<style type=\"text/css\">#outlook a { padding: 0; } body { width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0;} .ExternalClass { width: 100%; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } #backgroundTable { margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; border: none; -ms-interpolation-mode: bicubic; } a img { border: none; } .image_fix { display: block; } p { margin: 0px 0px !important; } table td { border-collapse: collapse; } table { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; } table[class=full] { width: 100%; clear: both; } table[class=spacetable] { height: 176px; } table[class=spacetable1] { height: 431px; } table[class=spacetable2] { height: 50px; } table[class=spacetable3] { height: 55px; } \t @media only screen and (min-width: 320px) and (max-width: 540px) { a[href^=\"tel\"], a[href^=\"sms\"] { text-decoration: none; color: #ffffff; pointer-events: none; cursor: default; } .mobile_link a[href^=\"tel\"], .mobile_link a[href^=\"sms\"] { text-decoration: default; color: #ffffff !important; pointer-events: auto; cursor: default; } img[class=logo] { width: 132px!important; } img[class=shop] { width:53px!important; text-align: center!important; } table[class=innerlayer] { width: 300px !important; text-align: center; } img[class=spot] { width: 65px!important; } img[class=banner] { width: 290px !important; text-align: center; } img[class=banner1] { width: 229px!important; } img[class=click] { width:55px!important; } img[class=border] { width: 290px!important; } td[class=txtfont] { font-size:11px!important; height:50px!important; line-height: 15px!important; } \t span[class=txtfont] { font-size:9px!important; height:98px!important; line-height:23px!important; } \t td[class=txtfont1] { font-size:11px!important; height:40px!important; line-height: 14px!important; } img[class=left] { width:195px!important; } img[class=right] { width:46px!important; } \t \t td[class=txtfont3] { font-size:8px!important;} \ttd[class=txtfont2] { font-size:6px!important; line-height:9px!important; } td[class=txtbold] { font-size: 21px!important; } img[class=gap] { width:92px!important; } img[class=gap1] { width: 20px!important; } table[class=social] { width: 99% !important; } img[class=fb] { width:20px!important; } img[class=in] { width:21px!important; } img[class=tw] { width:20px!important; } img[class=pin] { width:41px!important; } \t img[class=and] { width:81px!important; } img[class=my] { width: 44px!important; } \t img[class=you] { width:21px!important; } img[class=store] { width:65px!important; } \t \t img[class=snap] { width:24px!important; } td[class=textlen] { height:52px!important; } \ttd[class=tdlen] \t{ \theight:35px!important;font-size: 10px !important; \t} \t\t\timg[class=a] { width: 42px!important; } \t\t\timg[class=b] { width: 22px!important; } \t\t\timg[class=c] { width: 72px!important; } \t\t\timg[class=d] { width: 50px!important; } \t\t\timg[class=e] { width: 56px!important; } \t\t\timg[class=f] { width: 56px!important; } \t\t\t}\r\n\t</style>\r\n</head>\r\n<body>\r\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\">\r\n\t<tbody>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t<table align=\"center\" bgcolor=\"#fff\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"outerlayer\" style=\"width:650px\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">Shop at Aster Pharmacy this month and You could be the next lucky winner!</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td><a href=\"#\" style=\"pointer-events:none;\"><img class=\"banner\" src=\"https://s3-eu-west-1.amazonaws.com/fs.capillary.eu/intouch_creative_assets/890bdffee3b2322d8ec7.jpg\" style=\"border:none; display:block\" /></a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"txtfont2\" height=\"40\" style=\"font-family: Verdana, Geneva, sans-serif; text-align:center; font-size:11px; color:gray; line-height:13px;\" width=\"600\">To remove your email address from our mailing list , please click on {{unsubscribe}}</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</tbody>\r\n</table>\r\n</body>\r\n</html>\r\n","secondary_template_id":"9584","is_base_template":1,"language_name":"English","language":"English","lang_id":"69"}, {"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":false,"drag_drop_id":null,"scope":null,"tag":null,"is_default":null,"html_content":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> \t<title>Scheduled Report</title> \t<meta http-equiv=\"Content-Type\" content=\"text/html charset=UTF-8\"/> \t<style type=\"text/css\">.container-main p{line-height: 1.6;}@media screen and (max-width: 480px){a.brand{font-size: 35px;}}@media screen and (max-width: 480px){.container-main a{text-align: center;}a.brand{text-align: center;}}a.brand img{vertical-align: middle; padding: 0 8px 0 0; width: 250px;}@media screen and (max-width: 480px){a.brand img{width: 220px !important;}}@media screen and (max-width: 480px){.container-content{padding: 15px 20px; font-size: 12px !important;} .email-footer{font-size: 12px !important;}}.container-content table{border-collapse: collapse;}.container-content table tr td p{margin: 5px;}.container-content table tr td p span{font-weight: bold; padding: 0 3px 0 0;}@media screen and (max-width: 480px){a.btn-view-reports{margin: 25px auto 10px;}}a.btn-view-reports:hover{background: grey; color: #fff;}.email-footer p{text-align: center; font-size: 12px; color: grey;}.email-footer p a{color: blue; cursor: pointer;}.email-footer p a:hover{color: grey;} \t</style> </head> <body><center>\n\t\t\t\t\t\t\t\t\t\tIf you have difficulties viewing this mail, click\n\t\t\t\t\t\t\t\t\t\t<a href=\"https://nightly.capillary.in/business_controller/campaigns/emails/links/view.php?utrack={{user_id_b64}}&mtrack={{outbox_id_b64}}\" style = \"text-decoration: underline;color: #369;\" target=\"_blank\">here</a><br/>\n\t\t\t\t\t\t\t\t\t</center> <table class=\"container-main\" style=\"background:#eeeeee; color:#000000; font-family:'Open Sans',sans-serif; font-size:16px; font-weight:400; margin:0 auto; max-width:978px; padding:15px; width:100%\"> \t<tbody> \t\t<tr> \t\t\t<td> \t\t\t<table class=\"email-header\" style=\"background:#ffffff; margin:0 0 5px; padding:17px 0; width:100%\"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td style=\"width:100%\"><a class=\"brand\" href=\"#\" style=\"display: table; margin: 0 auto; text-decoration: none; font-size: 37px; color: grey;\"><img alt=\"Capillary Technologies\" src=\"https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/60221e2020ba572f6787.png\" /> </a></td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<div class=\"container-content\" style=\"background:#ffffff; padding:20px 35px\"> \t\t\t<p>Hi Ashish Karan,</p> \t\t\t<p>You&#39;ve received a new scheduled report. {{unsubscribe}}</p> \t\t\t<table> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Org Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>autotest1</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Scheduled Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>Schedule Test</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Time Period: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>1st Jan, 2017 to 24th Sep, 2017</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td><strong>Report Name: </strong></td> \t\t\t\t\t\t<td> \t\t\t\t\t\t<p>redDart Report</p> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> \t\t\t<p style=\"font-size:15px; margin-top:25px\">By clicking &quot;View Report&quot; you will be redirected to Capillary Analytics to view the automated report.</p> \t\t\t<a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91?snapshot=59c8bce750f4e75ec8b0d24c\" style=\"background: #009e0f; text-align: center; color: #fff; font-size: 16px; padding: 10px 25px; cursor: pointer; text-decoration: none; display: block; width: 120px; margin: 25px auto 15px;\" target=\"_blank\">View Report</a></div> \t\t\t<div class=\"email-footer\"> \t\t\t<p style=\"color:grey; font-size:12px; text-align:center\">You&#39;ve received this mail because you subscribed to Schedule Test schedule of redDart Report. <a href=\"https://nightly.capillary.in/analytics/v2/report/59c37820e626a10df78c8d91/schedule/59c8bce750f4e75ec8b0d24c/unsubscribeSchedule\" style=\"color: blue; cursor: pointer;\" target=\"_blank\">Unsubscribe</a></p> \t\t\t<p><a href=\"http://capillarytech.com/privacy-policy/\" target=\"_blank\">Privacy Policy</a> | <a href=\"http://capillarytech.com/about-us/\" target=\"_blank\">About Capillary</a></p> \t\t\t</div> \t\t\t</td> \t\t</tr> \t</tbody> </table> </body> </html> ","secondary_template_id":"9500","is_base_template":false,"language_name":"Hindi","language":"Hindi","lang_id":"151"},{"is_preview_generated":null,"preview_url":null,"is_favourite":null,"is_drag_drop":1,"drag_drop_id":"55acf47048a85bbf7681a35a","scope":null,"tag":null,"is_default":null,"html_content":"","secondary_template_id":"9500","is_base_template":0,"language_name":"Japanese","language":"Japanese","lang_id":"100"}]};
2047
+
2048
+ if (data && data.edit) {
2049
+ // const formData = {'0': {}};
2050
+ const formData = _.cloneDeep(this.state.formData);
2051
+ formData[0].selectedLanguages = [];
2052
+ let tabKey;
2053
+ if ((this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === 'false')) {
2054
+ formData['template-subject'] = data.base.subject ? data.base.subject : '';
2055
+ const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
2056
+ let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
2057
+
2058
+ if (languageIndex === -1) {
2059
+ languageIndex = 0;
2060
+ }
2061
+ const tempData = {
2062
+ "is_drag_drop": data.base.is_drag_drop,
2063
+ "lang_id": this.supportedLanguages[languageIndex].lang_id,
2064
+ "iso_code": this.supportedLanguages[languageIndex].iso_code,
2065
+ "language": this.supportedLanguages[languageIndex].language,
2066
+ "template-content": !data.base.is_drag_drop && data.base.is_drag_drop !== 1 ? data.base.html_content : "",
2067
+ };
2068
+ formData[0].base = true;
2069
+ formData[0].selectedLanguages.push(this.supportedLanguages[languageIndex].iso_code);
2070
+ formData[0][this.supportedLanguages[languageIndex].iso_code] = tempData;
2071
+ formData[0].activeTab = this.supportedLanguages[languageIndex].iso_code;
2072
+ tabKey = "2";
2073
+ } else {
2074
+ const additionalLanguages = [];
2075
+ _.forEach(data.secondary_templates, (templates) => {
2076
+ const id = "1";
2077
+ tabKey = id;
2078
+ let languageIndex = _.findIndex(this.supportedLanguages, {language: templates.language});
2079
+ if (languageIndex === -1) {
2080
+ languageIndex = 0;
2081
+ }
2082
+ const tempData = {
2083
+ "is_drag_drop": templates.is_drag_drop === "1" || false,
2084
+ "lang_id": this.supportedLanguages[languageIndex].lang_id,
2085
+ "iso_code": this.supportedLanguages[languageIndex].iso_code,
2086
+ "language": this.supportedLanguages[languageIndex].language,
2087
+ "template-content": templates.html_content,
2088
+ };
2089
+ if (templates.drag_drop_id) {
2090
+ tempData.drag_drop_id = templates.drag_drop_id;
2091
+ this.props.actions.getCmsSetting('edm', tempData.drag_drop_id, 'open', tempData.iso_code, isEdmSupport);
2092
+ }
2093
+ // formData.usingTabContainer = true;
2094
+ // formData.tabCount = 1;
2095
+
2096
+ // formData[0].tabkey = "1";
2097
+ // formData[0] = {};
2098
+ // formData[0].activeTab = this.props.currentOrgDetails.basic_details.base_language;
2099
+ formData[0].base = true;
2100
+ formData[0].selectedLanguages.push(this.supportedLanguages[languageIndex].iso_code);
2101
+ formData[0][this.supportedLanguages[languageIndex].iso_code] = tempData;
2102
+ if (templates.is_base_template === 1) {
2103
+ formData[0].activeTab = this.supportedLanguages[languageIndex].iso_code;
2104
+ // formData.base = tempData;
2105
+ } else {
2106
+ additionalLanguages.push(this.supportedLanguages[languageIndex]);
2107
+ }
2108
+ });
2109
+ this.addLanguage(false, formData, false, additionalLanguages);
2110
+ }
2111
+ formData.base = _.cloneDeep(formData[0]);
2112
+
2113
+ this.setState({formData, loading: false, injectedTags: data.tags, tabKey, isDragDrop: (data.base.is_drag_drop !== 0 )}, () => {
2114
+ // this.setState({tabKey: ''});
2115
+ _.forEach(formData[0].selectedLanguages, (language) => {
2116
+ if (formData[0][language].is_drag_drop) {
2117
+ this.props.actions.getCmsSetting('edm', formData[0][language].drag_drop_id, 'open', language, isEdmSupport);
2118
+ }
2119
+ });
2120
+ });
2121
+ } else {
2122
+ this.setState({injectedTags: data.tags});
2123
+ }
2124
+ this.props.globalActions.setInjectedTags(data.tags);
2125
+ }
2126
+
2127
+ startLoading = (ifEdit) => {
2128
+ if (ifEdit) {
2129
+ this.setState({loading: true});
2130
+ }
2131
+ }
2132
+
2133
+ injectContainer = (container) => {
2134
+ const temp = container;
2135
+ if (temp.type === 'tabs') {
2136
+ temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
2137
+ temp.tabBarExtraContent.sections = this.injectSections(temp.tabBarExtraContent.sections);
2138
+ temp.tabContent.sections = this.injectSections(temp.tabContent.sections);
2139
+ temp.injectedEvents = {};
2140
+ _.forEach(temp.supportedEvents, (event) => {
2141
+ temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
2142
+ });
2143
+ _.forEach(temp.panes, (pane) => {
2144
+ const tempPane = pane;
2145
+ tempPane.sections = this.injectSections(tempPane.sections);
2146
+ });
2147
+ }
2148
+ return temp;
2149
+ }
2150
+
2151
+ injectMultiColSection = (section) => {
2152
+ _.forEach(section.inputFields, (inputField) => {
2153
+ _.forEach(inputField.cols, (col) => {
2154
+ const temp = col;
2155
+ if (temp.type === 'popover') {
2156
+ temp.content.sections = this.injectSections(temp.content.sections);
2157
+ temp.value.sections = this.injectSections(temp.value.sections);
2158
+ return true;
2159
+ }
2160
+ temp.injectedEvents = {};
2161
+ _.forEach(col.supportedEvents, (event) => {
2162
+ //
2163
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
2164
+ });
2165
+ //
2166
+ if (temp.type === 'icon') {
2167
+ return true;
2168
+ }
2169
+ if (temp.value && messages[temp.value]) {
2170
+ temp.value = this.props.intl.formatMessage(messages[temp.value]);
2171
+ }
2172
+ if (temp.label && messages[temp.label]) {
2173
+ temp.label = this.props.intl.formatMessage(messages[temp.label]);
2174
+ }
2175
+ if (temp.errorMessage && messages[temp.errorMessage]) {
2176
+ temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
2177
+ }
2178
+ if (temp.placeholder && messages[temp.placeholder]) {
2179
+ temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
2180
+ }
2181
+ return true;
2182
+ });
2183
+ });
2184
+ _.forEach(section.actionFields, (actionField) => {
2185
+ _.forEach(actionField.cols, (col) => {
2186
+ const temp = col;
2187
+ if (temp.type === 'popover') {
2188
+ temp.content.sections = this.injectSections(temp.content.sections);
2189
+ temp.value.sections = this.injectSections(temp.value.sections);
2190
+ return true;
2191
+ }
2192
+ temp.injectedEvents = {};
2193
+ _.forEach(col.supportedEvents, (event) => {
2194
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
2195
+ });
2196
+ //
2197
+ if (temp.type === 'icon') {
2198
+ return true;
2199
+ }
2200
+ if (temp.value && messages[temp.value]) {
2201
+ temp.value = this.props.intl.formatMessage(messages[temp.value]);
2202
+ }
2203
+ if (temp.label && messages[temp.label]) {
2204
+ temp.label = this.props.intl.formatMessage(messages[temp.label]);
2205
+ }
2206
+ if (temp.errorMessage && messages[temp.errorMessage]) {
2207
+ temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
2208
+ }
2209
+ if (temp.placeholder && messages[temp.placeholder]) {
2210
+ temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
2211
+ }
2212
+ return true;
2213
+ });
2214
+ });
2215
+ return section;
2216
+ }
2217
+
2218
+ injectColLabelSection = (section) => {
2219
+ _.forEach(section.inputFields, (inputField) => {
2220
+ const temp = inputField;
2221
+ if (temp.type === 'popover') {
2222
+ temp.content.sections = this.injectSections(temp.content.sections);
2223
+ temp.value.sections = this.injectSections(temp.value.sections);
2224
+ return true;
2225
+ }
2226
+ temp.injectedEvents = {};
2227
+ _.forEach(inputField.supportedEvents, (event) => {
2228
+ temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
2229
+ });
2230
+ //
2231
+ if (temp.type === 'icon') {
2232
+ return true;
2233
+ }
2234
+ if (temp.value && messages[temp.value]) {
2235
+ temp.value = this.props.intl.formatMessage(messages[temp.value]);
2236
+ }
2237
+ if (temp.label && messages[temp.label]) {
2238
+ temp.label = this.props.intl.formatMessage(messages[temp.label]);
2239
+ }
2240
+ if (temp.errorMessage && messages[temp.errorMessage]) {
2241
+ temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
2242
+ }
2243
+ if (temp.placeholder && messages[temp.placeholder]) {
2244
+ temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
2245
+ }
2246
+ return true;
2247
+ });
2248
+ _.forEach(section.actionFields, (actionField) => {
2249
+ const temp = actionField;
2250
+ if (temp.type === 'popover') {
2251
+ temp.content.sections = this.injectSections(temp.content.sections);
2252
+ temp.value.sections = this.injectSections(temp.value.sections);
2253
+ return true;
2254
+ }
2255
+ temp.injectedEvents = {};
2256
+ _.forEach(actionField.supportedEvents, (event) => {
2257
+ temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
2258
+ });
2259
+ //
2260
+ if (temp.type === 'icon') {
2261
+ return true;
2262
+ }
2263
+ if (temp.value && messages[temp.value]) {
2264
+ temp.value = this.props.intl.formatMessage(messages[temp.value]);
2265
+ }
2266
+ if (temp.label && messages[temp.label]) {
2267
+ temp.label = this.props.intl.formatMessage(messages[temp.label]);
2268
+ }
2269
+ if (temp.errorMessage && messages[temp.errorMessage]) {
2270
+ temp.errorMessage = this.props.intl.formatMessage(messages[temp.errorMessage]);
2271
+ }
2272
+ if (temp.placeholder && messages[temp.placeholder]) {
2273
+ temp.placeholder = this.props.intl.formatMessage(messages[temp.placeholder]);
2274
+ }
2275
+ return true;
2276
+ });
2277
+ return section;
2278
+ }
2279
+
2280
+ injectSections = (sections) => {
2281
+ _.forEach(sections, (section) => {
2282
+ let temp = section;
2283
+ if (temp.type === 'col-label') {
2284
+ temp = this.injectColLabelSection(temp);
2285
+ } else if (section.type === 'multicols') {
2286
+ temp = this.injectMultiColSection(temp);
2287
+ } else if (section.type === 'parent') {
2288
+ temp = this.injectSections(temp.childSections);
2289
+ }
2290
+ });
2291
+ return sections;
2292
+ }
2293
+
2294
+ injectParentSection = (section) => {
2295
+ _.forEach(section.childSections, (childSection) => {
2296
+ let temp = childSection;
2297
+ if (temp.type === 'col-label') {
2298
+ temp = this.injectColLabelSection(temp);
2299
+ } else if (section.type === 'multicols') {
2300
+ temp = this.injectMultiColSection(temp);
2301
+ } else if (section.type === 'parent') {
2302
+ temp = this.injectParentSection(temp);
2303
+ }
2304
+ });
2305
+ return section;
2306
+ }
2307
+
2308
+ saveFormData = (passedData) => {
2309
+ //Logic to save in db etc
2310
+ // const isValidated = this.validateFormData(formData);
2311
+ //
2312
+ // if (!isValidated) {
2313
+ // return;
2314
+ // }
2315
+ //if (!this.state.startValidation) {
2316
+ // this.saveValidationData();
2317
+ // return;
2318
+ //}
2319
+
2320
+ if (this.state.gettingFormData && !this.props.isFullMode) {
2321
+ const response = {
2322
+ action: "getFormData",
2323
+ postAction: this.state.getFormDataValue || 'next',
2324
+ value: this.transformFormData(passedData),
2325
+ validity: this.state.isFormValid,
2326
+ type: 'EMAIL',
2327
+ };
2328
+
2329
+ this.setState({checkValidation: true});
2330
+ if (this.props.location.query.module === 'library' && this.props.isGetFormData) {
2331
+ this.props.getFormSubscriptionData(response);
2332
+ }
2333
+ parent.postMessage(JSON.stringify(response), "*");
2334
+ this.setState({gettingFormData: false, startValidation: false, loading: true});
2335
+ return;
2336
+ }
2337
+ const formData = _.cloneDeep(passedData);
2338
+
2339
+ const obj = {};
2340
+ obj.versions = {
2341
+ base: {},
2342
+ history: [],
2343
+ };
2344
+ if (this.state.isEdit) {
2345
+ obj._id = this.props.Email.templateDetails._id;
2346
+ }
2347
+ obj.type = 'EMAIL';
2348
+ const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
2349
+ let baseKey = -1;
2350
+ //let saveCount = 0;
2351
+
2352
+ _.forEach(formData, (data, index) => {
2353
+ const newdata = data;
2354
+
2355
+ if (!isNaN(index) && newdata) {
2356
+ const baseLangTabKey = newdata[baseLanguage].tabKey;
2357
+ newdata.tabKey = baseLangTabKey;
2358
+ newdata.activeTab = baseLanguage;
2359
+ if (newdata.base) {
2360
+ baseKey = baseLangTabKey;
2361
+ }
2362
+ _.forEach(newdata.selectedLanguages, (language) => {
2363
+ //
2364
+ // if (newdata[language].is_drag_drop && ((parseInt(index, 10) + 1) === this.state.currentTab)) {
2365
+ //
2366
+ // saveCount += 1;
2367
+ // }
2368
+ if (newdata[language].is_drag_drop) {
2369
+ delete newdata[language].edmeditorsrc;
2370
+ }
2371
+ });
2372
+ obj.versions.history.push(newdata);
2373
+ }
2374
+ });
2375
+ //const data = formData[`${this.state.currentTab - 1}`];
2376
+ obj.name = formData['template-name'];
2377
+ obj.versions.base = formData.base;
2378
+ obj.versions.base.tabKey = baseKey;
2379
+ obj.versions.base.subject = formData['template-subject'];
2380
+ obj.versions.base.activeTab = baseLanguage;
2381
+ _.forEach(obj.versions.base.selectedLanguages, (language) => {
2382
+ if (obj.versions.base[language].is_drag_drop) {
2383
+ delete obj.versions.base[language].edmeditorsrc;
2384
+ }
2385
+ });
2386
+
2387
+ // if (saveCount === 0) {
2388
+
2389
+ this.props.actions.createTemplate(obj, this.onUpdateTemplateComplete);
2390
+ // } else {
2391
+ // this.setState({saveObj: obj, targetSaveCount: saveCount, mode: "save", saveEdmDataMode: 'save'}, () => {
2392
+ // _.forEach(data.selectedLanguages, (language, langIndex) => {
2393
+ // if (data[language].is_drag_drop) {
2394
+ //
2395
+ // const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
2396
+ // win.postMessage("saveProject", '*');
2397
+ // }
2398
+ // });
2399
+ // });
2400
+ // }
2401
+ }
2402
+ handleOk = () => {
2403
+ const formData = _.cloneDeep(this.state.formData);
2404
+ const activeLangTab = formData[`${this.state.currentTab - 1}`].activeTab;
2405
+ const langIndex = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
2406
+
2407
+ this.setState({mode: "switchEditor"}, () => {
2408
+ const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
2409
+ win.postMessage("saveProject", '*');
2410
+ });
2411
+ }
2412
+
2413
+ handleCancel = () => {
2414
+ this.setState({ showConfirmationModal: false });
2415
+ }
2416
+
2417
+ handleCancelModal = () => {
2418
+ this.setState({showModal: false});
2419
+ }
2420
+
2421
+ openFileDialog() {
2422
+ document.getElementById("fileName").click();
2423
+ }
2424
+ getTemplateDataForGrid = ({templates, handlers, filterContent, isLoading, loadingTip}) => {
2425
+ const currentChannel = 'gallery';
2426
+ const cardDataList = templates.length ? _.map(templates, (template) => {
2427
+ const templateData =
2428
+ {
2429
+ key: `${currentChannel}-card-${template.name}`,
2430
+ title: <span title={template.name} >{template.name}</span>,
2431
+ };
2432
+ templateData.hoverOption = <CapButton onClick={(e) => handlers.onItemClick(e, template._id)}><FormattedMessage {...messages.select} /></CapButton>;
2433
+ const secureFilePath = _.get(template, 'metaInfo.secure_file_path');
2434
+ templateData.url = secureFilePath || _.get(template, 'metaInfo.public_url');
2435
+ return templateData;
2436
+ }) : [];
2437
+ return (<div>
2438
+ {filterContent}
2439
+ <CapSpin spinning={isLoading} tip={loadingTip}>
2440
+ {!_.isEmpty(templates) && <div className="pagination-container">
2441
+ <CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={'Email'} />
2442
+ </div>}
2443
+ </CapSpin>
2444
+
2445
+ </div>);
2446
+ }
2447
+ toggleEdmEmailTemplateSelection = () => {
2448
+ this.setState( (prevState) => ({
2449
+ showEdmEmailTemplates: !prevState.showEdmEmailTemplates}), () => {
2450
+ if (this.state.showEdmEmailTemplates) {
2451
+ this.props.templatesActions.getEdmDefaultTemplates();
2452
+ }
2453
+ });
2454
+ };
2455
+ handleEdmDefaultTemplateSelection = (isSelected, id) => {
2456
+ if (isSelected) {
2457
+ const data = _.find(this.props.Templates.cmsTemplates, {_id: id});
2458
+ // const type = this.props.location.query.type;
2459
+ // const module = this.props.location.query.module ? this.props.location.query.module : 'default';
2460
+ // const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : true;
2461
+ // const isEdmSupport = (this.props.location.query.isEdmSupport) ? this.props.location.query.isEdmSupport : true;
2462
+ // let getQuery = '';
2463
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
2464
+
2465
+ this.props.actions.getCmsSetting('edm', data.versions.base.drag_drop_id, 'create', this.state.formData[this.state.currentTab - 1].activeTab, isEdmSupport);
2466
+ // this.props.templatesActions.setEdmTemplate(data);
2467
+ this.toggleEdmEmailTemplateSelection();
2468
+ // if (type && type.toLowerCase() === 'email') {
2469
+ // getQuery = (type === 'embedded') ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport};
2470
+ // } else {
2471
+ // getQuery = (type === 'embedded') ? {type: 'embedded', module} : {module};
2472
+ // }
2473
+ // this.props.router.push({
2474
+ // pathname: `/${this.state.channel.toLowerCase()}/create`,
2475
+ // query: getQuery,
2476
+ // });
2477
+ }
2478
+ };
2479
+ isEmailLoading = () => {
2480
+ //let {isLoading} = this.props;
2481
+ let isLoading = this.props.isLoadingMetaEntities || this.state.loading || (this.props.Email && "createTemplateInProgress" in this.props.Email && this.props.Email.createTemplateInProgress) || (this.props.Email.assetUploading !== undefined && this.props.Email.assetUploading);
2482
+
2483
+ if (!isLoading) {
2484
+ isLoading = this.state.loadingStatus < 2;
2485
+ }
2486
+ // if (isLoading) {
2487
+ // this.props.creativesContainerActions.hideCreativesContanerLoader();
2488
+ // }
2489
+ if (!isLoading && this.props.setIsLoadingContent) {
2490
+ this.props.setIsLoadingContent(isLoading);
2491
+ }
2492
+ return isLoading;
2493
+ }
2494
+ renderConfirmationModal() {
2495
+ const modal = (
2496
+ <Modal
2497
+ visible={this.state.showConfirmationModal}
2498
+ title={this.props.intl.formatMessage(messages.switchEditor)}
2499
+ onOk={this.handleOk}
2500
+ onCancel={this.handleCancel}
2501
+ footer={[
2502
+ <CapButton key="back" onClick={this.handleCancel}>
2503
+ {this.props.intl.formatMessage(messages.cancel)}
2504
+ </CapButton>,
2505
+ <CapButton key="submit" type="primary" onClick={this.handleOk}>
2506
+ {this.props.intl.formatMessage(messages.yes)}
2507
+ </CapButton>,
2508
+ ]}
2509
+ >
2510
+ <p>{this.props.intl.formatMessage(messages.edmSwtichMessage)}</p>
2511
+ <p>{this.props.intl.formatMessage(messages.edmSwitchAcceptText)}</p>
2512
+ </Modal>);
2513
+ return modal;
2514
+ }
2515
+ getFilterContent = () => (
2516
+ <div className="action-container" style={{ display: 'inline-flex', width: '100%'}}>
2517
+ <div style={{ marginTop: '8px', width: '50%'}}>
2518
+ <CapInput
2519
+ className="search-text"
2520
+ style={{width: '210px'}}
2521
+ placeholder="Search"
2522
+ prefix={<i className="material-icons" style={{color: '#707070', fontSize: '16px'}}>search</i>}
2523
+ value={this.state.searchText}
2524
+ onChange={(e) => this.searchAsset(e.target.value)}
2525
+ />
2526
+ </div>
2527
+ <div>
2528
+ <form encType="multipart/form-data" id="myForm">
2529
+ <input style={{ display: 'none'}} id="fileName" type="file" onChange={(e) => this.uploadImages(e, {files: e.target.files})} accept="image/*" />
2530
+ <CapButton type={'secondary'} onClick={(e) => this.openFileDialog(e)} style={{float: 'right', marginRight: '24px'}}>
2531
+ <FormattedMessage {...messages.upload} />
2532
+ </CapButton>
2533
+ </form>
2534
+ </div>
2535
+ </div>
2536
+ );
2537
+ getImagePreviewContent = () => (
2538
+ <div key="creatives-email-add-image-container">
2539
+ <Pagination onPageChange={() => { this.fetchAllAssets({getNextPage: true}); }} paginationSelector="pagination-container">
2540
+ {/* <CardGrid
2541
+ listItem={this.prepareImageData()}
2542
+ filterContent={filterContent}
2543
+ onHoverItem={this.handleOnHoverItem}
2544
+ onItemClick={this.handleOnItemClick}
2545
+ colNumber={2}
2546
+ enablePagination
2547
+ isLoading={}
2548
+ /> */}
2549
+ {this.props.Email.assetList && this.props.Email.assetList.length && this.getTemplateDataForGrid({
2550
+ isLoading: this.props.Email.fetchingAllAssets,
2551
+ loadingTip: <FormattedMessage {...messages.loadingImages}/>,
2552
+ channel: this.state.channel,
2553
+ templates: this.props.Email.assetList,
2554
+ filterContent: this.getFilterContent(),
2555
+ handlers: {onItemClick: this.handleOnItemClick}})
2556
+ }
2557
+
2558
+ </Pagination>
2559
+ </div>
2560
+ );
2561
+
2562
+ render() {
2563
+ // const pageHeading = (this.state.isEdit) ? this.props.intl.formatMessage(messages.editHeading) : this.props.intl.formatMessage(messages.createHeading);
2564
+ // const actionComponents = '';
2565
+ const schema = this.state.schema;
2566
+ const isLoading = this.isEmailLoading();
2567
+ const previewHeader = (<h3>Email Preview</h3>);
2568
+ const imagePreviewHeader = (<h3>Image Selection</h3>);
2569
+ const imagePreviewContent = this.getImagePreviewContent();
2570
+ if (!this.props.currentOrgDetails || !this.props.currentOrgDetails.basic_details) {
2571
+ return (<div>Loading...</div>);
2572
+ }
2573
+
2574
+ let loaderText = this.props.Email.createTemplateInProgress ? this.props.intl.formatMessage(messages.saveTemplateLoader) : this.props.intl.formatMessage(messages.templateLoader);
2575
+ if (this.props.Email.assetUploading) {
2576
+ loaderText = this.props.intl.formatMessage(messages.uploadingImage);
2577
+ }
2578
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
2579
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
2580
+ tags = this.props.supportedTags;
2581
+ }
2582
+ return (
2583
+ <div className="email-container">
2584
+
2585
+ {/* <PageHeader pageHeading={pageHeading} /> */}
2586
+ <CapSpin tip={loaderText} spinning={isLoading}>
2587
+
2588
+ <Row>
2589
+ <Col>
2590
+ { !_.isEmpty(schema) && (this.state.formData[0] || this.state.formData["0"]) ?
2591
+ <FormBuilder
2592
+ isFullMode={this.props.isFullMode}
2593
+ schema={schema}
2594
+ onSubmit={this.saveFormData}
2595
+ onChange={this.onFormDataChange}
2596
+ currentTab={this.state.currentTab}
2597
+ parent={this}
2598
+ formData={_.cloneDeep(this.state.formData)}
2599
+ location={this.props.location}
2600
+ tabKey={this.state.tabKey}
2601
+ tags={tags}
2602
+ tagModule={this.props.getDefaultTags}
2603
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
2604
+ onFormValidityChange={this.setFormValidity}
2605
+ handleCancelModal={this.handleCancelModal}
2606
+ usingTabContainer
2607
+ checkValidation={this.state.checkValidation}
2608
+ onContextChange={this.handleOnTagsContextChange}
2609
+ tabCount={this.state.tabCount}
2610
+ isNewVersionFlow
2611
+ modal={this.state.modalContent}
2612
+ showModal={this.state.showModal}
2613
+ isEdit={this.state.isEdit}
2614
+ iframeParent={parent}
2615
+ router={this.props.router}
2616
+ baseLanguage={this.props.currentOrgDetails.basic_details.base_language}
2617
+ supportedLanguages={this.getSupportedLanguages(this.props)}
2618
+ isSchemaChanged={this.state.isSchemaChanged}
2619
+ cmsTemplates={this.props.Templates.cmsTemplates}
2620
+ getCmsTemplatesInProgress={this.props.Templates.getCmsTemplatesInProgress}
2621
+ showEdmEmailTemplates={this.state.showEdmEmailTemplates}
2622
+ toggleEdmEmailTemplateSelection={this.toggleEdmEmailTemplateSelection}
2623
+ handleEdmDefaultTemplateSelection={this.handleEdmDefaultTemplateSelection}
2624
+ setModalContent={this.setModalContent}
2625
+ addLanguageType={this.state.addLanguageType}
2626
+ startValidation={this.state.startValidation}
2627
+ getValidationData={this.saveValidationData}
2628
+ saveForm={this.state.saveForm}
2629
+ stopValidation={this.stopValidation}
2630
+ /> : ''}
2631
+ </Col>
2632
+ </Row>
2633
+ </CapSpin>
2634
+ {!_.isEmpty(this.state.formData[(this.state.currentTab - 1)]) && <EmailPreview
2635
+ header={previewHeader}
2636
+ content={this.state.formData[(this.state.currentTab - 1)][this.state.formData[(this.state.currentTab - 1)].activeTab] ? this.state.formData[(this.state.currentTab - 1)][this.state.formData[(this.state.currentTab - 1)].activeTab][`template-content`] : ''}
2637
+ show={this.state.showEmailPreview}
2638
+ device={this.state.device}
2639
+ handleClose={this.toggleEmailPreview}
2640
+ changePreviewDevice={this.changePreviewDevice}
2641
+ />}
2642
+ <CapSlideBox
2643
+ header={imagePreviewHeader}
2644
+ content={imagePreviewContent}
2645
+ show={this.state.showImageSelectionBox}
2646
+ handleClose={this.handleImagePreviewClose}
2647
+ isLoading={this.props.Email.fetchingAllAssets}
2648
+ size="size-l"
2649
+ />
2650
+ {this.state.showConfirmationModal && this.renderConfirmationModal()}
2651
+ </div>
2652
+ );
2653
+ }
2654
+ }
2655
+
2656
+ Email.propTypes = {
2657
+ actions: PropTypes.object.isRequired,
2658
+ Email: PropTypes.object,
2659
+ params: PropTypes.object,
2660
+ router: PropTypes.object,
2661
+ Templates: PropTypes.object,
2662
+ globalActions: PropTypes.object,
2663
+ location: PropTypes.object,
2664
+ intl: intlShape.isRequired,
2665
+ metaEntities: PropTypes.object,
2666
+ templatesActions: PropTypes.object,
2667
+ route: PropTypes.object,
2668
+ templateData: PropTypes.object,
2669
+ isGetFormData: PropTypes.bool,
2670
+ getFormSubscriptionData: PropTypes.func,
2671
+ supportedTags: PropTypes.array,
2672
+ getDefaultTags: PropTypes.string,
2673
+ currentOrgDetails: PropTypes.object,
2674
+ isLoadingMetaEntities: PropTypes.bool,
2675
+ // creativesContainerActions: PropTypes.object,
2676
+ isFullMode: PropTypes.bool,
2677
+ setIsLoadingContent: PropTypes.func,
2678
+ injectedTags: PropTypes.object,
2679
+ defaultData: PropTypes.object,
2680
+ showTemplateName: PropTypes.func,
2681
+ };
2682
+
2683
+ const mapStateToProps = (state, props) => createStructuredSelector({
2684
+ Email: makeSelectEmail(),
2685
+ Templates: makeSelectTemplates(),
2686
+ metaEntities: makeSelectMetaEntities(),
2687
+ currentOrgDetails: props.cap ? () => props.cap.currentOrgDetails : selectCurrentOrgDetails(),
2688
+ isLoadingMetaEntities: isLoadingMetaEntities(),
2689
+ Global: makeSelectAuthenticated(),
2690
+ injectedTags: setInjectedTags(),
2691
+ });
2692
+
2693
+ function mapDispatchToProps(dispatch) {
2694
+ return {
2695
+ actions: bindActionCreators(actions, dispatch),
2696
+ globalActions: bindActionCreators(globalActions, dispatch),
2697
+ templatesActions: bindActionCreators(templatesActions, dispatch),
2698
+ creativesContainerActions: bindActionCreators(creativesContainerActions, dispatch),
2699
+ };
2700
+ }
2701
+
2702
+ export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(Email)));
2703
+