Commit 4e192d90d72b944baef7db61c75aa9e075b7ff2f

Authored by João M. M. da Silva + Alessandro Palmeira + Diego Araújo
Committed by Paulo Meireles
1 parent 46b3891d

[Mezuro] Handling javascript errors in mezuro configuration edition.

plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb
@@ -28,7 +28,6 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController @@ -28,7 +28,6 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController
28 metric_configuration.save 28 metric_configuration.save
29 if metric_configuration_has_errors? metric_configuration 29 if metric_configuration_has_errors? metric_configuration
30 @error = metric_configuration.errors[0].message 30 @error = metric_configuration.errors[0].message
31 - #redirect_to_error_page metric_configuration.errors[0].message  
32 end 31 end
33 end 32 end
34 33
@@ -41,7 +40,7 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController @@ -41,7 +40,7 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController
41 metric_configuration.ranges[index] = Kalibro::Range.new params[:range] 40 metric_configuration.ranges[index] = Kalibro::Range.new params[:range]
42 metric_configuration.save 41 metric_configuration.save
43 if metric_configuration_has_errors? metric_configuration 42 if metric_configuration_has_errors? metric_configuration
44 - redirect_to_error_page metric_configuration.errors[0].message 43 + @error = metric_configuration.errors[0].message
45 end 44 end
46 end 45 end
47 46
@@ -57,9 +56,9 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController @@ -57,9 +56,9 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController
57 else 56 else
58 formatted_metric_name = metric_name.gsub(/\s/, '+') 57 formatted_metric_name = metric_name.gsub(/\s/, '+')
59 if metric_configuration.metric.class == Kalibro::CompoundMetric 58 if metric_configuration.metric.class == Kalibro::CompoundMetric
60 - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/edit_compound_metric_configuration?id=#{configuration_content.id}&metric_name=#{formatted_metric_name}" 59 + redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound_metric_configuration?id=#{configuration_content.id}&metric_name=#{formatted_metric_name}"
61 else 60 else
62 - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/edit_metric_configuration?id=#{configuration_content.id}&metric_name=#{formatted_metric_name}" 61 + redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_metric_configuration?id=#{configuration_content.id}&metric_name=#{formatted_metric_name}"
63 end 62 end
64 end 63 end
65 end 64 end
plugins/mezuro/lib/kalibro/range.rb
@@ -18,7 +18,7 @@ class Kalibro::Range < Kalibro::Model @@ -18,7 +18,7 @@ class Kalibro::Range < Kalibro::Model
18 18
19 def end=(value) 19 def end=(value)
20 @end = value.to_f 20 @end = value.to_f
21 - @end = 1.0/0.0 if value == "INF" 21 + @end = 1.0/0.0 if value =~ /INF/
22 end 22 end
23 23
24 def end 24 def end
plugins/mezuro/views/mezuro_plugin_range/create_range.rjs
1 -page.alert @error  
2 -page.visual_effect :toggle_slide, "range_form"  
3 -page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range} 1 +if @error.nil?
  2 + page.visual_effect :toggle_slide, "range_form"
  3 + page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range}
  4 +else
  5 + page.alert @error
  6 +end
plugins/mezuro/views/mezuro_plugin_range/update_range.rjs
1 -page.reload() 1 +if @error.nil?
  2 + page.reload()
  3 +else
  4 + page.alert @error
  5 +end