Merge pull request #3874 from cmgustavo/bug/improv-action-setpassword

Enhanced  response time when pressing Set/Ok with password enabled
This commit is contained in:
Matias Alejo Garcia 2016-02-18 16:22:56 -03:00
commit e867a6a0c7
2 changed files with 33 additions and 29 deletions

View File

@ -16,18 +16,23 @@
<div class="input m20t">
<input type="password" placeholder="{{'Your password'|translate}}"
id="passwordInput" name="password" ng-model="pass.password">
id="passwordInput" name="password" ng-model="password">
</div>
</div>
<div class="row">
<div class="small-6 columns">
<button class="round small-6 columns outline dark-gray expand" ng-click="pass.close(index.askPassword.callback)" translate>
<button
class="round small-6 columns outline dark-gray expand"
ng-click="pass.close(index.askPassword.callback)"
ng-disabled="pass.loading" translate>
CANCEL
</button>
</div>
<div class="small-6 columns">
<button class="round expand" ng-click="pass.set(index.askPassword.isSetup, index.askPassword.callback)" ng-disabled="!pass.password"
<button class="round expand"
ng-click="pass.set(index.askPassword.isSetup, index.askPassword.callback)"
ng-disabled="!password || pass.loading"
ng-style="{'background-color':index.backgroundColor}">
<span ng-if="index.askPassword.isSetup" translate>SET</span>
<span ng-if="!index.askPassword.isSetup">OK</span>

View File

@ -3,42 +3,41 @@
angular.module('copayApp.controllers').controller('passwordController',
function($rootScope, $scope, $timeout, profileService, notification, go, gettext) {
var self = this;
var pass1;
self.isVerification = false;
this.isVerification = false;
document.getElementById("passwordInput").focus();
self.close = function(cb) {
this.close = function(cb) {
return cb('No password given');
};
self.set = function(isSetup, cb) {
self.error = false;
if (isSetup && !self.isVerification) {
document.getElementById("passwordInput").focus();
self.isVerification = true;
pass1 = self.password;
self.password = null;
$timeout(function() {
$rootScope.$apply();
})
return;
}
if (isSetup) {
if (pass1 != self.password) {
self.error = gettext('Passwords do not match');
self.isVerification = false;
self.password = null;
pass1 = null;
this.set = function(isSetup, cb) {
this.loading = true;
this.error = false;
var self = this;
$timeout(function() {
if (isSetup && !self.isVerification) {
self.loading = false;
document.getElementById("passwordInput").focus();
self.isVerification = true;
pass1 = $scope.password;
$scope.password = null;
return;
}
}
return cb(null, self.password);
if (isSetup && pass1 != $scope.password) {
self.loading = false;
self.error = gettext('Passwords do not match');
self.isVerification = false;
$scope.password = null;
pass1 = null;
return;
}
return cb(null, $scope.password);
}, 100);
};
});
});