1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

load folder dropdowns for site add/edit forms

This commit is contained in:
Kyle Spearrin 2016-09-10 23:06:34 -04:00
parent 9ebec2a1bc
commit 1069b51266
4 changed files with 54 additions and 10 deletions

View File

@ -1,7 +1,7 @@
angular
.module('bit.vault')
.controller('vaultAddSiteController', function ($scope, $state, siteService, cipherService, $q) {
.controller('vaultAddSiteController', function ($scope, $state, siteService, folderService, cipherService, $q) {
$scope.site = {
folderId: null
};
@ -9,6 +9,30 @@
$('#name').focus();
popupUtils.initListSectionItemListeners();
var promises = [];
var decFolders = [{
id: null,
name: '(none)'
}];
folderService.getAll(function (folders) {
for (var i = 1; i < folders.length; i++) {
decFolders.push({
id: folders[i].id
});
var folderNamePromise = cipherService.decrypt(folders[i].name, i);
promises.push(folderNamePromise);
folderNamePromise.then(function (obj) {
decFolders[obj.index].name = obj.val;
});
}
$q.all(promises).then(function () {
$scope.folders = decFolders;
});
});
$scope.savePromise = null;
$scope.save = function (model) {
$scope.savePromise = cipherService.encryptSite(model).then(function (siteModel) {

View File

@ -1,7 +1,7 @@
angular
.module('bit.vault')
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, cipherService, $q) {
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cipherService, $q) {
$scope.site = {
folderId: null
};
@ -12,6 +12,30 @@
});
});
var promises = [];
var decFolders = [{
id: null,
name: '(none)'
}];
folderService.getAll(function (folders) {
for (var i = 1; i < folders.length; i++) {
decFolders.push({
id: folders[i].id
});
var folderNamePromise = cipherService.decrypt(folders[i].name, i);
promises.push(folderNamePromise);
folderNamePromise.then(function (obj) {
decFolders[obj.index].name = obj.val;
});
}
$q.all(promises).then(function () {
$scope.folders = decFolders;
});
});
popupUtils.initListSectionItemListeners();
$scope.savePromise = null;

View File

@ -42,10 +42,8 @@
<div class="list-section-items">
<div class="list-section-item">
<label for="folder">Folder</label>
<select id="folder" name="FolderId">
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
<select id="folder" name="FolderId" ng-model="site.folderId" bit-field>
<option ng-repeat="folder in folders" value="{{folder.id}}">{{folder.name}}</option>
</select>
</div>
<div class="list-section-item list-section-item-checkbox">

View File

@ -42,10 +42,8 @@
<div class="list-section-items">
<div class="list-section-item">
<label for="folder">Folder</label>
<select id="folder" name="FolderId">
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
<select id="folder" name="FolderId" ng-model="site.folderId" bit-field>
<option ng-repeat="folder in folders" value="{{folder.id}}">{{folder.name}}</option>
</select>
</div>
<div class="list-section-item list-section-item-checkbox">