Commit 6319f24585d07402b4c62738903827814465cc7d

Authored by João M. M. da Silva + Diego Araújo
Committed by Paulo Meireles
1 parent 38d8bf14

[Mezuro] Refactored duplicated code in views.

Showing 28 changed files with 172 additions and 315 deletions   Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_metric_configuration_controller.rb
... ... @@ -9,9 +9,9 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle
9 9  
10 10 def new_native
11 11 @configuration_content = profile.articles.find(params[:id])
12   - @base_tool_name = params[:base_tool_name]
13   - @metric = Kalibro::BaseTool.find_by_name(@base_tool_name).metric params[:metric_name]
14 12 @reading_group_names_and_ids = reading_group_names_and_ids
  13 + @metric = Kalibro::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name]
  14 + @metric_configuration = Kalibro::MetricConfiguration.new :base_tool_name => params[:base_tool_name], :metric => @metric
15 15 end
16 16  
17 17 def edit_native
... ... @@ -22,6 +22,8 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle
22 22 @configuration_content = profile.articles.find(params[:id])
23 23 @metric_configurations = @configuration_content.metric_configurations
24 24 @reading_group_names_and_ids = reading_group_names_and_ids
  25 + metric = Kalibro::Metric.new :compound => true
  26 + @metric_configuration = Kalibro::MetricConfiguration.new :metric => metric
25 27 if configuration_content_has_errors?
26 28 redirect_to_error_page @configuration_content.errors[:base]
27 29 end
... ... @@ -34,11 +36,11 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle
34 36 def create
35 37 configuration_content = profile.articles.find(params[:id])
36 38 metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration])
37   -
  39 +
38 40 if metric_configuration_has_errors? metric_configuration
39 41 redirect_to_error_page metric_configuration.errors[0].message
40 42 else
41   - redirect_to(metric_configuration_url(configuration_content))
  43 + redirect_to(metric_configuration_url(configuration_content, metric_configuration.id))
42 44 end
43 45 end
44 46  
... ... @@ -85,12 +87,12 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle
85 87 not @configuration_content.errors[:base].nil?
86 88 end
87 89  
88   - def metric_configuration_url configuration_content
  90 + def metric_configuration_url(configuration_content, metric_configuration_id)
89 91 url = configuration_content.view_url
90 92 url[:controller] = controller_name
91 93 url[:id] = configuration_content.id
92   - url[:metric_configuration_id] = params[:metric_configuration][:id].to_i
93   - url[:action] = (params[:metric_configuration][:metric][:compound] ? "edit_compound" : "edit_native")
  94 + url[:metric_configuration_id] = metric_configuration_id
  95 + url[:action] = (params[:metric_configuration][:metric][:compound] == "true" ? "edit_compound" : "edit_native")
94 96 url
95 97 end
96 98  
... ... @@ -104,3 +106,4 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle
104 106 end
105 107  
106 108 end
  109 +
... ...
plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb
... ... @@ -40,8 +40,7 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController
40 40 end
41 41  
42 42 def reading_labels_and_ids
43   - array = Kalibro::Reading.readings_of(params[:reading_group_id].to_i).map { |reading| [reading.label, reading.id] }
44   - array.sort { |x,y| x.first.downcase <=> y.first.downcase }
  43 + Kalibro::Reading.readings_of(params[:reading_group_id].to_i).map { |reading| [reading.label, reading.id] }
45 44 end
46 45  
47 46 def save_range
... ...
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
... ... @@ -19,7 +19,7 @@ class MezuroPluginRepositoryController &lt; MezuroPluginProfileController
19 19  
20 20 if( repository.errors.empty? )
21 21 repository.process
22   - redirect_to(repository_url(project_content))
  22 + redirect_to(repository_url(project_content, repository.id))
23 23 else
24 24 redirect_to_error_page repository.errors[0].message
25 25 end
... ... @@ -27,13 +27,13 @@ class MezuroPluginRepositoryController &lt; MezuroPluginProfileController
27 27  
28 28 def show
29 29 @project_content = profile.articles.find(params[:id])
30   - @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
  30 + @repository = @project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_i }.first
31 31 @configuration_name = Kalibro::Configuration.configuration_of(@repository.id).name
32 32 end
33 33  
34 34 def destroy
35 35 project_content = profile.articles.find(params[:id])
36   - repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
  36 + repository = Kalibro::Repository.new :id => params[:repository_id]
