clark_kent 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/clark_kent/application.js +13 -0
  6. data/app/assets/javascripts/clark_kent/reports.js +10 -0
  7. data/app/assets/stylesheets/_reports.scss +67 -0
  8. data/app/assets/stylesheets/_reports_print.scss +44 -0
  9. data/app/assets/stylesheets/clark_kent/application.css +15 -0
  10. data/app/assets/stylesheets/clark_kent/reports.css +4 -0
  11. data/app/assets/stylesheets/scaffold.css +56 -0
  12. data/app/controllers/clark_kent/application_controller.rb +2 -0
  13. data/app/controllers/clark_kent/report_columns_controller.rb +47 -0
  14. data/app/controllers/clark_kent/report_emails_controller.rb +47 -0
  15. data/app/controllers/clark_kent/report_filters_controller.rb +51 -0
  16. data/app/controllers/clark_kent/reports_controller.rb +79 -0
  17. data/app/controllers/clark_kent/user_report_emails_controller.rb +53 -0
  18. data/app/helpers/clark_kent/application_helper.rb +70 -0
  19. data/app/mailers/clark_kent/report_mailer.rb +15 -0
  20. data/app/models/clark_kent/report.rb +272 -0
  21. data/app/models/clark_kent/report_column.rb +24 -0
  22. data/app/models/clark_kent/report_date_filter.rb +81 -0
  23. data/app/models/clark_kent/report_email.rb +105 -0
  24. data/app/models/clark_kent/report_filter.rb +26 -0
  25. data/app/models/clark_kent/report_filter_option.rb +18 -0
  26. data/app/models/clark_kent/report_number_filter.rb +20 -0
  27. data/app/models/clark_kent/report_object_filter.rb +27 -0
  28. data/app/models/clark_kent/report_result.rb +55 -0
  29. data/app/models/clark_kent/report_string_filter.rb +5 -0
  30. data/app/models/clark_kent/reportable.rb +148 -0
  31. data/app/models/clark_kent/sharing_scope.rb +34 -0
  32. data/app/models/clark_kent/sharing_scope_kind.rb +73 -0
  33. data/app/models/clark_kent/user_report_email.rb +19 -0
  34. data/app/validators/clark_kent/user_email_validator.rb +7 -0
  35. data/app/views/clark_kent/report_columns/_form.html.erb +50 -0
  36. data/app/views/clark_kent/report_columns/_index.html.erb +16 -0
  37. data/app/views/clark_kent/report_columns/_show.html.erb +20 -0
  38. data/app/views/clark_kent/report_columns/_show_wrapper.html.erb +3 -0
  39. data/app/views/clark_kent/report_emails/_edit.html.erb +12 -0
  40. data/app/views/clark_kent/report_emails/_form.html.erb +34 -0
  41. data/app/views/clark_kent/report_emails/_index.html.erb +16 -0
  42. data/app/views/clark_kent/report_emails/_show.html.erb +17 -0
  43. data/app/views/clark_kent/report_emails/_show_wrapper.html.erb +3 -0
  44. data/app/views/clark_kent/report_filters/_date_filter_edit.html.erb +9 -0
  45. data/app/views/clark_kent/report_filters/_date_filter_show.html.erb +1 -0
  46. data/app/views/clark_kent/report_filters/_form.html.erb +58 -0
  47. data/app/views/clark_kent/report_filters/_index.html.erb +16 -0
  48. data/app/views/clark_kent/report_filters/_number_filter_edit.html.erb +2 -0
  49. data/app/views/clark_kent/report_filters/_number_filter_show.html.erb +1 -0
  50. data/app/views/clark_kent/report_filters/_object_filter_edit.html.erb +1 -0
  51. data/app/views/clark_kent/report_filters/_object_filter_show.html.erb +1 -0
  52. data/app/views/clark_kent/report_filters/_show.html.erb +14 -0
  53. data/app/views/clark_kent/report_filters/_show_wrapper.html.erb +3 -0
  54. data/app/views/clark_kent/report_filters/_string_filter_edit.html.erb +0 -0
  55. data/app/views/clark_kent/report_filters/_string_filter_show.html.erb +1 -0
  56. data/app/views/clark_kent/report_mailer/report_run.html.erb +2 -0
  57. data/app/views/clark_kent/reports/_date_filter.html.erb +23 -0
  58. data/app/views/clark_kent/reports/_download_link.html.erb +14 -0
  59. data/app/views/clark_kent/reports/_edit.html.erb +47 -0
  60. data/app/views/clark_kent/reports/_form.html.erb +33 -0
  61. data/app/views/clark_kent/reports/_number_filter.html.erb +21 -0
  62. data/app/views/clark_kent/reports/_object_filter.html.erb +15 -0
  63. data/app/views/clark_kent/reports/_print_report.html.erb +30 -0
  64. data/app/views/clark_kent/reports/_show.html.erb +21 -0
  65. data/app/views/clark_kent/reports/_string_filter.html.erb +9 -0
  66. data/app/views/clark_kent/reports/edit.html.erb +21 -0
  67. data/app/views/clark_kent/reports/index.html.erb +22 -0
  68. data/app/views/clark_kent/reports/new.html.erb +9 -0
  69. data/app/views/clark_kent/reports/show.html.erb +43 -0
  70. data/app/views/clark_kent/user_report_emails/_form.html.erb +40 -0
  71. data/app/views/clark_kent/user_report_emails/_index.html.erb +16 -0
  72. data/app/views/clark_kent/user_report_emails/_show.html.erb +11 -0
  73. data/app/views/clark_kent/user_report_emails/_show_wrapper.html.erb +3 -0
  74. data/config/routes.rb +13 -0
  75. data/db/migrate/20150304233739_create_clark_kent_reports.rb +12 -0
  76. data/lib/clark_kent/engine.rb +5 -0
  77. data/lib/clark_kent/version.rb +3 -0
  78. data/lib/clark_kent.rb +20 -0
  79. data/lib/tasks/clark_kent_tasks.rake +4 -0
  80. data/test/clark_kent_test.rb +7 -0
  81. data/test/controllers/clark_kent/reports_controller_test.rb +51 -0
  82. data/test/dummy/README.rdoc +28 -0
  83. data/test/dummy/Rakefile +6 -0
  84. data/test/dummy/app/assets/javascripts/application.js +13 -0
  85. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  86. data/test/dummy/app/controllers/application_controller.rb +5 -0
  87. data/test/dummy/app/helpers/application_helper.rb +2 -0
  88. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  89. data/test/dummy/bin/bundle +3 -0
  90. data/test/dummy/bin/rails +4 -0
  91. data/test/dummy/bin/rake +4 -0
  92. data/test/dummy/config/application.rb +23 -0
  93. data/test/dummy/config/boot.rb +5 -0
  94. data/test/dummy/config/database.yml +25 -0
  95. data/test/dummy/config/environment.rb +5 -0
  96. data/test/dummy/config/environments/development.rb +37 -0
  97. data/test/dummy/config/environments/production.rb +78 -0
  98. data/test/dummy/config/environments/test.rb +39 -0
  99. data/test/dummy/config/initializers/assets.rb +8 -0
  100. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  101. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  102. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  103. data/test/dummy/config/initializers/inflections.rb +16 -0
  104. data/test/dummy/config/initializers/mime_types.rb +4 -0
  105. data/test/dummy/config/initializers/session_store.rb +3 -0
  106. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  107. data/test/dummy/config/locales/en.yml +23 -0
  108. data/test/dummy/config/routes.rb +4 -0
  109. data/test/dummy/config/secrets.yml +22 -0
  110. data/test/dummy/config.ru +4 -0
  111. data/test/dummy/db/development.sqlite3 +0 -0
  112. data/test/dummy/db/schema.rb +25 -0
  113. data/test/dummy/log/development.log +35 -0
  114. data/test/dummy/public/404.html +67 -0
  115. data/test/dummy/public/422.html +67 -0
  116. data/test/dummy/public/500.html +66 -0
  117. data/test/dummy/public/favicon.ico +0 -0
  118. data/test/dummy/tmp/cache/assets/development/sprockets/0a5b3da98f8307d16bc302a1f7206591 +0 -0
  119. data/test/dummy/tmp/cache/assets/development/sprockets/0a9995208f1340e4b34008cbd5b73c64 +0 -0
  120. data/test/dummy/tmp/cache/assets/development/sprockets/0ec37c0a58c1be93659732a3efc73581 +0 -0
  121. data/test/dummy/tmp/cache/assets/development/sprockets/0fd54fd98cd2fa0085b77e6743046927 +0 -0
  122. data/test/dummy/tmp/cache/assets/development/sprockets/5d3db72d44bc30497bd84a40d2002e12 +0 -0
  123. data/test/dummy/tmp/cache/assets/development/sprockets/60fb63be4cad769d9adc90c4c5501c67 +0 -0
  124. data/test/dummy/tmp/cache/assets/development/sprockets/8aa37926d964a9eb59cf9b940e4fe2f4 +0 -0
  125. data/test/dummy/tmp/cache/assets/development/sprockets/8dd3bd27ebbaecaf6c7ee8ed81be5bde +0 -0
  126. data/test/dummy/tmp/cache/assets/development/sprockets/92058832b745b88c29a75bf2aad7245d +0 -0
  127. data/test/dummy/tmp/cache/assets/development/sprockets/ba6c7581456ee0f828ace58e4856a9f4 +0 -0
  128. data/test/dummy/tmp/cache/assets/development/sprockets/ebe8eac74b8e6016fd44b19e6e708e61 +0 -0
  129. data/test/dummy/tmp/cache/assets/development/sprockets/f23dd414c3bac1b6833d2aa9e62fbedd +0 -0
  130. data/test/fixtures/clark_kent/reports.yml +13 -0
  131. data/test/helpers/clark_kent/reports_helper_test.rb +6 -0
  132. data/test/integration/navigation_test.rb +10 -0
  133. data/test/models/clark_kent/report_test.rb +9 -0
  134. data/test/test_helper.rb +17 -0
  135. metadata +260 -0
