Added category delete (Fixes #8)
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
<button mat-raised-button (click)="create(c)">
|
||||
<mat-icon>edit</mat-icon>
|
||||
</button>
|
||||
<button mat-raised-button class="ml-3">
|
||||
<button mat-raised-button class="ml-3" (click)="delete(c)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
13
src/app/store/deleteCategory/deleteCategory.component.html
Normal file
13
src/app/store/deleteCategory/deleteCategory.component.html
Normal file
@ -0,0 +1,13 @@
|
||||
<mat-dialog-content>
|
||||
<h3 mat-dialog-title>Delete {{data.name}}</h3>
|
||||
<p>You are about to delete a category, any items attached to it will be lost.
|
||||
<br>Edit the items and change their category to prevent this, once ready,
|
||||
<br>please re-enter
|
||||
<span style="background-color: #ffff00">{{data.name}}</span> bellow to awknoledge your action.</p>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Confirm" [(ngModel)]="confirm">
|
||||
</mat-form-field>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions>
|
||||
<button mat-raised-button color="primary" (click)="delete()" [disabled]="confirm.toLowerCase() != data.name.toLowerCase()">Delete</button>
|
||||
</mat-dialog-actions>
|
16
src/app/store/deleteCategory/deleteCategory.component.ts
Normal file
16
src/app/store/deleteCategory/deleteCategory.component.ts
Normal file
@ -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<DeleteCategoryComponent>, @Inject(MAT_DIALOG_DATA) public data) {}
|
||||
|
||||
delete() {
|
||||
this.data.ref.delete().then(() => this.dialogRef.close());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user