Pārlūkot izejas kodu

template: fix validation for required selects

Since upgrading to Angular 1.6.1, selects with a default empty option
no longer show a popup with an error on submit. This fix adds an
empty option that is then removed with ng-if. Having the default
option set to null or undefined seems to be the cause of the bug.

The list of changes in 1.6 is here but could not find any obvious
cause for this bug:

https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6
Daniel Lee 8 gadi atpakaļ
vecāks
revīzija
5ecc8a171f
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6 2
      public/app/features/templating/partials/editor.html

+ 6 - 2
public/app/features/templating/partials/editor.html

@@ -159,7 +159,9 @@
           <div class="gf-form max-width-21">
             <span class="gf-form-label width-7">Data source</span>
             <div class="gf-form-select-wrapper max-width-14">
-              <select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required></select>
+              <select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required>
+                <option value="" ng-if="false"></option>
+              </select>
             </div>
           </div>
           <div class="gf-form max-width-21">
@@ -230,7 +232,9 @@
         <div class="gf-form max-width-21">
           <span class="gf-form-label width-8">Data source</span>
           <div class="gf-form-select-wrapper max-width-14">
-            <select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required ng-change="validate()"></select>
+            <select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required ng-change="validate()">
+              <option value="" ng-if="false"></option>
+            </select>
           </div>
         </div>
       </div>