From 29a2be148029979897dec1518e039107e4ccc983 Mon Sep 17 00:00:00 2001 From: Le Deng Date: Mon, 6 Mar 2017 12:32:56 -0500 Subject: [PATCH] latest --- .../book-list/book-list.component.html | 4 +- .../book-list/book-list.component.ts | 50 +++++++++++++++---- bookstore-api/.idea/workspace.xml | 6 +-- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/admin-portal/src/app/components/book-list/book-list.component.html b/admin-portal/src/app/components/book-list/book-list.component.html index 3357dc6..59e4730 100644 --- a/admin-portal/src/app/components/book-list/book-list.component.html +++ b/admin-portal/src/app/components/book-list/book-list.component.html @@ -17,7 +17,7 @@ - + {{book.title}} {{book.author}} @@ -35,6 +35,6 @@ - + diff --git a/admin-portal/src/app/components/book-list/book-list.component.ts b/admin-portal/src/app/components/book-list/book-list.component.ts index 7b5e099..9a3cd34 100644 --- a/admin-portal/src/app/components/book-list/book-list.component.ts +++ b/admin-portal/src/app/components/book-list/book-list.component.ts @@ -16,6 +16,7 @@ export class BookListComponent implements OnInit { private selectedBook : Book; private bookList: Book[]; + private removeBookList: Book[]=new Array(); constructor(private removeBookService:RemoveBookService, private getBookListService: GetBookListService, private router: Router, public dialog: MdDialog) { this.getBookListService.getBookList().subscribe( @@ -26,7 +27,7 @@ export class BookListComponent implements OnInit { err => { console.log(err); } - ); + ); } onSelect(book:Book) { @@ -40,18 +41,45 @@ export class BookListComponent implements OnInit { console.log(result); if(result=="yes") { this.removeBookService.sendBook(book.id).subscribe( - res => { - console.log(res); - location.reload(); - }, - err => { - console.log(err); + res => { + console.log(res); + location.reload(); + }, + err => { + console.log(err); + } + + ); } - - ); + }); + } + + updateRemoveBookList(checked:boolean, book:Book) { + if(checked){ + this.removeBookList.push(book); + } else { + this.removeBookList.splice(this.removeBookList.indexOf(book),1); + } + console.log(this.removeBookList); + } + + removeSelectedBooks() { + let dialogRef = this.dialog.open(DialogResultExampleDialog); + dialogRef.afterClosed().subscribe(result => { + if(result=="yes") { + for (let book of this.removeBookList) { + this.removeBookService.sendBook(book.id).subscribe( + res => { + }, + err => { + } + + ); + }; + location.reload(); + } + }); } -}); -} ngOnInit() { diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index e7bcdf5..d8e5a0f 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -841,12 +841,12 @@ - + - @@ -869,7 +869,7 @@ - +