mountain-goat 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +2 -0
  2. data/README.md +5 -4
  3. data/generators/mg/mg_generator.rb +2 -2
  4. data/generators/mg/templates/update_mountain_goat_tables_v2.rb +73 -0
  5. data/lib/mountain-goat/controllers/mg/choices_controller.rb +81 -0
  6. data/lib/mountain-goat/controllers/mg/goals_controller.rb +136 -0
  7. data/lib/mountain-goat/controllers/mg/records_controller.rb +46 -0
  8. data/lib/mountain-goat/controllers/mg/tests_controller.rb +139 -0
  9. data/lib/mountain-goat/mg_core.rb +403 -0
  10. data/lib/mountain-goat/models/mg/choice.rb +50 -0
  11. data/lib/mountain-goat/models/mg/gi_meta.rb +10 -0
  12. data/lib/mountain-goat/models/mg/goal.rb +183 -0
  13. data/lib/mountain-goat/models/mg/goal_meta_type.rb +20 -0
  14. data/lib/mountain-goat/models/mg/gs_meta.rb +10 -0
  15. data/lib/mountain-goat/models/mg/record.rb +59 -0
  16. data/lib/mountain-goat/models/mg/test.rb +31 -0
  17. data/lib/mountain-goat/public/g-funnel.js +168 -0
  18. data/lib/mountain-goat/switch_choice.rb +32 -0
  19. data/lib/mountain-goat/version.rb +1 -1
  20. data/lib/mountain-goat/views/mountain_goat/layouts/.tmp_mountain_goat.html.erb.50680~ +76 -0
  21. data/lib/mountain-goat/views/mountain_goat/mg/choices/_choice_form.html.erb +37 -0
  22. data/lib/mountain-goat/views/mountain_goat/mg/choices/edit.html.erb +13 -0
  23. data/lib/mountain-goat/views/mountain_goat/mg/choices/index.html.erb +34 -0
  24. data/lib/mountain-goat/views/mountain_goat/mg/choices/new.html.erb +15 -0
  25. data/lib/mountain-goat/views/mountain_goat/mg/choices/show.html.erb +30 -0
  26. data/lib/mountain-goat/views/mountain_goat/mg/goals/.tmp__goal_form.html.erb.5027~ +0 -0
  27. data/lib/mountain-goat/views/mountain_goat/mg/goals/.tmp__goal_meta_type_form.html.erb.39992~ +0 -0
  28. data/lib/mountain-goat/views/mountain_goat/mg/goals/.tmp_edit.html.erb.55874~ +0 -0
  29. data/lib/mountain-goat/views/mountain_goat/mg/goals/.tmp_index.html.erb.97274~ +36 -0
  30. data/lib/mountain-goat/views/mountain_goat/mg/goals/_goal_form.html.erb +28 -0
  31. data/lib/mountain-goat/views/mountain_goat/mg/goals/_goal_meta_type_form.html.erb +34 -0
  32. data/lib/mountain-goat/views/mountain_goat/mg/goals/edit.html.erb +12 -0
  33. data/lib/mountain-goat/views/mountain_goat/mg/goals/index.html.erb +37 -0
  34. data/lib/mountain-goat/views/mountain_goat/mg/goals/new.html.erb +12 -0
  35. data/lib/mountain-goat/views/mountain_goat/mg/goals/show.html.erb +32 -0
  36. data/lib/mountain-goat/views/mountain_goat/mg/records/_record.html.erb +16 -0
  37. data/lib/mountain-goat/views/mountain_goat/mg/records/_records.html.erb +5 -0
  38. data/lib/mountain-goat/views/mountain_goat/mg/records/_records_form.html.erb +21 -0
  39. data/lib/mountain-goat/views/mountain_goat/mg/records/edit.html.erb +13 -0
  40. data/lib/mountain-goat/views/mountain_goat/mg/records/index.html.erb +17 -0
  41. data/lib/mountain-goat/views/mountain_goat/mg/records/new.html.erb +13 -0
  42. data/lib/mountain-goat/views/mountain_goat/mg/records/show.html.erb +14 -0
  43. data/lib/mountain-goat/views/mountain_goat/mg/report_items/.tmp__chart.html.erb.13419~ +18 -0
  44. data/lib/mountain-goat/views/mountain_goat/mg/report_items/.tmp__funnel.html.erb.60493~ +18 -0
  45. data/lib/mountain-goat/views/mountain_goat/mg/report_items/.tmp__report_item_form.html.erb.87420~ +10 -0
  46. data/lib/mountain-goat/views/mountain_goat/mg/report_items/.tmp__report_item_pivot_form.html.erb.77056~ +14 -0
  47. data/lib/mountain-goat/views/mountain_goat/mg/report_items/.tmp_edit.html.erb.31048~ +19 -0
  48. data/lib/mountain-goat/views/mountain_goat/mg/report_items/.tmp_new.html.erb.36371~ +17 -0
  49. data/lib/mountain-goat/views/mountain_goat/mg/report_items/_funnel.html.erb +13 -0
  50. data/lib/mountain-goat/views/mountain_goat/mg/reports/.tmp__report_form.html.erb.76535~ +21 -0
  51. data/lib/mountain-goat/views/mountain_goat/mg/reports/.tmp__report_report_items.html.erb.26030~ +5 -0
  52. data/lib/mountain-goat/views/mountain_goat/mg/reports/.tmp_edit.html.erb.78064~ +36 -0
  53. data/lib/mountain-goat/views/mountain_goat/mg/reports/.tmp_index.html.erb.74591~ +23 -0
  54. data/lib/mountain-goat/views/mountain_goat/mg/reports/.tmp_show.html.erb.58427~ +21 -0
  55. data/lib/mountain-goat/views/mountain_goat/mg/tests/_test_form.html.erb +25 -0
  56. data/lib/mountain-goat/views/mountain_goat/mg/tests/edit.html.erb +12 -0
  57. data/lib/mountain-goat/views/mountain_goat/mg/tests/index.html.erb +48 -0
  58. data/lib/mountain-goat/views/mountain_goat/mg/tests/new.html.erb +12 -0
  59. data/lib/mountain-goat/views/mountain_goat/mg/tests/show.html.erb +63 -0
  60. metadata +69 -6
  61. data/lib/mountain-goat/metric_tracking.rb +0 -401
  62. data/lib/mountain-goat/switch_variant.rb +0 -32
