metric_admin 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ module MetricAdmin
2
+ class Admin::MetricSummariesController < ApplicationController
3
+ layout 'admin'
4
+
5
+ def destroy
6
+ @metric_summary = MetricSummary.find(params[:id])
7
+ if @metric_summary && @metric_summary.destroy
8
+ redirect_to edit_admin_metric_path(@metric_summary.metric), :notice => "Metric Summary was deleted."
9
+ else
10
+ redirect_to edit_admin_metric_path(@metric_summary.metric), :alert => "Metric Summary was not deleted."
11
+ end
12
+ end
13
+ end
14
+ end
@@ -17,6 +17,7 @@ module MetricAdmin
17
17
  @metric = Metric.find(params[:id])
18
18
  @resources = Resource.all
19
19
  @resource_type = ResourceType.find_by_id(@metric.resource_type_id)
20
+ 1.times { @metric.metric_summaries.build }
20
21
  end
21
22
 
22
23
  def new
@@ -39,6 +40,8 @@ module MetricAdmin
39
40
 
40
41
  def create
41
42
  @metric = Metric.new(params[:metric])
43
+ @metric.has_detail = 1
44
+ @metric.data_type = "integer"
42
45
  if @metric.save
43
46
  flash[:success] = "#{@metric.title} has been created"
44
47
  redirect_to admin_metrics_url
@@ -119,6 +122,5 @@ module MetricAdmin
119
122
  render :action => :index, :status => :unprocessable_entity
120
123
  end
121
124
  end
122
-
123
125
  end
124
126
  end
@@ -0,0 +1,19 @@
1
+ - f.fields_for :metric_summaries do |ms|
2
+ %div.summary
3
+ = ms.label "Metric summary title"
4
+ = ms.text_field :title
5
+ = ms.label "Group by"
6
+ = ms.select :group_by_key, eval(@metric.logic.match(/\['(.*?)'\]/)[0])
7
+ and
8
+ = ms.label "Action"
9
+ = ms.select :action, %w(count sum average median), {}, :class => "action-to-take"
10
+ on
11
+ %div.acton
12
+ = ms.label "Act on"
13
+ = ms.select :action_on, eval(@metric.logic.match(/\['(.*?)'\]/)[0])
14
+ = link_to "Add summary", "#", :class => "add_fields", :'data-id' => @metric.id
15
+ - if ms.object.new_record?
16
+ = link_to "Remove", "#", :class => "remove_fields"
17
+ - else
18
+ = link_to "Remove", admin_metric_metric_summary_path(@metric, ms.object), :method => :delete, :remote => true, :class => "remove_fields"
19
+ = ms.hidden_field :id
@@ -84,6 +84,10 @@
84
84
  %label.control-label{:for => "staff_evaluation"} Staff: (for purposes of metric evaluation)
85
85
  = collection_select :metric, :staff_evaluation, @metric.resource_type.resources, :code, :name
86
86
  %br
87
+ %label.control-label{:for => "description"} Configure Summaries:
88
+ .controls
89
+ = render :partial => "metric_summaries", :locals => { :f => f } if @metric.logic.match(/\['(.*?)'\]/).present?
90
+ %br
87
91
  %button.btn.run_logic{"aria-hidden" => "true", "data-dismiss" => "modal"}
88
92
  Run
89
93
  %i.icon-play
@@ -143,9 +147,11 @@
143
147
  contentType: "application/json; charset=utf-8",
144
148
  data: JSON.stringify({logic: editor_contents , logic_staff: $("#metric_staff_evaluation").val() }),
145
149
  success: function(data){
150
+ console.log("SUCCESS......", data)
146
151
  $('.loaderImage').hide();
147
152
  },
148
153
  error: function (response) {
154
+ console.log("FAILURE", response)
149
155
  $('.loaderImage').hide();
150
156
  $('.errors').html(response.responseText);
151
157
  $('.error-wrapper').show();
@@ -37,6 +37,11 @@
37
37
  = f.text_area :logic, :class=>"my-code-area input-block-level", :placeholder => "Technical Explanation", :value => @metric.logic, :rows => 20
38
38
 
39
39
  %br
40
+ .error-wrapper
41
+ %label.control-label{:for => "description"} Errors:
42
+ .controls
43
+ = f.text_area :logic_errors, :class=>"input-block-level errors", :placeholder => "Error Container", :value => "", :rows => 20
44
+ %br
40
45
  .controls
41
46
  %label.control-label{:for => "logic_staff"} Staff: (for purposes of metric evaluation)
42
47
  = text_field_tag :logic_staff, Resource.first(:conditions=>["resource_type_id = ?", params[:resource_type_id]]).code
@@ -89,7 +94,7 @@
89
94
  - content_for :footer do
90
95
  :javascript
91
96
  $(document).ready(function() {
92
-
97
+ $(".error-wrapper").hide();
93
98
  $("#metric_title").on("blur", function(){
94
99
  $("#metric_name").val( $("#metric_name").data('type') + "_" + this.value.replace(/[^A-Z0-9]/ig, "_").toLowerCase());
95
100
  });
@@ -105,7 +110,8 @@
105
110
 
106
111
  $('.quantified_result').html('');
107
112
  $('.detailed_results').html('');
108
-
113
+ $('.errors').html('');
114
+ $(".error-wrapper").hide()
109
115
  $.ajax(
110
116
  {
111
117
  type: "POST",
@@ -119,6 +125,8 @@
119
125
  },
120
126
  error: function (response) {
121
127
  $('.loaderImage').hide();
128
+ $('.errors').html(response.responseText);
129
+ $('.error-wrapper').show();
122
130
  }
123
131
  }
124
132
  );
@@ -1,3 +1,3 @@
1
1
  module MetricAdmin
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 12
9
- version: 0.0.12
8
+ - 13
9
+ version: 0.0.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - Analytics For Lawyers
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2016-09-23 00:00:00 -04:00
17
+ date: 2016-09-29 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,9 @@ files:
61
61
  - LICENSE.txt
62
62
  - README.md
63
63
  - Rakefile
64
+ - app/controllers/admin/metric_summaries_controller.rb
64
65
  - app/controllers/admin/metrics_controller.rb
66
+ - app/views/admin/metrics/_metric_summaries.html.haml
65
67
  - app/views/admin/metrics/edit.haml
66
68
  - app/views/admin/metrics/evaluate.js.erb
67
69
  - app/views/admin/metrics/index.haml