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,11 +2,15 @@
|
|||||||
<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 }">
|
||||||
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }"> </span>
|
<div class="input-prepend input-append input-block-level">
|
||||||
<input type="text" name="name" placeholder="New tag"
|
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }"> </span>
|
||||||
ng-maxlength="36" required ng-model="tag.name" ui-validate="'validateTag($value)'">
|
<input type="text" name="name" placeholder="New tag"
|
||||||
<button type="submit" class="btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</button>
|
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>
|
||||||
|
</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>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user