maily_herald-webui 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +5 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +250 -0
  6. data/Guardfile +23 -0
  7. data/LICENSE +11 -0
  8. data/README.md +62 -0
  9. data/Rakefile +30 -0
  10. data/app/assets/images/maily_herald/.gitkeep +0 -0
  11. data/app/assets/images/maily_herald/webui/arrow-bottom.png +0 -0
  12. data/app/assets/images/maily_herald/webui/arrow-left.png +0 -0
  13. data/app/assets/images/maily_herald/webui/arrow-right.png +0 -0
  14. data/app/assets/images/maily_herald/webui/arrow-top.png +0 -0
  15. data/app/assets/images/maily_herald/webui/logo.svg +38 -0
  16. data/app/assets/images/maily_herald/webui/sprite-dropdown.png +0 -0
  17. data/app/assets/images/maily_herald/webui/sprite-form.png +0 -0
  18. data/app/assets/images/maily_herald/webui/sprite.png +0 -0
  19. data/app/assets/images/maily_herald/webui/user.png +0 -0
  20. data/app/assets/javascripts/maily_herald/webui/application.js +20 -0
  21. data/app/assets/javascripts/maily_herald/webui/dispatches.coffee +58 -0
  22. data/app/assets/javascripts/maily_herald/webui/webui.coffee +209 -0
  23. data/app/assets/stylesheets/maily_herald/webui/application.css +18 -0
  24. data/app/assets/stylesheets/maily_herald/webui/webui-bootstrap.scss +0 -0
  25. data/app/assets/stylesheets/maily_herald/webui/webui.sass +846 -0
  26. data/app/controllers/maily_herald/webui/application_controller.rb +19 -0
  27. data/app/controllers/maily_herald/webui/dashboard_controller.rb +65 -0
  28. data/app/controllers/maily_herald/webui/dispatches_controller.rb +42 -0
  29. data/app/controllers/maily_herald/webui/lists_controller.rb +69 -0
  30. data/app/controllers/maily_herald/webui/logs_controller.rb +20 -0
  31. data/app/controllers/maily_herald/webui/mailings_controller.rb +68 -0
  32. data/app/controllers/maily_herald/webui/one_time_mailings_controller.rb +32 -0
  33. data/app/controllers/maily_herald/webui/periodical_mailings_controller.rb +25 -0
  34. data/app/controllers/maily_herald/webui/resources_controller.rb +144 -0
  35. data/app/controllers/maily_herald/webui/sequence_mailings_controller.rb +43 -0
  36. data/app/controllers/maily_herald/webui/sequences_controller.rb +56 -0
  37. data/app/controllers/maily_herald/webui/sessions_controller.rb +11 -0
  38. data/app/controllers/maily_herald/webui/subscriptions_controller.rb +33 -0
  39. data/app/helpers/maily_herald/webui/application_helper.rb +157 -0
  40. data/app/helpers/maily_herald/webui/dispatches_helper.rb +18 -0
  41. data/app/helpers/maily_herald/webui/logs_helper.rb +37 -0
  42. data/app/helpers/maily_herald/webui/mailings_helper.rb +64 -0
  43. data/app/helpers/maily_herald/webui/sequence_mailings_helper.rb +13 -0
  44. data/app/helpers/maily_herald/webui/sequences_helper.rb +6 -0
  45. data/app/helpers/maily_herald/webui/subscribers_helper.rb +25 -0
  46. data/app/helpers/maily_herald/webui/subscriptions_helper.rb +11 -0
  47. data/app/helpers/maily_herald_helper.rb +151 -0
  48. data/app/views/layouts/maily_herald/webui/application.html.haml +58 -0
  49. data/app/views/layouts/maily_herald/webui/modal.html.haml +6 -0
  50. data/app/views/maily_herald/webui/dashboard/_log.html.haml +20 -0
  51. data/app/views/maily_herald/webui/dashboard/_log_list.html.haml +19 -0
  52. data/app/views/maily_herald/webui/dashboard/_logs.html.haml +15 -0
  53. data/app/views/maily_herald/webui/dashboard/index.html.haml +43 -0
  54. data/app/views/maily_herald/webui/dashboard/index.js.erb +15 -0
  55. data/app/views/maily_herald/webui/dispatches/_entities.html.haml +7 -0
  56. data/app/views/maily_herald/webui/dispatches/_logs.html.haml +4 -0
  57. data/app/views/maily_herald/webui/dispatches/_schedules.html.haml +4 -0
  58. data/app/views/maily_herald/webui/dispatches/_toggle.js.erb +1 -0
  59. data/app/views/maily_herald/webui/lists/_details.html.haml +14 -0
  60. data/app/views/maily_herald/webui/lists/_details_form.html.haml +14 -0
  61. data/app/views/maily_herald/webui/lists/_form.html.haml +1 -0
  62. data/app/views/maily_herald/webui/lists/_header.html.haml +13 -0
  63. data/app/views/maily_herald/webui/lists/_items.html.haml +24 -0
  64. data/app/views/maily_herald/webui/lists/_opt_outs.html.haml +7 -0
  65. data/app/views/maily_herald/webui/lists/_potential_subscribers.html.haml +7 -0
  66. data/app/views/maily_herald/webui/lists/_subscribers.html.haml +7 -0
  67. data/app/views/maily_herald/webui/lists/context_variables.html.haml +15 -0
  68. data/app/views/maily_herald/webui/lists/subscribe.js.erb +10 -0
  69. data/app/views/maily_herald/webui/lists/unsubscribe.js.erb +7 -0
  70. data/app/views/maily_herald/webui/logs/_items.html.haml +34 -0
  71. data/app/views/maily_herald/webui/logs/preview.html.haml +22 -0
  72. data/app/views/maily_herald/webui/mailings-old/_entity.html.haml +17 -0
  73. data/app/views/maily_herald/webui/mailings-old/_entity_list.html.haml +26 -0
  74. data/app/views/maily_herald/webui/mailings-old/_form.html.haml +32 -0
  75. data/app/views/maily_herald/webui/mailings-old/_print.html.haml +123 -0
  76. data/app/views/maily_herald/webui/mailings-old/create.js.erb +1 -0
  77. data/app/views/maily_herald/webui/mailings-old/destroy.js.erb +1 -0
  78. data/app/views/maily_herald/webui/mailings-old/edit.html.haml +16 -0
  79. data/app/views/maily_herald/webui/mailings-old/edit.js.erb +2 -0
  80. data/app/views/maily_herald/webui/mailings-old/index.html.haml +9 -0
  81. data/app/views/maily_herald/webui/mailings-old/index.js.erb +1 -0
  82. data/app/views/maily_herald/webui/mailings-old/new.html.haml +16 -0
  83. data/app/views/maily_herald/webui/mailings-old/new.js.erb +1 -0
  84. data/app/views/maily_herald/webui/mailings-old/preview.js.erb +2 -0
  85. data/app/views/maily_herald/webui/mailings-old/refresh_list.js.erb +1 -0
  86. data/app/views/maily_herald/webui/mailings-old/show.html.haml +135 -0
  87. data/app/views/maily_herald/webui/mailings-old/show.js.erb +1 -0
  88. data/app/views/maily_herald/webui/mailings-old/update.js.erb +1 -0
  89. data/app/views/maily_herald/webui/mailings/_deliver.js.erb +1 -0
  90. data/app/views/maily_herald/webui/mailings/_details.html.haml +65 -0
  91. data/app/views/maily_herald/webui/mailings/_details_form.html.haml +39 -0
  92. data/app/views/maily_herald/webui/mailings/_form.html.haml +1 -0
  93. data/app/views/maily_herald/webui/mailings/_form_periodical.html.haml +2 -0
  94. data/app/views/maily_herald/webui/mailings/_form_sequence.html.haml +1 -0
  95. data/app/views/maily_herald/webui/mailings/_form_template_generic.html.haml +7 -0
  96. data/app/views/maily_herald/webui/mailings/_form_template_mailer.html.haml +4 -0
  97. data/app/views/maily_herald/webui/mailings/_header.html.haml +24 -0
  98. data/app/views/maily_herald/webui/mailings/_list.html.haml +27 -0
  99. data/app/views/maily_herald/webui/mailings/_template.html.haml +16 -0
  100. data/app/views/maily_herald/webui/mailings/_template_form.html.haml +7 -0
  101. data/app/views/maily_herald/webui/mailings/nav_secondary/_index.html.haml +3 -0
  102. data/app/views/maily_herald/webui/mailings/preview.html.haml +13 -0
  103. data/app/views/maily_herald/webui/mailings/update_form.js.erb +33 -0
  104. data/app/views/maily_herald/webui/resources/edit.js.erb +2 -0
  105. data/app/views/maily_herald/webui/resources/index.html.haml +11 -0
  106. data/app/views/maily_herald/webui/resources/index.js.erb +1 -0
  107. data/app/views/maily_herald/webui/resources/new.html.haml +5 -0
  108. data/app/views/maily_herald/webui/resources/show.html.haml +4 -0
  109. data/app/views/maily_herald/webui/resources/show.js.erb +3 -0
  110. data/app/views/maily_herald/webui/resources/update.js.erb +18 -0
  111. data/app/views/maily_herald/webui/sequences-old/_entity.html.haml +11 -0
  112. data/app/views/maily_herald/webui/sequences-old/_entity_list.html.haml +23 -0
  113. data/app/views/maily_herald/webui/sequences-old/_form.html.haml +17 -0
  114. data/app/views/maily_herald/webui/sequences-old/_log.html.haml +7 -0
  115. data/app/views/maily_herald/webui/sequences-old/_logs.html.haml +16 -0
  116. data/app/views/maily_herald/webui/sequences-old/_mailing.html.haml +4 -0
  117. data/app/views/maily_herald/webui/sequences-old/_mailing_list.html.haml +19 -0
  118. data/app/views/maily_herald/webui/sequences-old/edit.html.haml +14 -0
  119. data/app/views/maily_herald/webui/sequences-old/new.html.haml +13 -0
  120. data/app/views/maily_herald/webui/sequences-old/show.html.haml +122 -0
  121. data/app/views/maily_herald/webui/sequences-old/show.js.erb +2 -0
  122. data/app/views/maily_herald/webui/sequences-old/subscription.html.haml +79 -0
  123. data/app/views/maily_herald/webui/sequences/_details.html.haml +39 -0
  124. data/app/views/maily_herald/webui/sequences/_details_form.html.haml +27 -0
  125. data/app/views/maily_herald/webui/sequences/_form.html.haml +1 -0
  126. data/app/views/maily_herald/webui/sequences/_header.html.haml +11 -0
  127. data/app/views/maily_herald/webui/sequences/_list.html.haml +21 -0
  128. data/app/views/maily_herald/webui/sequences/_mailing_list.html.haml +21 -0
  129. data/app/views/maily_herald/webui/sequences/_mailings.html.haml +7 -0
  130. data/app/views/maily_herald/webui/sequences/update_form.js.erb +14 -0
  131. data/app/views/maily_herald/webui/shared/_context_attributes.html.haml +11 -0
  132. data/app/views/maily_herald/webui/subscribers/_item.html.haml +8 -0
  133. data/app/views/maily_herald/webui/subscribers/_list.html.haml +18 -0
  134. data/app/views/maily_herald/webui/subscription_groups/_form.html.haml +5 -0
  135. data/app/views/maily_herald/webui/subscription_groups/_subscription.html.haml +8 -0
  136. data/app/views/maily_herald/webui/subscription_groups/_subscription_list.html.haml +19 -0
  137. data/app/views/maily_herald/webui/subscription_groups/edit.html.haml +16 -0
  138. data/app/views/maily_herald/webui/subscription_groups/index.html.haml +35 -0
  139. data/app/views/maily_herald/webui/subscription_groups/new.html.haml +11 -0
  140. data/app/views/maily_herald/webui/subscription_groups/show.html.haml +42 -0
  141. data/app/views/maily_herald/webui/subscription_groups/show.js.erb +1 -0
  142. data/app/views/maily_herald/webui/subscriptions/show.html.haml +21 -0
  143. data/app/views/maily_herald/webui/subscriptions/toggle.js.erb +1 -0
  144. data/app/views/maily_herald/webui/webui/index.html.haml +136 -0
  145. data/app/views/maily_herald/webui/webui/show.html.haml +0 -0
  146. data/config/database.yml +5 -0
  147. data/config/initializers/smart_listing.rb +77 -0
  148. data/config/locales/en.yml +237 -0
  149. data/config/routes.rb +103 -0
  150. data/config/spring.rb +1 -0
  151. data/lib/maily_herald/webui.rb +15 -0
  152. data/lib/maily_herald/webui/breadcrumbs.rb +50 -0
  153. data/lib/maily_herald/webui/engine.rb +18 -0
  154. data/lib/maily_herald/webui/form_builder.rb +285 -0
  155. data/lib/maily_herald/webui/menu_manager.rb +66 -0
  156. data/lib/maily_herald/webui/version.rb +5 -0
  157. data/maily_herald-webui.gemspec +40 -0
  158. data/script/rails +8 -0
  159. data/spec/dummy/Guardfile +35 -0
  160. data/spec/dummy/README.rdoc +261 -0
  161. data/spec/dummy/Rakefile +7 -0
  162. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  163. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  164. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  165. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  166. data/spec/dummy/app/mailers/.gitkeep +0 -0
  167. data/spec/dummy/app/mailers/test_mailer.rb +11 -0
  168. data/spec/dummy/app/models/.gitkeep +0 -0
  169. data/spec/dummy/app/models/user.rb +7 -0
  170. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  171. data/spec/dummy/app/views/test_mailer/sample_mail.text.erb +1 -0
  172. data/spec/dummy/bin/rails +10 -0
  173. data/spec/dummy/bin/rake +7 -0
  174. data/spec/dummy/bin/rspec +7 -0
  175. data/spec/dummy/bin/spring +18 -0
  176. data/spec/dummy/config.ru +4 -0
  177. data/spec/dummy/config/application.rb +65 -0
  178. data/spec/dummy/config/boot.rb +10 -0
  179. data/spec/dummy/config/database.yml +25 -0
  180. data/spec/dummy/config/environment.rb +5 -0
  181. data/spec/dummy/config/environments/development.rb +38 -0
  182. data/spec/dummy/config/environments/production.rb +67 -0
  183. data/spec/dummy/config/environments/test.rb +37 -0
  184. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  185. data/spec/dummy/config/initializers/inflections.rb +15 -0
  186. data/spec/dummy/config/initializers/maily_herald.rb +101 -0
  187. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  188. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  189. data/spec/dummy/config/initializers/session_store.rb +8 -0
  190. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  191. data/spec/dummy/config/locales/en.yml +5 -0
  192. data/spec/dummy/config/locales/maily_herald.en.yml +28 -0
  193. data/spec/dummy/config/routes.rb +4 -0
  194. data/spec/dummy/db/migrate/20130723074347_create_users.rb +11 -0
  195. data/spec/dummy/db/migrate/20140804152249_create_maily_herald_tables.maily_herald.rb +68 -0
  196. data/spec/dummy/db/migrate/20140804152250_create_lists.maily_herald.rb +33 -0
  197. data/spec/dummy/db/schema.rb +79 -0
  198. data/spec/dummy/lib/assets/.gitkeep +0 -0
  199. data/spec/dummy/lib/tasks/dummy.rb +8 -0
  200. data/spec/dummy/log/.gitkeep +0 -0
  201. data/spec/dummy/public/404.html +26 -0
  202. data/spec/dummy/public/422.html +26 -0
  203. data/spec/dummy/public/500.html +25 -0
  204. data/spec/dummy/public/favicon.ico +0 -0
  205. data/spec/dummy/script/rails +6 -0
  206. data/spec/spec_helper.rb +46 -0
  207. data/vendor/assets/fonts/maily_herald/webui/FontAwesome.otf +0 -0
  208. data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.eot +0 -0
  209. data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.svg +1816 -0
  210. data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.ttf +0 -0
  211. data/vendor/assets/fonts/maily_herald/webui/Nexa_Free_Bold-webfont.woff +0 -0
  212. data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.eot +0 -0
  213. data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.svg +520 -0
  214. data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.ttf +0 -0
  215. data/vendor/assets/fonts/maily_herald/webui/fontawesome-webfont.woff +0 -0
  216. data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.eot +0 -0
  217. data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.svg +1825 -0
  218. data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.ttf +0 -0
  219. data/vendor/assets/fonts/maily_herald/webui/opensans-bold-webfont.woff +0 -0
  220. data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.eot +0 -0
  221. data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.svg +1825 -0
  222. data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.ttf +0 -0
  223. data/vendor/assets/fonts/maily_herald/webui/opensans-italic-webfont.woff +0 -0
  224. data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.eot +0 -0
  225. data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.svg +1825 -0
  226. data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.ttf +0 -0
  227. data/vendor/assets/fonts/maily_herald/webui/opensans-regular-webfont.woff +0 -0
  228. data/vendor/assets/javascripts/maily_herald/webui/bootstrap-datepicker.js +1681 -0
  229. data/vendor/assets/javascripts/maily_herald/webui/bootstrap.min.js +6 -0
  230. data/vendor/assets/javascripts/maily_herald/webui/d3.v3.js +5 -0
  231. data/vendor/assets/javascripts/maily_herald/webui/rickshaw.js +4067 -0
  232. data/vendor/assets/stylesheets/maily_herald/webui/bootstrap-datepicker.css +786 -0
  233. data/vendor/assets/stylesheets/maily_herald/webui/bootstrap.min.css +5 -0
  234. data/vendor/assets/stylesheets/maily_herald/webui/font-awesome.min.css +4 -0
  235. data/vendor/assets/stylesheets/maily_herald/webui/rickshaw.css +355 -0
  236. metadata +564 -0