37 37 repository.destroy
38 38 if( repository.errors.empty? )
39 39 redirect_to project_content.view_url
... ... @@ -44,11 +44,11 @@ class MezuroPluginRepositoryController &lt; MezuroPluginProfileController
44 44  
45 45 private
46 46  
47   - def repository_url project_content
  47 + def repository_url(project_content, repository_id)
48 48 url = project_content.view_url
49 49 url[:controller] = controller_name
50 50 url[:id] = project_content.id
51   - url[:repository_id] = params[:repository_id].to_i
  51 + url[:repository_id] = repository_id
52 52 url[:action] = "show"
53 53 url
54 54 end
... ...
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
... ... @@ -17,9 +17,7 @@ class MezuroPlugin::Helpers::ContentViewerHelper
17 17 def self.license_options
18 18 options = YAML.load_file("#{RAILS_ROOT}/plugins/mezuro/licenses.yml")
19 19 options = options.split(";")
20   - formated_options = []
21   - options.each { |option| formated_options << [option, option] }
22   - formated_options
  20 + options
23 21 end
24 22  
25 23 def self.generate_chart(score_history)
... ...
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
... ... @@ -56,7 +56,7 @@ class MezuroPluginMetricConfigurationControllerTest &lt; ActionController::TestCase
56 56 get :new_native, :profile => @profile.identifier, :id => @configuration_content.id, :base_tool_name => @base_tool.name, :metric_name => @metric.name
57 57 assert_equal @configuration_content, assigns(:configuration_content)
58 58 assert_equal @metric.name, assigns(:metric).name
59   - assert_equal @base_tool.name, assigns(:base_tool_name)
  59 + assert_equal @base_tool.name, assigns(:metric_configuration).base_tool_name
60 60 assert_equal [[@reading_group.name,@reading_group.id]], assigns(:reading_group_names_and_ids)
61 61 assert_response :success
62 62 end
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... ... @@ -84,9 +84,8 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
84 84 end
85 85  
86 86 should 'destroy a repository' do
  87 + Kalibro::Repository.expects(:new).with(:id => @repository.id.to_s).returns(@repository)
87 88 @repository.expects(:destroy)
88   - Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository])
89   -
90 89 get :destroy, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
91 90  
92 91 assert @repository.errors.empty?
... ... @@ -95,12 +94,11 @@ class MezuroPluginRepositoryControllerTest &lt; ActionController::TestCase
95 94  
96 95 should 'not destroy a repository' do
97 96 @repository.errors = [Exception.new]
  97 + Kalibro::Repository.expects(:new).with(:id => @repository.id.to_s).returns(@repository)
98 98 @repository.expects(:destroy)
99   - Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository])
100   -
101 99 get :destroy, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
102 100  
103   - assert !@repository.errors.empty?
  101 + #TODO verify if it is redirected to the right page
104 102 assert_response :redirect
105 103 end
106 104 end
... ...
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
... ... @@ -9,18 +9,11 @@
9 9  
10 10  
11 11 <%= hidden_field_tag 'configuration_content[profile_id]', profile.id %>
12   -<%= hidden_field_tag 'id', @article.id %>
13 12 <%= hidden_field_tag 'configuration_id', @article.configuration_id %>
  13 +<%= render :partial => "cms/mezuro_plugin/mezuro_content_form", :locals => {:f => f} %>
14 14  
15   -<%= required_fields_message %>
16   -
17   -<%= required f.text_field(:name) %>
18   -
19   -<%= f.text_field :description %><br/>
20   -
  15 +<br/>
21 16 <%= if kalibro_configuration.nil?
22 17 required labelled_form_field _('Clone Configuration'),
23 18 f.select(:configuration_to_clone_id, configuration_names_and_ids)
24 19 end %>
25   -<br/>
26   -
... ...
plugins/mezuro/views/cms/mezuro_plugin/_mezuro_content_form.html.erb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +<%= hidden_field_tag 'id', @article.id %>
  2 +<%= required_fields_message %>
  3 +<%= required f.text_field(:name) %>
  4 +<%= f.text_field :description %><br/>
