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,148 @@
1
+ module ClarkKent
2
+ module Reportable
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+
7
+ def chain_up(query, params)
8
+ params.each do |key,val|
9
+ arel_method_name = self.arel_method_for(key)
10
+ if arel_method_name.present? and self.respond_to? arel_method_name and val.present?
11
+ query = self.send(arel_method_name, query, key, val)
12
+ end
13
+ end
14
+
15
+ query
16
+ end
17
+
18
+ def report(params,report,count = false)
19
+ @selects = []
20
+ @includes = []
21
+ @joins = []
22
+ @extra_scopes = []
23
+ @extra_filters = []
24
+ @groups = []
25
+ if 'ClarkKent::ReportEmail' == report.class.name
26
+ @report_email = report
27
+ report = @report_email.report
28
+ end
29
+ if count == false
30
+ report.select_clauses.each do |select_clause|
31
+ @selects.push select_clause
32
+ end
33
+ end
34
+ report.arel_includes.each do |arel_include|
35
+ @includes.push arel_include
36
+ end
37
+ report.arel_joins.each do |arel_join|
38
+ @joins.push arel_join
39
+ end
40
+ report.extra_scopes.each do |extra_scope|
41
+ @extra_scopes.push extra_scope
42
+ end
43
+ report.extra_filters.each do |extra_filter|
44
+ @extra_filters.push extra_filter
45
+ end
46
+ report.groups.each do |grouper|
47
+ @groups.push grouper
48
+ end
49
+ query = self.all
50
+ if @report_email and @report_email.is_a? ClarkKent::ReportEmail
51
+ params = @report_email.report_filter_params.symbolize_keys!.merge(params)
52
+ else
53
+ params = report.report_filter_params.symbolize_keys!.merge(params)
54
+ end
55
+ params.each do |param_type,param_value|
56
+ if param_value.present?
57
+ arel_method_name = self.arel_method_for(param_type)
58
+ if arel_method_name.present?
59
+ query = self.send(arel_method_name, query, param_type, param_value)
60
+ report_column_options = report.column_options_for(param_type)
61
+ if(report_column_options.respond_to? :joins) && (@joins.exclude? report_column_options.joins)
62
+ @joins.push report_column_options.joins
63
+ end
64
+ if(report_column_options.respond_to? :includes) && (@includes.exclude? report_column_options.includes)
65
+ @includes.push report_column_options.includes
66
+ end
67
+ if (count == false) && (report_column_options.respond_to? :custom_select) && (@selects.exclude? report_column_options.custom_select)
68
+ @selects.push report_column_options.custom_select
69
+ end
70
+ end
71
+ end
72
+ end
73
+ if @selects.any?
74
+ query = query.select("DISTINCT " + self.column_names.map{|cn| self.table_name + '.' + cn}.join(', '))
75
+ @selects.uniq.each do |selectable|
76
+ query = query.select(selectable)
77
+ end
78
+ end
79
+ @includes.uniq.each do |includeable|
80
+ query = query.includes(includeable)
81
+ end if @includes.any?
82
+ @extra_scopes.uniq.each do |extra_scope|
83
+ query = query.send(extra_scope)
84
+ end if @extra_scopes.any?
85
+ @extra_filters.uniq.each do |extra_filter|
86
+ query = query.where(extra_filter)
87
+ end if @extra_filters.any?
88
+ @joins.uniq.each do |joinable|
89
+ query = query.joins(joinable).uniq
90
+ end if @joins.any?
91
+ @groups.uniq.each do |grouper|
92
+ query = query.group(grouper)
93
+ end if @groups.any?
94
+
95
+ if count == true
96
+ return query.count
97
+ else
98
+ return query
99
+ end
100
+
101
+ end
102
+
103
+ def arel_method_for(param_type)
104
+ method_name = self::AREL_METHODS[param_type.to_s]
105
+ method_name ||= "#{param_type}_arel" if self.respond_to? "#{param_type}_arel"
106
+ method_name
107
+ end
108
+
109
+ def simple_equality_arel(query, field_name, match_value)
110
+ query.
111
+ where(field_name.to_sym => match_value)
112
+ end
113
+
114
+ def before_date_arel(query, field_name, match_value)
115
+ query.
116
+ where("#{self.table_name}.#{field_name.to_s.sub(/_until/,'')} <= :date_limit", date_limit: match_value)
117
+ end
118
+
119
+ def after_date_arel(query, field_name, match_value)
120
+ query.
121
+ where("#{self.table_name}.#{field_name.to_s.sub(/_from/,'')} >= :date_limit", date_limit: match_value)
122
+ end
123
+
124
+ def order_arel(query, field_name, match_value)
125
+ if match_value.is_a? Map
126
+ order_column = match_value.order_column
127
+ order_direction = match_value.order_direction
128
+ else
129
+ order_column, order_direction = match_value.split('-')
130
+ end
131
+ column_info = self::REPORT_COLUMN_OPTIONS[order_column.to_sym]
132
+ if column_info.respond_to? :order_sql
133
+ order_sql = column_info.order_sql
134
+ order_sql = "#{order_sql} #{order_direction}"
135
+ query = query.order(order_sql)
136
+ if column_info.respond_to? :includes
137
+ order_includes = column_info.includes
138
+ query = query.includes(order_includes).references(order_includes)
139
+ end
140
+ query
141
+ else
142
+ query
143
+ end
144
+ end
145
+
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,34 @@
1
+ module ClarkKent
2
+ class SharingScope
3
+
4
+ attr_accessor :parent
5
+
6
+ def initialize(record, parent)
7
+ @record = record
8
+ @parent = parent
9
+ end
10
+
11
+ def dom_id
12
+ str = parent.type
13
+ str += "_#{@record.id}" if @record.respond_to? :id
14
+ str += "_reports"
15
+ end
16
+
17
+ def human_name
18
+ if @record.respond_to? :name
19
+ @record.name
20
+ else
21
+ @record
22
+ end
23
+ end
24
+
25
+ def reports
26
+ if 'Everyone' == @record
27
+ ClarkKent::Report.shared
28
+ else
29
+ @record.clark_kent_reports
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,73 @@
1
+ module ClarkKent
2
+ class SharingScopeKind
3
+ attr_accessor :type, :name, :human_name, :class_name, :user_association
4
+
5
+ def self.all
6
+ return @ss_types if @ss_types
7
+ user_ss = self.new(ClarkKent.user_class_name)
8
+ @ss_types = [user_ss]
9
+ ClarkKent.other_sharing_scopes.each do |ss_type|
10
+ @ss_types << self.new(*ss_type)
11
+ end
12
+ @ss_types << self.new('Everyone')
13
+ @ss_types
14
+ end
15
+
16
+ def self.find_by_class_name(klass_name)
17
+ self.all.detect{|ssk| klass_name == ssk.class_name}
18
+ end
19
+
20
+ def self.custom
21
+ all.select{|ssk| ['everyone',ClarkKent.user_class_name.underscore].exclude? ssk.type}
22
+ end
23
+
24
+ def self.select_options
25
+ return @sharing_scope_options if @sharing_scope_options
26
+ @sharing_scope_options = {}
27
+ self.all.each do |sharing_scope|
28
+ @sharing_scope_options[sharing_scope.human_name] = sharing_scope.class_name
29
+ end
30
+ @sharing_scope_options
31
+ end
32
+
33
+ def initialize(class_name,user_association = nil)
34
+ if 'Everyone' == class_name
35
+ @class_name = ''
36
+ @human_name = 'Everyone'
37
+ else
38
+ @class_name = class_name
39
+ end
40
+ @user_association = user_association
41
+ end
42
+
43
+ def human_name
44
+ @human_name ||= @class_name.humanize
45
+ end
46
+
47
+ def type
48
+ human_name.gsub(' ','_').downcase
49
+ end
50
+
51
+ def basic_association_id_collection_name
52
+ (class_name.underscore + '_ids').to_sym
53
+ end
54
+
55
+ def associated_containers_for(user)
56
+ user.send @user_association
57
+ end
58
+
59
+ def scopes_for(user)
60
+ case type
61
+ when 'everyone'
62
+ [ClarkKent::SharingScope.new('Everyone',self)]
63
+ when ClarkKent.user_class_name.underscore
64
+ [ClarkKent::SharingScope.new(user,self)]
65
+ else
66
+ associated_containers_for(user).map do |associated_container|
67
+ ClarkKent::SharingScope.new(associated_container,self)
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,19 @@
1
+ module ClarkKent
2
+ class UserReportEmail < ActiveRecord::Base
3
+ belongs_to :user
4
+ belongs_to :report_email
5
+
6
+ attr_accessible :email, :report_email_id
7
+
8
+ validates_with UserEmailValidator
9
+
10
+ def email=(address)
11
+ self.user = User.where("lower(users.email) = lower(:email)",email: address).first
12
+ self.errors.add(:email, "Couldn't find a user with that email addres") unless self.user.present?
13
+ end
14
+
15
+ def email
16
+ self.user.try :email
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module ClarkKent
2
+ class UserEmailValidator < ActiveModel::Validator
3
+ def validate(record)
4
+ record.errors[:email] << "Couldn't find a user with that email address" unless record.user.present?
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,50 @@
1
+ <div class="ih-row editing">
2
+ <%= simple_form_for report_column,
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: report_column.new_record? ? '#report_column_list' : "#report_column_#{report_column.id}",
13
+ insert_method: report_column.new_record? ? 'append' : 'html',
14
+ container: '#new_report_column_container',
15
+ ajax_flash: true } } do |f| %>
16
+ <div class="ih-span one-fifth">
17
+ <%= f.input :report_id, as: :hidden %>
18
+ <% if report_column.new_record? %>
19
+ <%= f.input :column_name, collection: @report.available_columns, prompt: 'select column' %>
20
+ <% else %>
21
+ <div class="ih-row quiet">Column Name</div>
22
+ <div class="ih-row"><%= report_column.column_name %></div>
23
+ <% end %>
24
+ </div>
25
+ <div class="ih-span one-fifth">
26
+ <%= f.input :column_order %>
27
+ </div>
28
+ <div class="ih-span one-fifth">
29
+ <% if !report_column.new_record? and report_column.summarizable? %>
30
+ <%= f.input :summary_method, collection: ReportColumn::SummaryMethods %>
31
+ <% else %>
32
+ &nbsp;
33
+ <% end %>
34
+ </div>
35
+ <div class="ih-span one-fifth">
36
+ <% unless report_column.report.sort_column.present? and report_column.report.sort_column != report_column %>
37
+ <%= f.input :report_sort, collection: [['A->Z','ascending'],['Z->A','descending']], include_blank: true %>
38
+ <% end %>
39
+ </div>
40
+ <div class="ih-span right margin-top">
41
+ <%= f.button :submit %>
42
+ <% unless report_column.new_record? %>
43
+ &nbsp; <%= link_to 'cancel', report_column_url(report_column),
44
+ data: {
45
+ ajax_link: "true", ajax_target: "#report_column_#{report_column.id}" } %>
46
+ &nbsp; <%= link_to '&otimes;'.html_safe, report_column_url(report_column), class: "delete", data: {ajax_delete: "true", ajax_target: "#report_column_#{report_column.id}" }, tabindex: "-1" %>
47
+ <% end %>
48
+ </div>
49
+ <% end %>
50
+ </div>
@@ -0,0 +1,16 @@
1
+ <div id="report_column_container">
2
+ <h3>Report Columns</h3>
3
+ <div id="report_column_list" class="ih-row">
4
+ <% for report_column in @report.report_columns %>
5
+ <%= render partial: '/clark_kent/report_columns/show_wrapper', locals: {report_column: report_column} %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div class="ih-row margin-top">
10
+ <%= link_to 'Add a Column', new_report_column_url(report_id: @report.id), class: 'btn btn-primary', data: {ajax_link: "true", ajax_target: '#new_report_column_container'} %>
11
+ </div>
12
+
13
+ <div id="new_report_column_container" class="ih-row margin-top">
14
+
15
+ </div>
16
+ </div>
@@ -0,0 +1,20 @@
1
+ <div class="ih-row read-only">
2
+ <div class="ih-span one-fifth">
3
+ <%= report_column.column_name %>
4
+ </div>
5
+ <div class="ih-span one-fifth">
6
+ <%= report_column.column_order %>
7
+ </div>
8
+ <div class="ih-span one-fifth">
9
+ <%= report_column.summary_method.present? ? "summarize: #{report_column.summary_method}" : '' %>
10
+ </div>
11
+ <div class="ih-span one-fifth">
12
+ <%= report_column.report_sort_pretty %>
13
+ </div>
14
+ <div class="ih-span right">
15
+ <%= link_to 'edit', edit_report_column_url(report_column),
16
+ data: {
17
+ ajax_link: true,
18
+ ajax_target: "#report_column_#{report_column.id}" } %>
19
+ </div>
20
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="report_column_<%= report_column.id %>">
2
+ <%= render partial: '/clark_kent/report_columns/show', locals: {report_column: report_column} %>
3
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="ih-row editing">
2
+ <%= render partial: '/clark_kent/report_emails/form', locals: {report_email: report_email} %>
3
+ <% unless report_email.new_record? %>
4
+ <div class="well margin-top ih-row">
5
+ <%= render partial: '/clark_kent/report_filters/index', locals: {filterable: report_email} %>
6
+ </div>
7
+ <div class="well margin-top ih-row">
8
+ <%= render partial: '/clark_kent/user_report_emails/index', locals: {report_email: report_email} %>
9
+ </div>
10
+ <% end %>
11
+
12
+ </div>
@@ -0,0 +1,34 @@
1
+ <%= simple_form_for report_email,
2
+ as: report_email,
3
+ url: report_email.new_record? ? report_emails_url : report_email_url(report_email),
4
+ defaults: {
5
+ wrapper_html: { class: 'span2'},
6
+ input_html: { class: 'input-medium' },
7
+ label_html: { class: 'quiet'}},
8
+ html: {
9
+ class: 'form-inline',
10
+ data: {
11
+ ajax_form: true,
12
+ sub_type: "AddALineForm",
13
+ ajax_target: report_email.new_record? ? '#report_email_list' : "#report_email_#{report_email.id}",
14
+ error_target: "new_report_email_container_#{report_email.report_id}",
15
+ insert_method: report_email.new_record? ? 'append' : 'html',
16
+ container: "new_report_email_container_#{report_email.report_id}",
17
+ ajax_flash: true }} do |f| %>
18
+ <div class="ih-span one-third">
19
+ <%= f.input :name %>
20
+ </div>
21
+ <div class="ih-span one-third">
22
+ <%= f.input :report_id, as: :hidden %>
23
+ <%= f.input :when_to_send, collection: ClarkKent::ReportEmail::SEND_TIMES, include_blank: false %>
24
+ </div>
25
+ <div class="ih-span one-third right margin-top">
26
+ <%= f.button :submit %>
27
+ <% unless report_email.new_record? %>
28
+ &nbsp; <%= link_to 'cancel', report_email_url(report_email),
29
+ data: {ajax_link: "true", ajax_target: "#report_email_#{report_email.id}" } %>
30
+ &nbsp; <%= link_to '&otimes;'.html_safe, report_email_url(report_email), class: "delete", data: {ajax_delete: "true", ajax_target: "#report_email_#{report_email.id}"}, tabindex: "-1" %>
31
+ <% end %>
32
+ </div>
33
+ <% end %>
34
+
@@ -0,0 +1,16 @@
1
+ <div id="report_email_container">
2
+ <h3>Timed Emails</h3>
3
+ <div id="report_email_list" class="ih-row">
4
+ <% for report_email in @report.report_emails %>
5
+ <%= render partial: '/clark_kent/report_emails/show_wrapper', locals: {report_email: report_email} %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div class="ih-row margin-top">
10
+ <%= link_to 'Add a timed email', new_report_email_url(report_id: @report.id), class: 'btn btn-primary', data: {ajax_link: "true", ajax_target: "#new_report_email_container_#{@report.id}" } %>
11
+ </div>
12
+
13
+ <div id="new_report_email_container_<%= @report.id %>" class="ih-row margin-top">
14
+
15
+ </div>
16
+ </div>
@@ -0,0 +1,17 @@
1
+ <div class="ih-row read-only">
2
+ <div class="ih-span one-quarter">
3
+ <%= report_email.name %> <span class="quiet">send</span> <%= report_email.when_to_send %>
4
+ </div>
5
+ <div class="ih-span one-quarter">
6
+ <%= link_to 'edit', edit_report_email_url(report_email),
7
+ data: {
8
+ ajax_link: true,
9
+ ajax_target: "#report_email_#{report_email.id}" } %>
10
+ </div>
11
+ <div class="ih-span one-quarter">
12
+ <%= report_email.period_pretty %>
13
+ </div>
14
+ <div class="ih-span one-quarter">
15
+ <%= display_for_value(report_email.emails) %>
16
+ </div>
17
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="report_email_<%= report_email.id %>">
2
+ <%= render partial: '/clark_kent/report_emails/show', locals: {report_email: report_email} %>
3
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= f.input :kind_of_day, collection: ClarkKent::ReportDateFilter::DayOptions, label: 'Report start: what kind of day?',
2
+ input_html: {data: {revealer: "true", sub_type: "FormFieldRevealer", revealer_children_id: "period_options_#{name}_#{f.object.object_id}"}} %>
3
+ <div data-revealer-target="period_options_<%= name %>_<%= f.object.object_id %>">
4
+ <%= f.input :offset, collection: ClarkKent::ReportDateFilter::WeekPeriodOptions, include_blank: false, label: 'Report start: when?',
5
+ wrapper_html: {'data-revealer_id' => "period_options_#{name}_#{f.object.object_id}", 'data-revealer-triggers' => "['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']"} %>
6
+ <%= f.input :offset, collection: ClarkKent::ReportDateFilter::MonthPeriodOptions, include_blank: false, label: 'Report start: when?',
7
+ wrapper_html: {'data-revealer_id' => "period_options_#{name}_#{f.object.object_id}", 'data-revealer-triggers' => "['beginning of month','beginning of week']"} %>
8
+ </div>
9
+ <%= f.input :duration, collection: ClarkKent::ReportDateFilter::Durations %>
@@ -0,0 +1 @@
1
+ <%= report_filter.date_display %>
@@ -0,0 +1,58 @@
1
+ <div class="ih-row editing">
2
+ <%= simple_form_for report_filter,
3
+ as: report_filter,
4
+ url: report_filter.new_record? ? report_filters_url : report_filter_url(report_filter),
5
+ defaults: {
6
+ wrapper_html: { class: 'span2'},
7
+ input_html: { class: 'input-medium' },
8
+ label_html: { class: 'quiet'}},
9
+ html: {
10
+ id: "report_filter_form_#{report_filter.object_id}",
11
+ class: 'form-inline',
12
+ data: {
13
+ ajax_form: true,
14
+ sub_type: "AddALineForm",
15
+ ajax_target: report_filter.new_record? ? "#report_filter_list_#{dom_id(report_filter.filterable)}" : "#report_filter_#{report_filter.id}",
16
+ insert_method: report_filter.new_record? ? 'append' : 'html',
17
+ container: "#new_report_filter_container_#{dom_id(report_filter.filterable)}",
18
+ ajax_flash: true } } do |f| %>
19
+ <div class="ih-span one-third">
20
+ <%= f.input :filterable_id, as: :hidden %>
21
+ <%= f.input :filterable_type, as: :hidden %>
22
+ <% if report_filter.new_record? %>
23
+ <%= f.input :filter_name, collection: report_filter.filterable.available_filter_options,
24
+ input_html: {
25
+ data: {
26
+ revealer: 'true',
27
+ sub_type: 'FormFieldRevealer',
28
+ revealer_children_id: "filter_value_options_#{report_filter.object_id}" },
29
+ id: "report_filter_filter_name_#{report_filter.object_id}"},
30
+ include_blank: false %>
31
+ <% else %>
32
+ <div class="ih-row quiet">Filter Name</div>
33
+ <div class="ih-row"><%= report_filter.filter_name %></div>
34
+ <% end %>
35
+ </div>
36
+ <% if report_filter.new_record? %>
37
+ <div class="ih-span one-third" data-revealer-target="filter_value_options_<%= report_filter.object_id %>">
38
+ <% report_filter.filterable.available_filters.each do |name,label| %>
39
+ <div data-revealer_id="filter_value_options_<%= report_filter.object_id %>" data-revealer-trigger="<%= name %>" id="filter_value_options_<%= name %>">
40
+ <%= render partial: report_filter.filterable.filter_kind(name) + '_edit', locals: {f: f, report_filter: report_filter, name: name} %>
41
+ </div>
42
+ <% end %>
43
+ </div>
44
+ <% else %>
45
+ <div class="ih-span one-third">
46
+ <%= render partial: report_filter.filterable.filter_kind(report_filter.filter_name) + '_edit', locals: {f: f, report_filter: report_filter, name: report_filter.filter_name} %>
47
+ </div>
48
+ <% end %>
49
+ <div class="ih-span right margin-top">
50
+ <%= f.button :submit %>
51
+ <% unless report_filter.new_record? %>
52
+ &nbsp; <%= link_to 'cancel', report_filter_url(report_filter),
53
+ data: {ajax_link: "true", ajax_target: "#report_filter_#{report_filter.id}"} %>
54
+ &nbsp; <%= link_to '&otimes;'.html_safe, report_filter_url(report_filter), class: "delete", data: {ajax_delete: "true", ajax_target: "#report_filter_#{report_filter.id}" }, tabindex: "-1" %>
55
+ <% end %>
56
+ </div>
57
+ <% end %>
58
+ </div>
@@ -0,0 +1,16 @@
1
+ <div id="report_filter_container_<%= dom_id(filterable) %>">
2
+ <h3><%= filterable.class.name.sub('ClarkKent::','').underscore.humanize %> Filters</h3>
3
+ <div id="report_filter_list_<%= dom_id(filterable) %>" class="ih-row">
4
+ <% for report_filter in filterable.report_filters %>
5
+ <%= render partial: '/clark_kent/report_filters/show_wrapper', locals: {report_filter: report_filter} %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div class="ih-row margin-top">
10
+ <%= link_to 'Add a Filter', new_report_filter_url(filterable_id: filterable.id, filterable_type: filterable.class.name), class: 'btn btn-primary', data: {ajax_link: "true", ajax_target: "#new_report_filter_container_#{dom_id(filterable)}" } %>
11
+ </div>
12
+
13
+ <div id="new_report_filter_container_<%= dom_id(filterable) %>" class="ih-row margin-top">
14
+
15
+ </div>
16
+ </div>
@@ -0,0 +1,2 @@
1
+ <%= f.input :min_value %>
2
+ <%= f.input :max_value %>
@@ -0,0 +1 @@
1
+ <%= report_filter.min_value %> - <%= report_filter.max_value %>
@@ -0,0 +1 @@
1
+ <%= f.input :filter_value, collection: @filter_collections.send(report_filter.filterable.collection_for(name)) %>
@@ -0,0 +1 @@
1
+ <%= report_filter.get_display_value %>
@@ -0,0 +1,14 @@
1
+ <div class="ih-row read-only">
2
+ <div class="ih-span one-third">
3
+ <%= report_filter.display_name %>
4
+ </div>
5
+ <div class="ih-span one-third">
6
+ <%= render partial: '/clark_kent/report_filters/' + report_filter.filterable.filter_kind(report_filter.filter_name) + '_show', locals: {report_filter: report_filter} %>
7
+ </div>
8
+ <div class="ih-span right">
9
+ <%= link_to 'edit', edit_report_filter_url(report_filter),
10
+ data: {
11
+ ajax_link: true,
12
+ ajax_target: "#report_filter_#{report_filter.id}" } %>
13
+ </div>
14
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="report_filter_<%= report_filter.id %>">
2
+ <%= render partial: '/clark_kent/report_filters/show', locals: {report_filter: report_filter} %>
3
+ </div>
@@ -0,0 +1 @@
1
+ <%= report_filter.filter_value %>
@@ -0,0 +1,2 @@
1
+ Click this link to download your report:
2
+ <a href="<%= @report_download_url %>"><%= @report.name %></a>
@@ -0,0 +1,23 @@
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
+ from<br>
8
+ <%= text_field_tag "#{filter.param}_from",
9
+ params["#{filter.param}_from"],
10
+ data: {date_picker: 'true', sub_type: 'DatePickerLoader'},
11
+ class: 'string input-small',
12
+ id: "#{filter.param}_start_date" %>
13
+ </div>
14
+ <div class="ih-span">
15
+ to<br>
16
+ <%= text_field_tag "#{filter.param}_until",
17
+ params["#{filter.param}_until"],
18
+ data: {date_picker: 'true', sub_type: 'DatePickerLoader'},
19
+ class: 'string input-small',
20
+ id: "#{filter.param}_end_date" %>
21
+ </div>
22
+ </div>
23
+ </div>
@@ -0,0 +1,14 @@
1
+ <% if @report_result_name %>
2
+ <%= link_to 're-download full csv', '',
3
+ data: {
4
+ listener: true,
5
+ channel: @report_result_name,
6
+ key: 'report_result_url',
7
+ progress_indicator: true,
8
+ trigger_on_message: true } %>
9
+ <% else %>
10
+ <%= link_to 'download full csv', (download_link_report_url(@report.id) + '?' + request.query_parameters.to_param),
11
+ data: {
12
+ ajax_link: true,
13
+ ajax_target: '#download_link' } %>
14
+ <% end %>