@@ -0,0 +1,43 @@
1
+ module MailyHerald
2
+ class Webui::SequenceMailingsController < Webui::MailingsController
3
+ add_breadcrumb :label_sequence_plural, Proc.new{ sequences_path }
4
+ set_menu_item :sequences
5
+
6
+ before_filter :find_sequence
7
+
8
+ def new
9
+ super
10
+ @item.sequence = @sequence
11
+ end
12
+
13
+ def create
14
+ super do |mailing|
15
+ mailing.sequence = @sequence
16
+ end
17
+ end
18
+
19
+ protected
20
+
21
+ def find_sequence
22
+ @sequence = MailyHerald::Sequence.find(params[:sequence_id])
23
+ add_breadcrumb view_context.friendly_name(@sequence), Proc.new{ sequence_path(@sequence) }
24
+ end
25
+
26
+ def set_resource_spec
27
+ spec = super
28
+ spec.params.push(:absolute_delay_in_days)
29
+ spec.update_containers["schedules"] = true
30
+ spec.containers_order = ["details", "template", "entities", "schedules", "logs"]
31
+ spec
32
+ end
33
+
34
+ def action_dependencies *containers
35
+ super do |container|
36
+ case container
37
+ when "schedules"
38
+ @schedules = smart_listing_create(:schedules, @item.logs.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,56 @@
1
+ module MailyHerald
2
+ class Webui::SequencesController < Webui::DispatchesController
3
+ add_breadcrumb :label_sequence_plural, Proc.new{ sequences_path }
4
+ set_menu_item :sequences
5
+
6
+ protected
7
+
8
+ def set_resource_spec
9
+ Webui::ResourcesController::Spec.new.tap do |spec|
10
+ spec.klass = "MailyHerald::#{controller_name.classify}".constantize
11
+ if Rails::VERSION::MAJOR == 3
12
+ spec.scope = spec.klass.scoped
13
+ else
14
+ spec.scope = spec.klass.all
15
+ end
16
+ spec.filter_proc = Proc.new do |scope, query|
17
+ scope.where("name like ? or title like ?", "%#{query}%", "%#{query}%")
18
+ end
19
+ spec.items_partial = "maily_herald/webui/sequences/list"
20
+ spec.item_partial = "maily_herald/webui/sequences/sequence"
21
+ spec.params = [:title, :list, :start_at, :override_subscription]
22
+ spec.update_containers = {
23
+ "mailings" => true,
24
+ "entities" => true,
25
+ "schedules" => true,
26
+ "logs" => true
27
+ }
28
+ spec.containers_order = ["details", "mailings", "entities", "schedules", "logs"]
29
+ end
30
+ end
31
+
32
+ def action_dependencies *containers
33
+ containers.flatten!
34
+
35
+ @sequence = @item
36
+ @list = @sequence.list
37
+
38
+ containers.each do |container|
39
+ case container
40
+ when "logs"
41
+ @logs = smart_listing_create(:logs, @item.logs.processed, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "desc"})
42
+ when "schedules"
43
+ @schedules = smart_listing_create(:schedules, @item.logs.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
44
+ when "entities"
45
+ @entities = @item.list.subscribers
46
+ @entities = @entities.merge(@item.list.context.scope_like(params[:entities_filter])) if params[:entities_filter]
47
+ @entities = smart_listing_create(:entities, @entities, :partial => "maily_herald/webui/subscribers/list")
48
+ when "mailings"
49
+ @mailings = smart_listing_create(:mailings, @item.mailings, :partial => "maily_herald/webui/mailings/list")
50
+ else
51
+ yield(container) if block_given?
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,11 @@
1
+ module MailyHerald
2
+ class Webui::SessionsController < Webui::ApplicationController
3
+ def switch_mode
4
+ if %w{regular expert}.include? params[:mode]
5
+ session[:work_mode] = params[:mode].to_sym
6
+ end
7
+
8
+ redirect_to :back
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module MailyHerald
2
+ class Webui::SubscriptionsController < Webui::ResourcesController
3
+ add_breadcrumb :label_list_plural, Proc.new{ lists_path }
4
+ set_menu_item :lists
5
+
6
+ def show
7
+ super
8
+
9
+ @list = @item.list
10
+
11
+ add_breadcrumb @list.title || @list.name, list_path(@list)
12
+
13
+ add_breadcrumb view_context.tw("subscriptions.show.users_subscription", user: @item.entity.to_s)
14
+
15
+ @entity = @item
16
+ smart_listing_create(:delivered_logs, @item.logs.delivered, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "desc"})
17
+ smart_listing_create(:scheduled_logs, @item.logs.scheduled, :partial => "maily_herald/webui/logs/items", default_sort: {processing_at: "asc"})
18
+ end
19
+
20
+ def toggle
21
+ find_item
22
+ @item.toggle!
23
+ end
24
+
25
+ protected
26
+
27
+ def resource_spec
28
+ @resource_spec ||= Webui::ResourcesController::Spec.new.tap do |spec|
29
+ spec.klass = MailyHerald::Subscription
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,157 @@
1
+ module MailyHerald
2
+ module Webui
3
+ module ApplicationHelper
4
+ include MailyHerald::Webui::Breadcrumbs::HelperExtensions
5
+
6
+ def render_main_menu
7
+ content_tag(:ul, :class => "nav nav-main") do
8
+ menu_manager.items.each do |i|
9
+ title = i[:title] || i[:name]
10
+ title = tw(title) if title.is_a?(Symbol)
11
+
12
+ url = i[:url]
13
+ url = self.instance_eval(&url) if url.is_a?(Proc)
14
+
15
+ classes = []
16
+ classes << "active" if current_menu_item == i[:name]
17
+
18
+ concat(content_tag(:li, :class => classes) do
19
+ concat(link_to(title, url))
20
+ end)
21
+ end
22
+ end
23
+ end
24
+
25
+ def render_breadcrumbs
26
+ if has_breadcrumbs?
27
+ content_tag(:ul, :class => "breadcrumb") do
28
+ @breadcrumbs.each do |b|
29
+ unless @breadcrumbs.last == b
30
+ concat(content_tag(:li) do
31
+ concat(link_to(b[:name].is_a?(Symbol) ? tw(b[:name]) : b[:name], b[:url]))
32
+ end)
33
+ else
34
+ concat(content_tag(:li, :class => "active") do
35
+ concat(b[:name].is_a?(Symbol) ? tw(b[:name]) : b[:name])
36
+ end)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def link_to_context_attributes_overview list, options = {}
44
+ link_to context_variables_list_path(id: list, context: list.context_name), data: {toggle: "modal", target: "#modal-generic"}, class: ["link link-help", options[:class]] do
45
+ html = concat(icon(:list))
46
+ html.concat(" ").concat(list.context_name) if options[:text]
47
+ end if list.try(:context_name)
48
+ end
49
+
50
+ def render_context_attributes_info list
51
+ render partial: "maily_herald/webui/shared/context_attributes", locals: {list: list}
52
+ end
53
+
54
+ def display_context_attributes attributes
55
+ content_tag(:ul) do
56
+ attributes.each do |k, v|
57
+ if v.is_a?(Hash)
58
+ concat(content_tag(:li) do
59
+ concat(k)
60
+ concat(display_context_attributes(v))
61
+ end)
62
+ else
63
+ concat(content_tag(:li, k))
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ def content_for_expert
70
+ yield if expert_mode?
71
+ end
72
+
73
+ def work_mode_t mode
74
+ t(mode, {scope: [:maily_herald, :webui, :work_modes]})
75
+ end
76
+
77
+ def tw(key, options = {})
78
+ t(key, {scope: [:maily_herald, :webui]}.merge(options))
79
+ end
80
+
81
+ def friendly_name obj
82
+ return unless obj
83
+ obj.respond_to?(:title) && obj.title.present? ? obj.title : obj.try(:name)
84
+ end
85
+
86
+ def form_for(object, options = {}, &block)
87
+ options.reverse_merge!({builder: MailyHerald::Webui::FormBuilder})
88
+ layout = case options[:layout]
89
+ when :inline
90
+ "form-inline"
91
+ when :horizontal
92
+ "form-horizontal"
93
+ end
94
+ if layout
95
+ options[:html] ||= {}
96
+ options[:html][:class] = [options[:html][:class], layout].compact.join(" ")
97
+ end
98
+
99
+ super(object, options, &block)
100
+ end
101
+
102
+ def icon(icon, text="", html_options={})
103
+ content_class = "fa fa-#{icon}"
104
+ content_class << " #{html_options[:class]}" if html_options.key?(:class)
105
+ html_options[:class] = content_class
106
+
107
+ html = content_tag(:i, nil, html_options)
108
+ html << " #{text}" unless text.blank?
109
+ html.html_safe
110
+ end
111
+
112
+ def boolean_icon value, options = {}
113
+ options = {
114
+ :style => :check,
115
+ :text => :active,
116
+ }.merge(options)
117
+
118
+ i = case options[:style]
119
+ when :check
120
+ value ? "check-square-o" : "square-o"
121
+ when :toggle
122
+ value ? "toggle-on" : "toggle-off"
123
+ end
124
+
125
+ text = case options[:text]
126
+ when :active
127
+ value ? tw("commons.active") : tw("commons.inactive")
128
+ when :enabled
129
+ value ? tw("commons.enabled") : tw("commons.disabled")
130
+ when :yes
131
+ value ? tw("commons.positive") : tw("commons.negative")
132
+ end
133
+
134
+ icon(i, text)
135
+ end
136
+
137
+ def display_help_icon title, options = {}
138
+ link_to "#", class: "link link-help", data: {toggle: "tooltip", placement: options[:placement] || "right"}, title: (options[:scope] ? tw("#{options[:scope]}.help.#{title}") : t(".help.#{title}")) do
139
+ icon(:question)
140
+ end
141
+ end
142
+
143
+ def filter_box field_name = :filter
144
+ content_tag(:div, class: "filter filter-search") do
145
+ concat(text_field_tag(field_name, params[field_name], class: "search form-control", placeholder: "Search...", autocomplete: "off"))
146
+ concat(button_tag(class: "btn", type: "submit") do
147
+ icon(:search)
148
+ end)
149
+ end
150
+ end
151
+
152
+ def smart_listing_config_profile
153
+ :maily_herald
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,18 @@
1
+ module MailyHerald
2
+ module Webui
3
+ module DispatchesHelper
4
+ def display_dispatch_state s
5
+ content_tag(:span) do
6
+ case s.state
7
+ when :enabled
8
+ boolean_icon true, style: :toggle, text: :enabled
9
+ when :disabled
10
+ boolean_icon false, style: :toggle, text: :enabled
11
+ when :archived
12
+ icon("archive", tw("commons.archived"))
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ module MailyHerald
2
+ module Webui
3
+ module LogsHelper
4
+ def log_actions log
5
+ actions = []
6
+ subscription = log.mailing.list.subscription_for(log.entity) if log.entity
7
+ actions << {
8
+ name: :custom,
9
+ url: subscription_path(subscription),
10
+ icon: "fa fa-book",
11
+ title: tw("label_subscription")
12
+ } if subscription && !@item.is_a?(Subscription)
13
+ actions << {
14
+ name: :custom,
15
+ url: preview_log_path(log),
16
+ icon: "fa fa-file-o",
17
+ data: {
18
+ toggle: "modal",
19
+ target: "#modal-generic"
20
+ }
21
+ }
22
+ end
23
+
24
+ def display_log_status log
25
+ case log.status
26
+ when :delivered
27
+ content_tag(:span, icon(:check, tw("logs.status.delivered")), class: "text-success")
28
+ when :skipped
29
+ when :error
30
+ content_tag(:span, icon(:exclamation, tw("logs.status.error")), class: "text-danger")
31
+ when :scheduled
32
+ content_tag(:span, icon(:"clock-o", tw("logs.status.scheduled")), class: "text-muted")
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,64 @@
1
+ module MailyHerald
2
+ module Webui
3
+ module MailingsHelper
4
+ def display_mailing_mailer mailer
5
+ content_tag(:code, class: "mailing-mailer") do
6
+ if mailer == :generic
7
+ icon(:cubes, tw(:label_generic_mailer))
8
+ else
9
+ icon("file-code-o", mailer)
10
+ end
11
+ end
12
+ end
13
+
14
+ def mailing_subscriber_actions mailing, entity
15
+ actions = []
16
+ actions << {
17
+ name: :custom,
18
+ url: deliver_one_time_mailing_path(mailing, entity),
19
+ icon: "fa fa-paper-plane",
20
+ title: tw("mailings.list.deliver"),
21
+ if: mailing.processable?(entity),
22
+ remote: true,
23
+ method: :post,
24
+ confirm: tw("mailings.list.deliver_confirm")
25
+ } if mailing.one_time?
26
+ actions << {
27
+ name: :custom,
28
+ url: {action: :preview, id: mailing, entity_id: entity},
29
+ icon: "fa fa-search",
30
+ title: tw("mailings.list.preview"),
31
+ data: {
32
+ toggle: "modal",
33
+ target: "#modal-generic"
34
+ }
35
+ }
36
+ end
37
+
38
+ def url_for_mailing mailing
39
+ if mailing.sequence?
40
+ sequence_mailing_path(mailing.sequence_id, mailing)
41
+ else
42
+ url_for(mailing)
43
+ end
44
+ end
45
+
46
+ def link_to_mailing mailing
47
+ link_to friendly_name(mailing), url_for_mailing(mailing)
48
+ end
49
+
50
+ def display_mailing_from mailing
51
+ tw("mailings.from.default", email: mailing.mailer.default[:from])
52
+ end
53
+
54
+ def display_mailing_period mailing
55
+ #tw("commons.day", count: mailing.period_in_days)
56
+ distance_of_time_in_words mailing.period
57
+ end
58
+
59
+ def display_mailing_absolute_delay mailing
60
+ distance_of_time_in_words mailing.absolute_delay
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,13 @@
1
+ module MailyHerald
2
+ module Webui
3
+ module SequenceMailingsHelper
4
+ def sequence_mailing_actions mailing
5
+ actions = []
6
+ actions << {
7
+ name: :show,
8
+ url: sequence_mailing_path(mailing),
9
+ }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ module MailyHerald
2
+ module Webui
3
+ module SequencesHelper
4
+ end
5
+ end
6
+ end