mirror of
https://github.com/sismics/docs.git
synced 2024-12-22 11:23:48 +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 tag.name == name;
|
||||
});
|
||||
|
@ -2,11 +2,15 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span4 well text-center">
|
||||
<form name="tagForm" novalidate>
|
||||
<div class="control-group input-prepend input-append input-block-level" ng-class="{ error: !tagForm.name.$valid }">
|
||||
<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"
|
||||
ng-maxlength="36" required ng-model="tag.name" ui-validate="'validateTag($value)'">
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</button>
|
||||
<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>
|
||||
<input type="text" name="name" placeholder="New tag"
|
||||
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>
|
||||
</form>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user