-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d889fa2
commit 2819055
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="form-check"> | ||
<label class="form-check-label"> | ||
<input type="checkbox" class="form-check-input" [(ngModel)]="includeShipped"/> | ||
Display Shipped Orders | ||
</label> | ||
</div> | ||
<div class="table table-sm"> | ||
<thead> | ||
<tr><th>Name</th><th>Zip</th><th colspan="2">Cart</th><th></th></tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngIf="getOrders().length == 0"> | ||
<td colspan="5">There are no orders</td> | ||
</tr> | ||
<ng-template ngFor let-o [ngForOf]="getOrders()"> | ||
<tr> | ||
<td>{{o.name}}</td> | ||
<td>{{o.zip}}</td> | ||
<th>Product</th> | ||
<th>Quantity</th> | ||
<td> | ||
<button class="btn btn-warning" (click)="markShipped(o)">Ship</button> | ||
<button class="btn btn-danger" (click)="delete(o.id)">Delete</button> | ||
</td> | ||
</tr> | ||
<tr *ngFor="let line of o.cart.lines"> | ||
<td colspan="2"></td> | ||
<td>{{line.product.name}}</td> | ||
<td>{{line.quantity}}</td> | ||
</tr> | ||
</ng-template> | ||
</tbody> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
import { Component } from "@angular/core"; | ||
import { Order } from "../model/order.model"; | ||
import { OrderRepository } from "../model/order.repository"; | ||
|
||
@Component({ | ||
template: `<div class="bg-info p-2 text-white"><h3>Order Table placeholder</h3></div>` | ||
templateUrl: "orderTable.component.html" | ||
}) | ||
|
||
export class OrderTableComponent {} | ||
export class OrderTableComponent { | ||
|
||
includeShipped: boolean = false; | ||
|
||
constructor(private repository: OrderRepository) {} | ||
|
||
getOrders(): Order[] { | ||
return this.repository.getOrders().filter(o => this.includeShipped || !o.shipped); | ||
} | ||
|
||
markShipped(order: Order) { | ||
order.shipped = true; | ||
this.repository.updateOrder(order); | ||
} | ||
|
||
delete(id: number) { | ||
this.repository.deleteOrder(id); | ||
} | ||
} |