Skip to content

Commit

Permalink
se eliminan libros desde el admin
Browse files Browse the repository at this point in the history
  • Loading branch information
matias1305 committed Dec 13, 2018
1 parent ff0fa45 commit 8df45f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/app/admin/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ <h4 class="card-title"><span class="lstick"></span> Libros por eliminar </h4>
<th>Nombre</th>
<th>Tipo</th>
<th> Fecha del acuerdo </th>
<th>Estado</th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -311,6 +313,13 @@ <h6> {{ book.title }} </h6>
<td>
{{ book.date_transaction | date }}
</td>
<td>
<span *ngIf="book.type === 'Libro'" class="label label-success label-rounded">Activo</span>
<span *ngIf="book.type === 'sale'" class="label label-danger label-rounded">Inactivo</span>
</td>
<td>
<button class="btn btn-primary" (click)="deleteBook(book)"> Eliminar libro </button>
</td>
</tr>
</tbody>
</table>
Expand Down
14 changes: 13 additions & 1 deletion src/app/admin/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down Expand Up @@ -87,7 +89,6 @@ export class DashboardComponent implements OnInit {
)
.subscribe( data => {
this.booksTrans = data;
console.log(data);
});

// this._dbService.getData( "tasks")
Expand Down Expand Up @@ -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'));
}


}

0 comments on commit 8df45f4

Please sign in to comment.