meta_reports 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +1 -0
  3. data/README.md +65 -12
  4. data/lib/generators/meta_reports/install_engine_generator.rb +4 -0
  5. data/{app/controllers/meta_reports → lib/generators/meta_reports/templates/controllers}/reports_controller.rb +0 -0
  6. data/lib/generators/meta_reports/templates/models/report.rb +19 -2
  7. data/lib/generators/meta_reports/templates/models/report_non_activerecord.rb +19 -2
  8. data/lib/meta_reports/version.rb +1 -1
  9. data/lib/tasks/meta_reports_tasks.rake +59 -4
  10. data/spec/dummy/app/assets/stylesheets/lib/metareports_color_variables.scss +9 -0
  11. data/spec/dummy/app/assets/stylesheets/lib/metareports_colors.scss +10 -0
  12. data/spec/dummy/app/controllers/meta_reports/reports_controller.rb +91 -0
  13. data/spec/dummy/app/models/meta_reports/report.rb +19 -3
  14. data/spec/dummy/db/development.sqlite3 +0 -0
  15. data/spec/dummy/db/migrate/{20130801071213_create_meta_reports_reports.rb → 20130801071213_for_testing_only.rb} +1 -1
  16. data/spec/dummy/db/schema.rb +5 -5
  17. data/spec/dummy/db/test.sqlite3 +0 -0
  18. data/spec/dummy/log/development.log +1285 -0
  19. data/spec/dummy/log/test.log +781 -0
  20. data/spec/dummy/tmp/cache/assets/CD1/A80/sprockets%2F25be813f3840b407d514e03973fbac40 +0 -0
  21. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  22. data/spec/dummy/tmp/cache/assets/CDC/FB0/sprockets%2F16b037c6f739184fc67a82dc140a3b83 +0 -0
  23. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  24. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  25. data/spec/dummy/tmp/cache/assets/DDC/340/sprockets%2F8ad88a197ff3462ea8dd3ad7b1e2b7e9 +0 -0
  26. data/spec/dummy/tmp/cache/assets/DF1/CD0/sprockets%2F3b66bd14b91d4fb176ce0a30ab5fd9bf +0 -0
  27. data/spec/dummy/tmp/cache/assets/test/sass/cd99a83fa417594c8715ee09005855a11886141c/metareports_color_variables.scssc +0 -0
  28. data/spec/dummy/tmp/cache/assets/test/sass/cd99a83fa417594c8715ee09005855a11886141c/metareports_colors.scssc +0 -0
  29. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  30. data/spec/dummy/tmp/cache/assets/test/sprockets/16b037c6f739184fc67a82dc140a3b83 +0 -0
  31. data/spec/dummy/tmp/cache/assets/test/sprockets/25be813f3840b407d514e03973fbac40 +0 -0
  32. data/spec/dummy/tmp/cache/assets/test/sprockets/2e7ca7e84b7c22471bbca0e4504a2597 +0 -0
  33. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  34. data/spec/dummy/tmp/cache/assets/test/sprockets/34d1d79bff5dc36e7f78550df20eec85 +0 -0
  35. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  36. data/spec/dummy/tmp/cache/assets/test/sprockets/3b66bd14b91d4fb176ce0a30ab5fd9bf +0 -0
  37. data/spec/dummy/tmp/cache/assets/test/sprockets/7d10cf1420e7efe789dd0a850b92fe72 +0 -0
  38. data/spec/dummy/tmp/cache/assets/test/sprockets/89b49044c6f7d85bbb660b73a9a4e181 +0 -0
  39. data/spec/dummy/tmp/cache/assets/test/sprockets/8ad88a197ff3462ea8dd3ad7b1e2b7e9 +0 -0
  40. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  41. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  42. data/spec/generators/install_engine_spec.rb +13 -3
  43. data/spec/tasks/meta_reports_rake_spec.rb +58 -0
  44. metadata +55 -7
  45. data/spec/dummy/README.rdoc +0 -261
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 183b24506be1116a9d39a68487dd42a62faff299
4
- data.tar.gz: c39766e84b3a4c341a24523431cdc90623c8c2e3
3
+ metadata.gz: 444a74c33cfc1decb3b4d7876b1238a1428169da
4
+ data.tar.gz: 34dfb23512870e57cd31ff9f95adb9ea66527730
5
5
  SHA512:
