Merge pull request #3532 from ssilvert/enter-key

KEYCLOAK-3948: Unexpected behavior when pressing Enter with some forms
This commit is contained in:
Stan Silvert 2016-11-21 14:23:21 -05:00 committed by GitHub
commit 33cd261d83
5 changed files with 14 additions and 5 deletions

View file

@ -2286,6 +2286,8 @@ module.directive('kcSave', function ($compile, Notifications) {
elem.addClass("btn btn-primary"); elem.addClass("btn btn-primary");
elem.attr("type","submit"); elem.attr("type","submit");
elem.bind('click', function() { elem.bind('click', function() {
if ($scope.hasOwnProperty("changed") && !$scope.changed) return;
$scope.$apply(function() { $scope.$apply(function() {
var form = elem.closest('form'); var form = elem.closest('form');
if (form && form.attr('name')) { if (form && form.attr('name')) {

View file

@ -535,6 +535,9 @@ module.controller('UserCredentialsCtrl', function($scope, realm, user, $route, R
}); });
$scope.resetPassword = function() { $scope.resetPassword = function() {
// hit enter without entering both fields - ignore
if (!$scope.passwordAndConfirmPasswordEntered()) return;
if ($scope.pwdChange) { if ($scope.pwdChange) {
if ($scope.password != $scope.confirmPassword) { if ($scope.password != $scope.confirmPassword) {
Notifications.error("Password and confirmation does not match."); Notifications.error("Password and confirmation does not match.");
@ -563,6 +566,10 @@ module.controller('UserCredentialsCtrl', function($scope, realm, user, $route, R
}); });
}; };
$scope.passwordAndConfirmPasswordEntered = function() {
return $scope.password && $scope.confirmPassword;
}
$scope.disableCredentialTypes = function() { $scope.disableCredentialTypes = function() {
Dialog.confirm('Disable credentials', 'Are you sure you want to disable these the users credentials?', function() { Dialog.confirm('Disable credentials', 'Are you sure you want to disable these the users credentials?', function() {
UserCredentials.disableCredentialTypes({ realm: realm.realm, userId: user.id }, $scope.disableableCredentialTypes, function() { UserCredentials.disableCredentialTypes({ realm: realm.realm, userId: user.id }, $scope.disableableCredentialTypes, function() {

View file

@ -35,7 +35,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-10 col-md-offset-2" data-ng-show="password && confirmPassword"> <div class="col-md-10 col-md-offset-2" data-ng-show="passwordAndConfirmPasswordEntered()">
<button class="btn btn-danger" type="submit" data-ng-click="resetPassword(true)">{{:: 'reset-password' | translate}}</button> <button class="btn btn-danger" type="submit" data-ng-click="resetPassword(true)">{{:: 'reset-password' | translate}}</button>
</div> </div>
</div> </div>
@ -57,7 +57,7 @@
<label class="col-md-2 control-label" for="disableCredentialTypes">{{:: 'disable-credential-types' | translate}}</label> <label class="col-md-2 control-label" for="disableCredentialTypes">{{:: 'disable-credential-types' | translate}}</label>
<div class="col-md-6"> <div class="col-md-6">
<button id="disableCredentialTypes" class="btn btn-default" data-ng-click="disableCredentialTypes()">{{:: 'disable' | translate}}</button> <button type="button" id="disableCredentialTypes" class="btn btn-default" data-ng-click="disableCredentialTypes()">{{:: 'disable' | translate}}</button>
</div> </div>
<kc-tooltip>{{:: 'credentials.disable.tooltip' | translate}}</kc-tooltip> <kc-tooltip>{{:: 'credentials.disable.tooltip' | translate}}</kc-tooltip>
</div> </div>
@ -79,7 +79,7 @@
<label class="col-md-2 control-label" for="reqActionsEmail">{{:: 'reset-actions-email' | translate}}</label> <label class="col-md-2 control-label" for="reqActionsEmail">{{:: 'reset-actions-email' | translate}}</label>
<div class="col-md-6"> <div class="col-md-6">
<button id="reqActionsEmail" class="btn btn-default" data-ng-click="sendExecuteActionsEmail()">{{:: 'send-email' | translate}}</button> <button type="button" id="reqActionsEmail" class="btn btn-default" data-ng-click="sendExecuteActionsEmail()">{{:: 'send-email' | translate}}</button>
</div> </div>
<kc-tooltip>{{:: 'credentials.reset-actions-email.tooltip' | translate}}</kc-tooltip> <kc-tooltip>{{:: 'credentials.reset-actions-email.tooltip' | translate}}</kc-tooltip>
</div> </div>

View file

@ -27,7 +27,7 @@
<input class="form-control" type="text" data-ng-model="config[ option.name ][0]" > <input class="form-control" type="text" data-ng-model="config[ option.name ][0]" >
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<button type="submit" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button> <button type="button" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -22,7 +22,7 @@
<input class="form-control" type="text" data-ng-model="config[ option.name ]" > <input class="form-control" type="text" data-ng-model="config[ option.name ]" >
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<button type="submit" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button> <button type="button" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
</div> </div>
</div> </div>
</div> </div>