1
0
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:
Kyle Spearrin
2016-09-10 17:13:29 -04:00
parent 8716c50f81
commit d78dfac43c
11 changed files with 234 additions and 42 deletions

View File

@@ -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);
});
});
}
});