... ...
plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
... ... @@ -7,14 +7,5 @@
7 7 <%= error_messages_for 'project_content' %>
8 8  
9 9 <%= hidden_field_tag 'project_content[profile_id]', profile.id %>
10   -<%= hidden_field_tag 'id', @article.id %>
11 10 <%= hidden_field_tag 'project_id', @article.project_id %>
12   -
13   -<%= required_fields_message %>
14   -
15   -<%= required f.text_field(:name) %>
16   -
17   -<%= f.text_field :description %><br/>
18   -
19   -<!-- partial rendered in app/views/cms/edit.rhtml -->
20   -<!-- After submit, the action cms/new is called -->
  11 +<%= render :partial => "cms/mezuro_plugin/mezuro_content_form", :locals => {:f => f} %>
... ...
plugins/mezuro/views/cms/mezuro_plugin/_reading_group_content.html.erb
... ... @@ -7,14 +7,5 @@
7 7 <%= error_messages_for 'reading_group_content' %>
8 8  
9 9 <%= hidden_field_tag 'reading_group_content[profile_id]', profile.id %>
10   -<%= hidden_field_tag 'id', @article.id %>
11 10 <%= hidden_field_tag 'reading_group_id', (reading_group.id unless reading_group.nil?) %>
12   -
13   -<%= required_fields_message %>
14   -
15   -<%= required f.text_field(:name) %>
16   -
17   -<%= f.text_field :description %><br/>
18   -
19   -<!-- partial rendered in app/views/cms/edit.rhtml -->
20   -<!-- After submit, the action cms/new is called -->
  11 +<%= render :partial => "cms/mezuro_plugin/mezuro_content_form", :locals => {:f => f} %>
... ...
plugins/mezuro/views/content_viewer/show_configuration.rhtml
1 1 <% @configuration_content = @page
2 2 @kalibro_configuration = @page.kalibro_configuration %>
  3 +<!-- #TODO check owner verification to remove or edit metric configuration -->
3 4 <% owner = (not user.nil?) && user.id == @profile.id %>
4 5 <% unless @page.errors[:base].nil? %>
5 6 <% if @page.errors[:base] =~ /Kalibro::Errors::RecordNotFound/ %>
... ...
plugins/mezuro/views/content_viewer/show_project.rhtml
1 1 <% @project = @page.project %>
2 2 <% unless @page.errors[:base].nil? %>
  3 +<!-- #TODO add owner verification to remove or edit repository -->
3 4 <% if @page.errors[:base] == "Kalibro::Errors::RecordNotFound" %>
4 5 <h3>Warning:</h3>
5 6 <p>This project doesn't exist on the Web Service. Do you want to <%= link_to 'delete', :action => 'destroy', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %> or <%= link_to 'save it again', :action => 'edit', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %>?</p>
... ...
plugins/mezuro/views/content_viewer/show_reading_group.rhtml
1 1 <% @reading_group = @page.reading_group %>
  2 +<!-- #TODO add owner verification to remove or edit reading group -->
2 3 <% unless @page.errors[:base].nil? %>
3 4 <% if @page.errors[:base] == "Kalibro::Errors::RecordNotFound" %>
4 5 <h3>Warning:</h3>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/_compound_metric_configuration_form.html.erb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +<%= hidden_field_tag :id, @configuration_content.id %>
  2 +<%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %>
  3 +
  4 +<% f.fields_for :metric do |m| %>
  5 + <%= m.hidden_field :compound, :value => "true" %>
  6 + <%= required labelled_form_field _('Metric Name:'), m.text_field(:name, :value => @metric_configuration.metric.name) %>
  7 + <%= labelled_form_field _('Description:'), m.text_field(:description, :value => @metric_configuration.metric.description) %>
  8 + <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5, :value => @metric_configuration.metric.script) %>
  9 + <%= required labelled_form_field _('Scope:'),
  10 + m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options, :selected => @metric_configuration.metric.scope) %>
  11 +<% end %>
  12 +
  13 +<%= required labelled_form_field _('Code:'), f.text_field(:code) %>
  14 +<%= required labelled_form_field _('Aggregation Form:'),
  15 + f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %>
  16 +<%= required labelled_form_field _('Weight:'), f.text_field(:weight) %>
  17 +<%= required labelled_form_field _('Reading Group:'), f.select(:reading_group_id, @reading_group_names_and_ids) %>
  18 +
  19 +<p><%= f.submit "Save" %></p>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/_metric_configuration_view.rhtml
