bitwarden-estensione-browser/src/popup/settings/folder-add-edit.component.ts

55 lines
1.6 KiB
TypeScript
Raw Normal View History

import { Component } from '@angular/core';
import {
ActivatedRoute,
Router,
} from '@angular/router';
import { FolderService } from 'jslib/abstractions/folder.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import {
FolderAddEditComponent as BaseFolderAddEditComponent,
} from 'jslib/angular/components/folder-add-edit.component';
@Component({
selector: 'app-folder-add-edit',
templateUrl: 'folder-add-edit.component.html',
})
export class FolderAddEditComponent extends BaseFolderAddEditComponent {
constructor(folderService: FolderService, i18nService: I18nService,
2018-04-13 19:18:43 +02:00
platformUtilsService: PlatformUtilsService, private router: Router,
private route: ActivatedRoute) {
super(folderService, i18nService, platformUtilsService);
}
async ngOnInit() {
2018-12-20 16:20:57 +01:00
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
if (params.folderId) {
this.folderId = params.folderId;
}
2019-03-06 20:31:50 +01:00
await this.init();
2019-01-17 05:30:39 +01:00
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
});
}
async submit(): Promise<boolean> {
if (await super.submit()) {
2018-04-13 19:18:43 +02:00
this.router.navigate(['/folders']);
return true;
}
return false;
}
async delete(): Promise<boolean> {
const confirmed = await super.delete();
if (confirmed) {
2018-04-13 19:18:43 +02:00
this.router.navigate(['/folders']);
}
return confirmed;
}
}