(js) Keep form pristine when changing passwords

Fixes #4138
pull/236/head
Francis Lachapelle 2017-04-24 12:08:15 -04:00
parent da44afdcf5
commit 3d0c958a19
3 changed files with 36 additions and 2 deletions

1
NEWS
View File

@ -12,6 +12,7 @@ Enhancements
Bug fixes
- [web] fixed attachment path when inside multiple body parts
- [web] fixed email reminder with attendees (#4115)
- [web] prevented form to be marked dirty when changing password (#4138)
- [core] cherry-picked comma escaping fix from v2 (#3296)
- [core] fix sogo-tool restore potentially crashing on corrupted data (#4048)
- [core] handle properly mails using windows-1255 charset (#4124)

View File

@ -233,13 +233,13 @@
<md-input-container class="md-block" flex="50">
<label><var:string label:value="New password"/>
</label>
<input type="password" ng-model="app.passwords.newPassword"/>
<input type="password" sg-no-dirty-check="true" ng-model="app.passwords.newPassword"/>
</md-input-container>
<md-input-container class="md-block" flex="50">
<label><var:string label:value="Confirmation"/>
</label>
<input type="password" ng-model="app.passwords.newPasswordConfirmation"/>
<input type="password" sg-no-dirty-check="true" ng-model="app.passwords.newPasswordConfirmation"/>
</md-input-container>
</div>
<div layout="row" layout-align="end center">

View File

@ -0,0 +1,33 @@
/* -*- Mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */
(function() {
'use strict';
angular
.module('SOGo.Common')
.directive('sgNoDirtyCheck', sgNoDirtyCheck);
/*
* sgNoDirtyCheck - prevent input from affecting the form's pristine state.
* @restrict attribute
*/
function sgNoDirtyCheck() {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, elem, attrs, ngModelCtrl) {
if (!ngModelCtrl) {
return;
}
var clean = (ngModelCtrl.$pristine && !ngModelCtrl.$dirty);
if (clean) {
ngModelCtrl.$pristine = false;
ngModelCtrl.$dirty = true;
}
}
};
}
})();