... ... @@ -1,15 +0,0 @@
1   -<p>
2   - <b>Collector Name:</b> <%= @metric_configuration.base_tool_name %>
3   -</p>
4   -<p>
5   - <b>Metric Name:</b> <%= @metric.name %>
6   -</p>
7   -<p>
8   - <b>Code:</b> <%= @metric_configuration.code %>
9   -</p>
10   -<p>
11   - <b>Aggregation Form:</b> <%= @metric_configuration.aggregation_form %>
12   -</p>
13   -<p>
14   - <b>Weight:</b> <%= @metric_configuration.weight %>
15   -</p>
plugins/mezuro/views/mezuro_plugin_metric_configuration/_native_metric_configuration_form.rhtml
1   -<% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
2   - <%= hidden_field_tag :id, @configuration_content.id %>
3   - <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %>
4   - <%= f.hidden_field :id %>
  1 +<%= hidden_field_tag :id, @configuration_content.id %>
  2 +<%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %>
5 3  
6   - <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :readonly => true) %>
  4 +<%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :readonly => true) %>
7 5  
8   - <% f.fields_for :metric do |m| %>
9   - <%= m.hidden_field :compound, :value => "false" %>
10   - <% @metric.language.each do |language| %>
11   - <%= m.hidden_field :language, :multiple => true, :value => language %>
12   - <% end %>
13   - <%= m.hidden_field "scope", :value => @metric.scope %>
14   - <%= labelled_form_field _('Metric Name:'), m.text_field(:name, :value => @metric.name, :readonly => true) %>
15   - <%= labelled_form_field _('Description:'), m.text_field(:description, :value => @metric.description, :readonly => true) %>
  6 +<% f.fields_for :metric do |m| %>
  7 + <%= m.hidden_field :compound, :value => "false" %>
  8 + <% @metric_configuration.metric.language.each do |language| %>
  9 + <%= m.hidden_field :language, :multiple => true, :value => language %>
16 10 <% end %>
17   -
18   - <%= required labelled_form_field _('Code:'), f.text_field(:code) %>
  11 + <%= m.hidden_field "scope", :value => @metric.scope %>
  12 + <%= required labelled_form_field _('Metric Name:'), m.text_field(:name, :readonly => true, :value => @metric.name) %>
  13 + <%= labelled_form_field _('Description:'), m.text_field(:description, :readonly => true, :value => @metric.description) %>
  14 +<% end %>
19 15  
20   - <%= required labelled_form_field _('Aggregation Form:'),
21   - f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %>
  16 +<%= required labelled_form_field _('Code:'), f.text_field(:code) %>
22 17  
23   - <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %>
24   -
25   - <%= required labelled_form_field _('Reading Group:'),
26   - f.select(:reading_group_id, @reading_group_names_and_ids) %>
27   -
28   - <p>
29   - <%= f.submit "Save" %>
30   - </p>
31   -<% end %>
  18 +<%= required labelled_form_field _('Aggregation Form:'),
  19 +f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %>
  20 +
  21 +<%= required labelled_form_field _('Weight:'), f.text_field(:weight) %>
  22 +
  23 +<%= required labelled_form_field _('Reading Group:'),
  24 +f.select(:reading_group_id, @reading_group_names_and_ids) %>
  25 +
  26 +<p><%= f.submit "Save" %></p>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/_native_metric_configuration_view.rhtml 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +<p>
  2 + <b>Collector Name:</b> <%= @metric_configuration.base_tool_name %>
  3 +</p>
  4 +<p>
  5 + <b>Metric Name:</b> <%= @metric.name %>
  6 +</p>
  7 +<p>
  8 + <b>Code:</b> <%= @metric_configuration.code %>
  9 +</p>
  10 +<p>
  11 + <b>Aggregation Form:</b> <%= @metric_configuration.aggregation_form %>
  12 +</p>
  13 +<p>
  14 + <b>Weight:</b> <%= @metric_configuration.weight %>
  15 +</p>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound.html.erb
