]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4183 Prevent adding blank column in Measures Service
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 12 Jul 2013 07:57:58 +0000 (09:57 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 12 Jul 2013 07:57:58 +0000 (09:57 +0200)
sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb

index 7d5c6e76bde86012898816a8788c4266863a7c85..1f03eef00ba4991de90d8356515e6a63511b1eb7 100644 (file)
       $j(document).ready(function () {
         $j("#select-metric").on("change", function (e) {
           var selectedKey = $j("#select-metric option:selected").val();
-          if (selectedKey.indexOf('metric:') == 0) {
-            if (selectedKey.indexOf('metric:new_') == 0) {
-              $j('#select-period option :eq(0)').attr('disabled', 'disabled');
-              $j('#select-period ').val('1');
+          if (selectedKey != null && selectedKey != '') {
+            if (selectedKey.indexOf('metric:') == 0) {
+              if (selectedKey.indexOf('metric:new_') == 0) {
+                $j('#select-period option :eq(0)').attr('disabled', 'disabled');
+                $j('#select-period ').val('1');
+              } else {
+                $j('#select-period option :eq(0)').removeAttr('disabled');
+                $j('#select-period').val('');
+              }
+              $j('#select-period').show();
             } else {
-              $j('#select-period option :eq(0)').removeAttr('disabled');
-              $j('#select-period').val('');
+              $j('#select-period').hide();
             }
-            $j('#select-period').show();
+            $j("#add-metric").removeAttr('disabled');
           } else {
-            $j('#select-period').hide();
+            $j("#add-metric").attr("disabled", "disabled");
           }
-          $j("#add-metric").removeAttr('disabled');
-
         });
+
         $j("#add-metric").on("click", function (e) {
           var cols = filterCriteria<%= widget_id -%>['cols']||[];
           var columnKey = $j("#select-metric option:selected").val();
           filterCriteria['edit']='true';
           window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria<%= widget_id -%>);
         });
+        $j("#add-metric").attr("disabled", "disabled");
+
         $j("#exit-edit").on("click", function (e) {
           delete filterCriteria['edit'];
           window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria<%= widget_id -%>);