From 1f929062725d05a0c7c72e4db19eae34c78052ab Mon Sep 17 00:00:00 2001
From: Alessandro Palmeira + João M. M. da Silva
Date: Thu, 29 Mar 2012 17:17:57 -0300
Subject: [PATCH] [Mezuro] Added "new range" partials in metric configuration
---
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb | 20 ++++++++++++++++++++
plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb | 15 +++++++++++++++
plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs | 2 ++
plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb | 35 ++++++++++++++++++++++++++++++++++-
plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs | 2 ++
6 files changed, 128 insertions(+), 1 deletion(-)
create mode 100644 plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb
create mode 100644 plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb
create mode 100644 plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs
create mode 100644 plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs
diff --git a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
index c57402b..3397f43 100644
--- a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
+++ b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -56,6 +56,13 @@ class MezuroPluginProfileController < ProfileController
@metric_configuration.metric = Kalibro::Entities::NativeMetric.new
@metric_configuration.metric.name = "Nome falso"
@metric_configuration.metric.origin = "Origem Falsa"
+ range = Kalibro::Entities::Range.new
+ range.beginning = "0"
+ range.end = "100"
+ range.label = "fake label"
+ range.grade = "100"
+ range.color = "FFFFFF"
+ @metric_configuration.range = [range]
end
def create_metric_configuration
@@ -67,4 +74,17 @@ class MezuroPluginProfileController < ProfileController
@configuration_name = params[:configuration_name]
redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
end
+
+ def new_range
+ end
+
+ def create_range
+ @range = Kalibro::Entities::Range.new
+ @range.beginning = params[:range][:beginning]
+ @range.end = params[:range][:end]
+ @range.label = params[:range][:label]
+ @range.grade = params[:range][:grade]
+ @range.color = params[:range][:color]
+ @range.comments = params[:range][:comments]
+ end
end
diff --git a/plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb b/plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb
new file mode 100644
index 0000000..0f5cc57
--- /dev/null
+++ b/plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb
@@ -0,0 +1,55 @@
+<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %>
+ <%= hidden_field_tag :configuration_name, @configuration_name %>
+ <%= hidden_field_tag :metric_name, @metric_name %>
+
+
+ |
+ <%= f.label :label, "Label:" %>
+ |
+
+ <%= f.text_field :label %>
+ |
+
+
+ |
+ <%= f.label :beginning, "Beginning:" %>
+ |
+
+ <%= f.text_field :beginning %>
+ |
+
+
+ |
+ <%= f.label :end, "End:" %>
+ |
+
+ <%= f.text_field :end %>
+ |
+
+
+ |
+ <%= f.label :grade, "Grade:" %>
+ |
+
+ <%= f.text_field :grade %>
+ |
+
+
+ |
+ <%= f.label :color, "Color:" %>
+ |
+
+ <%= f.text_field :color %>
+ |
+
+
+ |
+ <%= f.label :comments, "Comments:" %>
+ |
+
+ <%= f.text_field :comments %>
+ |
+
+
+ <%= f.submit "Save Range" %>
+<% end %>
diff --git a/plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb b/plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb
new file mode 100644
index 0000000..486c70f
--- /dev/null
+++ b/plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb
@@ -0,0 +1,15 @@
+
+ |
+ <%=range.label%>
+ |
+
+ <%=range.beginning%>
+ |
+
+ <%=range.end%>
+ |
+
+ <%=range.grade%>
+ |
+ |
+
diff --git a/plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs b/plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs
new file mode 100644
index 0000000..ef31d1d
--- /dev/null
+++ b/plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs
@@ -0,0 +1,2 @@
+page.visual_effect :toggle_slide, "new_range"
+page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range}
diff --git a/plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb b/plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb
index 4e53145..2af27d5 100644
--- a/plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb
+++ b/plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb
@@ -26,8 +26,41 @@
<%= f.label :weight, "Weight:" %>
<%= f.text_field :weight %>
+
<%= f.submit "Save" %>
-
<% end %>
+
+
+ Ranges
+
+
+
+ |
+ Label
+ |
+
+ Beginning
+ |
+
+ End
+ |
+
+ Grade
+ |
+
+ Color
+ |
+
+ <% if (@metric_configuration.ranges!=nil)
+ @metric_configuration.ranges.each do |range| %>
+ <%= render :partial => "range", :locals => {:range => range} %>
+ <% end
+ end %>
+
+
+
+<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_profile"} %>
+
+
diff --git a/plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs b/plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs
new file mode 100644
index 0000000..2613dd3
--- /dev/null
+++ b/plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs
@@ -0,0 +1,2 @@
+page.replace_html 'new_range', :partial => "new_range"
+page.visual_effect :toggle_slide, "new_range"
--
libgit2 0.21.2