@@ -0,0 +1,47 @@
1
+ <div class="ih-row">
2
+ <%= simple_form_for @report, html: @report.persisted? ? {
3
+ data: {
4
+ ajax_form: true,
5
+ ajax_target: '#report_info_container' }
6
+ } : {} do |f| %>
7
+ <div class="ih-span one-quarter">
8
+ <%= f.input :name %>
9
+ </div>
10
+ <div class="ih-span one-quarter">
11
+ <%= f.input :resource_type,
12
+ collection: ClarkKent.resource_options,
13
+ label: 'A row for every:' %>
14
+
15
+ </div>
16
+ <div class="ih-span one-quarter">
17
+ <div class="ih-row">sharing</div>
18
+ <div class="ih-row">
19
+ <%= f.input :sharing_scope_type, collection: ClarkKent::SharingScopeKind.select_options,
20
+ input_html: {data: {revealer: true, sub_type: "FormFieldRevealer", revealer_children_id: "sharing_options"}},
21
+ label: false, include_blank: false %>
22
+ </div>
23
+ <div class="ih-row" data-revealer-target="sharing_options">
24
+ <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: current_user.id}, wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => ClarkKent.user_class_name, id: "sharing_options_#{ClarkKent.user_class_name}"} %>
25
+ <% ClarkKent::SharingScopeKind.custom.each do |sharing_scope_kind| %>
26
+ <%= f.input :sharing_scope_id, collection: sharing_scope_kind.associated_containers_for(current_user), label: false, include_blank: false,
27
+ wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => sharing_scope_kind.class_name, id: "sharing_options_#{sharing_scope_kind.class_name}"} %>
28
+ <% end %>
29
+ <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: ''},
30
+ wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => "", id: "sharing_options_"} %>
31
+ </div>
32
+ </div>
33
+ <div class="ih-span one-quarter margin-top right">
34
+ <div class="ih-row">
35
+ <%= f.button :submit %>
36
+ <% unless @report.new_record? %>
37
+ &nbsp; <%= ajax_link 'cancel', report_url(@report), {class: 'right'}, "#report_info_container" %>
38
+ }
39
+ </div>
40
+ <div class="ih-row right">or</div>
41
+ <div class="ih-row">
42
+ <%= link_to "Delete Report", @report, class: 'right', :method=>:delete, :data => { delete_link: true, :confirm => "Are you sure you want to delete this report?" } %>
43
+ <% end %>
44
+ </div>
45
+ </div>
46
+ <% end %>
47
+ </div>
@@ -0,0 +1,33 @@
1
+ <%= form_for(@report) do |f| %>
2
+ <% if @report.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@report.errors.count, "error") %> prohibited this report from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @report.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :resource_type %><br>
20
+ <%= f.text_field :resource_type %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :sharing_scope_type %><br>
24
+ <%= f.text_field :sharing_scope_type %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :sharing_scope_id %><br>
28
+ <%= f.number_field :sharing_scope_id %>
29
+ </div>
30
+ <div class="actions">
31
+ <%= f.submit %>
32
+ </div>
33
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <div class="ih-span one-quarter">
2
+ <div class="ih-row">
3
+ <%= filter.label.humanize %>
4
+ </div>
5
+ <div class="ih-row">
6
+ <div class="ih-span">
7
+ min<br>
8
+ <%= number_field_tag "#{filter.param}_min",
9
+ params["#{filter.param}_min"],
10
+ class: 'string input-small',
11
+ id: "#{filter.param}_min" %>
12
+ </div>
13
+ <div class="ih-span">
14
+ max<br>
15
+ <%= text_field_tag "#{filter.param}_max",
16
+ params["#{filter.param}_max"],
17
+ class: 'string input-small',
18
+ id: "#{filter.param}_max" %>
19
+ </div>
20
+ </div>
21
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="ih-span one-quarter">
2
+ <div class="ih-row">
3
+ <%= filter.param.humanize %>
4
+ </div>
5
+ <div class="ih-row">
6
+ <% options = @filter_collections.send(filter.collection) %>
7
+ <%= select_tag filter.param,
8
+ options_from_collection_for_select(
9
+ options,
10
+ (select_value_method(filter.param,options.first)),
11
+ (select_text_method(filter.param,options.first)),
12
+ params[filter.param]), {include_blank: true}.merge((options.length > 25) ? {'data-autocomplete' => true} : {}) %>
13
+
14
+ </div>
15
+ </div>
@@ -0,0 +1,30 @@
1
+ <% if rows %>
2
+ <% if rows.total_count > rows.count(:id) %>
3
+ <%= link_to 'Print',
4
+ 'javascript:void(0)',
5
+ onclick: "$('#print_report_modal').modal('show');",
6
+ class: 'btn'
7
+ %>
8
+ <div id="print_report_modal" class="modal hide fade">
9
+ <div class="modal-header">
10
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
11
+ &nbsp;
12
+ </div>
13
+ <div class="modal-body">
14
+ <p> You will only be printing the current page of results (50 of <%= @rows.total_count %> total results).
15
+ To print all results click the <strong>download full csv</strong> link at the bottom of the page.</p>
16
+ <div class="row-fluid" >
17
+ <div class="span8"></div>
18
+ <div class="span1">
19
+ <%= print_button(@rows, true) %>
20
+ </div>
21
+ <div class="span1">
22
+ <button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ <% else %>
28
+ <%= print_button(@rows) %>
29
+ <% end %>
30
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <div class="ih-span one-quarter">
2
+ <%= @report.name %>
3
+ </div>
4
+ <div class="ih-span one-quarter">
5
+ <span class="quiet">a row for every</span> <%= @report.resource_type_pretty.singularize %>
6
+ </div>
7
+ <div class="ih-span one-quarter">
8
+ <span class="quite">shared with</span> <%= @report.sharing_scope_pretty %>
9
+ </div>
10
+ <div class="ih-span one-quarter right">
11
+ <%= link_to 'clone', clone_report_url(@report),
12
+ method: :post,
13
+ style: 'margin-left: 10px',
14
+ class: 'right' %>
15
+
16
+ <%= link_to 'edit', edit_report_url(@report),
17
+ data: {
18
+ ajax_link: true,
19
+ ajax_target: '#report_info_container' },
20
+ class: 'right' %>
21
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="ih-span one-quarter">
2
+ <div class="ih-row">
3
+ <%= filter.param.humanize %>
4
+ </div>
5
+ <div class="ih-row">
6
+ <%= text_field_tag filter.param, params[filter.param] %>
7
+
8
+ </div>
9
+ </div>
@@ -0,0 +1,21 @@
1
+ <h1> Editing report: <%= @report.name %></h1>
2
+ <%= link_to "&larr; back to report index".html_safe, reports_url %>
3
+
4
+
5
+ <div class="ih-row margin-top">
6
+ <div id="report_info_container">
7
+ <%= render partial: 'show' %>
8
+ </div>
9
+ </div>
10
+
11
+ <% unless @report.new_record? %>
12
+ <div class="well margin-top ih-row">
13
+ <%= render partial: '/clark_kent/report_filters/index', locals: {filterable: @report} %>
14
+ </div>
15
+ <div class="well margin-top ih-row">
16
+ <%= render partial: '/clark_kent/report_columns/index' %>
17
+ </div>
18
+ <div class="well margin-top ih-row">
19
+ <%= render partial: '/clark_kent/report_emails/index' %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <h1>Reports</h1>
2
+ <% ClarkKent::SharingScopeKind.all.each do |sharing_scope_kind| %>
3
+ <% sharing_scope_kind.scopes_for(current_user).each do |sharing_scope| %>
4
+ <% if sharing_scope.reports.any? %>
5
+ <div id="<%= sharing_scope.dom_id %>">
6
+ <h3><%= sharing_scope.human_name %></h3>
7
+ <% sharing_scope.reports.each do |report| %>
8
+ <%= link_to report.name, report_url(report) %> <%= link_to '(edit)', edit_report_url(report) %><br>
9
+ <% end %>
10
+ <% if 'everyone' == sharing_scope_kind.type %>
11
+ <% ClarkKent.custom_report_links.each do |link_text,link_path_string| %>
12
+ <%= link_to link_text, eval("main_app.#{link_path_string}") %><br>
13
+ <% end %>
14
+ <% end %>
15
+ </div>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ <hr>
20
+ <div id="controls">
21
+ <%= link_to "create a new report", new_report_path %>
22
+ </div>
@@ -0,0 +1,9 @@
1
+ <h1>Create a new report.</h1>
2
+ <%= link_to "&larr; back to report index".html_safe, reports_url %>
3
+
4
+
5
+ <div class="ih-row margin-top">
6
+ <div id="report_info_container">
7
+ <%= render partial: 'edit' %>
8
+ </div>
9
+ </div>
@@ -0,0 +1,43 @@
1
+ <h1><%= @report.name %></h1>
2
+ <%= link_to "&larr; back to report index".html_safe, reports_url, id: 'report_index' %>
3
+
4
+ <div class="ih-row margin-top">
5
+ <form action="<%= report_url(@report) %>" method="get">
6
+ <% @report.custom_filters.each do |filter| %>
7
+ <%= render partial: filter.kind, locals: {filter: filter} %>
8
+ <% end %>
9
+ <input type="hidden" name="run_report" value="true">
10
+ <%= button_tag 'Run Report', class: 'btn', style: 'margin-left: 0px' %>
11
+ <%= render partial: 'print_report', locals: {rows: @rows} %>
12
+ </form>
13
+ </div>
14
+ <% if @rows %>
15
+ <div class="ih-row margin-top">
16
+ <table class="stripey-table">
17
+ <tr>
18
+ <% @report.report_columns.sorted.each do |column| %>
19
+ <th>
20
+ <%=
21
+ @report.sortable?(column) ?
22
+ (link_to column.column_name, request.path + '?' + request.query_parameters.merge(order: "#{column.column_name}-#{get_temp_order_direction(params)}").to_param) :
23
+ column.column_name.humanize %> <%= get_selected_order_direction(params, column)
24
+ %>
25
+ </th>
26
+ <% end %>
27
+ </tr>
28
+ <% @rows.each do |row| %>
29
+ <tr>
30
+ <% @report.report_columns.each do |column| %>
31
+ <td><%= display_for_value(row[column.column_name], column.column_name) %></td>
32
+ <% end %>
33
+ </tr>
34
+ <% end if @rows.present? %>
35
+ </table>
36
+ </div>
37
+ <div class="ih-row margin-top">
38
+ <%= paginate @rows %>
39
+ <div id="download_link"><%= render partial: 'download_link' %></div>
40
+ </div>
41
+ <% end %>
42
+ <div class="ih-span">&nbsp;</div>
43
+
@@ -0,0 +1,40 @@
1
+ <div class="ih-row editing">
2
+ <%= simple_form_for user_report_email,
3
+ defaults: {
4
+ wrapper_html: { class: 'span2'},
5
+ input_html: { class: 'input-medium' },
6
+ label_html: { class: 'quiet'}},
7
+ html: {
8
+ class: 'form-inline',
9
+ data: {
10
+ ajax_form: true,
11
+ sub_type: "AddALineForm",
12
+ ajax_target: user_report_email.new_record? ? "#user_report_email_list_#{user_report_email.report_email_id}" : "#user_report_email_#{user_report_email.id}",
13
+ insert_method: user_report_email.new_record? ? 'append' : 'html',
14
+ error_target: "#new_user_report_email_container_#{user_report_email.report_email_id}",
15
+ container: "#new_user_report_email_container_#{user_report_email.report_email_id}",
16
+ ajax_flash: true }} do |f| %>
17
+ <div class="ih-span">
18
+ <%= f.input :report_email_id, as: :hidden %>
19
+ <% if user_report_email.new_record? %>
20
+ <%= f.input :email, label: 'email address' %>
21
+ <% else %>
22
+ <div class="ih-row"><%= user_report_email.email %></div>
23
+ <% end %>
24
+ </div>
25
+ <div class="ih-span right margin-top">
26
+ <%= f.button :submit %>
27
+ <% unless user_report_email.new_record? %>
28
+ &nbsp; <%= link_to 'cancel', user_report_email_url(user_report_email),
29
+ data: {
30
+ ajax_link: "true",
31
+ ajax_target: "#user_report_email_#{user_report_email.id}" } %>
32
+ &nbsp; <%= link_to '&otimes;'.html_safe, user_report_email_url(user_report_email),
33
+ class: "delete",
34
+ data: {
35
+ ajax_delete: "true", ajax_target: "#user_report_email_#{user_report_email.id}"},
36
+ tabindex: "-1" %>
37
+ <% end %>
38
+ </div>
39
+ <% end %>
40
+ </div>
@@ -0,0 +1,16 @@
1
+ <div id="user_report_emails_container_<%= report_email.id %>">
2
+ <h3>Who to email</h3>
3
+ <div id="user_report_email_list_<%= report_email.id %>" class="ih-row">
4
+ <% for user_report_email in report_email.user_report_emails %>
5
+ <%= render partial: '/clark_kent/user_report_emails/show_wrapper', locals: {user_report_email: user_report_email} %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div class="ih-row margin-top">
10
+ <%= link_to 'Add an email address', new_user_report_email_url(report_email_id: report_email.id), class: 'btn btn-primary', data: {ajax_link: "true", ajax_target: "#new_user_report_email_container_#{report_email.id}" } %>
11
+ </div>
12
+
13
+ <div id="new_user_report_email_container_<%= report_email.id %>" class="ih-row margin-top">
14
+
15
+ </div>
16
+ </div>
@@ -0,0 +1,11 @@
1
+ <div class="ih-row read-only">
2
+ <div class="ih-span">
3
+ <%= user_report_email.user.full_name %>
4
+ </div>
5
+ <div class="ih-span right">
6
+ <%= link_to 'edit', edit_user_report_email_url(user_report_email),
7
+ data: {
8
+ ajax_link: true,
9
+ ajax_target: "#user_report_email_#{user_report_email.id}" } %>
10
+ </div>
11
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="user_report_email_<%= user_report_email.id %>">
2
+ <%= render partial: '/clark_kent/user_report_emails/show', locals: {user_report_email: user_report_email} %>
3
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,13 @@
1
+ ClarkKent::Engine.routes.draw do
2
+ resources :reports do
3
+ member do
4
+ get :download_link
5
+ post :clone
6
+ end
7
+ end
8
+ resources :report_filters
9
+ resources :report_columns
10
+ resources :report_emails
11
+ resources :user_report_emails
12
+ root to: 'reports#index'
13
+ end
@@ -0,0 +1,12 @@
1
+ class CreateClarkKentReports < ActiveRecord::Migration
2
+ def change
3
+ create_table :clark_kent_reports do |t|
4
+ t.string :name
5
+ t.string :resource_type
6
+ t.string :sharing_scope_type
7
+ t.integer :sharing_scope_id
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module ClarkKent
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ClarkKent
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module ClarkKent
2
+ VERSION = "0.0.1"
3
+ end
data/lib/clark_kent.rb ADDED
@@ -0,0 +1,20 @@
1
+ require "clark_kent/engine"
2
+
3
+ module ClarkKent
4
+ mattr_accessor :resource_options, :user_class_name, :other_sharing_scopes, :base_controller,
5
+ :custom_report_links
6
+
7
+ def self.config(options)
8
+ @@resource_options = options[:resource_options]
9
+ @@user_class_name = options[:user_class_name]
10
+ @@other_sharing_scopes = options[:other_sharing_scopes]
11
+ base_controller_name = options[:base_controller_name]
12
+ @@base_controller = base_controller_name.constantize
13
+ @@custom_report_links = options[:custom_report_links]
14
+ end
15
+
16
+ def self.user_class
17
+ @@user_class = @@user_class_name.constantize
18
+ end
19
+
20
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :clark_kent do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ClarkKentTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, ClarkKent
6
+ end
7
+ end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module ClarkKent
4
+ class ReportsControllerTest < ActionController::TestCase
5
+ setup do
6
+ @report = reports(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:reports)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create report" do
21
+ assert_difference('Report.count') do
22
+ post :create, report: { name: @report.name, resource_type: @report.resource_type, sharing_scope_id: @report.sharing_scope_id, sharing_scope_type: @report.sharing_scope_type }
23
+ end
24
+
25
+ assert_redirected_to report_path(assigns(:report))
26
+ end
27
+
28
+ test "should show report" do
29
+ get :show, id: @report
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, id: @report
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update report" do
39
+ patch :update, id: @report, report: { name: @report.name, resource_type: @report.resource_type, sharing_scope_id: @report.sharing_scope_id, sharing_scope_type: @report.sharing_scope_type }
40
+ assert_redirected_to report_path(assigns(:report))
41
+ end
42
+
43
+ test "should destroy report" do
44
+ assert_difference('Report.count', -1) do
45
+ delete :destroy, id: @report
46
+ end
47
+
48
+ assert_redirected_to reports_path
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "clark_kent"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)