mochigome 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -0
- data/Gemfile.lock +15 -0
- data/TODO +3 -0
- data/lib/mochigome_ver.rb +1 -1
- data/lib/model_extensions.rb +1 -1
- data/lib/query.rb +6 -2
- data/test/app_root/app/controllers/application_controller.rb +15 -0
- data/test/app_root/app/controllers/report_controller.rb +388 -0
- data/test/app_root/app/helpers/application_helper.rb +8 -0
- data/test/app_root/app/models/product.rb +2 -2
- data/test/app_root/app/models/sale.rb +1 -1
- data/test/app_root/app/models/store.rb +4 -0
- data/test/app_root/app/transforms/report.fo.via-html.xslt.haml +173 -0
- data/test/app_root/app/transforms/report.html.xslt.haml +198 -0
- data/test/app_root/app/views/layouts/application.html.haml +15 -0
- data/test/app_root/app/views/report/edit.html.haml +56 -0
- data/test/app_root/app/views/report/show.html.haml +6 -0
- data/test/app_root/config/database.yml +7 -0
- data/test/app_root/config/environments/development.rb +17 -0
- data/test/app_root/config/initializers/mime_types.rb +8 -0
- data/test/app_root/config/routes.rb +3 -2
- data/test/app_root/db/development.sqlite3 +0 -0
- data/test/app_root/lib/apache_fop.rb +151 -0
- data/test/app_root/public/index.html +14 -0
- data/test/app_root/public/javascripts/prototype.js +6084 -0
- data/test/app_root/public/javascripts/report_edit.js +153 -0
- data/test/app_root/public/stylesheets/common.css +183 -0
- data/test/app_root/vendor/plugins/mochigome/init.rb +3 -1
- data/test/server.rb +3 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/query_test.rb +12 -3
- metadata +20 -5
- data/test/app_root/app/controllers/owners_controller.rb +0 -2
@@ -0,0 +1,153 @@
|
|
1
|
+
// TODO: This whole file is ugly, there must be a trillion
|
2
|
+
// better ways to do this with widget toolkits.
|
3
|
+
|
4
|
+
var report_settings_possible_layers = [];
|
5
|
+
function add_possible_layer(label, clsname) {
|
6
|
+
report_settings_possible_layers.push([label, clsname]);
|
7
|
+
}
|
8
|
+
|
9
|
+
var report_settings_possible_aggregate_sources = [];
|
10
|
+
function add_possible_aggregate_source(label, name) {
|
11
|
+
report_settings_possible_aggregate_sources.push([label, name]);
|
12
|
+
}
|
13
|
+
|
14
|
+
var ReportSettingList = function(ul, name, choice_f, options, prev) {
|
15
|
+
this.ul = $(ul);
|
16
|
+
this.li = null;
|
17
|
+
this.sel_elem = null;
|
18
|
+
this.name = name;
|
19
|
+
this.choice_f = choice_f;
|
20
|
+
this.next = null;
|
21
|
+
this.prev = prev || null;
|
22
|
+
this.initialized = false;
|
23
|
+
this.values_to_preload = [];
|
24
|
+
this.options = {
|
25
|
+
"label_f": null,
|
26
|
+
"limit": null
|
27
|
+
}
|
28
|
+
if (options) { Object.extend(this.options, options); }
|
29
|
+
|
30
|
+
if (document.loaded) {
|
31
|
+
this.initialize();
|
32
|
+
} else {
|
33
|
+
Event.observe(document, 'dom:loaded', this.initialize.bind(this), false);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
ReportSettingList.prototype = {
|
38
|
+
initialize: function() {
|
39
|
+
this.li = new Element('li');
|
40
|
+
if (this.options["label_f"]) {
|
41
|
+
this.li.insert(this.options["label_f"](this) + ": ");
|
42
|
+
}
|
43
|
+
|
44
|
+
var select = new Element('select', {'name': this.name + "[]"});
|
45
|
+
this.sel_elem = select;
|
46
|
+
var empty_option = new Element('option', {'value': ''});
|
47
|
+
select.insert(empty_option);
|
48
|
+
this.choice_f(this).each(function(c) {
|
49
|
+
var option = new Element('option', {'value': c[1]});
|
50
|
+
option.insert(c[0]);
|
51
|
+
select.insert(option);
|
52
|
+
})
|
53
|
+
|
54
|
+
this.li.insert(select);
|
55
|
+
this.ul.insert(this.li);
|
56
|
+
this.sel_elem.observe("change", this.handle_change.bind(this));
|
57
|
+
|
58
|
+
this.unpack_values_to_preload();
|
59
|
+
this.initialized = true;
|
60
|
+
},
|
61
|
+
|
62
|
+
choices: function() {
|
63
|
+
return this.choice_f(this);
|
64
|
+
},
|
65
|
+
|
66
|
+
destroy_li: function() {
|
67
|
+
if (this.next) {
|
68
|
+
this.next.destroy_li();
|
69
|
+
}
|
70
|
+
if (this.li) {
|
71
|
+
this.li.remove();
|
72
|
+
this.li = null;
|
73
|
+
}
|
74
|
+
},
|
75
|
+
|
76
|
+
handle_change: function() {
|
77
|
+
if (this.next) { this.next.destroy_li(); }
|
78
|
+
if (this.selected_value()) {
|
79
|
+
if (this.options["limit"] != null) {
|
80
|
+
if (this.num_prev()+1 >= this.options["limit"]) {
|
81
|
+
return
|
82
|
+
}
|
83
|
+
}
|
84
|
+
var next_rsl = new ReportSettingList(
|
85
|
+
this.ul, this.name, this.choice_f, this.options, this
|
86
|
+
);
|
87
|
+
if (next_rsl.choices().size() > 0) {
|
88
|
+
this.next = next_rsl;
|
89
|
+
} else {
|
90
|
+
next_rsl.destroy_li();
|
91
|
+
}
|
92
|
+
} else {
|
93
|
+
this.next = null;
|
94
|
+
}
|
95
|
+
},
|
96
|
+
|
97
|
+
num_prev: function() {
|
98
|
+
if (this.prev) {
|
99
|
+
return 1 + this.prev.num_prev();
|
100
|
+
} else {
|
101
|
+
return 0;
|
102
|
+
}
|
103
|
+
},
|
104
|
+
|
105
|
+
selected_value: function() {
|
106
|
+
var v = this.sel_elem.options[this.sel_elem.selectedIndex].value;
|
107
|
+
if (v == "") {
|
108
|
+
return null;
|
109
|
+
} else {
|
110
|
+
return v;
|
111
|
+
}
|
112
|
+
},
|
113
|
+
|
114
|
+
values_to_here: function() {
|
115
|
+
var r = [];
|
116
|
+
if (this.prev) {
|
117
|
+
r = this.prev.values_to_here();
|
118
|
+
}
|
119
|
+
var v = this.selected_value();
|
120
|
+
if (v) {
|
121
|
+
r.push(v);
|
122
|
+
}
|
123
|
+
return r;
|
124
|
+
},
|
125
|
+
|
126
|
+
preload_value: function(v) {
|
127
|
+
this.values_to_preload.push(v);
|
128
|
+
if (this.initialized) {
|
129
|
+
this.unpack_values_to_preload();
|
130
|
+
}
|
131
|
+
},
|
132
|
+
|
133
|
+
unpack_values_to_preload: function() {
|
134
|
+
var me = this;
|
135
|
+
me.values_to_preload.each(function(v) {
|
136
|
+
if (me.selected_value() == null) {
|
137
|
+
var idx = null;
|
138
|
+
me.choices().each(function(e, i) {
|
139
|
+
if (e[1] == v) {
|
140
|
+
idx = i;
|
141
|
+
throw $break;
|
142
|
+
}
|
143
|
+
})
|
144
|
+
if (idx != null) {
|
145
|
+
me.sel_elem.selectedIndex = idx+1;
|
146
|
+
me.handle_change();
|
147
|
+
}
|
148
|
+
} else if (me.next) {
|
149
|
+
me.next.preload_value(v);
|
150
|
+
}
|
151
|
+
})
|
152
|
+
}
|
153
|
+
}
|
@@ -0,0 +1,183 @@
|
|
1
|
+
body {
|
2
|
+
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
3
|
+
color: #657b83;
|
4
|
+
background: #fdf6e3;
|
5
|
+
}
|
6
|
+
|
7
|
+
.flash {
|
8
|
+
border: solid 1px black;
|
9
|
+
padding: 0.5em;
|
10
|
+
margin-bottom: 1em;
|
11
|
+
min-height: 32px;
|
12
|
+
}
|
13
|
+
|
14
|
+
.flash_notice {
|
15
|
+
border-color: #99cc99;
|
16
|
+
color: #006600;
|
17
|
+
background: #eeffee;
|
18
|
+
}
|
19
|
+
|
20
|
+
.flash_warning {
|
21
|
+
border-color: #cc9999;
|
22
|
+
color: white;
|
23
|
+
background: #cc6622;
|
24
|
+
}
|
25
|
+
|
26
|
+
.flash_alert {
|
27
|
+
border-color: #cc9999;
|
28
|
+
color: white;
|
29
|
+
background: #cc0000;
|
30
|
+
}
|
31
|
+
|
32
|
+
#report-edit-form div {
|
33
|
+
padding-left: 3px;
|
34
|
+
}
|
35
|
+
|
36
|
+
#report-edit-form div ul {
|
37
|
+
list-style-type: none;
|
38
|
+
}
|
39
|
+
|
40
|
+
#report-edit-form div {
|
41
|
+
background-color: #eee8d5;
|
42
|
+
margin: 10px 0;
|
43
|
+
border: 1px solid gray;
|
44
|
+
}
|
45
|
+
|
46
|
+
#report-body {
|
47
|
+
margin-left: 250px;
|
48
|
+
}
|
49
|
+
|
50
|
+
#sidebar {
|
51
|
+
position: fixed;
|
52
|
+
top: 0px;
|
53
|
+
left: 0px;
|
54
|
+
width: 230px;
|
55
|
+
background-color: #ddd;
|
56
|
+
padding: 3px;
|
57
|
+
margin: 5px;
|
58
|
+
}
|
59
|
+
|
60
|
+
.report table {
|
61
|
+
border-collapse: collapse;
|
62
|
+
width: 100%;
|
63
|
+
table-layout: fixed;
|
64
|
+
margin-left: 0px;
|
65
|
+
margin-bottom: 2px;
|
66
|
+
}
|
67
|
+
|
68
|
+
.report table thead tr {
|
69
|
+
background-color: #eee8d5;
|
70
|
+
color: #586e75;
|
71
|
+
}
|
72
|
+
|
73
|
+
.report table td, .report table th {
|
74
|
+
padding-bottom: 0.35em;
|
75
|
+
border: 1px solid gray;
|
76
|
+
}
|
77
|
+
|
78
|
+
.report .report-header {
|
79
|
+
background-color: #eee8d5;
|
80
|
+
padding: 4px;
|
81
|
+
margin: 8px 0;
|
82
|
+
border: 1px solid gray;
|
83
|
+
}
|
84
|
+
|
85
|
+
.report table col.item-name {
|
86
|
+
width: 200px;
|
87
|
+
}
|
88
|
+
|
89
|
+
.report table tr td.item-name {
|
90
|
+
font-weight: bold;
|
91
|
+
}
|
92
|
+
|
93
|
+
.report table tr th {
|
94
|
+
font-style: italic;
|
95
|
+
}
|
96
|
+
|
97
|
+
.report table tr th.item-name {
|
98
|
+
font-weight: bold;
|
99
|
+
}
|
100
|
+
|
101
|
+
.report table tr.subtable-name-row {
|
102
|
+
color: #eee8d5;
|
103
|
+
background-color: #777777;
|
104
|
+
}
|
105
|
+
|
106
|
+
.report table tr.subtable-name-row th {
|
107
|
+
font-weight: bold;
|
108
|
+
}
|
109
|
+
|
110
|
+
.report .node {
|
111
|
+
padding: 4px;
|
112
|
+
border-left: solid 1px gray;
|
113
|
+
margin: 8px 0;
|
114
|
+
}
|
115
|
+
|
116
|
+
.report .node .node {
|
117
|
+
margin-left: 18px;
|
118
|
+
}
|
119
|
+
|
120
|
+
.report .node.subtable-node {
|
121
|
+
border: solid 1px gray;
|
122
|
+
margin-bottom: 15px;
|
123
|
+
background-color: #eeeeff;
|
124
|
+
}
|
125
|
+
|
126
|
+
.report .datum label {
|
127
|
+
font-style: italic;
|
128
|
+
}
|
129
|
+
|
130
|
+
.report .datum label:after {
|
131
|
+
content: ": ";
|
132
|
+
}
|
133
|
+
|
134
|
+
.report .datum span.value {
|
135
|
+
font-weight: bold;
|
136
|
+
}
|
137
|
+
|
138
|
+
h1 {
|
139
|
+
font-size: 240%;
|
140
|
+
}
|
141
|
+
|
142
|
+
h2 {
|
143
|
+
font-size: 200%;
|
144
|
+
}
|
145
|
+
|
146
|
+
h3 {
|
147
|
+
font-size: 170%;
|
148
|
+
}
|
149
|
+
|
150
|
+
h4 {
|
151
|
+
font-size: 150%;
|
152
|
+
}
|
153
|
+
|
154
|
+
h5 {
|
155
|
+
font-size: 135%;
|
156
|
+
}
|
157
|
+
|
158
|
+
h6 {
|
159
|
+
font-size: 120%;
|
160
|
+
}
|
161
|
+
|
162
|
+
.report h1, .report h2, .report h3, .report h4, .report h5, .report h6 {
|
163
|
+
margin-top: 0.1em;
|
164
|
+
margin-bottom: 0.2em;
|
165
|
+
}
|
166
|
+
|
167
|
+
.report img.chart {
|
168
|
+
margin: 0.4em 0;
|
169
|
+
padding: 0.4em;
|
170
|
+
background-color: #eee8d5;
|
171
|
+
}
|
172
|
+
|
173
|
+
@media screen {
|
174
|
+
.printonly {
|
175
|
+
display: none;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
@media print {
|
180
|
+
.noprint {
|
181
|
+
display: none;
|
182
|
+
}
|
183
|
+
}
|
data/test/server.rb
ADDED
data/test/test_helper.rb
CHANGED
data/test/unit/query_test.rb
CHANGED
@@ -423,8 +423,6 @@ describe Mochigome::Query do
|
|
423
423
|
assert_equal 4, data_node["Count squared"]
|
424
424
|
end
|
425
425
|
|
426
|
-
# TODO: Test case where data model is already in layer path
|
427
|
-
# TODO: Test case where the condition is deeper than the focus model
|
428
426
|
# TODO: Test use of non-trivial function for aggregation value
|
429
427
|
|
430
428
|
it "puts a comment on the root node describing the query" do
|
@@ -503,5 +501,16 @@ describe Mochigome::Query do
|
|
503
501
|
assert_equal 2, dn.children.size
|
504
502
|
end
|
505
503
|
|
506
|
-
|
504
|
+
it "uses default values for aggregations on an empty result set" do
|
505
|
+
Sale.destroy_all
|
506
|
+
q = Mochigome::Query.new(
|
507
|
+
[Store, Product],
|
508
|
+
:aggregate_sources => [[Product, Sale]]
|
509
|
+
)
|
510
|
+
dn = q.run
|
511
|
+
assert_equal 3, dn.children.size
|
512
|
+
assert_equal 0, dn['Gross']
|
513
|
+
assert_equal 0, (dn/0)['Gross']
|
514
|
+
assert_equal 0, (dn/0/0)['Gross']
|
515
|
+
end
|
507
516
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mochigome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Mike Simon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -115,7 +115,8 @@ files:
|
|
115
115
|
- lib/query.rb
|
116
116
|
- lib/subgroup_model.rb
|
117
117
|
- test/app_root/app/controllers/application_controller.rb
|
118
|
-
- test/app_root/app/controllers/
|
118
|
+
- test/app_root/app/controllers/report_controller.rb
|
119
|
+
- test/app_root/app/helpers/application_helper.rb
|
119
120
|
- test/app_root/app/models/boring_datum.rb
|
120
121
|
- test/app_root/app/models/category.rb
|
121
122
|
- test/app_root/app/models/owner.rb
|
@@ -123,20 +124,34 @@ files:
|
|
123
124
|
- test/app_root/app/models/sale.rb
|
124
125
|
- test/app_root/app/models/store.rb
|
125
126
|
- test/app_root/app/models/store_product.rb
|
127
|
+
- test/app_root/app/transforms/report.fo.via-html.xslt.haml
|
128
|
+
- test/app_root/app/transforms/report.html.xslt.haml
|
129
|
+
- test/app_root/app/views/layouts/application.html.haml
|
130
|
+
- test/app_root/app/views/report/edit.html.haml
|
131
|
+
- test/app_root/app/views/report/show.html.haml
|
126
132
|
- test/app_root/config/boot.rb
|
127
133
|
- test/app_root/config/database-my.yml
|
128
134
|
- test/app_root/config/database-pg.yml
|
129
135
|
- test/app_root/config/database.yml
|
130
136
|
- test/app_root/config/environment.rb
|
137
|
+
- test/app_root/config/environments/development.rb
|
131
138
|
- test/app_root/config/environments/test.rb
|
132
139
|
- test/app_root/config/initializers/arel.rb
|
140
|
+
- test/app_root/config/initializers/mime_types.rb
|
133
141
|
- test/app_root/config/offroad.yml
|
134
142
|
- test/app_root/config/preinitializer.rb
|
135
143
|
- test/app_root/config/routes.rb
|
144
|
+
- test/app_root/db/development.sqlite3
|
136
145
|
- test/app_root/db/migrate/20110817163830_create_tables.rb
|
146
|
+
- test/app_root/lib/apache_fop.rb
|
147
|
+
- test/app_root/public/index.html
|
148
|
+
- test/app_root/public/javascripts/prototype.js
|
149
|
+
- test/app_root/public/javascripts/report_edit.js
|
150
|
+
- test/app_root/public/stylesheets/common.css
|
137
151
|
- test/app_root/vendor/plugins/mochigome/init.rb
|
138
152
|
- test/console.sh
|
139
153
|
- test/factories.rb
|
154
|
+
- test/server.rb
|
140
155
|
- test/test.watchr
|
141
156
|
- test/test_helper.rb
|
142
157
|
- test/unit/data_node_test.rb
|