wco_email 0.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/README.txt +129 -0
  3. data/Rakefile +5 -0
  4. data/app/assets/config/wco_email_manifest.js +7 -0
  5. data/app/assets/javascript/vendor-trash/jquery-ui.min.js +13 -0
  6. data/app/assets/javascript/vendor-trash/jquery.fileupload.js +1482 -0
  7. data/app/assets/javascript/vendor-trash/jquery.iframe-transport.js +224 -0
  8. data/app/assets/javascript/vendor-trash/jquery.ui.widget.js +572 -0
  9. data/app/assets/javascript/vendor-trash/summernote-bs4.min.js +3 -0
  10. data/app/assets/javascript/wco_email/application.js +11 -0
  11. data/app/assets/javascript/wco_email/contexts.js +19 -0
  12. data/app/assets/javascript/wco_email/conversations.js +177 -0
  13. data/app/assets/javascript/wco_email/file_upload.js-trash +32 -0
  14. data/app/assets/javascript/wco_email/shared.js +22 -0
  15. data/app/assets/stylesheets/wco_email/application.scss +29 -0
  16. data/app/assets/stylesheets/wco_email/contexts.scss +63 -0
  17. data/app/assets/stylesheets/wco_email/conversations.scss +16 -0
  18. data/app/assets/stylesheets/wco_email/tags.scss +6 -0
  19. data/app/controllers/wco_email/application_controller.rb +16 -0
  20. data/app/controllers/wco_email/contexts_controller.rb +156 -0
  21. data/app/controllers/wco_email/conversations_controller.rb +129 -0
  22. data/app/controllers/wco_email/email_action_templates_controller.rb +77 -0
  23. data/app/controllers/wco_email/email_actions_controller.rb +55 -0
  24. data/app/controllers/wco_email/email_campaigns_controller.rb +73 -0
  25. data/app/controllers/wco_email/email_filters_controller.rb +72 -0
  26. data/app/controllers/wco_email/email_layouts_controller.rb +13 -0
  27. data/app/controllers/wco_email/email_templates_controller.rb +124 -0
  28. data/app/controllers/wco_email/message_stubs_controller.rb +14 -0
  29. data/app/controllers/wco_email/messages_controller.rb +28 -0
  30. data/app/controllers/wco_email/obfuscated_redirects_controller.rb +20 -0
  31. data/app/controllers/wco_email/sessions_controller.rb +19 -0
  32. data/app/controllers/wco_email/unsubscribes_controller.rb +40 -0
  33. data/app/helpers/wco_email/application_helper.rb +20 -0
  34. data/app/jobs/wco_email/message_intake_job.rb +54 -0
  35. data/app/mailers/wco_email/application_mailer.rb +98 -0
  36. data/app/views/202212 Mailchimp Templates/202212 1col fixed-width.html +863 -0
  37. data/app/views/202212 Mailchimp Templates/202212 1col full-width.html +906 -0
  38. data/app/views/202212 Mailchimp Templates/202212 2col fixed-width 2.html +1003 -0
  39. data/app/views/202212 Mailchimp Templates/202212 2col fixed-width.html +1082 -0
  40. data/app/views/202212 Mailchimp Templates/202212 2col full-width 2.html +1053 -0
  41. data/app/views/202212 Mailchimp Templates/202212 2col full-width.html +1147 -0
  42. data/app/views/202212 Mailchimp Templates/202212 3col fixed-width.html +1087 -0
  43. data/app/views/202212 Mailchimp Templates/202212 3col full-width.html +1136 -0
  44. data/app/views/202212 Mailchimp Templates/202212 catalog various-colors-1.html +1223 -0
  45. data/app/views/202212 Mailchimp Templates/202212 educate.html +1080 -0
  46. data/app/views/202212 Mailchimp Templates/202212 follow up.html +1001 -0
  47. data/app/views/202212 Mailchimp Templates/202212 make an announcement.html +1048 -0
  48. data/app/views/202212 Mailchimp Templates/202212 sell-a-product.html +977 -0
  49. data/app/views/202212 Mailchimp Templates/202212 tell a story.html +1168 -0
  50. data/app/views/202212 Mailchimp Templates/202212 theme art-newsletter.html +1612 -0
  51. data/app/views/202212 Mailchimp Templates/202212 theme caribou-xmas.html +856 -0
  52. data/app/views/202212 Mailchimp Templates/202212 theme colorbox.html +1027 -0
  53. data/app/views/202212 Mailchimp Templates/202212 theme competition-invitation.html +918 -0
  54. data/app/views/202212 Mailchimp Templates/202212 theme event-veerle.html +1132 -0
  55. data/app/views/202212 Mailchimp Templates/202212 theme fall-colors.html +1407 -0
  56. data/app/views/202212 Mailchimp Templates/202212 theme gift-giving.html +787 -0
  57. data/app/views/202212 Mailchimp Templates/202212 theme giftgiving-snowmen.html +731 -0
  58. data/app/views/202212 Mailchimp Templates/202212 theme heart-of-flowers.html +795 -0
  59. data/app/views/202212 Mailchimp Templates/202212 theme hero-card.html +915 -0
  60. data/app/views/202212 Mailchimp Templates/202212 theme hero-image.html +1148 -0
  61. data/app/views/202212 Mailchimp Templates/202212 theme monthly-contest.html +967 -0
  62. data/app/views/202212 Mailchimp Templates/202212 theme multiple-event.html +1189 -0
  63. data/app/views/202212 Mailchimp Templates/202212 theme postcard.html +914 -0
  64. data/app/views/202212 Mailchimp Templates/202212 theme snowy-fields.html +733 -0
  65. data/app/views/202212 Mailchimp Templates/202212 theme soft.html +849 -0
  66. data/app/views/202212 Mailchimp Templates/202212 theme sophisticated.html +1079 -0
  67. data/app/views/202212 Mailchimp Templates/202212 theme subtle.html +1218 -0
  68. data/app/views/202212 Mailchimp Templates/202212 theme ticket.html +1015 -0
  69. data/app/views/202212 Mailchimp Templates/202212 theme whale.html +888 -0
  70. data/app/views/202310 Email Templates/_acknowledgement_of_document_receipt.html.erb +23 -0
  71. data/app/views/202310 Email Templates/_support_ticket_created.html.erb +26 -0
  72. data/app/views/layouts/wco_email/application.haml +64 -0
  73. data/app/views/layouts/wco_email/mailbox.haml-trash +62 -0
  74. data/app/views/wco_email/_analytics.erb +16 -0
  75. data/app/views/wco_email/_main_header.haml +31 -0
  76. data/app/views/wco_email/_sidebar.haml +10 -0
  77. data/app/views/wco_email/application_mailer/_footer_unsubscribe.html.erb +24 -0
  78. data/app/views/wco_email/application_mailer/_header_logo.html.erb +12 -0
  79. data/app/views/wco_email/application_mailer/forwarder_notify.html.erb +17 -0
  80. data/app/views/wco_email/contexts/_form.haml +59 -0
  81. data/app/views/wco_email/contexts/_form_reply.haml +27 -0
  82. data/app/views/wco_email/contexts/_header.haml +22 -0
  83. data/app/views/wco_email/contexts/_index.haml +8 -0
  84. data/app/views/wco_email/contexts/edit.haml +8 -0
  85. data/app/views/wco_email/contexts/iframe_src.haml +3 -0
  86. data/app/views/wco_email/contexts/index.haml +51 -0
  87. data/app/views/wco_email/contexts/new.haml +5 -0
  88. data/app/views/wco_email/contexts/show.haml +34 -0
  89. data/app/views/wco_email/contexts/summary.csv.erb +4 -0
  90. data/app/views/wco_email/contexts/summary.haml +16 -0
  91. data/app/views/wco_email/conversations/_actions.haml +21 -0
  92. data/app/views/wco_email/conversations/_search.haml +14 -0
  93. data/app/views/wco_email/conversations/index.haml +43 -0
  94. data/app/views/wco_email/conversations/show.haml +27 -0
  95. data/app/views/wco_email/email_action_templates/_form.haml +45 -0
  96. data/app/views/wco_email/email_action_templates/_header.haml +8 -0
  97. data/app/views/wco_email/email_action_templates/edit.haml +7 -0
  98. data/app/views/wco_email/email_action_templates/index.haml +36 -0
  99. data/app/views/wco_email/email_action_templates/new.haml +9 -0
  100. data/app/views/wco_email/email_action_templates/show.haml +11 -0
  101. data/app/views/wco_email/email_actions/_form.haml +24 -0
  102. data/app/views/wco_email/email_actions/_form_mini.haml-trash +28 -0
  103. data/app/views/wco_email/email_actions/_header.haml +8 -0
  104. data/app/views/wco_email/email_actions/edit.haml +4 -0
  105. data/app/views/wco_email/email_actions/index.haml +31 -0
  106. data/app/views/wco_email/email_actions/new.haml +4 -0
  107. data/app/views/wco_email/email_actions/show.haml +0 -0
  108. data/app/views/wco_email/email_campaigns/_form.haml +33 -0
  109. data/app/views/wco_email/email_campaigns/_header.haml +5 -0
  110. data/app/views/wco_email/email_campaigns/edit.haml +5 -0
  111. data/app/views/wco_email/email_campaigns/index.haml +14 -0
  112. data/app/views/wco_email/email_campaigns/new.haml +5 -0
  113. data/app/views/wco_email/email_campaigns/show.haml +17 -0
  114. data/app/views/wco_email/email_filters/_form.haml +40 -0
  115. data/app/views/wco_email/email_filters/_header.haml +5 -0
  116. data/app/views/wco_email/email_filters/edit.haml +5 -0
  117. data/app/views/wco_email/email_filters/index.haml +48 -0
  118. data/app/views/wco_email/email_filters/new.haml +5 -0
  119. data/app/views/wco_email/email_templates/_form.haml +48 -0
  120. data/app/views/wco_email/email_templates/_form_mini.haml +9 -0
  121. data/app/views/wco_email/email_templates/_form_reply_mini.haml +8 -0
  122. data/app/views/wco_email/email_templates/_form_schedule_mini.haml +11 -0
  123. data/app/views/wco_email/email_templates/_header.haml +6 -0
  124. data/app/views/wco_email/email_templates/_index.haml +26 -0
  125. data/app/views/wco_email/email_templates/_index_expanded.haml +13 -0
  126. data/app/views/wco_email/email_templates/_m20221201react.html.erb +1202 -0
  127. data/app/views/wco_email/email_templates/_m20221222merryxmas.html.erb +766 -0
  128. data/app/views/wco_email/email_templates/_m202309_feedback.html.erb +1161 -0
  129. data/app/views/wco_email/email_templates/_m202309_ror4.html.erb +1068 -0
  130. data/app/views/wco_email/email_templates/_marketing_node_1.html.erb +984 -0
  131. data/app/views/wco_email/email_templates/_marketing_react_1.html +0 -0
  132. data/app/views/wco_email/email_templates/_marketing_react_2.html.erb +749 -0
  133. data/app/views/wco_email/email_templates/_marketing_react_3.html.erb +628 -0
  134. data/app/views/wco_email/email_templates/_marketing_ror_1.html +751 -0
  135. data/app/views/wco_email/email_templates/_marketing_ror_2.html.erb +755 -0
  136. data/app/views/wco_email/email_templates/_marketing_ror_3.html.erb +25 -0
  137. data/app/views/wco_email/email_templates/_marketing_ror_4.html.erb +25 -0
  138. data/app/views/wco_email/email_templates/_marketing_ror_5.html.erb +17 -0
  139. data/app/views/wco_email/email_templates/_marketing_wordpress_1.html +0 -0
  140. data/app/views/wco_email/email_templates/_marketing_wordpress_2.html +0 -0
  141. data/app/views/wco_email/email_templates/_meta.haml +6 -0
  142. data/app/views/wco_email/email_templates/_piousbox_roundborders.html.erb +1007 -0
  143. data/app/views/wco_email/email_templates/_piousbox_social.html.erb +181 -0
  144. data/app/views/wco_email/email_templates/_plain.haml +15 -0
  145. data/app/views/wco_email/email_templates/_rec_resume_shared_with_you.html.erb +39 -0
  146. data/app/views/wco_email/email_templates/_slug-1.html.erb +0 -0
  147. data/app/views/wco_email/email_templates/_slug-2.html.erb +0 -0
  148. data/app/views/wco_email/email_templates/_slug-3.html.erb +0 -0
  149. data/app/views/wco_email/email_templates/_tracking_footer.html.erb +13 -0
  150. data/app/views/wco_email/email_templates/_wasyaco_roundborders.html.erb +686 -0
  151. data/app/views/wco_email/email_templates/_wasyaco_social.html.erb +181 -0
  152. data/app/views/wco_email/email_templates/edit.haml +6 -0
  153. data/app/views/wco_email/email_templates/new.haml +6 -0
  154. data/app/views/wco_email/email_templates/show.haml +11 -0
  155. data/app/views/wco_email/email_templates/show_iframe.haml +2 -0
  156. data/app/views/wco_email/lead_action_templates/_header.haml +7 -0
  157. data/app/views/wco_email/lead_actions/_header.haml +8 -0
  158. data/app/views/wco_email/message_stubs/_index.haml +10 -0
  159. data/app/views/wco_email/messages/_form_reply.haml-trash +17 -0
  160. data/app/views/wco_email/messages/_meta.haml +30 -0
  161. data/app/views/wco_email/messages/show.haml +13 -0
  162. data/app/views/wco_email/messages/show_iframe.haml +5 -0
  163. data/app/views/wco_email/sessions/new.html.erb +4 -0
  164. data/app/views/wco_email/unsubscribes/_header.haml +4 -0
  165. data/app/views/wco_email/unsubscribes/_table.haml +22 -0
  166. data/config/initializers/assets.rb +10 -0
  167. data/config/routes.rb +49 -0
  168. data/lib/tasks/bjjcollective/sitemap.rb +50 -0
  169. data/lib/tasks/db_tasks.rake +12 -0
  170. data/lib/tasks/direct_mail_tasks.rake +35 -0
  171. data/lib/tasks/infinite_shelter/sitemap.rb +25 -0
  172. data/lib/tasks/piousbox/sitemap.rb +80 -0
  173. data/lib/tasks/publish2_wordpress_tasks.rake +54 -0
  174. data/lib/tasks/scrape_reddit_tasks.rake-bk +23 -0
  175. data/lib/tasks/trash/email_tasks.rake-trash +126 -0
  176. data/lib/tasks/trash/sitemap_tasks.rake-trash +146 -0
  177. data/lib/tasks/wasya_co/sitemap.rb +281 -0
  178. data/lib/tasks/wco_email_tasks.rake +117 -0
  179. data/lib/wco_email/README_email_actions.rb +7 -0
  180. data/lib/wco_email/README_email_contexts.rb +7 -0
  181. data/lib/wco_email/engine.rb +8 -0
  182. data/lib/wco_email.rb +19 -0
  183. metadata +493 -0