6
- metadata.gz: 322e5a34703a417265c797d50278ff25b10e2f7aba3082742f86feb3bc96f68ba2a911e230d0f0d69ee2635d1e495d5f9aac296853b650a8b740d28b9939168e
7
- data.tar.gz: 1d4765a6fffbebb7e78eb960d0539ccbaa26ad1627723bd92495db778bd98c9991fce6331bf09932e48fa775abc5e8293cce962c6a2b7165cd3f6c630ca5e7f4
6
+ metadata.gz: 706f15ea4d6287cae130aa6a83e0c919622c452253ff82b6f4e11a3f37bff1ae9639c18f31b26ec6ffd0edaae3f52c20dd3e4f05b442dccb4fb4f265a6a50076
7
+ data.tar.gz: 80318f873898149a3eb90f42ca6347fc71a4d2230691d93408555b7a99d156135656c83487c0122c3d0ca3410c916c8f9c5f7a3bf94683ccc8cf8bc41f25036a
data/Guardfile CHANGED
@@ -8,6 +8,7 @@ guard 'rspec', :version => 2, zeus: false, parallel: false, all_on_start: false,
8
8
  watch(%r{^app/controllers/meta_reports/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
9
9
  watch('lib/generators/meta_reports/install_generator.rb') { "spec/generators/install_spec.rb" }
10
10
  watch('lib/generators/meta_reports/install_templates_generator.rb') { "spec/generators/install_templates_spec.rb" }
11
+ watch('lib/tasks/meta_reports_tasks.rake') { "spec/tasks/meta_reports_rake_spec.rb" }
11
12
  watch('spec/dummy/app/controllers/application_controller.rb') { "spec/controllers" }
12
13
  # dummy app
13
14
  watch(%r{^spec/dummy/app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
data/README.md CHANGED
@@ -22,14 +22,20 @@ MetaReports exports to HTML, PDF, and XLSX formats. [More are to come](#todo).
22
22
 
23
23
  ##Philosophy
24
24
 
25
- MetaReports is avowedly fat model. It is also ActiveRecord based. This could change if a better way makes sense.
25
+ ###Templates / data structures only
26
26
 
27
- **NOTE:** There is a generator that [installs templates only](#install-templates-only). Then you can use the data structures and templates in whatever way you see fit, and write your own controllers / reports.
27
+ There is a generator that [installs templates only](#install-templates-only). Then you can use the data structures and templates in whatever way you see fit as you write your own controllers / reports.
28
+
29
+ ###Rails engine
30
+
31
+ The MetaReports engine is avowedly fat model. It is also ActiveRecord based. This could change if a better way makes sense.
28
32
 
29
33
  - **Fat model:** All reports are class methods in the MetaReports::Report class. This allows one to generate reports in various contexts without creating an instance (e.g. a mailer.) The reports themselves are meant to be pure data without formatting, except for class names, and html cell content if that is needed.
30
34
  - **ActiveRecord:** Right now a database record is required in addition to the class method. So far this is for convenience in listing available reports and handling permissions. Someday, the code for a report might also be stored in a database, or an abstract description of a report with a web based query builder could be implemented.
31
- - **Non ActiveRecord:** A non ActiveRecord implementation and install generator will be implemented.
32
- - **That pesky formatting:** The class names / html content may broken out into helpers or a decorator pattern or something else in the future. It is difficult to think of a useful generic way to specify HTML content (e.g. an HTML link within a paragraph of text) outside of the report method itself. A reports controller already breaks strict REST ideology (where does a report belong that combines 5 models?) and unnecessary work for an ideology does not help create a useful tool.
35
+
36
+ ###Thoughts on REST
37
+
38
+ The class names / html content may broken out into helpers or a decorator pattern or something else in the future. It is difficult to think of a useful generic way to specify HTML content (e.g. an HTML link within a paragraph of text) outside of the report method itself. A reports controller already breaks strict REST ideology (where does a report belong that combines 5 models?) and unnecessary work for an ideology does not help create a useful tool.
33
39
 
34
40
  ##Usage
35
41
 
@@ -60,7 +66,7 @@ This copies over the meta_reports migration, model, views, and controller:
60
66
  - `app/models/meta_reports/base.rb`: The ActiveRecord base, should you need it
61
67
  - `app/models/meta_reports/data.rb`: The MetaReports::Data metadata model. Contains report data.
62
68
  - `app/models/meta_reports/table.rb`: The MetaReports::Table model for storing options and table data.
63
- - `app/models/meta_reports/report.rb`: The MetaReports::Report model for storing colors.
69
+ - `app/models/meta_reports/report.rb`: The MetaReports::Report model for storing colors and, if you wish, report methods.
64
70
  - `app/helpers/meta_reports/reports_helper.rb`: MetaReports helper methods.
65
71
  - `app/views/meta_reports/reports/templates/*`: All templates.
66
72
 
@@ -72,7 +78,7 @@ After installing the gem, run the generator:
72
78
 
73
79
  This copies over the meta_reports migration, model, views, and controller:
74
80
 
75
- - `db/migrate/<number>_create_meta_reports_reports.rb`
81
+ - `db/migrate/<timestamp>_create_meta_reports_reports.rb`
76
82
  - `app/models/meta_reports/report.rb`
77
83
  - `app/controllers/meta_reports/reports_controller.rb`
78
84
  - `app/views/meta_reports/reports/*`
@@ -144,19 +150,65 @@ Here is a simple example. See the [example class](spec/dummy/app/models/meta_rep
144
150
 
145
151
  ###Colors
146
152
 
147
- There is currently an imperfect implementation of shared colors. You will define your colors by name in the MetaReports::Report class in the COLORS hash constant. If a table row contains a corresponding class name it will have that color in HTML, PDF, and XLSX format. Currently it is only applied in the PDF format. HTML is not far away. It is also intended to implement a means of specifying cell background and text color.
153
+ There is currently an incomplete implementation of shared colors. You will define your colors by name in the MetaReports::Report class in the COLORS hash constant. If a table row contains a corresponding class name it will have that color in HTML, PDF, and XLSX format. Currently it is only applied in the PDF and HTML formats. It is also intended to implement a means of specifying cell background and text color.
154
+
155
+ An example COLORS hash is below:
148
156
 
149
157
  ```ruby
150
158
  COLORS = {
151
- even: 'efefef',
152
- odd: 'ffffff',
153
- attention: 'ff9999 !important',
159
+ _even: 'efefef',
160
+ _odd: 'ffffff',
161
+ _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
162
+ tr____highlight: '$_yellow_1 !important',
163
+ 'a--hover' => ['ffcccc', 'ffc5c5']
154
164
  }
155
165
  ```
156
166
 
157
- Note that you can specify `!important` and it will be reproduced in the HTML style.
167
+ When you run `rake meta_reports:export_colors` task it exports two SCSS files, one including HTML styles, the other including SCSS variables (for your use in other files.) The export uses the following conventions:
168
+
169
+ - The corresponding SASS variable will be named the same as the key (with $ prepended of course). If the value is an array, the variable names will be the class name plus a numerical suffix for each entry.
170
+ - The corresponding CSS entry will use these conversions:
171
+ - '___' will be converted to to a space
172
+ - '__' will be converted to a hash (id indicator)
173
+ - '_' will be converted to a period (class indicator)
174
+ - '--' (double dash) will be converted to to a colon (pseudo class)
175
+ - arrays of values will be converted into nth-child rules to color consecutive rows
176
+
177
+ This means '____' will be converted to a space and period (' .'), '_____' to ' #', and 'a--first-child' will become 'a:first-child'.
178
+
179
+ Given the above example the generated `lib/metareports_color_variables.scss` SASS file will be:
180
+
181
+ ```scss
182
+ $_even: #efefef;
183
+ $_odd: #ffffff;
184
+ $_yellow_0: #ffffaa;
185
+ $_yellow_1: #ffffcc;
186
+ $_yellow_2: #f9f9a4;
187
+ $_yellow_3: #f9f9c6;
188
+ $tr____highlight: $_yellow_1;
189
+ $a--hover_0: #ffcccc;
190
+ $a--hover_1: #ffc5c5;
191
+ ```
192
+
193
+ And the generated `assets/stylesheets/lib/metareports_colors.scss` SASS file would be:
194
+
195
+ ```scss
196
+ @import 'metareports_color_variables.scss';
197
+ .even { background: $_even; }
198
+ .odd { background: $_odd; }
199
+ .yellow:nth-child(4n+0) { background: $_yellow_0; }
200
+ .yellow:nth-child(4n+1) { background: $_yellow_1; }
201
+ .yellow:nth-child(4n+2) { background: $_yellow_2; }
202
+ .yellow:nth-child(4n+3) { background: $_yellow_3; }
203
+ tr .highlight { background: $_yellow_1 !important; }
204
+ a:hover:nth-child(2n+0) { background: $a--hover_0; }
205
+ a:hover:nth-child(2n+1) { background: $a--hover_1; }
206
+ ```
207
+
208
+ Note that you can specify `!important` and it will be reproduced in the CSS style.
158
209
 
159
- For HTML, necessary styles will either be injected into the HTML output, or a rake task will be created that will generate an appropriate css file to be included in the layout. I have the latter solution working in a test app, but it is not working as a generic rake task.
210
+ To export only the variables file, use the `meta_reports:export_color_variables` Rake task.
211
+ To export only the colors file, use the `meta_reports:export_colors_only` Rake task.
160
212
 
161
213
  ##TODO
162
214
 
@@ -168,6 +220,7 @@ For HTML, necessary styles will either be injected into the HTML output, or a ra
168
220
 
169
221
  ##Changelog
170
222
 
223
+ - **0.0.4:** (10/7/13) Colors rake task
171
224
  - **0.0.3:** (10/7/13) Template/model/helper generator
172
225
  - **0.0.2:** (9/29/13) Relax rails requirement, better testing
173
226
  - **0.0.1:** (9/29/13) Initial release
@@ -13,6 +13,10 @@ module MetaReports
13
13
  end
14
14
  end
15
15
 
16
+ def install_controller
17
+ copy_file "controllers/reports_controller.rb", "app/controllers/meta_reports/reports_controller.rb"
18
+ end
19
+
16
20
  def install_model
17
21
  copy_file "models/report.rb", "app/models/meta_reports/report.rb"
18
22
  end
@@ -3,10 +3,26 @@ class MetaReports::Report < MetaReports::Base
3
3
  #
4
4
  # Shared colors. The key is the class name, value is RGB in hex format
5
5
  #
6
+ # When you run the meta_reports:export_colors Rake task, the key changes as follows:
7
+ # * In the SASS CSS file:
8
+ # - '___' will be changed to ' '
9
+ # - '__' will be changed to '#'
10
+ # - '_' will be changed to '.'
11
+ # - '--' will be changed to ':'
12
+ # - an array of values will be changed to nth-child rules for consecutive rows
13
+ # * In the SASS variables file:
14
+ # - the variable name will be the same as the key
15
+ # - an array of values will be changed into variables whose name is the class name plus a numerical suffix for each entry
16
+ #
17
+ # Example: 'tr____highlight' is 'tr .highlight {}' in CSS, and $tr____highlight as a SASS variable.
18
+ #
6
19
 
7
20
  COLORS = {
8
- even: 'efefef',
9
- odd: 'ffffff',
21
+ _even: 'efefef',
22
+ _odd: 'ffffff',
23
+ _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
24
+ tr____highlight: '$_yellow_1 !important',
25
+ 'a--hover' => ['ffcccc', 'ffc5c5']
10
26
  }
11
27
 
12
28
 
@@ -23,6 +39,7 @@ class MetaReports::Report < MetaReports::Base
23
39
  d.tables["Table 1"] = MetaReports::Table.new do |t|
24
40
  t << ['One', 'Two', 'Three']
25
41
  t << [1, 2, 3]
42
+ t << [4, "#{params[:disco]} Moo", 'No Way!']
26
43
  end
27
44
  end
28
45
  end
@@ -3,10 +3,26 @@ class MetaReports::Report
3
3
  #
4
4
  # Shared colors. The key is the class name, value is RGB in hex format
5
5
  #
6
+ # When you run the meta_reports:export_colors Rake task, the key changes as follows:
7
+ # * In the SASS CSS file:
8
+ # - '___' will be changed to ' '
9
+ # - '__' will be changed to '#'
10
+ # - '_' will be changed to '.'
11
+ # - '--' will be changed to ':'
12
+ # - an array of values will be changed to nth-child rules for consecutive rows
13
+ # * In the SASS variables file:
14
+ # - the variable name will be the same as the key
15
+ # - an array of values will be changed into variables whose name is the class name plus a numerical suffix for each entry
16
+ #
17
+ # Example: 'tr____highlight' is 'tr .highlight {}' in CSS, and $tr____highlight as a SASS variable.
18
+ #
6
19
 
7
20
  COLORS = {
8
- even: 'efefef',
9
- odd: 'ffffff',
21
+ _even: 'efefef',
22
+ _odd: 'ffffff',
23
+ _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
24
+ tr____highlight: '$_yellow_1 !important',
25
+ 'a--hover' => ['ffcccc', 'ffc5c5']
10
26
  }
11
27
 
12
28
 
@@ -23,6 +39,7 @@ class MetaReports::Report
23
39
  d.tables["Table 1"] = MetaReports::Table.new do |t|
24
40
  t << ['One', 'Two', 'Three']
25
41
  t << [1, 2, 3]
42
+ t << [4, "#{params[:disco]} Moo", 'No Way!']
26
43
  end
27
44
  end
28
45
  end
@@ -1,3 +1,3 @@
1
1
  module MetaReports
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,4 +1,59 @@
1
- # desc "Explaining what the task does"
2
- # task :meta_reports do
3
- # # Task goes here
4
- # end
1
+ def process_value(val)
2
+ ret = val =~ /^\$/ ? val : '#' + val
3
+ ret.gsub /\s*\;$/, ''
4
+ end
5
+
6
+ def printfl(str)
7
+ print str
8
+ $stdout.flush
9
+ end
10
+
11
+ namespace :meta_reports do
12
+ desc "export both color variables and the colors sass files"
13
+ task :export_colors => [:export_color_variables, :export_colors_only]
14
+
15
+ desc "export the colors file"
16
+ task :export_colors_only => :environment do
17
+ FileUtils.mkdir_p "app/assets/stylesheets/lib"
18
+ File.open("app/assets/stylesheets/lib/metareports_color_variables.scss", "w") do |f|
19
+ printfl "\tVariables: "
20
+ MetaReports::Report::COLORS.each do |klass, value|
21
+ printfl "."
22
+ klass = klass.to_s
23
+ if value.is_a? Array
24
+ count = -1
25
+ value.each_with_index do |val, i|
26
+ f.puts "$#{klass}_#{i}: #{process_value(val.split.first)};"
27
+ end
28
+ else
29
+ f.puts "$#{klass}: #{process_value(value.split.first)};"
30
+ end
31
+ end
32
+ puts " Done"
33
+ end
34
+ end
35
+
36
+ desc "export the colors variable file"
37
+ task :export_color_variables => :environment do
38
+ File.open("app/assets/stylesheets/lib/metareports_colors.scss", "w") do |f|
39
+ f.puts "@import 'metareports_color_variables.scss';"
40
+ print "\tCSS classes: "
41
+ MetaReports::Report::COLORS.each do |klass, color|
42
+ printfl "."
43
+ css_klass = klass.to_s.gsub(/___/,' ').gsub(/__/,'#').gsub(/_/,'.').gsub(/--/,':')
44
+ if color.is_a? Array
45
+ len = color.length
46
+ color.each_with_index do |val, i|
47
+ f.puts "#{css_klass}:nth-child(#{len}n+#{i}) { background: $#{klass}_#{i}; }"
48
+ end
49
+ elsif color.to_s =~ /^\s*\$/
50
+ f.puts "#{css_klass} { background: #{color}; }"
51
+ else
52
+ f.puts "#{css_klass} { background: $#{klass}; }"
53
+ end
54
+ end
55
+ puts " Done"
56
+
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,9 @@
1
+ $_even: #efefef;
2
+ $_odd: #ffffff;
3
+ $_yellow_0: #ffffaa;
4
+ $_yellow_1: #ffffcc;
5
+ $_yellow_2: #f9f9a4;
6
+ $_yellow_3: #f9f9c6;
7
+ $tr____highlight: $_yellow_1;
8
+ $a--hover_0: #ffcccc;
9
+ $a--hover_1: #ffc5c5;
@@ -0,0 +1,10 @@
1
+ @import 'metareports_color_variables.scss';
2
+ .even { background: $_even; }
3
+ .odd { background: $_odd; }
4
+ .yellow:nth-child(4n+0) { background: $_yellow_0; }
5
+ .yellow:nth-child(4n+1) { background: $_yellow_1; }
6
+ .yellow:nth-child(4n+2) { background: $_yellow_2; }
7
+ .yellow:nth-child(4n+3) { background: $_yellow_3; }
8
+ tr .highlight { background: $_yellow_1 !important; }
9
+ a:hover:nth-child(2n+0) { background: $a--hover_0; }
10
+ a:hover:nth-child(2n+1) { background: $a--hover_1; }
@@ -0,0 +1,91 @@
1
+ require_dependency "meta_reports/application_controller"
2
+
3
+ module MetaReports
4
+ class ReportsController < ApplicationController
5
+ # remember to add authentication/authorization. E.g:
6
+ # before_filter :require_user
7
+ # load_and_authorize_resource
8
+
9
+ def index
10
+ @reports = Report.order("meta_reports_reports.title") || []
11
+ end
12
+
13
+ def show
14
+ if params[:id].to_s =~ /^\d+$/
15
+ _report = Report.find(params[:id])
16
+ elsif Report.respond_to?(params[:id])
17
+ _report = Report.find_by_name(params[:id])
18
+ else
19
+ redirect_to root_url, notice: 'That report does not exist'
20
+ return
21
+ end
22
+ @report = _report.run(params)
23
+ template = {template: "meta_reports/reports/templates/" + (@report[:template] || "default") }
24
+
25
+ respond_to do |format|
26
+ format.html { render template }
27
+ format.pdf { render template }
28
+ format.xlsx { render template }
29
+ end
30
+ _report.view
31
+ end
32
+
33
+ def new
34
+ @report = Report.new
35
+ end
36
+
37
+ def edit
38
+ @report = Report.find params[:id]
39
+ end
40
+
41
+ def create
42
+ @report = Report.new(params[:report])
43
+ if @report.save
44
+ flash[:notice] = 'Report was successfully created.'
45
+ redirect_to(edit_report_path(@report))
46
+ else
47
+ render action: "new"
48
+ end
49
+ end
50
+
51
+ def update
52
+ @report = Report.find params[:id]
53
+ if @report.update_attributes(params[:meta_report])
54
+ flash[:notice] = 'Report was successfully updated.'
55
+ redirect_to(edit_report_path(@report))
56
+ else
57
+ format.html { render action: "edit" }
58
+ end
59
+ end
60
+
61
+ def destroy
62
+ @report = Report.find params[:id]
63
+ @report.destroy
64
+ flash[:notice] = 'Report was successfully deleted.'
65
+
66
+ redirect_to root_url
67
+ end
68
+
69
+ def file
70
+ dir = params[:dir].to_sym
71
+ path = Report::FILE_DIRS[dir] + params[:file].gsub(/\/../,'')
72
+ if File.exists?(path)
73
+ send_file path, type: "application/pdf", x_sendfile: true, disposition: 'inline'
74
+ else
75
+ puts "file doesn't exist: #{path}"
76
+ end
77
+ end
78
+
79
+ def form
80
+ if params[:id].to_s =~ /^\d+$/
81
+ @report = Report.find(params[:id])
82
+ elsif Report.respond_to?(params[:id])
83
+ @report = Report.find_by_name(params[:id])
84
+ else
85
+ redirect_to reports_url, notice: 'That report does not exist'
86
+ return
87
+ end
88
+ render "meta_reports/reports/forms/form"
89
+ end
90
+ end
91
+ end
@@ -3,12 +3,28 @@ class MetaReports::Report < MetaReports::Base
3
3
  #
4
4
  # Shared colors. The key is the class name, value is RGB in hex format
5
5
  #
6
+ # When you run the meta_reports:export_colors Rake task, the key changes as follows:
7
+ # * In the SASS CSS file:
8
+ # - '___' will be changed to ' '
9
+ # - '__' will be changed to '#'
10
+ # - '_' will be changed to '.'
11
+ # - '--' will be changed to ':'
12
+ # - an array of values will be changed to nth-child rules for consecutive rows
13
+ # * In the SASS variables file:
14
+ # - the variable name will be the same as the key
15
+ # - an array of values will be changed into variables whose name is the class name plus a numerical suffix for each entry
16
+ #
17
+ # Example: 'tr____highlight' is 'tr .highlight {}' in CSS, and $tr____highlight as a SASS variable.
18
+ #
6
19
 
7
20
  COLORS = {
8
- even: 'efefef',
9
- odd: 'ffffff',
21
+ _even: 'efefef',
22
+ _odd: 'ffffff',
23
+ _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
24
+ tr____highlight: '$_yellow_1 !important',
25
+ 'a--hover' => ['ffcccc', 'ffc5c5']
10
26
  }
11
-
27
+
12
28
 
13
29
  #
14
30
  # Reports