mirror of
https://github.com/sismics/docs.git
synced 2024-11-16 19:27:56 +01:00
More details in tag name validation
This commit is contained in:
parent
bd71dbd445
commit
70a86dc86f
@ -26,9 +26,9 @@ App.controller('Tag', function($scope, $dialog, $state, Tag, Restangular) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a tag.
|
* Validate a tag name for duplicate.
|
||||||
*/
|
*/
|
||||||
$scope.validateTag = function(name) {
|
$scope.validateDuplicate = function(name) {
|
||||||
return !_.find($scope.tags, function(tag) {
|
return !_.find($scope.tags, function(tag) {
|
||||||
return tag.name == name;
|
return tag.name == name;
|
||||||
});
|
});
|
||||||
|
@ -2,12 +2,16 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span4 well text-center">
|
<div class="span4 well text-center">
|
||||||
<form name="tagForm" novalidate>
|
<form name="tagForm" novalidate>
|
||||||
<div class="control-group input-prepend input-append input-block-level" ng-class="{ error: !tagForm.name.$valid }">
|
<div class="control-group" ng-class="{ error: !tagForm.name.$valid }">
|
||||||
|
<div class="input-prepend input-append input-block-level">
|
||||||
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }"> </span>
|
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }"> </span>
|
||||||
<input type="text" name="name" placeholder="New tag"
|
<input type="text" name="name" placeholder="New tag"
|
||||||
ng-maxlength="36" required ng-model="tag.name" ui-validate="'validateTag($value)'">
|
ng-maxlength="36" required ng-model="tag.name" ui-validate="{duplicate: 'validateDuplicate($value)', space: '!$value || $value.indexOf(\' \') == -1' }">
|
||||||
<button type="submit" class="btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</button>
|
<button type="submit" class="btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</button>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="help-inline" ng-show="tagForm.name.$error.duplicate">This tag already exists</span>
|
||||||
|
<span class="help-inline" ng-show="tagForm.name.$error.space">Space are not allowed</span>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="input-prepend input-block-level">
|
<div class="input-prepend input-block-level">
|
||||||
|
Loading…
Reference in New Issue
Block a user