@@ -0,0 +1,16 @@
1
+ <%# locals => record %>
2
+
3
+ <li class="record" data-record-id="<%= record.id %>">
4
+ <div class="record-context">
5
+ <div class="name"><%= record.mg_goal.name %></div>
6
+ <div class="time"><%= content_tag(:abbr, record.created_at.to_s, :title => record.created_at.getutc.iso8601, :class => "time-ago") %></div>
7
+ </div>
8
+
9
+ <ul class="record-content">
10
+ <% record.all_metas.each do |k,v| %>
11
+ <% if !v.blank? %>
12
+ <li><%= k %>: <%= v %></li>
13
+ <% end %>
14
+ <% end %>
15
+ </ul>
16
+ </li>
@@ -0,0 +1,5 @@
1
+ <%# locals => records %>
2
+
3
+ <% records.each do |record| %>
4
+ <%= render 'record', :locals => { :record => record } %>
5
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <%# locals => f %>
2
+
3
+ <% if f.object.new_record? %>
4
+ <div class="item goal-type">
5
+ <%= f.label :goal_type, 'Type (this is technical)' %>
6
+ <%= f.text_field :goal_type %>
7
+ </div>
8
+ <% else %>
9
+ <%= f.hidden_field(:goal_id) %>
10
+ <h2><%= f.object.mg_goal.name %></h2>
11
+ <span class="item created_at">
12
+ <%= f.label :created_at %>
13
+ <%= f.text_field :created_at %>
14
+ </span>
15
+ <% end %>
16
+
17
+ <%# TODO: Metas %>
18
+
19
+ <div class="item submit">
20
+ <%= f.submit 'Submit' %>
21
+ </div>
@@ -0,0 +1,13 @@
1
+
2
+ <div id="container-main" class="mg-records">
3
+ <div class="mountain-goat-panel centered">
4
+ <h2>Edit Record</h2>
5
+
6
+ <% form_for :record, @record, :url => mg_records_url do |f| %>
7
+ <%= f.error_messages %>
8
+
9
+ <%= render 'records_form', :f => f %>
10
+ <% end %>
11
+
12
+ </div>
13
+ </div>
@@ -0,0 +1,17 @@
1
+ <div id="container-main" class="mg-records">
2
+ <h1><% if @goal %><%=h @goal.name %><% else %>Comprehensive<% end %> Records</h1>
3
+ <div class="container-content">
4
+ <div class="recent-record" data-reload="true" data-record-id="<%= @records.count > 0 ? @records.first.id : -1 %>" data-goal-id="<%= @goal ? @goal.id : '' %>"></div>
5
+ <a class="button" href="javascript:void(0)" class="reload">Reload</a>
6
+
7
+ <% if @records.count > 0 %>
8
+ <ul class="record-list">
9
+ <% @records.each do |record| %>
10
+ <%= render 'record', :record => record %>
11
+ <% end %>
12
+ </ul>
13
+ <% else %>
14
+ <h3>No records yet...</h3>
15
+ <% end %>
16
+ </div>
17
+ </div>
@@ -0,0 +1,13 @@
1
+
2
+ <div id="container-main" class="mg-records">
3
+ <div class="mountain-goat-panel centered">
4
+ <h2>New Record</h2>
5
+
6
+ <% form_for :record, @record, :url => mg_records_url do |f| %>
7
+ <%= f.error_messages %>
8
+
9
+ <%= render 'records_form', :f => f %>
10
+ <% end %>
11
+
12
+ </div>
13
+ </div>
@@ -0,0 +1,14 @@
1
+
2
+ <div id="container-main" class="mg-records">
3
+ <div class="mountain-goat-panel centered">
4
+ <h2>Record for <%=h @record.goal.name %></h2>
5
+
6
+ <div class="record">
7
+ <span class="occurred"><%= @record.created_at.to_s %></span>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <a class="button" href="<%= edit_mg_record_url @record.id %>">Edit</a>
12
+ </div>
13
+ </div>
14
+ </div>
@@ -0,0 +1,18 @@
1
+ <%# locals => report_item %>
2
+
3
+ <div class="statpad">
4
+ <div class="title"><%= report_item.chart_title %></div>
5
+ <div class="statbody">
6
+ <div id="chart_item<%=h report_item.id %>" data-raphael="line" data-x-axis="date"
7
+ <% it = 0 %>
8
+ <%# TODO: There's a ton of assumptions here %>
9
+ <% report_item.chart_items.each do |name, channel| %>
10
+ data-title<%= it %>="<%= name || "Direct" %>"
11
+ data-x<%= it %>="<%= channel.map { |i| i[:x].to_time.to_i * 1000 }.join(',') %>"
12
+ data-y<%= it %>="<%= channel.map { |i| i[:y] }.join(',') %>"
13
+ <% it = it + 1 %>
14
+ <% end %>
15
+ style="width: 425px; height: 260px;" />
16
+ </div>
17
+ </div>
18
+ </div>
@@ -0,0 +1,18 @@
1
+ <%# locals => report_item %>
2
+
3
+ <div class="statpad">
4
+ <div class="title"><%= report_item.chart_title %></div>
5
+ <div class="statbody">
6
+ <div id="chart_item<%=h report_item.id %>" data-raphael="line" data-x-axis="date"
7
+ <% it = 0 %>
8
+ <%# TODO: There's a ton of assumptions here %>
9
+ <% report_item.chart_items.each do |name, channel| %>
10
+ data-title<%= it %>="<%= name || "Direct" %>"
11
+ data-x<%= it %>="<%= channel.map { |i| i[:x].to_time.to_i * 1000 }.join(',') %>"
12
+ data-y<%= it %>="<%= channel.map { |i| i[:y] }.join(',') %>"
13
+ <% it = it + 1 %>
14
+ <% end %>
15
+ style="width: 425px; height: 260px;" />
16
+ </div>
17
+ </div>
18
+ </div>
@@ -0,0 +1,10 @@
1
+ <%# locals => f %>
2
+ <div class="item reportable">
3
+ <%= f.label :reportable, "Report Item" %>
4
+ <%= f.select :reportable, options_for_select( [[ "Select a Goal", "" ]] + Mg::Convert.all.map { |conv| [ conv.name, "#{conv.id}-#{conv.class}" ] }, f.object.reportable.nil? ? "" : "#{f.object.reportable_id}-#{f.object.reportable_type}" ), {}, :'data-varies' => 'change', :'data-varies-path' => get_extra_mg_report_items_url, :'data-varies-res' => '#extra' %>
5
+ </div>
6
+ <div id="extra">
7
+ <% if !f.object.nil? && !f.object.reportable.nil? %>
8
+ <%= render :partial => 'mg/report_items/report_item_pivot_form', :locals => { :reportable => f.object.reportable }.merge( f.object.pivot.nil? ? {} : { :pivot => f.object.pivot } ) %>
9
+ <% end %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <%# locals => reportable, optional => pivot %>
2
+
3
+ <% pivot = nil if !local_assigns.has_key?(:pivot) %>
4
+
5
+ <% if reportable.instance_of?(Mg::Convert) %>
6
+ <% cmts = reportable.convert_meta_types %>
7
+ <% end %>
8
+
9
+ <% if !cmts.nil? %>
10
+ <div class="item pivot">
11
+ <%= label_tag :'report_item[pivot]', "Pivot" %>
12
+ <%= select_tag :'report_item[pivot]', options_for_select( [[ "None", "" ]] + cmts.map { |cmt| [ cmt.name, "#{cmt.id}-#{cmt.class}" ] }, pivot.nil? ? "" : "#{pivot.id}-#{pivot.type}" ) %>
13
+ </div>
14
+ <% end %>
@@ -0,0 +1,19 @@
1
+
2
+ <div class="header">
3
+ <span class="title">Edit Report Item</span>
4
+ </div>
5
+ <div class="body">
6
+ <div class="report-items">
7
+ <% form_for :report_item, @report_item, :url => update_mg_report_item_url(:id => @report_item.id), :html => { :method => :post, :class => "remote-form report-item", :'data-res' => ".report-items-model .model" } do |f| %>
8
+
9
+ <div>
10
+ <%= f.error_messages %>
11
+ <%= render :partial => 'mg/report_items/report_item_form', :locals => { :f => f } %>
12
+ </div>
13
+
14
+ <div class="submit">
15
+ <%= f.submit 'Update', :class => 'bluebutton' %>
16
+ </div>
17
+ <% end %>
18
+ </div>
19
+ </div>
@@ -0,0 +1,17 @@
1
+
2
+ <div class="header">
3
+ <span class="title">Add a new Report Item</span>
4
+ </div>
5
+ <div class="body">
6
+ <% form_for :report_item, @report_item, :url => mg_report_report_items_url(:report_id => @report.id), :html => { :method => :post, :class => "remote-form report-item", :'data-res' => ".report-items-model .model" } do |f| %>
7
+
8
+ <div>
9
+ <%= f.error_messages %>
10
+ <%= render :partial => 'mg/report_items/report_item_form', :locals => { :f => f } %>
11
+ </div>
12
+
13
+ <div class="submit">
14
+ <%= f.submit 'Save', :class => 'bluebutton' %>
15
+ </div>
16
+ <% end %>
17
+ </div>
@@ -0,0 +1,13 @@
1
+ <%# locals => report %>
2
+
3
+ <div class="statpad funnel">
4
+ <div class="title">Funnel Chart</div>
5
+ <div class="statbody">
6
+ <div id="chart_<%=h report.id %>" data-raphael="funnel" data-x-axis="date"
7
+ <%# TODO: There's a ton of assumptions here %>
8
+ data-x="<%= report.mg_report_items.map { |ri| ri.reportable.mg_records.count }.join(',') %>"
9
+ data-y="<%= report.mg_report_items.map { |ri| "'#{ri.reportable.name}'" }.join(',') %>"
10
+ style="width: 450px; height: 450px;" />
11
+ </div>
12
+ </div>
13
+ </div>
@@ -0,0 +1,21 @@
1
+ <%# locals => f %>
2
+
3
+ <div class="item title">
4
+ <%= f.label :title %>
5
+ <%= f.text_field :title %>
6
+ </div>
7
+
8
+ <div class="item description">
9
+ <%= f.label :description %>
10
+ <%= f.text_area :description %>
11
+ </div>
12
+
13
+ <div class="item delivert_set">
14
+ <%= f.label :delivery_set, 'Frequency' %>
15
+ <%= f.select :delivery_set, options_for_select( [ [ 'daily', 'daily' ], [ 'weekly', 'weekly' ], [ 'monthly', 'monthly' ] ] ) %>
16
+ </div>
17
+
18
+ <div class="item recipients">
19
+ <%= f.label :recipients, 'Recipients' %>
20
+ <%= f.text_area :recipients %>
21
+ </div>
@@ -0,0 +1,5 @@
1
+ <%# locals => report %>
2
+
3
+ <% report.report_items.each do |report_item| %>
4
+ <%= render :partial => 'mg/report_items/show', :locals => { :report_item => report_item } %>
5
+ <% end %>
@@ -0,0 +1,36 @@
1
+
2
+ <div id="container-main" class="mt-reports">
3
+ <div class="mountain-goat-panel centered">
4
+ <ul class="nav">
5
+ <li><a href="<%= mg_reports_url %>">Reports</a></li>
6
+ <li><a href="<%= mg_report_url @report.id %>"><%=h @report.title %></a></li>
7
+ </ul>
8
+
9
+ <h1>Edit <%= @report.title %></h1>
10
+
11
+ <% form_for :report, @report, :url => mg_report_url(:id => @report.id), :html => { :method => :put } do |f| %>
12
+ <%= f.error_messages %>
13
+
14
+ <div class="report-report-items">
15
+ <h4>Report Items</h4>
16
+ <%= render :partial => "mg/reports/report_report_items", :locals => { :report => @report } %>
17
+ </div>
18
+
19
+ <a href="javascript:void(0)" class="smallbutton redbutton remote-link" data-path="<%= new_mg_report_report_item_url(:report_id => @report.id) %>" data-res=".report-items-model .model">+ Add Item</a>
20
+
21
+ <%= render :partial => 'mg/reports/report_form', :locals => { :f => f } %>
22
+
23
+ <div class="item submit">
24
+ <%= f.submit 'Submit' %>
25
+ </div>
26
+
27
+ <div class="report-items-model flash-model model">
28
+ <div class="jqmWindow">
29
+ <a href="#" class="jqmClose">Close</a>
30
+ <div class="model" data-model=".jqmWindow"></div>
31
+ </div>
32
+ </div>
33
+ <% end %>
34
+ </div>
35
+ </div>
36
+
@@ -0,0 +1,23 @@
1
+ <div id="container-main" class="mg-reports">
2
+ <h1>Your Reports</h1>
3
+ <div class="container-content">
4
+ <div class="title-bar">
5
+ <span class="category name">Report</span>
6
+ <span class="category frequency">Frequency</span>
7
+ <span class="category actions">Actions</span>
8
+ </div>
9
+ <ul class="listed">
10
+ <% @reports.each do |report| %>
11
+ <li class="report">
12
+ <span class="category name"><%=h report.title %></span>
13
+ <span class="category frequency">Frequency</span>
14
+ <span class="category actions"><a href="<%= edit_mg_report_url :id => report.id %>">Edit</a> Hide</span>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+
19
+ <div class="action-bar">
20
+ <a class="button" href="<%= new_mg_report_url %>">New Report</a>
21
+ </div>
22
+ </div>
23
+ </div>
@@ -0,0 +1,21 @@
1
+
2
+ <div id="container-main" class="mt-reports show">
3
+ <div class="mountain-goat-panel centered">
4
+ <ul class="nav">
5
+ <li><a href="<%= mg_reports_url %>">Reports</a></li>
6
+ <li><a href="<%= mg_report_url @report.id %>"><%=h @report.title %></a></li>
7
+ </ul>
8
+
9
+ <h2><%=h @report.title %></h2>
10
+
11
+ <h4><%=h @report.description %></h4>
12
+
13
+ <% @report.report_items.each do |report_item| %>
14
+ <%= render 'mg/report_items/chart', :report_item => report_item %>
15
+ <% end %>
16
+
17
+ <div class="actions">
18
+ <a class="button" href="<%= edit_mg_report_url @report %>">Edit</a>
19
+ </div>
20
+ </div>
21
+ </div>
@@ -0,0 +1,25 @@
1
+ <%# locals => f %>
2
+
3
+ <div class="item test-type">
4
+ <% if f.object.new_record? %>
5
+ <%= f.text_field :test_type %>
6
+ <%= f.label :test_type, 'Test Type (Technical)' %>
7
+ <% else %>
8
+ <h2><%= f.object.test_type %></h2>
9
+ <label>Test Type (Technical)</label>
10
+ <% end %>
11
+ </div>
12
+
13
+ <div class="item title">
14
+ <%= f.text_field :title %>
15
+ <%= f.label :title %>
16
+ </div>
17
+
18
+ <div class="item tally-each-serve">
19
+ <%= f.check_box :tally_each_serve %>
20
+ <%= f.label :tally_each_serve, "Tally every hit?" %>
21
+ </div>
22
+
23
+ <div class="item submit">
24
+ <%= f.submit 'Submit' %>
25
+ </div>
@@ -0,0 +1,12 @@
1
+ <div id="container-main" class="mg-test-edit">
2
+ <h1>Edit <%= @test.title.capitalize %></h1>
3
+ <div class="container-content">
4
+ <div class="edit-form">
5
+ <% form_for :test, @test, :url => mg_test_url(:id => @test.id), :html => { :method => :put } do |f| %>
6
+ <%= f.error_messages %>
7
+
8
+ <%= render 'test_form', :f => f %>
9
+ <% end %>
10
+ </div>
11
+ </div>
12
+ </div>
@@ -0,0 +1,48 @@
1
+ <div id="container-main" class="mg-tests">
2
+ <h1>Your Tests</h1>
3
+ <div class="container-content">
4
+ <div class="title-bar">
5
+ <span class="category test">Test</span>
6
+ <span class="category choice">Choice</span>
7
+ <span class="category served">Served</span>
8
+ <span class="category hit-points">Points</span>
9
+ <span class="category actions">Actions</span>
10
+ </div>
11
+ <ul class="listed">
12
+ <% @tests.each do |test| %>
13
+ <li class="test-condition">
14
+ <span class="category test"><%=h test.title %></span>
15
+ <span class="category choice"></span>
16
+ <span class="category served"><%=h test.total_served %></span>
17
+ <span class="category hit-points"><%=h test.total_reward %></span>
18
+ <span class="category actions">
19
+ <a href="<%= mg_test_url test %>">View</a>
20
+ <a href="<%= edit_mg_test_url :id => test %>">Edit</a>
21
+ <a href="<%= hide_mg_test_url test %>">Hide</a>
22
+ </span>
23
+ <ul class="choices">
24
+ <% test.mg_choices.each do |choice| %>
25
+ <li class="choice">
26
+ <span class="category test"></span>
27
+ <span class="category choice"><%=h choice.name %></span>
28
+ <span class="category served"><%=h choice.served %></span>
29
+ <span class="category hit-points"><%=h choice.reward %></span>
30
+ <span class="category actions"></span>
31
+ </li>
32
+ <% end %>
33
+ </ul>
34
+ </li>
35
+ <% end %>
36
+ </ul>
37
+ <div class="action-bar">
38
+ <a class="button" href="<%= new_mg_test_url %>">New Test</a>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="hidden-tests">
43
+ <% @hidden_tests.each do |test| %>
44
+ <span class="name"><%=h test.title %></span>
45
+ <span class="unhide"><a href="<%= unhide_mg_test_url :id => test.id %>">Restore</a></span>
46
+ <% end %>
47
+ </div>
48
+ </div>
@@ -0,0 +1,12 @@
1
+ <div id="container-main" class="mg-test-new">
2
+ <h1>Create New Test</h1>
3
+ <div class="container-content">
4
+ <div class="edit-form">
5
+ <% form_for :test, @test, :url => mg_tests_url do |f| %>
6
+ <%= f.error_messages %>
7
+
8
+ <%= render 'test_form', :f => f %>
9
+ <% end %>
10
+ </div>
11
+ </div>
12
+ </div>