Commit ecda16cc1f8fecb4a8c59bd738fb931b2cef94d5
1 parent
40b4aab6
Exists in
colab
and in
4 other branches
Refactored choose metric.
Can't create compound metric if the configuration is empty. signed-off-by: Guilherme Rojas V. de Lima <guilhermehrojas@gmail.com>
Showing
3 changed files
with
11 additions
and
4 deletions
Show diff stats
app/controllers/metric_configurations_controller.rb
@@ -11,6 +11,7 @@ class MetricConfigurationsController < ApplicationController | @@ -11,6 +11,7 @@ class MetricConfigurationsController < ApplicationController | ||
11 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i | 11 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i |
12 | @metric_configuration_id = params[:metric_configuration_id].to_i | 12 | @metric_configuration_id = params[:metric_configuration_id].to_i |
13 | @base_tools = KalibroGem::Entities::BaseTool.all | 13 | @base_tools = KalibroGem::Entities::BaseTool.all |
14 | + @exist_metric = params[:exist_metric] | ||
14 | end | 15 | end |
15 | 16 | ||
16 | def new | 17 | def new |
app/views/metric_configurations/choose_metric.html.erb
@@ -18,7 +18,9 @@ | @@ -18,7 +18,9 @@ | ||
18 | <% end %> | 18 | <% end %> |
19 | </div><br /> | 19 | </div><br /> |
20 | 20 | ||
21 | -<%= link_to 'Compound Metric', new_mezuro_configuration_compound_metric_configuration_path(@mezuro_configuration_id), class: 'btn btn-info' %> | 21 | +<%= link_to 'Back', mezuro_configuration_path(@mezuro_configuration_id), class: 'btn btn-default' %> |
22 | +<%= link_to 'Compound Metric', new_mezuro_configuration_compound_metric_configuration_path(@mezuro_configuration_id), class: 'btn btn-info', id: "link_to_compound" %> | ||
23 | + | ||
22 | 24 | ||
23 | <script type="text/javascript"> | 25 | <script type="text/javascript"> |
24 | //Loads the accordion | 26 | //Loads the accordion |
@@ -28,4 +30,8 @@ | @@ -28,4 +30,8 @@ | ||
28 | collapsible: true, | 30 | collapsible: true, |
29 | }); | 31 | }); |
30 | }); | 32 | }); |
33 | + | ||
34 | + <% if @exist_metric.nil? %> | ||
35 | + $("#link_to_compound").css("display", "none"); | ||
36 | + <% end %> | ||
31 | </script> | 37 | </script> |
app/views/mezuro_configurations/show.html.erb
@@ -10,9 +10,9 @@ | @@ -10,9 +10,9 @@ | ||
10 | <hr> | 10 | <hr> |
11 | 11 | ||
12 | <h2> Metrics </h2> | 12 | <h2> Metrics </h2> |
13 | - | ||
14 | <% if mezuro_configuration_owner? @mezuro_configuration.id %> | 13 | <% if mezuro_configuration_owner? @mezuro_configuration.id %> |
15 | - <%= link_to 'Add Metric', mezuro_configuration_choose_metric_path(@mezuro_configuration.id), class: 'btn btn-info' %> | 14 | +<% options = @mezuro_configuration_metric_configurations.empty? ? {} : {exist_metric: true}%> |
15 | + <%= link_to 'Add Metric', mezuro_configuration_choose_metric_path(@mezuro_configuration.id, options), class: 'btn btn-info' %> | ||
16 | <% end %> | 16 | <% end %> |
17 | 17 | ||
18 | <table class="table table-hover"> | 18 | <table class="table table-hover"> |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | </tr> | 24 | </tr> |
25 | </thead> | 25 | </thead> |
26 | <tbody> | 26 | <tbody> |
27 | - <% if @mezuro_configuration_metric_configurations.size == 0 %> | 27 | + <% if @mezuro_configuration_metric_configurations.empty? %> |
28 | <%= render partial: 'no_metric_configurations' %> | 28 | <%= render partial: 'no_metric_configurations' %> |
29 | <% else %> | 29 | <% else %> |
30 | <%= render partial: 'metric_configurations', collection: @mezuro_configuration_metric_configurations, as: :metric_configuration %> | 30 | <%= render partial: 'metric_configurations', collection: @mezuro_configuration_metric_configurations, as: :metric_configuration %> |