From 8df45f4de4a3c0a6a631c6d2ae773a765edc516c Mon Sep 17 00:00:00 2001 From: Matias Espinoza Date: Thu, 13 Dec 2018 13:32:44 -0300 Subject: [PATCH] se eliminan libros desde el admin --- src/app/admin/dashboard/dashboard.component.html | 9 +++++++++ src/app/admin/dashboard/dashboard.component.ts | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app/admin/dashboard/dashboard.component.html b/src/app/admin/dashboard/dashboard.component.html index ec5937e..72fdbec 100644 --- a/src/app/admin/dashboard/dashboard.component.html +++ b/src/app/admin/dashboard/dashboard.component.html @@ -297,6 +297,8 @@

Libros por eliminar

Nombre Tipo Fecha del acuerdo + Estado + @@ -311,6 +313,13 @@
{{ book.title }}
{{ book.date_transaction | date }} + + Activo + Inactivo + + + + diff --git a/src/app/admin/dashboard/dashboard.component.ts b/src/app/admin/dashboard/dashboard.component.ts index 94ec69a..002bcab 100644 --- a/src/app/admin/dashboard/dashboard.component.ts +++ b/src/app/admin/dashboard/dashboard.component.ts @@ -34,6 +34,8 @@ export class DashboardComponent implements OnInit { form:FormGroup; + hoy:any = new Date().getTime(); + constructor( private _dbService:DatabaseService, private _date:DateService ) { this.actual_user = JSON.parse( localStorage.getItem( "user" ) ); @@ -87,7 +89,6 @@ export class DashboardComponent implements OnInit { ) .subscribe( data => { this.booksTrans = data; - console.log(data); }); // this._dbService.getData( "tasks") @@ -181,4 +182,15 @@ export class DashboardComponent implements OnInit { } + deleteBook(book) { + book.type = 'sale'; + const KEY = book.key; + delete book.key; + + this._dbService.updateData('books', KEY, book) + .then( () => swal('Libro eliminado', `El libro ${book.title} ha sido eliminado`, 'success') ) + .catch( () => swal('Error al eliminar libro', 'Vuelva a intentarlo', 'error')); + } + + }