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 | 11 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i |
12 | 12 | @metric_configuration_id = params[:metric_configuration_id].to_i |
13 | 13 | @base_tools = KalibroGem::Entities::BaseTool.all |
14 | + @exist_metric = params[:exist_metric] | |
14 | 15 | end |
15 | 16 | |
16 | 17 | def new | ... | ... |
app/views/metric_configurations/choose_metric.html.erb
... | ... | @@ -18,7 +18,9 @@ |
18 | 18 | <% end %> |
19 | 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 | 25 | <script type="text/javascript"> |
24 | 26 | //Loads the accordion |
... | ... | @@ -28,4 +30,8 @@ |
28 | 30 | collapsible: true, |
29 | 31 | }); |
30 | 32 | }); |
33 | + | |
34 | + <% if @exist_metric.nil? %> | |
35 | + $("#link_to_compound").css("display", "none"); | |
36 | + <% end %> | |
31 | 37 | </script> | ... | ... |
app/views/mezuro_configurations/show.html.erb
... | ... | @@ -10,9 +10,9 @@ |
10 | 10 | <hr> |
11 | 11 | |
12 | 12 | <h2> Metrics </h2> |
13 | - | |
14 | 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 | 16 | <% end %> |
17 | 17 | |
18 | 18 | <table class="table table-hover"> |
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | </tr> |
25 | 25 | </thead> |
26 | 26 | <tbody> |
27 | - <% if @mezuro_configuration_metric_configurations.size == 0 %> | |
27 | + <% if @mezuro_configuration_metric_configurations.empty? %> | |
28 | 28 | <%= render partial: 'no_metric_configurations' %> |
29 | 29 | <% else %> |
30 | 30 | <%= render partial: 'metric_configurations', collection: @mezuro_configuration_metric_configurations, as: :metric_configuration %> | ... | ... |