Commit e02dd3ba0b81491c16721eb352549b924382f0fd
1 parent
27eeb8a0
Exists in
colab
and in
4 other branches
Refactored MetricConfigurationsController create and new
Showing
3 changed files
with
14 additions
and
16 deletions
Show diff stats
app/controllers/metric_configurations_controller.rb
| ... | ... | @@ -10,19 +10,17 @@ class MetricConfigurationsController < ApplicationController |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | 12 | def new |
| 13 | - @base_tool_name = params[:base_tool_name] | |
| 14 | - @metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] | |
| 15 | - @mezuro_configuration_id = params[:mezuro_configuration_id].to_i | |
| 16 | 13 | @metric_configuration = MetricConfiguration.new |
| 14 | + @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i | |
| 15 | + @metric_configuration.base_tool_name = params[:base_tool_name] | |
| 16 | + @metric_configuration.metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] | |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | def create |
| 20 | 20 | @metric_configuration = MetricConfiguration.new(metric_configuration_params) |
| 21 | - @base_tool_name = params[:base_tool_name] | |
| 22 | - @metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric(params[:metric_name]) | |
| 23 | 21 | @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i |
| 24 | - @metric_configuration.metric = @metric | |
| 25 | - @metric_configuration.base_tool_name = @base_tool_name | |
| 22 | + @metric_configuration.metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] | |
| 23 | + @metric_configuration.base_tool_name = params[:base_tool_name] | |
| 26 | 24 | respond_to do |format| |
| 27 | 25 | create_and_redir(format) |
| 28 | 26 | end | ... | ... |
app/views/metric_configurations/_form.html.erb
| ... | ... | @@ -20,9 +20,9 @@ |
| 20 | 20 | <%= f.select( :reading_group_id, reading_group_options, {class: 'form-control'} ) %> |
| 21 | 21 | </div> |
| 22 | 22 | |
| 23 | -<%= hidden_field_tag(:metric_name, @metric.name) %> | |
| 24 | -<%= hidden_field_tag(:base_tool_name, @base_tool_name) %> | |
| 23 | +<%= hidden_field_tag(:metric_name, @metric_configuration.metric.name) %> | |
| 24 | +<%= hidden_field_tag(:base_tool_name, @metric_configuration.base_tool_name) %> | |
| 25 | 25 | |
| 26 | 26 | <br> |
| 27 | 27 | <%= f.submit 'Save', class: 'btn btn-primary' %> |
| 28 | -<%= link_to 'Back', mezuro_configuration_path(@mezuro_configuration_id), class: 'btn btn-default' %> | |
| 28 | +<%= link_to 'Back', mezuro_configuration_path(@metric_configuration.configuration_id), class: 'btn btn-default' %> | ... | ... |
app/views/metric_configurations/new.html.erb
| ... | ... | @@ -3,24 +3,24 @@ |
| 3 | 3 | </div> |
| 4 | 4 | |
| 5 | 5 | <p> |
| 6 | - <b>Base Tool:</b> <%= @base_tool_name %> | |
| 6 | + <b>Base Tool:</b> <%= @metric_configuration.base_tool_name %> | |
| 7 | 7 | </p> |
| 8 | 8 | <p> |
| 9 | - <b>Metric Name:</b> <%= @metric.name %> | |
| 9 | + <b>Metric Name:</b> <%= @metric_configuration.metric.name %> | |
| 10 | 10 | </p> |
| 11 | 11 | <p> |
| 12 | - <b>Metric Description:</b> <%= @metric.description.nil? ? "No description available." : @metric.description %> | |
| 12 | + <b>Metric Description:</b> <%= @metric_configuration.metric.description.nil? ? "No description available." : @metric.description %> | |
| 13 | 13 | </p> |
| 14 | 14 | <p> |
| 15 | - <b>Language:</b> <%= @metric.languages.to_s %> | |
| 15 | + <b>Language:</b> <%= @metric_configuration.metric.languages.to_s %> | |
| 16 | 16 | </p> |
| 17 | 17 | |
| 18 | 18 | <p> |
| 19 | - <b>Scope:</b> <%= @metric.scope %> | |
| 19 | + <b>Scope:</b> <%= @metric_configuration.metric.scope %> | |
| 20 | 20 | </p> |
| 21 | 21 | |
| 22 | 22 | <br> |
| 23 | 23 | |
| 24 | -<%= form_for(@metric_configuration, :url => mezuro_configuration_metric_configurations_path(@mezuro_configuration_id)) do |f| %> | |
| 24 | +<%= form_for(@metric_configuration, :url => mezuro_configuration_metric_configurations_path(@metric_configuration.configuration_id)) do |f| %> | |
| 25 | 25 | <%= render partial: 'form', locals: {f: f} %> |
| 26 | 26 | <% end %> | ... | ... |