зеркало из https://github.com/github/vitess-gh.git
web/vtctld: Validate vindex owner.
This commit is contained in:
Родитель
a45da92687
Коммит
4572d8f2ef
|
@ -305,6 +305,7 @@ They are only used with the
|
|||
<md-not-found>No tables found matching "{{vindex.Owner}}".</md-not-found>
|
||||
<div ng-messages="vindexForm.vindexOwner.$error">
|
||||
<div ng-message="vdefined">Undefined Table</div>
|
||||
<div ng-message="vcontained">Table's class doesn't contain this vindex.</div>
|
||||
</div>
|
||||
</md-autocomplete>
|
||||
<input ng-hide="true" name="vindexOwner" ng-model="vindex.Owner" vindex-owner>
|
||||
|
@ -366,6 +367,7 @@ They are only used with the
|
|||
<md-not-found>No tables found matching "{{newVindexOwner}}".</md-not-found>
|
||||
<div ng-messages="vindexForm.vindexOwner.$error">
|
||||
<div ng-message="vdefined">Undefined Table</div>
|
||||
<div ng-message="vcontained">Table's class doesn't contain this vindex.</div>
|
||||
</div>
|
||||
</md-autocomplete>
|
||||
<input ng-hide="true" name="vindexOwner" ng-model="newVindexOwner" vindex-owner>
|
||||
|
|
|
@ -362,6 +362,25 @@ app.directive('vindexOwner', function() {
|
|||
return viewValue in scope.keyspace.Tables;
|
||||
return true;
|
||||
};
|
||||
ctrl.$validators.vcontained = function(modelValue, viewValue) {
|
||||
var form = scope.vindexForm;
|
||||
var vindex = form.vindex.$modelValue;
|
||||
|
||||
if (viewValue && scope.keyspace.Tables[viewValue]) {
|
||||
var classname = scope.keyspace.Tables[viewValue];
|
||||
if (classname && scope.keyspace.Classes[classname]) {
|
||||
var cls = scope.keyspace.Classes[classname];
|
||||
if (cls.ColVindexes) {
|
||||
for (var i = 0; i < cls.ColVindexes.length; i++) {
|
||||
if (cls.ColVindexes[i].Name == vindex)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче