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
This commit is contained in:
Daniel Lee 2017-03-20 22:51:55 +01:00
parent 65910db991
commit 94498d533b

View File

@ -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>