mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
* Convert settings to TypeScript. * Simplify loadSettings using await. * Re-write save feature settings. * Minor fixes.
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import * as angular from 'angular';
|
|
import { Folder } from '../../../../models/domain/folder';
|
|
import { UtilsService } from '../../../../services/abstractions/utils.service';
|
|
import * as template from './add-folder.component.html';
|
|
|
|
class AddFolderController {
|
|
savePromise: any;
|
|
folder: {};
|
|
i18n: any;
|
|
|
|
constructor(private folderService: any, private $state: any, private toastr: any, utilsService: UtilsService,
|
|
private $analytics: any, private i18nService: any, $timeout: any) {
|
|
$timeout(() => {
|
|
utilsService.initListSectionItemListeners(document, angular);
|
|
document.getElementById('name').focus();
|
|
}, 500);
|
|
|
|
this.i18n = i18nService;
|
|
this.folder = {};
|
|
this.savePromise = null;
|
|
}
|
|
|
|
save(model: any) {
|
|
if (!model.name) {
|
|
this.toastr.error(this.i18nService.nameRequired, this.i18nService.errorsOccurred);
|
|
return;
|
|
}
|
|
|
|
this.savePromise = this.folderService
|
|
.encrypt(model)
|
|
.then((folderModel: any) => {
|
|
const folder = new Folder(folderModel, true);
|
|
return this.folderService.saveWithServer(folder);
|
|
})
|
|
.then((folder: any) => {
|
|
this.$analytics.eventTrack('Added Folder');
|
|
this.toastr.success(this.i18nService.addedFolder);
|
|
this.$state.go('^.list', { animation: 'out-slide-down' });
|
|
});
|
|
}
|
|
}
|
|
|
|
export const AddFolderComponent = {
|
|
bindings: {},
|
|
controller: AddFolderController,
|
|
template,
|
|
};
|