mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
Form and field directives, form loading spinner
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
angular
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultAddSiteController', function ($scope, $state, siteService, cipherService) {
|
||||
.controller('vaultAddSiteController', function ($scope, $state, siteService, cipherService, $q) {
|
||||
$scope.site = {
|
||||
folderId: null
|
||||
};
|
||||
|
||||
$('#name').focus();
|
||||
$('.list-section-item').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).find('input[type="text"], textarea, select').focus();
|
||||
var checkbox = $(this).find('input[type="checkbox"]');
|
||||
if (checkbox.length > 0) {
|
||||
checkbox.prop('checked', !checkbox.is(':checked'));
|
||||
}
|
||||
});
|
||||
|
||||
$scope.savePromise = null;
|
||||
$scope.save = function (model) {
|
||||
cipherService.encryptSite(model, function (siteModel) {
|
||||
$scope.savePromise = cipherService.encryptSite(model).then(function (siteModel) {
|
||||
var site = new Site(siteModel, true);
|
||||
siteService.saveWithServer(site, function () {
|
||||
$scope.close();
|
||||
return site;
|
||||
}).then(function (site) {
|
||||
return saveSite(site, function (site) {
|
||||
alert('Saved ' + site.id + '!');
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -18,4 +31,14 @@
|
||||
$scope.close = function () {
|
||||
$state.go('tabs.vault', { animation: 'out-slide-down' });
|
||||
};
|
||||
|
||||
function saveSite(site) {
|
||||
return $q(function (resolve, reject) {
|
||||
siteService.saveWithServer(site, function (site) {
|
||||
resolve(site);
|
||||
}, function (error) {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user