homogenized modals - add addressbook modal
This commit is contained in:
parent
9fa24c9d3d
commit
df2811eeba
13 changed files with 491 additions and 489 deletions
153
src/js/controllers/modals/addressbook.js
Normal file
153
src/js/controllers/modals/addressbook.js
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressbookController', function($rootScope, $scope, $timeout, profileService, walletService, addressService, addressbookService) {
|
||||
var self = $scope.self;
|
||||
|
||||
var fc = profileService.focusedClient;
|
||||
self.lockAddress = false;
|
||||
self._address = null;
|
||||
$scope.editAddressbook = false;
|
||||
$scope.addAddressbookEntry = false;
|
||||
$scope.selectedAddressbook = {};
|
||||
$scope.newAddress = address;
|
||||
$scope.walletName = fc.credentials.walletName;
|
||||
$scope.color = fc.backgroundColor;
|
||||
$scope.addressbook = {
|
||||
'address': ($scope.newAddress || ''),
|
||||
'label': ''
|
||||
};
|
||||
|
||||
$scope.checkClipboard = function() {
|
||||
if (!$scope.newAddress) {
|
||||
getClipboard(function(value) {
|
||||
$scope.newAddress = value;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.beforeQrCodeScann = function() {
|
||||
$scope.error = null;
|
||||
$scope.addAddressbookEntry = true;
|
||||
$scope.editAddressbook = false;
|
||||
};
|
||||
|
||||
$scope.onQrCodeScanned = function(data, addressbookForm) {
|
||||
$timeout(function() {
|
||||
var form = addressbookForm;
|
||||
if (data && form) {
|
||||
data = data.replace('bitcoin:', '');
|
||||
form.address.$setViewValue(data);
|
||||
form.address.$isValid = true;
|
||||
form.address.$render();
|
||||
}
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.toggleEditAddressbook = function() {
|
||||
$scope.editAddressbook = !$scope.editAddressbook;
|
||||
$scope.selectedAddressbook = {};
|
||||
$scope.addAddressbookEntry = false;
|
||||
};
|
||||
|
||||
$scope.selectAddressbook = function(addr) {
|
||||
self.setForm(addr);
|
||||
$scope.cancel();
|
||||
};
|
||||
|
||||
$scope.toggleSelectAddressbook = function(addr) {
|
||||
$scope.selectedAddressbook[addr] = $scope.selectedAddressbook[addr] ? false : true;
|
||||
};
|
||||
|
||||
$scope.toggleAddAddressbookEntry = function() {
|
||||
$scope.error = null;
|
||||
$scope.addressbook = {
|
||||
'address': '',
|
||||
'label': ''
|
||||
};
|
||||
$scope.addAddressbookEntry = !$scope.addAddressbookEntry;
|
||||
};
|
||||
|
||||
$scope.list = function() {
|
||||
$scope.error = null;
|
||||
addressbookService.list(function(err, ab) {
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.list = ab;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.add = function(addressbook) {
|
||||
$scope.error = null;
|
||||
$timeout(function() {
|
||||
addressbookService.add(addressbook, function(err, ab) {
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$rootScope.$emit('Local/AddressbookUpdated', ab);
|
||||
$scope.list = ab;
|
||||
$scope.editAddressbook = true;
|
||||
$scope.toggleEditAddressbook();
|
||||
$scope.$digest();
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.remove = function(addr) {
|
||||
$scope.error = null;
|
||||
$timeout(function() {
|
||||
addressbookService.remove(addr, function(err, ab) {
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$rootScope.$emit('Local/AddressbookUpdated', ab);
|
||||
$scope.list = ab;
|
||||
$scope.$digest();
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.selectWallet = function(walletId, walletName) {
|
||||
var client = profileService.getClient(walletId);
|
||||
$scope.errorSelectedWallet = {};
|
||||
|
||||
walletService.isReady(client, function(err) {
|
||||
if (err) $scope.errorSelectedWallet[walletId] = err;
|
||||
else {
|
||||
$scope.gettingAddress = true;
|
||||
$scope.selectedWalletName = walletName;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
addressService.getAddress(walletId, false, function(err, addr) {
|
||||
$scope.gettingAddress = false;
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$scope.cancelAddress();
|
||||
return;
|
||||
}
|
||||
|
||||
self.setForm(addr);
|
||||
$scope.cancel();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancelAddress = function() {
|
||||
self.resetForm();
|
||||
$scope.cancel();
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.addressbookModal.hide();
|
||||
};
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('payproController', function($scope, profileService) {
|
||||
angular.module('copayApp.controllers').controller('payproController', function($scope) {
|
||||
var self = $scope.self;
|
||||
|
||||
$scope.alternative = self.alternativeAmount;
|
||||
|
|
@ -11,6 +11,5 @@ angular.module('copayApp.controllers').controller('payproController', function($
|
|||
|
||||
$scope.cancel = function() {
|
||||
$scope.payproModal.hide();
|
||||
$scope.payproModal.remove();
|
||||
};
|
||||
});
|
||||
|
|
|
|||
10
src/js/controllers/modals/search.js
Normal file
10
src/js/controllers/modals/search.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('searchController', function($scope) {
|
||||
var self = $scope.self;
|
||||
$scope.search = '';
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.searchModal.hide();
|
||||
};
|
||||
});
|
||||
|
|
@ -49,7 +49,5 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
|||
|
||||
$scope.cancel = function() {
|
||||
$scope.txDetailsModal.hide();
|
||||
$scope.txDetailsModal.remove();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue