From 00df2af43ddbf96bf0c99a3e190a23d7ecf4f777 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 21 Jun 2013 17:56:34 +0200 Subject: [PATCH] SONAR-4336 Fix display of measure filter criteria --- .../app/views/measures/_sidebar.html.erb | 105 ++++++++++++------ 1 file changed, 73 insertions(+), 32 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_sidebar.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_sidebar.html.erb index 210e58bdb2c..78a91d4620b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_sidebar.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_sidebar.html.erb @@ -11,7 +11,6 @@ function submitSearch() { // remove empty parameters from URL var form = $j("#search-form"); - form.find(':input[value=""]').attr('disabled', 'disabled'); return true; } function removeUrlAttr(url, attribute_key) { @@ -33,28 +32,44 @@ $j('#more-criteria') .select2({allowClear: true, width: '100%', placeholder: '<%= message 'measure_filter.more_criteria' -%>'}) .on("change", function (e) { - $j("#criteria-" + e.val).insertBefore($j("#more-td")).show(); - if (e.val == 'lang' || e.val == 'project') { - $j("#select-" + e.val).select2("enable"); - $j("#select-" + e.val).select2("focus"); - } else if (e.val=='fav') { - $j('#check-fav').attr('checked', 'checked'); - } + $j("#criteria-" + e.val).insertBefore($j("#more-td")).show(); - if (e.val == 'metric') { - if (hiddenConditionIndexes.length > 0) { - var index = hiddenConditionIndexes.pop(); - $j("#criteria-metric-" + index).insertBefore($j("#more-td")).show(); - $j("#c" + index + "_metric").select2("focus"); - if (hiddenConditionIndexes.length == 0) { - $j("#more-criteria option[value='metric']").remove(); + if (e.val == 'lang' || e.val == 'project') { + $j("#select-" + e.val).select2("enable"); + $j("#select-" + e.val).select2("focus"); + } else if (e.val == 'fav') { + $j('#check-fav').attr('checked', 'checked'); + } else if (e.val == 'date') { + $j("#criteria-" + e.val + " input[name=fromDate]").focus(); + } else if (e.val == 'age') { + $j("#criteria-" + e.val + " input[name=ageMinDays]").focus(); + } else if (e.val == 'key') { + $j("#criteria-" + e.val + " input").focus(); + } else if (e.val == 'name') { + $j("#criteria-" + e.val + " input").focus(); + } + + if (e.val == 'metric') { + if (hiddenConditionIndexes.length > 0) { + var index = hiddenConditionIndexes.pop(); + $j("#criteria-metric-" + index).insertBefore($j("#more-td")).show(); + $j("#c" + index + "_metric").select2("enable"); + $j("#c" + index + "_metric").select2("focus"); + $j("#c" + index + "_metric").removeAttr("disabled"); + $j("#c" + index + "_period").removeAttr('disabled'); + $j("#c" + index + "_op").removeAttr('disabled'); + $j("#c" + index + "_val").removeAttr('disabled'); + if (hiddenConditionIndexes.length == 0) { + $j("#more-criteria option[value='metric']").remove(); + } } + } else { + // applies to any criteria except metrics + $j("#criteria-" + e.val + " input").removeAttr('disabled'); + $j("#more-criteria option[value='" + e.val + "']").remove(); } - } else { - $j("#more-criteria option[value='" + e.val + "']").remove(); - } - $j("#more-criteria").select2("val", ""); - }); + $j("#more-criteria").select2("val", ""); + }); }); <% end %> @@ -103,49 +118,75 @@ :allow_clear => true -%> +
  • class="marginbottom5"> <% languages = [['', '']].concat(Api::Utils.languages.map { |lang| [lang.name, lang.key] }) %> <%= select_tag 'languages[]', options_for_select(languages, @filter.criteria['languages']), :multiple => true, :id => 'select-lang' -%>
  • +
  • class="marginbottom5"> <%= message('measure_filter.name_contains') -%>:
    - + >
  • +
  • class="marginbottom5"> <%= message('measure_filter.key_like') -%>:
    -
    + >
    <%= message 'measure.filter.criteria.key_note' -%>
  • +
  • class="marginbottom5"> <%= message 'measure_filter.criteria.only_favourites' %>: <%= check_box_tag 'onFavourites', 'true', @filter.criteria['onFavourites']=='true', :id => 'check-fav' -%>
  • - <% condition_metrics = Metric.all.select { |m| m.numeric? && !m.hidden } %> - <% for i in 1..3 %> + <% + condition_metrics = Metric.all.select { |m| m.numeric? && !m.hidden } + for i in 1..3 + disabled = @filter.criteria("c#{i}_metric").blank? + %>
  • " class="marginbottom5"> - <%= metric_select_tag "c#{i}_metric", condition_metrics, :allow_empty => true, :selected_key => @filter.criteria("c#{i}_metric"), :width => '100%', :placeholder => message('measure_filter.criteria.metric') -%> - <%= select_tag "c#{i}_period", options_for_select([[message('value'), ''], [Api::Utils.period_label(1), '1'], [Api::Utils.period_label(2), '2'], [Api::Utils.period_label(3), '3']], @filter.criteria("c#{i}_period")) -%> + <%= metric_select_tag "c#{i}_metric", condition_metrics, + :allow_empty => true, + :selected_key => @filter.criteria("c#{i}_metric"), + :width => '100%', + :placeholder => message('measure_filter.criteria.metric'), + :disabled => disabled + -%> + <%= + select_tag "c#{i}_period", + options_for_select([[message('value'), ''], [Api::Utils.period_label(1), '1'], [Api::Utils.period_label(2), '2'], [Api::Utils.period_label(3), '3']], @filter.criteria("c#{i}_period")), + :disabled => disabled + -%>
    - <%= select_tag "c#{i}_op", options_for_select([['=', 'eq'], ['<', 'lt'], ['<=', 'lte'], ['>', 'gt'], ['>=', 'gte']], @filter.criteria("c#{i}_op")) -%> - "> + <%= select_tag "c#{i}_op", + options_for_select([['=', 'eq'], ['<', 'lt'], ['<=', 'lte'], ['>', 'gt'], ['>=', 'gte']], @filter.criteria("c#{i}_op")), + :disabled => disabled + -%> + " <%= 'disabled' if disabled -%>/>
  • <% end %> +
  • class="marginbottom5"> + <% disabled = @filter.criteria['fromDate'].blank? && @filter.criteria['toDate'].blank? %> <%= message('measure_filter.criteria.from_date') -%>:
    - + >
    <%= message 'measure_filter.criteria.to_date' -%>:
    -
    + >
    <%= message 'measure_filter.criteria.date_format' -%>
  • + +
  • class="marginbottom5"> + <% disabled = @filter.criteria['ageMinDays'].blank? && @filter.criteria['ageMaxDays'].blank? %> <%= message 'measure_filter.criteria.age.more_than' -%>:
    - <%= message 'measure_filter.criteria.age.days_ago' -%> + > <%= message 'measure_filter.criteria.age.days_ago' -%>
    <%= message 'measure_filter.criteria.age.within_last' -%>:
    - <%= message 'measure_filter.criteria.age.days' -%> + > <%= message 'measure_filter.criteria.age.days' -%>
  • +