update option if enabled/disabled
This commit is contained in:
parent
313269a45c
commit
34413278ec
3 changed files with 23 additions and 21 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $ionicScrollDelegate, pincodeService) {
|
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $timeout, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $ionicScrollDelegate, pincodeService) {
|
||||||
|
|
||||||
var updateConfig = function() {
|
var updateConfig = function() {
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
|
|
@ -53,22 +53,21 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.usePincodeChange = function() {
|
$scope.usePincodeChange = function() {
|
||||||
var opts = {};
|
pincodeService.lockChange({
|
||||||
opts.enabled = $scope.usePincode.enabled;
|
enabled: $scope.usePincode.enabled,
|
||||||
opts.from = 'settings';
|
from: 'settings'
|
||||||
|
|
||||||
pincodeService.lockChange(opts, function(err) {
|
|
||||||
if (err) {
|
|
||||||
$log.warn(err);
|
|
||||||
|
|
||||||
// ToDo show error?
|
|
||||||
$scope.usePincode.enabled = false;
|
|
||||||
$scope.$apply();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$rootScope.$on('updatePincodeOption', function(event) {
|
||||||
|
console.log('ON');
|
||||||
|
var config = configService.getSync();
|
||||||
|
$scope.usePincode = {
|
||||||
|
enabled: config.pincode ? config.pincode.enabled : false
|
||||||
|
};
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
updateConfig();
|
updateConfig();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('pincodeController', function($timeout, $scope, $log, $window, configService) {
|
angular.module('copayApp.controllers').controller('pincodeController', function($rootScope, $timeout, $scope, $log, $window, configService) {
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
$scope.currentPincode = config.pincode ? config.pincode.value : null;
|
$scope.currentPincode = config.pincode ? config.pincode.value : null;
|
||||||
$scope.pincode = $scope.pc1 = $scope.pc2 = '';
|
$scope.pincode = $scope.pc1 = $scope.pc2 = null;
|
||||||
|
|
||||||
console.log('#######', $scope.from, $scope.enabled);
|
|
||||||
|
|
||||||
angular.element($window).on('keydown', function(e) {
|
angular.element($window).on('keydown', function(e) {
|
||||||
if (e.which === 8) { // you can add others here inside brackets.
|
if (e.which === 8) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$scope.delete();
|
$scope.delete();
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +14,7 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
||||||
if (e && e.key.match(/^[0-9]$/))
|
if (e && e.key.match(/^[0-9]$/))
|
||||||
$scope.add(e.key);
|
$scope.add(e.key);
|
||||||
else if (e && e.keyCode == 27)
|
else if (e && e.keyCode == 27)
|
||||||
$scope.close(false);
|
$scope.cancel();
|
||||||
else if (e && e.keyCode == 13)
|
else if (e && e.keyCode == 13)
|
||||||
$scope.save();
|
$scope.save();
|
||||||
});
|
});
|
||||||
|
|
@ -70,4 +68,9 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
||||||
$scope.close = function() {
|
$scope.close = function() {
|
||||||
$scope.pincodeModal.hide();
|
$scope.pincodeModal.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.cancel = function() {
|
||||||
|
$rootScope.$emit('updatePincodeOption', false);
|
||||||
|
$scope.close();
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ angular.module('copayApp.services').factory('pincodeService', function($log, $ro
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.lockChange = function(opts, cb) {
|
root.lockChange = function(opts) {
|
||||||
if (opts.enabled) console.log('Locking app from service');
|
if (opts.enabled) console.log('Locking app from service');
|
||||||
else console.log('Unlocking app from service');
|
else console.log('Unlocking app from service');
|
||||||
openPincodeModal(opts);
|
openPincodeModal(opts);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue