diff --git a/projects/common/app.module.ts b/projects/common/app.module.ts index 3d15f7257e405038a685ef7186efcdd58f6bedd0..98d352674f57f0574d927b3d80098d25a10687c8 100644 --- a/projects/common/app.module.ts +++ b/projects/common/app.module.ts @@ -17,6 +17,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatDialogModule } from '@angular/material/dialog'; import { MatTabsModule } from '@angular/material/tabs'; import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; import { ButtonComponent } from './element-components/button.component'; import { CorrectionComponent } from './element-components/compound-components/correction.component'; @@ -76,7 +77,8 @@ import { DropdownComponent } from './element-components/dropdown.component'; RadioButtonGroupComponent, CheckboxComponent, DropdownComponent, - CorrectionComponent + CorrectionComponent, + MatSnackBarModule ] }) export class SharedModule { } diff --git a/projects/common/message.service.ts b/projects/common/message.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ff6669b800c89c7399a541a13abb71b940a30fe --- /dev/null +++ b/projects/common/message.service.ts @@ -0,0 +1,13 @@ +import { Injectable } from '@angular/core'; +import { MatSnackBar } from '@angular/material/snack-bar'; + +@Injectable({ + providedIn: 'root' +}) +export class MessageService { + constructor(private _snackBar: MatSnackBar) { } + + showWarning(text: string): void { + this._snackBar.open(text, undefined, { duration: 2000, panelClass: 'snackbar-warning' }); + } +} diff --git a/projects/editor/src/app/unit.service.ts b/projects/editor/src/app/unit.service.ts index f8815f7d8621817e19b1979469c89d3bd2201542..0d5d8204dc3c287bd1a02d0b264035bc44b8f648 100644 --- a/projects/editor/src/app/unit.service.ts +++ b/projects/editor/src/app/unit.service.ts @@ -7,6 +7,7 @@ import { } from '../../../common/unit'; import { FileService } from '../../../common/file.service'; import * as UnitFactory from './model/UnitFactory'; +import { MessageService } from '../../../common/message.service'; @Injectable({ providedIn: 'root' @@ -21,7 +22,7 @@ export class UnitService { pageSwitch = new Subject(); elementUpdated = new Subject(); - constructor() { + constructor(private messageService: MessageService) { this._unit = new BehaviorSubject(UnitFactory.createUnit()); const initialPage = UnitFactory.createUnitPage(); const initialSection = UnitFactory.createUnitPageSection(); @@ -85,8 +86,7 @@ export class UnitService { deleteSection(): void { if (this._unit.value.pages[this._selectedPageIndex.value].sections.length < 2) { - // TODO show toast - console.log('cant delete last section'); + this.messageService.showWarning('cant delete last section'); } else { const index = this._selectedPageSectionIndex.value; this._unit.value.pages[this._selectedPageIndex.value].sections.splice(index, 1); diff --git a/projects/editor/src/styles.css b/projects/editor/src/styles.css index d22844d299f515e7e9dfe54bf0ac7841d7faf4ac..ed26e0b07d5dc3adbfb07017f56cab7954b98f7d 100644 --- a/projects/editor/src/styles.css +++ b/projects/editor/src/styles.css @@ -4,3 +4,5 @@ html, body { height: 100%; } body { margin: 0; } + +.snackbar-warning {border: 3px double #ff4d4d}