... ... @@ -7,57 +7,8 @@
7 7 <% owner = (not user.nil?) && user.id == @profile.id %>
8 8  
9 9 <% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
10   - <%= hidden_field_tag :id, @configuration_content.id %>
11   - <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %>
12 10 <%= f.hidden_field :id %>
13   -
14   - <% f.fields_for :metric do |m| %>
15   - <%= m.hidden_field :compound, :value => "true" %>
16   - <%= required labelled_form_field _('Metric Name:'), m.text_field(:name, :value => @metric.name) %>
17   - <%= labelled_form_field _('Description:'), m.text_field(:description, :value => @metric.description) %>
18   - <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5, :value => @metric.script) %>
19   - <%= required labelled_form_field _('Scope:'),
20   - m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options, :selected => @metric.scope) %>
21   - <% end %>
22   -
23   - <%= required labelled_form_field _('Code:'), f.text_field(:code) %>
24   - <%= required labelled_form_field _('Aggregation Form:'),
25   - f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %>
26   - <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %>
27   - <%= required labelled_form_field _('Reading Group:'), f.select(:reading_group_id, @reading_group_names_and_ids) %>
28   -
29   - <p><%= f.submit "Save" %></p>
30   -
  11 + <%= render :partial => "compound_metric_configuration_form", :locals => {:f => f} %>
31 12 <% end %>
32 13  
33   -<h5> Ranges </h5><br/>
34   -
35   -<table id="ranges">
36   - <tr>
37   - <td>
38   - Label
39   - </td>
40   - <td>
41   - Beginning
42   - </td>
43   - <td>
44   - End
45   - </td>
46   - <td>
47   - Grade
48   - </td>
49   - <td>
50   - Color
51   - </td>
52   - </tr>
53   - <% @ranges.each do |range| %>
54   - <%= render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id,
55   - :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %>
56   - <% end %>
57   -</table>
58   -
59   -<br/>
60   -<% if owner %>
61   - <%= link_to_remote "New Range", :url => {:action =>"new", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id} %>
62   -<% end %>
63   -<div id="form" style="display:none"></div>
  14 +<%= render :partial => "mezuro_plugin_range/ranges", :locals => {:owner => owner} %>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_native.html.erb
... ... @@ -7,42 +7,12 @@
7 7 <% owner = (not user.nil?) && user.id == @profile.id %>
8 8  
9 9 <% if owner %>
10   - <%= render :partial => "native_metric_configuration_form" %>
11   -<% else %>
12   - <%= render :partial => "metric_configuration_view" %>
13   -<% end %>
14   -
15   -<h5> Ranges </h5><br/>
16   -
17   -<table id="ranges">
18   - <tr>
19   - <td>
20   - Label
21   - </td>
22   - <td>
23   - Beginning
24   - </td>
25   - <td>
26   - End
27   - </td>
28   - <td>
29   - Grade
30   - </td>
31   - <td>
32   - Color
33   - </td>
34   - <td></td>
35   - <td></td>
36   - </tr>
37   - <% @ranges.each do |range| %>
38   - <%= render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id,
39   - :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %>
  10 + <% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
  11 + <%= f.hidden_field :id %>
  12 + <%= render :partial => "native_metric_configuration_form", :locals => {:f => f} %>
40 13 <% end %>
41   -</table>
42   -
43   -<br/>
44   -<% if owner %>
45   - <%= link_to_remote "New Range", :url => {:action =>"new", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %>
  14 +<% else %>
  15 + <%= render :partial => "native_metric_configuration_view" %>
46 16 <% end %>
47   -<div id="form" style="display:none"></div>
48 17  
  18 +<%= render :partial => "mezuro_plugin_range/ranges", :locals => {:owner => owner} %>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound.html.erb
1 1 <h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
2 2  
3 3 <% form_for :metric_configuration, :url => {:action =>"create", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @configuration_content.id %>
5   - <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %>
6   -
7   - <% f.fields_for :metric do |m| %>
8   - <%= m.hidden_field :compound, :value => "true" %>
9   - <%= required labelled_form_field _('Metric Name:'), m.text_field(:name) %>
10   - <%= labelled_form_field _('Description:'), m.text_field(:description) %>
11   - <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5) %>
12   - <%= required labelled_form_field _('Scope:'), m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options) %>
13   - <% end %>
14   -
15   - <%= required labelled_form_field _('Code:'), f.text_field(:code) %>
16   - <%= required labelled_form_field _('Aggregation Form:'), f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %>
17   - <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %>
18   - <%= required labelled_form_field _('Reading Group:'),
19   - f.select(:reading_group_id, @reading_group_names_and_ids) %>
20   -
21   - <p> <%= f.submit "Add" %> </p>
  4 + <%= render :partial => "compound_metric_configuration_form", :locals => {:f => f} %>
