2018-04-13 06:06:48 +02:00
|
|
|
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) {
|
2018-10-03 06:21:22 +02:00
|
|
|
super(folderService, i18nService, platformUtilsService);
|
2018-04-13 06:06:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async ngOnInit() {
|
2018-12-20 16:20:57 +01:00
|
|
|
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
|
2018-04-13 06:06:48 +02:00
|
|
|
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();
|
|
|
|
}
|
2018-04-13 06:06:48 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async submit(): Promise<boolean> {
|
|
|
|
if (await super.submit()) {
|
2018-04-13 19:18:43 +02:00
|
|
|
this.router.navigate(['/folders']);
|
2018-04-13 06:06:48 +02:00
|
|
|
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']);
|
2018-04-13 06:06:48 +02:00
|
|
|
}
|
|
|
|
return confirmed;
|
|
|
|
}
|
|
|
|
}
|