fix angular scope issue + disable LastPass in some forms

This commit is contained in:
Benjamin Gamard 2018-03-09 19:20:20 +01:00
parent f167e8ea0a
commit 6b940c4366
6 changed files with 2506 additions and 34 deletions

2467
docs-web/src/main/webapp/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
data.storage_quota /= 1000000; data.storage_quota /= 1000000;
$scope.user = data; $scope.user = data;
}); });
} else {
$scope.user = {}; // Very important otherwise ng-if in template will make a new scope variable
} }
/** /**

View File

@ -34,12 +34,14 @@
<form> <form>
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="inputUsername">{{ 'login.username' | translate }}</label> <label class="sr-only" for="inputUsername">{{ 'login.username' | translate }}</label>
<input class="form-control" type="text" id="inputUsername" ng-attr-placeholder="{{ 'login.username' | translate }}" ng-model="user.username" /> <input class="form-control" type="text" id="inputUsername" name="username"
ng-attr-placeholder="{{ 'login.username' | translate }}" ng-model="user.username" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="inputPassword">{{ 'login.password' | translate }}</label> <label class="sr-only" for="inputPassword">{{ 'login.password' | translate }}</label>
<input class="form-control" type="password" id="inputPassword" ng-attr-placeholder="{{ 'login.password' | translate }}" ng-model="user.password" /> <input class="form-control" type="password" id="inputPassword" name="password"
ng-attr-placeholder="{{ 'login.password' | translate }}" ng-model="user.password" />
</div> </div>
<span class="help-block" ng-if="codeRequired"> <span class="help-block" ng-if="codeRequired">
@ -48,12 +50,13 @@
</span> </span>
<div class="form-group" ng-if="codeRequired"> <div class="form-group" ng-if="codeRequired">
<label class="sr-only" for="inputCode">{{ 'login.validation_code' | translate }}</label> <label class="sr-only" for="inputCode">{{ 'login.validation_code' | translate }}</label>
<input class="form-control" type="text" id="inputCode" ng-attr-placeholder="{{ 'login.validation_code' | translate }}" ng-model="user.code" /> <input class="form-control" type="text" id="inputCode" name="code"
ng-attr-placeholder="{{ 'login.validation_code' | translate }}" ng-model="user.code" />
</div> </div>
<div class="checkbox text-muted"> <div class="checkbox text-muted">
<label> <label>
<input type="checkbox" ng-model="user.remember" /> {{ 'login.remember_me' | translate }} <input type="checkbox" ng-model="user.remember" name="remember" /> {{ 'login.remember_me' | translate }}
</label> </label>
</div> </div>

View File

@ -1,22 +1,22 @@
<h1 translate="settings.account.title"></h1> <h1 translate="settings.account.title"></h1>
<form class="form-horizontal" name="editUserForm" novalidate> <form class="form-horizontal" name="editUserForm" novalidate autocomplete="off">
<div class="form-group" ng-class="{ 'has-error': !editUserForm.password.$valid && editUserForm.$dirty, success: editUserForm.password.$valid }"> <div class="form-group" ng-class="{ 'has-error': !editUserForm.accountPassword.$valid && editUserForm.$dirty, success: editUserForm.accountPassword.$valid }">
<label class="col-sm-2 control-label" for="inputPassword">{{ 'settings.account.password' | translate }}</label> <label class="col-sm-2 control-label" for="inputAccountPassword">{{ 'settings.account.password' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="password" type="password" id="inputPassword" required class="form-control" <input name="accountPassword" type="password" id="inputAccountPassword" required class="form-control"
ng-minlength="8" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.account.password' | translate }}" ng-model="user.password" /> ng-minlength="8" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.account.password' | translate }}" ng-model="user.password" />
</div> </div>
<div class="col-sm-3"> <div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.password.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span> <span class="help-block" ng-show="editUserForm.accountPassword.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editUserForm.password.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span> <span class="help-block" ng-show="editUserForm.accountPassword.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editUserForm.password.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span> <span class="help-block" ng-show="editUserForm.accountPassword.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span>
</div> </div>
</div> </div>
<div class="form-group" ng-class="{ 'has-error': !editUserForm.passwordconfirm.$valid && editUserForm.$dirty, success: editUserForm.passwordconfirm.$valid }"> <div class="form-group" ng-class="{ 'has-error': !editUserForm.passwordconfirm.$valid && editUserForm.$dirty, success: editUserForm.passwordconfirm.$valid }">
<label class="col-sm-2 control-label" for="inputPasswordConfirm">{{ 'settings.account.password_confirm' | translate }}</label> <label class="col-sm-2 control-label" for="inputAccountPasswordConfirm">{{ 'settings.account.password_confirm' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="passwordconfirm" type="password" id="inputPasswordConfirm" required class="form-control" <input name="passwordconfirm" type="password" id="inputAccountPasswordConfirm" required class="form-control"
ui-validate="'$value == user.password'" ui-validate-watch="'user.password'" ui-validate="'$value == user.password'" ui-validate-watch="'user.password'"
ng-attr-placeholder="{{ 'settings.account.password_confirm' | translate }}" ng-model="user.passwordconfirm" /> ng-attr-placeholder="{{ 'settings.account.password_confirm' | translate }}" ng-model="user.passwordconfirm" />
</div> </div>

View File

@ -65,7 +65,7 @@
</button> </button>
<button type="submit" class="btn btn-warning" ng-click="testInboxConfig()"> <button type="submit" class="btn btn-warning" ng-click="testInboxConfig()">
<span class="fas fa-pencil-alt"></span> {{ 'settings.inbox.test' | translate }} <span class="fas fa-pencil-alt"></span> {{ 'settings.inbox.test' | translate }}
<span ng-if="testLoading" class="fas fa-circle-notch fa-spin"></> <span ng-if="testLoading" class="fas fa-circle-notch fa-spin"></span>
</button> </button>
</div> </div>
</div> </div>

View File

@ -4,37 +4,37 @@
<h2 ng-show="isEdit()" translate="settings.user.edit.edit_user_title" translate-values="{ username: user.username }"></h2> <h2 ng-show="isEdit()" translate="settings.user.edit.edit_user_title" translate-values="{ username: user.username }"></h2>
<h2 ng-show="!isEdit()" translate="settings.user.edit.add_user_title"></h2> <h2 ng-show="!isEdit()" translate="settings.user.edit.add_user_title"></h2>
<form class="form-horizontal" name="editUserForm" novalidate> <form class="form-horizontal" name="editUserForm" novalidate autocomplete="off">
<div class="form-group" ng-class="{ 'has-error': !editUserForm.username.$valid && editUserForm.$dirty, success: editUserForm.username.$valid }"> <div class="form-group" ng-class="{ 'has-error': !editUserForm.userUsername.$valid && editUserForm.$dirty, success: editUserForm.userUsername.$valid }">
<label class="col-sm-2 control-label" for="inputUsername">{{ '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="username" type="text" id="inputUsername" required ng-disabled="isEdit()" class="form-control" <input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control"
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>
<div class="col-sm-3"> <div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.username.$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.username.$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.username.$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>
</div> </div>
</div> </div>
<div class="form-group" ng-class="{ 'has-error': !editUserForm.email.$valid && editUserForm.$dirty, success: editUserForm.email.$valid }"> <div class="form-group" ng-class="{ 'has-error': !editUserForm.userEmail.$valid && editUserForm.$dirty, success: editUserForm.userEmail.$valid }">
<label class="col-sm-2 control-label" for="inputEmail">{{ 'settings.user.edit.email' | translate }}</label> <label class="col-sm-2 control-label" for="inputEmail">{{ 'settings.user.edit.email' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="email" type="email" id="inputEmail" required class="form-control" <input name="userEmail" type="email" id="inputEmail" required class="form-control"
ng-minlength="1" ng-maxlength="100" ng-attr-placeholder="{{ 'settings.user.edit.email' | translate }}" ng-model="user.email"/> ng-minlength="1" ng-maxlength="100" ng-attr-placeholder="{{ 'settings.user.edit.email' | translate }}" ng-model="user.email"/>
</div> </div>
<div class="col-sm-3"> <div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.email.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span> <span class="help-block" ng-show="editUserForm.userEmail.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editUserForm.email.$error.email && editUserForm.$dirty">{{ 'validation.email' | translate }}</span> <span class="help-block" ng-show="editUserForm.userEmail.$error.email && editUserForm.$dirty">{{ 'validation.email' | translate }}</span>
<span class="help-block" ng-show="editUserForm.email.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span> <span class="help-block" ng-show="editUserForm.userEmail.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editUserForm.email.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span> <span class="help-block" ng-show="editUserForm.userEmail.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span>
</div> </div>
</div> </div>
<div class="form-group" ng-if="user.groups.length > 0"> <div class="form-group" ng-show="user.groups.length > 0">
<label class="col-sm-2 control-label">{{ 'settings.user.edit.groups' | translate }}</label> <label class="col-sm-2 control-label">{{ 'settings.user.edit.groups' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<span ng-repeat="group in user.groups"> <span ng-repeat="group in user.groups">
@ -60,17 +60,17 @@
</div> </div>
<div class="form-group" ng-if="user.username != 'guest'" <div class="form-group" ng-if="user.username != 'guest'"
ng-class="{ 'has-error': !editUserForm.password.$valid && editUserForm.$dirty, success: editUserForm.password.$valid }"> ng-class="{ 'has-error': !editUserForm.userPassword.$valid && editUserForm.$dirty, success: editUserForm.userPassword.$valid }">
<label class="col-sm-2 control-label" for="inputPassword">{{ 'settings.user.edit.password' | translate }}</label> <label class="col-sm-2 control-label" for="inputUserPassword">{{ 'settings.user.edit.password' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="password" type="password" id="inputPassword" ng-required="!isEdit()" class="form-control" <input name="userPassword" type="password" id="inputUserPassword" ng-required="!isEdit()" class="form-control"
ng-minlength="8" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.password' | translate }}" ng-model="user.password"/> ng-minlength="8" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.password' | translate }}" ng-model="user.password"/>
</div> </div>
<div class="col-sm-3"> <div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.password.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span> <span class="help-block" ng-show="editUserForm.userPassword.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editUserForm.password.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span> <span class="help-block" ng-show="editUserForm.userPassword.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editUserForm.password.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span> <span class="help-block" ng-show="editUserForm.userPassword.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span>
</div> </div>
</div> </div>