diff --git a/frontend/src/app/modules/main/dialogs/categories-dialog/categories-dialog.component.html b/frontend/src/app/modules/main/dialogs/categories-dialog/categories-dialog.component.html index ffb491e..956f166 100644 --- a/frontend/src/app/modules/main/dialogs/categories-dialog/categories-dialog.component.html +++ b/frontend/src/app/modules/main/dialogs/categories-dialog/categories-dialog.component.html @@ -13,7 +13,7 @@ [categories]="categories" [category]="editableCategory" [saveButtonEnabled]="isBusy" - (back)="editableCategory = undefined" + (back)="editableCategory = undefined; fetch()" (save)="saveCategory($event)"> diff --git a/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.html b/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.html index 4a2b7f3..c5a369e 100644 --- a/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.html +++ b/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.html @@ -42,11 +42,17 @@ - - + +
+ + + +
diff --git a/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.ts b/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.ts index 0c58475..4a15d90 100644 --- a/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.ts +++ b/frontend/src/app/modules/main/dialogs/categories-dialog/category-edit/category-edit.component.ts @@ -1,5 +1,8 @@ import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {NbDialogService} from '@nebular/theme'; +import {CategoryApiService} from '../../../../../api/category.api.service'; import {Category} from '../../../../../api/objects/category'; +import {ConfirmDialogComponent} from '../../confirm-dialog/confirm-dialog.component'; @Component({ templateUrl: 'category-edit.component.html', @@ -30,6 +33,12 @@ export class CategoryEditComponent { private _categories: Category[]; + public constructor( + private dialogService: NbDialogService, + private categoryApiService: CategoryApiService, + ) { + } + @Input() get categories(): Category[] { return this._categories; @@ -41,4 +50,21 @@ export class CategoryEditComponent { this.usedColors[category.color] = true; } } + + public deleteCategory(): void { + this.dialogService + .open(ConfirmDialogComponent, { + context: { + question: 'Are you sure you want delete this category?', + } + }) + .onClose + .subscribe((result?: boolean) => { + if (result) { + this.categoryApiService + .delete(this.category.id) + .subscribe(() => this.back.emit(true)); + } + }); + } } diff --git a/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.html b/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.html index f1ffee4..a7ed639 100644 --- a/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.html +++ b/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.html @@ -44,5 +44,8 @@ Add a calendar... + diff --git a/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.ts b/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.ts index b4359e8..45bd8ba 100644 --- a/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.ts +++ b/frontend/src/app/modules/main/sidebar/calendar-list/calendar-list.component.ts @@ -4,6 +4,7 @@ import {CalendarApiService} from '../../../../api/calendar.api.service'; import {Calendar} from '../../../../api/objects/calendar'; import {UserApiService} from '../../../../api/user.api.service'; import {CalendarEditComponent} from '../../dialogs/calendars-dialog/calendar-edit/calendar-edit.component'; +import {CategoriesDialogComponent} from '../../dialogs/categories-dialog/categories-dialog.component'; import {ConfirmDialogComponent} from '../../dialogs/confirm-dialog/confirm-dialog.component'; import {StatementImportDialogComponent} from '../../dialogs/statement-import-dialog/statement-import-dialog.component'; import {MainService} from '../../main.service'; @@ -97,6 +98,15 @@ export class CalendarSidebarListComponent { .subscribe((calendar: Calendar) => this.openCalendarDialog(calendar)); } + public editCategories(): void { + this.dialogService + .open(CategoriesDialogComponent, { + context: { + isSelectable: false, + } + }); + } + public fetch(): void { this.calendarApiService .list()