Skip to content
Snippets Groups Projects
Commit f1b38832 authored by rhenck's avatar rhenck
Browse files

[editor] Minor Refactoring

Remove useless methods and add comments.
parent 8ec9e99e
No related branches found
No related tags found
No related merge requests found
import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { Observable, Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { UnitService } from '../../unit.service'; import { UnitService } from '../../unit.service';
import { DialogService } from '../../dialog.service'; import { DialogService } from '../../dialog.service';
...@@ -68,12 +68,14 @@ export class UnitViewComponent implements OnInit, OnDestroy { ...@@ -68,12 +68,14 @@ export class UnitViewComponent implements OnInit, OnDestroy {
} }
deletePage(page: UnitPage): void { deletePage(page: UnitPage): void {
this.showConfirmDialog().pipe(takeUntil(this.ngUnsubscribe)).subscribe((result: boolean) => { this.dialogService.showConfirmDialog('Seite löschen?')
if (result) { .pipe(takeUntil(this.ngUnsubscribe))
this.unitService.deletePage(page); .subscribe((result: boolean) => {
this.selectedPageIndex -= 1; if (result) {
} this.unitService.deletePage(page);
}); this.selectedPageIndex -= 1;
}
});
} }
updateModel(page: UnitPage, property: string, value: number | boolean, isInputValid: boolean | null = true): void { updateModel(page: UnitPage, property: string, value: number | boolean, isInputValid: boolean | null = true): void {
...@@ -87,10 +89,6 @@ export class UnitViewComponent implements OnInit, OnDestroy { ...@@ -87,10 +89,6 @@ export class UnitViewComponent implements OnInit, OnDestroy {
} }
} }
showConfirmDialog(): Observable<boolean> {
return this.dialogService.showConfirmDialog();
}
ngOnDestroy(): void { ngOnDestroy(): void {
this.ngUnsubscribe.next(); this.ngUnsubscribe.next();
this.ngUnsubscribe.complete(); this.ngUnsubscribe.complete();
......
...@@ -328,6 +328,7 @@ export class UnitService { ...@@ -328,6 +328,7 @@ export class UnitService {
} }
} }
/* Silently ignores nonsense reorders! */
private static moveArrayItem(item: unknown, array: unknown[], direction: 'up' | 'down'): void { private static moveArrayItem(item: unknown, array: unknown[], direction: 'up' | 'down'): void {
const oldIndex = array.indexOf(item); const oldIndex = array.indexOf(item);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment