Closes #387: validation username and group name in UI

This commit is contained in:
bgamard 2020-03-25 19:02:50 +01:00
parent e614cb41d8
commit 2c5ff64d42
5 changed files with 11 additions and 4 deletions

View File

@ -436,6 +436,9 @@ angular.module('docs',
} else { } else {
// Or else determine the language based on the user's browser // Or else determine the language based on the user's browser
$translateProvider.determinePreferredLanguage(); $translateProvider.determinePreferredLanguage();
if (!$translateProvider.use()) {
$translateProvider.use('en');
}
} }
// Configuring Timago // Configuring Timago

View File

@ -562,7 +562,8 @@
"email": "Must be a valid e-mail", "email": "Must be a valid e-mail",
"password_confirm": "Password and password confirmation must match", "password_confirm": "Password and password confirmation must match",
"number": "Number required", "number": "Number required",
"no_space": "Spaces and colons are not allowed" "no_space": "Spaces and colons are not allowed",
"alphanumeric": "Only letters and numbers are allowed"
}, },
"action_type": { "action_type": {
"ADD_TAG": "Add a tag", "ADD_TAG": "Add a tag",

View File

@ -551,7 +551,8 @@
"email": "Doit être une adresse e-mail valide", "email": "Doit être une adresse e-mail valide",
"password_confirm": "Le mot de passe et sa confirmation doivent être identiques", "password_confirm": "Le mot de passe et sa confirmation doivent être identiques",
"number": "Nombre requis", "number": "Nombre requis",
"no_space": "Les espaces ne sont pas autorisés" "no_space": "Les espaces ne sont pas autorisés",
"alphanumeric": "Seuls les lettres et les chiffres sont autorisés"
}, },
"action_type": { "action_type": {
"ADD_TAG": "Ajouter un tag", "ADD_TAG": "Ajouter un tag",

View File

@ -9,7 +9,7 @@
<label class="col-sm-2 control-label" for="inputName">{{ 'settings.group.edit.name' | translate }}</label> <label class="col-sm-2 control-label" for="inputName">{{ 'settings.group.edit.name' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="name" type="text" id="inputName" required class="form-control" <input name="name" type="text" id="inputName" required class="form-control"
ui-validate="{ space: '!$value || $value.indexOf(\' \') == -1' }" ng-pattern="/^[a-zA-Z0-9_]*$/"
ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.group.edit.name' | translate }}" ng-model="group.name"/> ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.group.edit.name' | translate }}" ng-model="group.name"/>
</div> </div>
@ -17,7 +17,7 @@
<span class="help-block" ng-show="editGroupForm.name.$error.required && editGroupForm.$dirty">{{ 'validation.required' | translate }}</span> <span class="help-block" ng-show="editGroupForm.name.$error.required && editGroupForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.minlength && editGroupForm.$dirty">{{ 'validation.too_short' | translate }}</span> <span class="help-block" ng-show="editGroupForm.name.$error.minlength && editGroupForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.maxlength && editGroupForm.$dirty">{{ 'validation.too_long' | translate }}</span> <span class="help-block" ng-show="editGroupForm.name.$error.maxlength && editGroupForm.$dirty">{{ 'validation.too_long' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.space && editGroupForm.$dirty">{{ 'validation.no_space' | translate }}</span> <span class="help-block" ng-show="editGroupForm.name.$error.pattern && editGroupForm.$dirty">{{ 'validation.alphanumeric' | translate }}</span>
</div> </div>
</div> </div>

View File

@ -9,6 +9,7 @@
<label class="col-sm-2 control-label" for="inputUserUsername">{{ 'settings.user.edit.username' | translate }}</label> <label class="col-sm-2 control-label" for="inputUserUsername">{{ 'settings.user.edit.username' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control" <input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control"
ng-pattern="/^[a-zA-Z0-9_]*$/"
ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.username' | translate }}" ng-model="user.username"/> ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.username' | translate }}" ng-model="user.username"/>
</div> </div>
@ -16,6 +17,7 @@
<span class="help-block" ng-show="editUserForm.userUsername.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span> <span class="help-block" ng-show="editUserForm.userUsername.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editUserForm.userUsername.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span> <span class="help-block" ng-show="editUserForm.userUsername.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editUserForm.userUsername.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span> <span class="help-block" ng-show="editUserForm.userUsername.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span>
<span class="help-block" ng-show="editUserForm.userUsername.$error.pattern && editUserForm.$dirty">{{ 'validation.alphanumeric' | translate }}</span>
</div> </div>
</div> </div>