latest
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
<tr *ngFor="let book of bookList">
|
||||
<td>
|
||||
<input hidden="hidden" name="id" />
|
||||
<input class="checkboxBook" type="checkbox"/>
|
||||
<input type="checkbox" [checked]="checked" (change)="updateRemoveBookList($event.target.checked, book)" />
|
||||
</td>
|
||||
<td><a (click)="onSelect(book)" style="cursor: pointer">{{book.title}}</a></td>
|
||||
<td>{{book.author}}</td>
|
||||
@@ -35,6 +35,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button md-raised-button class="mat-warn" id="deleteSelected">Delete Selected</button>
|
||||
<button md-raised-button class="mat-warn" id="deleteSelected" (click)="removeSelectedBooks()">Delete Selected</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user