@@ -0,0 +1,177 @@
1
+ $(function() {
2
+
3
+
4
+ /*
5
+ * select-all
6
+ * _vp_ 2023-02-28
7
+ **/
8
+ $("input[type='checkbox'].i-sel").change((ev) => {
9
+ // logg(ev, 'changed-112')
10
+
11
+ $( $(".n-selected")[0] ).html( $("input[type='checkbox'].i-sel:checked").length )
12
+ })
13
+ $("th.select-all input[type='checkbox']").change((e) => {
14
+ const count = $("input[type='checkbox'].i-sel:checked").length
15
+ const new_state = count ? false : true // all will be checked?
16
+
17
+ $(".select-all input[type='checkbox']").prop('checked', new_state)
18
+
19
+ $( $("input[type='checkbox'].i-sel") ).each( i => {
20
+ $( $("input[type='checkbox'].i-sel")[i] ).prop('checked', new_state)
21
+ })
22
+
23
+ $( $(".n-selected")[0] ).html( $("input[type='checkbox'].i-sel:checked").length )
24
+ })
25
+
26
+
27
+
28
+ // $("body.email_conversations-show .preview-btn").click(function(e) {
29
+ // // logg($(this).data(), 'clicked')
30
+ // var msgId = $(this).data().msg.id
31
+ // var msgC = $(`.msg-container[data-msg-id='${msgId}']`) // msgContainer
32
+ // if ($(msgC).data('expanded')) {
33
+ // $(msgC).data('expanded', false)
34
+ // msgC.find(".to-expand").css('display', 'none')
35
+ // } else {
36
+ // $(msgC).data('expanded', true)
37
+ // msgC.find(".to-expand").css('display', 'block')
38
+ // }
39
+ // })
40
+
41
+
42
+
43
+ $(".archive-btn").click(function(e) {
44
+ if ( !confirm('Are you sure?') ) { return; }
45
+
46
+ const jwt_token = $("#Config").data('jwt-token')
47
+ const action_path = $(this).data('url')
48
+ const out = []
49
+
50
+ $( $("input[type='checkbox'].i-sel:checked") ).each( idx => {
51
+ let val = $($("input[type='checkbox'].i-sel:checked")[idx]).val()
52
+ out.push(val)
53
+ })
54
+
55
+ $.ajax({
56
+ url: action_path,
57
+ type: 'POST',
58
+ data: {
59
+ ids: out,
60
+ jwt_token: jwt_token,
61
+ },
62
+ success: e => {
63
+ logg((e||{}).responseText, 'archived Ok')
64
+ location.reload()
65
+ },
66
+ error: e => {
67
+ logg((e||{}).responseText, 'archived Err')
68
+ },
69
+ })
70
+
71
+ })
72
+
73
+ $(".add-tag-btn").click(function(e) {
74
+ if ( !confirm('Are you sure?') ) { return; }
75
+
76
+ const jwt_token = $("#Config").data('jwt-token')
77
+ const action_path = $(this).data('url')
78
+ const emailtag = $("select[name='emailtag']").val()
79
+ const out = []
80
+
81
+ $( $("input[type='checkbox'].i-sel:checked") ).each( idx => {
82
+ let val = $($("input[type='checkbox'].i-sel:checked")[idx]).val()
83
+ out.push(val)
84
+ })
85
+
86
+ let data = {
87
+ ids: out,
88
+ jwt_token: jwt_token,
89
+ slug: emailtag,
90
+ }
91
+ if ($("#is_move").prop('checked')) {
92
+ data.is_move = true
93
+ }
94
+ $.ajax({
95
+ url: action_path,
96
+ type: 'POST',
97
+ data: data,
98
+ success: e => {
99
+ logg((e||{}).responseText, 'Ok')
100
+ location.reload()
101
+ },
102
+ error: e => {
103
+ logg((e||{}).responseText, 'Err')
104
+ },
105
+ })
106
+
107
+ })
108
+
109
+ $(".remove-tag-btn").click(function(e) {
110
+ if ( !confirm('Are you sure?') ) { return; }
111
+
112
+ const jwt_token = $("#Config").data('jwt-token')
113
+ const action_path = $(this).data('url')
114
+ const emailtag = $("select[name='emailtag']").val()
115
+ const out = []
116
+
117
+ $( $("input[type='checkbox'].i-sel:checked") ).each( idx => {
118
+ let val = $($("input[type='checkbox'].i-sel:checked")[idx]).val()
119
+ out.push(val)
120
+ })
121
+
122
+ $.ajax({
123
+ url: action_path,
124
+ type: 'POST',
125
+ data: {
126
+ ids: out,
127
+ jwt_token: jwt_token,
128
+ slug: emailtag,
129
+ },
130
+ success: e => {
131
+ logg((e||{}).responseText, 'Ok')
132
+ location.reload()
133
+ },
134
+ error: e => {
135
+ logg((e||{}).responseText, 'Err')
136
+ },
137
+ })
138
+
139
+ })
140
+
141
+ $(".delete-btn").click(function(e) {
142
+ if ( !confirm('Are you sure?') ) { return; }
143
+
144
+ const jwt_token = $("#Config").data('jwt-token')
145
+ const action_path = $(this).data('url')
146
+ const out = []
147
+
148
+ $( $("input[type='checkbox'].i-sel:checked") ).each( idx => {
149
+ let val = $($("input[type='checkbox'].i-sel:checked")[idx]).val()
150
+ out.push(val)
151
+ })
152
+
153
+ $.ajax({
154
+ url: action_path,
155
+ type: 'DELETE',
156
+ data: {
157
+ ids: out,
158
+ jwt_token: jwt_token,
159
+ },
160
+ success: e => {
161
+ logg((e||{}).responseText, 'deleted Ok')
162
+ location.reload()
163
+ },
164
+ error: e => {
165
+ logg((e||{}).responseText, 'deleted Err')
166
+ },
167
+ })
168
+
169
+ })
170
+
171
+
172
+
173
+
174
+
175
+
176
+ }); // END
177
+
@@ -0,0 +1,32 @@
1
+
2
+ $(function () {
3
+
4
+ var fileuploadCount = 0
5
+ $('#fileupload').fileupload({
6
+ dataType: 'json',
7
+ success: function(ev) {
8
+ logg(ev, 'success')
9
+ ev = ev[0]
10
+ fileuploadCount += 1
11
+ var el = $('<div class="item" />')
12
+ var photosEl = $('#photos')
13
+ $('<div/>').html(fileuploadCount).appendTo(el)
14
+ $('<img/>').attr('src', ev.thumbnail_url).appendTo(el)
15
+ $('<div/>').html(ev.name).appendTo(el)
16
+ el.appendTo(photosEl)
17
+ },
18
+ error: function(err) {
19
+ logg(err, 'error')
20
+ err = err.responseJSON
21
+ fileuploadCount += 1
22
+ var el = $('<div class="item" />')
23
+ var errorsEl = $('.photos--multinew .errors')
24
+ $('<div/>').html(fileuploadCount).appendTo(el)
25
+ $('<div />').html(err.filename).appendTo(el)
26
+ $('<div />').html(err.message).appendTo(el)
27
+ el.appendTo(errorsEl)
28
+ },
29
+ });
30
+
31
+
32
+ })(); // END
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * Usage: logg(someObject, 'label')
4
+ *
5
+ * This development-grade logger can be used instead of console.log() with some advantages:
6
+ * * It encourages consistent labeling of logs. By labeling each log line, you can have dozens of log lines
7
+ * written per action, and still know which log line comes from where.
8
+ * The recommended label is the component name, or function name.
9
+ * * If the label is present, the logged object is placed in the window, allowing you to inspect it in the console. The
10
+ * label becomes the name of the object (stripped to [0-9a-zA-Z\-_] chars). If you're logging a function, you can execute it.
11
+ * If you log more than one thing, they can interact, allowing you to validate control flow.
12
+ * * the logger can be turned off by making this function simply return.
13
+ **/
14
+ function logg (a, b="", c=null) {
15
+ c = "string" === typeof c ? c : b.replace(/\W/g, "");
16
+ if (c.length > 0) {
17
+ window[c] = a;
18
+ }
19
+
20
+ console.log(`+++ ${b}:`, a); // eslint-disable-line no-console
21
+ };
22
+
@@ -0,0 +1,29 @@
1
+ /*
2
+ *= require_self
3
+ *= require_tree .
4
+ **/
5
+
6
+ .application--sidebar {
7
+ min-width: 200px;
8
+ border-right: 1px solid red;
9
+ }
10
+
11
+ iframe.email-template-iframe {
12
+ width: 100%;
13
+ /* height: 100%; */
14
+ min-height: 40vh;
15
+
16
+ margin-top: 1em;
17
+ }
18
+
19
+ iframe.message-iframe {
20
+ width: 100%;
21
+ height: 100%;
22
+ min-height: 80vh;
23
+ }
24
+
25
+
26
+ /* S */
27
+ .application--sidebar {
28
+ font-size: 0.8em;
29
+ }
@@ -0,0 +1,63 @@
1
+
2
+ .email-contexts--form-reply {
3
+ margin-bottom: 2em;
4
+ }
5
+
6
+ .email-contexts--form,
7
+ .email-templates--form {
8
+ form {
9
+ > .actions {
10
+ text-align: right;
11
+ }
12
+
13
+ .tab-labels {
14
+ // border: 1px solid red;
15
+ margin-top: 1em;
16
+
17
+ display: flex;
18
+
19
+ > * {
20
+ // border: 1px solid red;
21
+ }
22
+ > .active {
23
+ border: 2px solid red;
24
+ border-radius: 0.5em 0.5em 0 0;
25
+ border-bottom: 0;
26
+ margin-bottom: -2px;
27
+ background: white;
28
+ padding: 0 .5em;
29
+ margin: 0 .5em;
30
+ }
31
+
32
+ }
33
+ .tabs {
34
+ .tab-raw {
35
+ display: none;
36
+ }
37
+ .tab-preview {
38
+ height: 500px;
39
+ // display: none;
40
+ }
41
+ }
42
+
43
+ }
44
+ }
45
+
46
+ .email-templates--form-mini {
47
+ border: 1px solid red;
48
+ padding: 1em;
49
+
50
+ form {
51
+ display: flex;
52
+
53
+ > * {
54
+ padding-right: 20px;
55
+ }
56
+ }
57
+
58
+ }
59
+
60
+ .email-templates--form-reply-mini,
61
+ .email-templates--form-schedule-mini {
62
+
63
+ }
@@ -0,0 +1,16 @@
1
+
2
+
3
+ // .conversations--actions {
4
+ // display: flex;
5
+ // }
6
+
7
+ th.select-all {
8
+ width: 50px;
9
+
10
+ > div {
11
+ // border: 1px solid red;
12
+ display: flex;
13
+ padding: 8px 10px;
14
+ }
15
+ }
16
+
@@ -0,0 +1,6 @@
1
+
2
+ ul.tags-list {
3
+ margin: 0;
4
+ padding: 0;
5
+ list-style-type: none;
6
+ }
@@ -0,0 +1,16 @@
1
+
2
+ class WcoEmail::ApplicationController < Wco::ApplicationController
3
+ before_action :set_lists
4
+ layout 'wco_email/application'
5
+
6
+
7
+ ##
8
+ ## private
9
+ ##
10
+ private
11
+
12
+ def set_lists
13
+ @tags = Wco::Tag.all
14
+ end
15
+
16
+ end
@@ -0,0 +1,156 @@
1
+ require 'csv'
2
+
3
+
4
+ class WcoEmail::ContextsController < WcoEmail::ApplicationController
5
+
6
+ before_action :set_lists
7
+
8
+ def create
9
+ @ctx = WcoEmail::Context.new params[:context].permit!
10
+ @tmpl = WcoEmail::EmailTemplate.find @ctx.email_template_id
11
+
12
+ @ctx.from_email ||= @tmpl.from_email
13
+ @ctx.subject ||= @tmpl.subject
14
+
15
+ if params[:respond_inline]
16
+ @ctx.reply_to_message_id = params[:respond_inline]
17
+ end
18
+
19
+ authorize! :create, @ctx
20
+ if @ctx.save
21
+ flash_notice 'Saved.'
22
+ redirect_to action: 'show', id: @ctx.id
23
+ return
24
+ else
25
+ flash_alert @ctx
26
+ redirect_to request.referrer
27
+ end
28
+ end
29
+
30
+ def destroy
31
+ @ctx = WcoEmail::Context.find params[:id]
32
+ authorize! :destroy, @ctx
33
+ flag = @ctx.destroy
34
+ if flag
35
+ flash[:notice] = 'Destroyed the email context'
36
+ else
37
+ flash[:alert] = 'Could not destroy email context'
38
+ end
39
+ redirect_to action: :index
40
+ end
41
+
42
+ def edit
43
+ @ctx = WcoEmail::Context.find params[:id]
44
+ authorize! :edit, @ctx
45
+ end
46
+
47
+ def iframe_src
48
+ @ctx = @email_context = WcoEmail::Context.find params[:id]
49
+ authorize! :iframe_src, @ctx
50
+
51
+ @tmpl = @email_template = @ctx.email_template
52
+ @tmpl_config = OpenStruct.new JSON.parse( @ctx.tmpl[:config_json] )
53
+ @lead = @ctx.lead
54
+ @body = @ctx.body
55
+
56
+ render layout: false
57
+ end
58
+
59
+ def index
60
+ authorize! :index, WcoEmail::Context
61
+ @ctxs = WcoEmail::Context.all.order_by( sent_at: :desc, send_at: :desc
62
+ ).page( params[:ctxs_page]
63
+ ).per( current_profile.per_page )
64
+
65
+ if params[:lead_id]
66
+ @lead = Lead.find params[:lead_id]
67
+ @ctxs = @ctxs.where( lead_id: @lead.id )
68
+ else
69
+ if my_truthy? params[:sent]
70
+ @ctxs = @ctxs.or({ :sent_at.ne => nil }, { :unsubscribed_at.ne => nil })
71
+ else
72
+ @ctxs = @ctxs.where( sent_at: nil, unsubscribed_at: nil )
73
+ end
74
+ end
75
+ end
76
+
77
+ def new
78
+ authorize! :new, WcoEmail::Context
79
+ @tmpl = @email_template = WcoEmail::EmailTemplate.where( slug: params[:template_slug] ).first ||
80
+ WcoEmail::EmailTemplate.where( id: params[:template_slug] ).first ||
81
+ WcoEmail::EmailTemplate.new
82
+ attrs = {}
83
+ if @tmpl
84
+ attrs = @tmpl.attributes.slice( :subject, :body, :from_email )
85
+ end
86
+ @ctx = WcoEmail::Context.new({ email_template: @tmpl }.merge(attrs))
87
+ end
88
+
89
+ def send_immediate
90
+ @ctx = WcoEmail::Context.find params[:id]
91
+ authorize! :do_send, @ctx
92
+
93
+ out = WcoEmail::ApplicationMailer.send_context_email( @ctx[:id].to_s )
94
+ Rails.env.production? ? out.deliver_later : out.deliver_now
95
+
96
+ flash_notice 'Sent immediately.'
97
+ redirect_to request.referrer
98
+ end
99
+
100
+ def send_schedule
101
+ @ctx = WcoEmail::Context.find params[:id]
102
+ authorize! :do_send, @ctx
103
+
104
+ flash[:notice] = 'Scheduled a single send - v2'
105
+ @ctx.send_at = Time.now
106
+ @ctx.save
107
+
108
+ redirect_to action: 'index'
109
+ end
110
+
111
+ def show
112
+ @ctx = @email_context = WcoEmail::Context.find( params[:id] )
113
+ authorize! :show, @ctx
114
+ end
115
+
116
+ def summary
117
+ authorize! :summary, WcoEmail::Context
118
+ @results = WcoEmail::Context.summary
119
+
120
+ respond_to do |format|
121
+ format.html
122
+ format.csv do
123
+ render layout: false
124
+ end
125
+ end
126
+ end
127
+
128
+ def update
129
+ @ctx = WcoEmail::Context.find params[:id]
130
+ authorize! :update, @ctx
131
+
132
+ if @ctx.update_attributes params[:ctx].permit!
133
+ flash[:notice] = 'Saved.'
134
+ redirect_to action: 'edit', id: @ctx.id
135
+ return
136
+ else
137
+ flash[:alert] = "Could not save: #{@ctx.errors.full_messages.join(', ')}"
138
+ render action: :edit
139
+ return
140
+ end
141
+ end
142
+
143
+ ##
144
+ ## Private
145
+ ##
146
+ private
147
+
148
+ def set_lists
149
+ super
150
+ @email_layouts_list = WcoEmail::EmailTemplate::LAYOUTS
151
+ @email_templates_list = [ [nil, nil] ] + WcoEmail::EmailTemplate.all.map { |tmpl| [ tmpl.slug, tmpl.id ] }
152
+ @leads_list = Wco::Lead.list
153
+ end
154
+
155
+ end
156
+
@@ -0,0 +1,129 @@
1
+
2
+ class WcoEmail::ConversationsController < WcoEmail::ApplicationController
3
+
4
+ # layout 'wco_email/mailbox'
5
+
6
+ before_action :set_lists
7
+
8
+ ## many tags to many convs
9
+ def addtag
10
+ authorize! :addtag, WcoEmail::Conversation
11
+ # convs = WcoEmail::Conversation.where({ :id.in => params[:ids].split(",") })
12
+ convs = WcoEmail::Conversation.find( params[:ids] )
13
+ tags = Wco::Tag.where({ :slug.in => params[:slug].split(",") })
14
+ if tags.blank?
15
+ tags = Wco::Tag.where({ :id.in => params[:slug].split(",") })
16
+ end
17
+ inbox = Wco::Tag.inbox
18
+ outs = convs.map do |conv|
19
+ conv.tags.push tags
20
+ conv.tags.delete( inbox ) if params[:is_move]
21
+ conv.save
22
+ end
23
+ flash_notice "Outcomes: #{outs}"
24
+ redirect_to request.referrer || root_path
25
+ end
26
+
27
+ # def delete
28
+ # authorize! :delete, WcoEmail::Conversation
29
+ # convs = WcoEmail::Conversation.find params[:ids]
30
+ # outs = convs.map do |conv|
31
+ # conv.add_tag( WpTag::TRASH )
32
+ # conv.remove_tag( WpTag::INBOX )
33
+ # end
34
+ # flash[:notice] = "outcome: #{outs}"
35
+ # render json: { status: :ok }
36
+ # end
37
+
38
+ def index
39
+ authorize! :index, WcoEmail::Conversation
40
+ @conversations = WcoEmail::Conversation.all
41
+
42
+ if params[:tagname]
43
+ tag = Wco::Tag.find_by slug: params[:tagname]
44
+ @conversations = @conversations.where( :tag_ids.in => [ tag.id ] )
45
+ end
46
+ if params[:tagname_not]
47
+ tag_not = Wco::Tag.find_by slug: params[:tagname_not]
48
+ @conversations = @conversations.where( :tag_ids.nin => [ tag_not.id ] )
49
+ end
50
+
51
+ if params[:subject].present?
52
+ @conversations = @conversations.where({ subject: /.*#{params[:subject]}.*/i })
53
+ end
54
+
55
+ if params[:from_email].present?
56
+ @conversations = @conversations.where({ from_emails: /.*#{params[:from_email]}.*/i })
57
+ end
58
+
59
+ @conversations = @conversations.order_by( latest_at: :desc
60
+ ).includes( :leads
61
+ ).page( params[:conv_page]
62
+ ).per( current_profile.per_page
63
+ )
64
+ end
65
+
66
+ ## merge conv1 into conv2, and delete conv1
67
+ def merge
68
+ authorize! :merge, WcoEmail::Conversation
69
+ conv1 = WcoEmail::Conversation.find params[:id1]
70
+ conv2 = WcoEmail::Conversation.find params[:id2]
71
+ conv1.messages.map do |msg|
72
+ msg.update conversation: conv2
73
+ end
74
+ conv1.tags.map do |tag|
75
+ conv2.tags.push tag
76
+ end
77
+ conv1.leads.map do |lead|
78
+ conv2.leads.push lead
79
+ end
80
+ conv2.save!
81
+ conv1.delete
82
+
83
+ flash_notice "Probably ok"
84
+ redirect_to action: :show, id: conv2.id
85
+ end
86
+
87
+ #
88
+ def rmtag
89
+ authorize! :addtag, WcoEmail::Conversation
90
+ convs = WcoEmail::Conversation.find params[:ids]
91
+ outs = convs.map do |conv|
92
+ conv.remove_tag( params[:emailtag] )
93
+ end
94
+ flash[:notice] = "outcome: #{outs}"
95
+ redirect_to request.referrer
96
+ end
97
+
98
+ def show
99
+ authorize! :show, WcoEmail::Conversation
100
+ @conversation = ::WcoEmail::Conversation.find( params[:id] )
101
+ @messages = @conversation.messages.order_by( date: :asc )
102
+ @conversation.update_attributes({ status: Conv::STATUS_READ })
103
+
104
+ @other_convs = WcoEmail::Message.where( :message_id.in => @messages.map( &:in_reply_to_id )
105
+ ).where( :conversation_id.ne => @conversation.id
106
+ ).map( &:conversation_id ).uniq
107
+ other_convs_by_subj = WcoEmail::Conversation.where( subject: @conversation.subject
108
+ ).where( :conversation_id.ne => @conversation.id
109
+ ).map( &:id )
110
+ if @other_convs.present?
111
+ @other_convs = WcoEmail::Conversation.find( @other_convs + other_convs_by_subj )
112
+ end
113
+ end
114
+
115
+
116
+ ##
117
+ ## private
118
+ ##
119
+ private
120
+
121
+ def set_lists
122
+ super
123
+ @email_templates_list = [ [nil, nil] ] + WcoEmail::EmailTemplate.all.map { |tmpl| [ tmpl.slug, tmpl.id ] }
124
+ @leads_list = Wco::Lead.list
125
+ @tags_list = Wco::Tag.list
126
+ end
127
+
128
+ end
129
+