diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 21836a7..6d4c19c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,6 +21,7 @@ import {BreadcrumbService} from './store/breadcrumb.service'; import {LoginComponent} from './login/login.component'; import {AngularFireAuthModule} from 'angularfire2/auth'; import {NewCategoryComponent} from './store/newCategory/newCategory.component'; +import {DeleteCategoryComponent} from './store/deleteCategory/deleteCategory.component'; @NgModule({ declarations: [ @@ -28,6 +29,7 @@ import {NewCategoryComponent} from './store/newCategory/newCategory.component'; CategoriesComponent, ConvertFromGPipe, ConvertToGPipe, + DeleteCategoryComponent, FormulaManagerComponent, HomeComponent, LoginComponent, @@ -56,7 +58,7 @@ import {NewCategoryComponent} from './store/newCategory/newCategory.component'; ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}) ], providers: [BreadcrumbService], - entryComponents: [LoginComponent, NewCategoryComponent], + entryComponents: [DeleteCategoryComponent, LoginComponent, NewCategoryComponent], bootstrap: [AppComponent] }) export class AppModule { diff --git a/src/app/store/categories.component.html b/src/app/store/categories.component.html index f753e59..1e35ae3 100644 --- a/src/app/store/categories.component.html +++ b/src/app/store/categories.component.html @@ -29,7 +29,7 @@ - diff --git a/src/app/store/categories.component.ts b/src/app/store/categories.component.ts index a1579ac..75e5915 100644 --- a/src/app/store/categories.component.ts +++ b/src/app/store/categories.component.ts @@ -8,6 +8,7 @@ import {MatDialog} from '../../../node_modules/@angular/material'; import {NewCategoryComponent} from './newCategory/newCategory.component'; import {AppComponent} from '../app.component'; import {DomSanitizer} from '../../../node_modules/@angular/platform-browser'; +import {DeleteCategoryComponent} from './deleteCategory/deleteCategory.component'; @Component({ selector: 'store', @@ -61,4 +62,8 @@ export class CategoriesComponent { create(category) { this.dialog.open(NewCategoryComponent, {data: {category: category, currentCategory: this.category}}); } + + delete(category) { + this.dialog.open(DeleteCategoryComponent, {data: category}); + } } diff --git a/src/app/store/deleteCategory/deleteCategory.component.html b/src/app/store/deleteCategory/deleteCategory.component.html new file mode 100644 index 0000000..308591b --- /dev/null +++ b/src/app/store/deleteCategory/deleteCategory.component.html @@ -0,0 +1,13 @@ + +

Delete {{data.name}}

+

You are about to delete a category, any items attached to it will be lost. +
Edit the items and change their category to prevent this, once ready, +
please re-enter + {{data.name}} bellow to awknoledge your action.

+ + + +
+ + + \ No newline at end of file diff --git a/src/app/store/deleteCategory/deleteCategory.component.ts b/src/app/store/deleteCategory/deleteCategory.component.ts new file mode 100644 index 0000000..1a6a8c2 --- /dev/null +++ b/src/app/store/deleteCategory/deleteCategory.component.ts @@ -0,0 +1,16 @@ +import {Component, Inject} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from '../../../../node_modules/@angular/material'; + +@Component({ + selector: 'delete-category', + templateUrl: 'deleteCategory.component.html' +}) +export class DeleteCategoryComponent { + confirm = ''; + + constructor(private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) {} + + delete() { + this.data.ref.delete().then(() => this.dialogRef.close()); + } +}