22 5 <% end %>
23 6  
24 7 <%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %>
25   -
26   -
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_native.html.erb
1 1 <script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script>
2 2  
3 3 <h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
4   -<!-- TODO This form should be a partial similar to _native_metric_configuration_form.rhtml -->
5   -<% form_for :metric_configuration, :url => {:action =>"create", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
6   -
7   - <%= hidden_field_tag :id, @configuration_content.id %>
8   - <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %>
9   -
10   - <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %>
11   -
12   - <% f.fields_for :metric do |m| %>
13   - <%= m.hidden_field :compound, :value => "false" %>
14   - <% @metric.language.each do |language| %>
15   - <%= m.hidden_field :language, :multiple => true, :value => language %>
16   - <% end %>
17   - <%= m.hidden_field "scope", :value => @metric.scope %>
18   - <%= labelled_form_field _('Metric Name:'), m.text_field(:name, :value => @metric.name, :readonly => true) %>
19   - <%= labelled_form_field _('Description:'), m.text_field(:description, :value => @metric.description, :readonly => true) %>
20   - <% end %>
21   -
22   - <%= required labelled_form_field _('Code:'), f.text_field(:code) %>
23   -
24   - <%= required labelled_form_field _('Aggregation Form:'),
25   - f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %>
26   -
27   - <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %>
28   -
29   - <%= required labelled_form_field _('Reading Group:'),
30   - f.select(:reading_group_id, @reading_group_names_and_ids) %>
31   -
32   - <p>
33   - <%= f.submit "Save" %>
34   - </p>
35 4  
  5 +<% form_for :metric_configuration, :url => {:action =>"create", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
  6 + <%= render :partial => "native_metric_configuration_form", :locals => {:f => f} %>
36 7 <% end %>
37   -
... ...
plugins/mezuro/views/mezuro_plugin_range/_ranges.html.erb 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +<h5> Ranges </h5><br/>
  2 +
  3 +<table id="ranges">
  4 + <tr>
  5 + <td>
  6 + Label
  7 + </td>
  8 + <td>
  9 + Beginning
  10 + </td>
  11 + <td>
  12 + End
  13 + </td>
  14 + <td>
  15 + Grade
  16 + </td>
  17 + <td>
  18 + Color
  19 + </td>
  20 + </tr>
  21 + <% @ranges.each do |range| %>
  22 + <%= render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id,
  23 + :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %>
  24 + <% end %>
  25 +</table>
  26 +
  27 +<br/>
  28 +<% if owner %>
  29 + <%= link_to_remote "New Range", :url => {:action =>"new", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %>
  30 +<% end %>
  31 +<div id="form" style="display:none"></div>
... ...
plugins/mezuro/views/mezuro_plugin_reading/_form.html.erb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +<%= hidden_field_tag :id, @reading_group_content.id %>
  2 +
  3 +<%= required labelled_form_field _('label:'), f.text_field(:label) %>
  4 +
  5 +<%= required labelled_form_field _('grade:'),
  6 +f.text_field(:grade) %>
  7 +
  8 +<%= required labelled_form_field _('color:'),
  9 +colorpicker_field(:reading, :color) %>Click in the field to change Color
  10 +
  11 +<p><%= f.submit "Save" %></p>
... ...
plugins/mezuro/views/mezuro_plugin_reading/edit.html.erb
... ... @@ -3,19 +3,6 @@
3 3 <h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2>
4 4  
5 5 <% form_for :reading, :url => {:action =>"save", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %>
6   - <%= hidden_field_tag :id, @reading_group_content.id %>
7   -
8 6 <%= f.hidden_field :id %>
9   - <%= required labelled_form_field _('label:'), f.text_field(:label) %>
10   -
11   - <%= required labelled_form_field _('grade:'),
12   - f.text_field(:grade) %>
13   -
14   - <%= required labelled_form_field _('color:'),
15   - colorpicker_field(:reading, :color) %>Click in the field to change Color
16   -
17   - <p>
18   - <%= f.submit "Add" %>
19   - </p>
20   -
  7 + <%= render :partial => "form", :locals => {:f => f} %>
21 8 <% end %>
... ...
plugins/mezuro/views/mezuro_plugin_reading/new.html.erb
... ... @@ -3,18 +3,5 @@
3 3 <h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2>
4 4  
5 5 <% form_for :reading, :url => {:action =>"save", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %>
6   - <%= hidden_field_tag :id, @reading_group_content.id %>
7   -
8   - <%= required labelled_form_field _('label:'), f.text_field(:label) %>
9   -
10   - <%= required labelled_form_field _('grade:'),
11   - f.text_field(:grade) %>
12   -
13   - <%= required labelled_form_field _('color:'),
14   - colorpicker_field(:reading, :color) %>Click in the field to change Color
15   -
16   - <p>
17   - <%= f.submit "Add" %>
18   - </p>
19   -
  6 + <%= render :partial => "form", :locals => {:f => f} %>
20 7 <% end %>
... ...
plugins/mezuro/views/mezuro_plugin_repository/_form.html.erb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +<h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2>
  2 +
  3 +<% form_for :repository, :url => {:action =>"save", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
  4 + <%= f.hidden_field :id %>
  5 + <%= hidden_field_tag :id, @project_content.id %>
  6 +
  7 + <%= required labelled_form_field _('Name'), f.text_field(:name) %>
  8 +
  9 + <%= labelled_form_field _("Description"), f.text_field(:description) %>
  10 +
  11 + <%= required labelled_form_field _('License'),
  12 + f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options) %>
  13 +
  14 + <%= required labelled_form_field _('Process Period'),
  15 + f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options) %>
  16 +
  17 + <%= required labelled_form_field _('Type'),
  18 + f.select(:type, @repository_types) %>
  19 +
  20 + <%= required labelled_form_field _('Address'),
  21 + f.text_field(:address) %>
  22 +
  23 + <%= required labelled_form_field _('Configuration'),
  24 + f.select(:configuration_id, @configuration_select) %>
  25 +
  26 + <p> <%= f.submit "Add" %> </p>
  27 +
  28 +<% end %>
... ...
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
1   -<h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2>
2   -
3   -<% form_for :repository, :url => {:action =>"save", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @project_content.id %>
5   -
6   - <%= f.hidden_field :id%>
7   - <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
8   -
9   - <%= labelled_form_field _("Description:"), f.text_field(:description) %>
10   -
11   - <%= required labelled_form_field _('License'),
12   - f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options, :selected => @repository.license) %>
13   -
14   - <%= required labelled_form_field _('Process Period'),
15   - f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options, :selected => @repository.process_period.to_i) %>
16   -
17   - <%= required labelled_form_field _('Type'),
18   - f.select(:type, @repository_types, :selected => @repository.type) %>
19   -
20   - <%= required labelled_form_field _('Address'),
21   - f.text_field(:address) %>
22   -
23   - <%= required labelled_form_field _('Configuration'),
24   - f.select(:configuration_id, @configuration_select, :selected => @repository.configuration_id.to_i) %>
25   -
26   - <p> <%= f.submit "Add" %> </p>
27   -
28   -<% end %>
  1 +<%= render :partial => "form" %>
... ...
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
1   -<h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2>
2   -
3   -<% form_for :repository, :url => {:action =>"save", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @project_content.id %>
5   -
6   - <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
7   -
8   - <%= labelled_form_field _('Description'), f.text_field(:description) %>
9   -
10   - <%= required labelled_form_field _('License'),
11   - f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options) %>
12   -
13   - <%= required labelled_form_field _('Process Period'),
14   - f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options ) %>
15   -
16   - <%= required labelled_form_field _('Type'),
17   - f.select(:type, @repository_types) %>
18   -
19   - <%= required labelled_form_field _('Address'),
20   - f.text_field(:address) %>
21   -
22   - <%= required labelled_form_field _('Configuration'),
23   - f.select(:configuration_id, @configuration_select) %>
24   -
25   - <p> <%= f.submit "Add" %> </p>
26   -
27   -<% end %>
  1 +<%= render :partial => "form" %>
... ...