2018-04-13 06:06:48 +02:00
|
|
|
import { Component } from '@angular/core';
|
|
|
|
import {
|
|
|
|
ActivatedRoute,
|
|
|
|
Router,
|
|
|
|
} from '@angular/router';
|
|
|
|
|
|
|
|
import { Angulartics2 } from 'angulartics2';
|
|
|
|
|
|
|
|
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-10-03 05:33:56 +02:00
|
|
|
analytics: Angulartics2,
|
2018-04-13 19:18:43 +02:00
|
|
|
platformUtilsService: PlatformUtilsService, private router: Router,
|
|
|
|
private route: ActivatedRoute) {
|
2018-10-03 05:33:56 +02:00
|
|
|
super(folderService, i18nService, analytics, platformUtilsService);
|
2018-04-13 06:06:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
this.route.queryParams.subscribe(async (params) => {
|
|
|
|
if (params.folderId) {
|
|
|
|
this.folderId = params.folderId;
|
|
|
|
}
|
|
|
|
await super.ngOnInit();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|