Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix initial values for new events. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 113 additions & 122 deletions order-web-ui/app/event/PartyEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,9 @@ <h3 class="panel-title">Allgemeinen</h3>
</div>
<div class="form-group col-sm-3">
<label for="estimatedNumberOfPizzas" class="control-label">Anzahl Pizzen*</label>
<div class="input-group">
<span class="input-group-btn"><button type="button" class="btn btn-default"
(click)="changeEstimatedNumberOfPizzas(-4)">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span></button></span>
<input class="form-control" type="number" id="estimatedNumberOfPizzas" name="estimatedNumberOfPizzas" [(ngModel)]="party.estimatedNumberOfPizzas"/>
<span class="input-group-btn"><button type="button" class="btn btn-default"
(click)="changeEstimatedNumberOfPizzas(4)">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button></span>
</div>
<input class="form-control" type="number" min="4" step="2" id="estimatedNumberOfPizzas"
name="estimatedNumberOfPizzas"
[(ngModel)]="party.estimatedNumberOfPizzas"/>
</div>
<div class="form-group col-sm-3">
<label for="blendStatistics" class="control-label">Anteil der allg. Statistik*</label>
Expand All @@ -107,123 +101,120 @@ <h3 class="panel-title">Allgemeinen</h3>
</div>
</div>

<div *ngIf="party.id">

<div class="print-info">
<div class="print_only">
<h2>Pizzateig für {{party.estimatedNumberOfPizzas}} Pizzen (300 g Teiglinge)</h2>
<ul class="recipe">
<li>{{(1.5 / 8 * party.estimatedNumberOfPizzas) |number: "1.1-1"}} kg Mehl</li>
<li>{{(820 / 8 * party.estimatedNumberOfPizzas) |number: "1.0-0"}} ml Wasser</li>
<li>{{(40 / 12 * party.estimatedNumberOfPizzas) |number: "1.0-0"}} g Hefe</li>
<li>{{(30 / 8 * party.estimatedNumberOfPizzas) |number: "1.0-0"}} g Salz</li>
</ul>
<h2>Weitere Gewürze</h2>
<p>Oregano, Thymian, Majoran, Zimt, Pfeffer und Salz</p>
<h2>Kommentare</h2>
</div>
<span class="label label-default label-comment"
*ngFor="let order of orders">{{showOrderLabel(order)}}</span>
<div class="clear"></div>
<div class="print_only">
<h2>Checkliste</h2>
<ul>
<li>Backofen, Pizzasteine, Schieber, Brett für den Ofen, Backofengitter</li>
<li>Küchenmaschine, Waage, Margarine-Schälchen</li>
<li>Schneidebretter (groß/klein), Küchenmesser, Schalen, Schüsseln, Dosenöffner, Knoblauchpresse,
Kuchengabeln
</li>
<li>Backbretter, Wellholz, Tassen, Esslöffel, Gabeln, Teigschaber, Wiegemesser, Reibe, Lasagneheber,
Topflappen
</li>
<li>Handtücher, Putzschwamm, Spühlmittel, Müllbeutel</li>
<li>Laptops, Tablets, Smartphones, Mäuse, Netzteile, W-Lan Router, LTE-Hotspot, Verlängerungskabel,
Mehrfachsteckdosen
</li>
<li>Bestellzettel, Speisekarte</li>
</ul>
</div>
<div class="print-info">
<div class="print_only">
<h2>Pizzateig für {{party.estimatedNumberOfPizzas}} Pizzen (300 g Teiglinge)</h2>
<ul class="recipe">
<li>{{(1.5 / 8 * party.estimatedNumberOfPizzas) |number: "1.1-1"}} kg Mehl</li>
<li>{{(820 / 8 * party.estimatedNumberOfPizzas) |number: "1.0-0"}} ml Wasser</li>
<li>{{(40 / 12 * party.estimatedNumberOfPizzas) |number: "1.0-0"}} g Hefe</li>
<li>{{(30 / 8 * party.estimatedNumberOfPizzas) |number: "1.0-0"}} g Salz</li>
</ul>
<h2>Weitere Gewürze</h2>
<p>Oregano, Thymian, Majoran, Zimt, Pfeffer und Salz</p>
<h2>Kommentare</h2>
</div>
<span class="label label-default label-comment"
*ngFor="let order of orders">{{showOrderLabel(order)}}</span>
<div class="clear"></div>
<div class="print_only">
<h2>Checkliste</h2>
<ul>
<li>Backofen, Pizzasteine, Schieber, Brett für den Ofen, Backofengitter</li>
<li>Küchenmaschine, Waage, Margarine-Schälchen</li>
<li>Schneidebretter (groß/klein), Küchenmesser, Schalen, Schüsseln, Dosenöffner, Knoblauchpresse,
Kuchengabeln
</li>
<li>Backbretter, Wellholz, Tassen, Esslöffel, Gabeln, Teigschaber, Wiegemesser, Reibe, Lasagneheber,
Topflappen
</li>
<li>Handtücher, Putzschwamm, Spühlmittel, Müllbeutel</li>
<li>Laptops, Tablets, Smartphones, Mäuse, Netzteile, W-Lan Router, LTE-Hotspot, Verlängerungskabel,
Mehrfachsteckdosen
</li>
<li>Bestellzettel, Speisekarte</li>
</ul>
</div>
</div>

<h2 class="print_not">Zutaten</h2>
<div class="panel panel-default panel-condiment">
<table class="table table-condensed">
<ng-container *ngFor="let category of categories">
<thead>
<tr>
<th class="td_center print_not">Aktiv</th>
<th class="td_center">%</th>
<th>{{category[0]}}</th>
<th class="td_right">je Pizza</th>
<th class="td_right">nach Statistik</th>
<th class="td_right">Manuell</th>
<th class="td_center print_not">Bewertung</th>
<h2 class="print_not">Zutaten</h2>
<div class="panel panel-default panel-condiment">
<table class="table table-condensed">
<ng-container *ngFor="let category of categories">
<thead>
<tr>
<th class="td_center print_not">Aktiv</th>
<th class="td_center">%</th>
<th>{{category[0]}}</th>
<th class="td_right">je Pizza</th>
<th class="td_right">nach Statistik</th>
<th class="td_right">Manuell</th>
<th class="td_center print_not">Bewertung</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let condiment of category[1]">
<tr [ngClass]="{print_not: !isCondimentSelected(condiment.id)}">
<td class="td_center print_not"><input
id="condiment{{condiment.id.value}}"
name="condiment{{condiment.id.value}}"
[(ngModel)]="availableCondiments[condiment.id.value]"
type="checkbox"></td>
<td class="td_center">{{blendCondimentStatistic(condiment) | number: "1.1-1"}}</td>
<td>{{condiment.name}}</td>
<td class="td_right">{{amountPerPizza(condiment) | number: "1.1-1"}} {{condiment.unit}}
<a (click)="showCondimentDetails(condiment.id)"
style="cursor:pointer" class="print_not">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</a></td>
<td class="td_right">
{{amountCalculated(condiment) | number: "1.1-1"}}
{{condiment.unit}}
</td>
<td class="td_right print_not">
<div class="input-group input-group-sm input-100">
<input size="2" type="text"
class="form-control"
[(ngModel)]="condiment.amount"
[ngModelOptions]="{standalone: true}"
[disabled]="!isCondimentSelected(condiment.id)">
<span class="input-group-addon">{{condiment.unit}}</span>
</div>
</td>
<td class="td_right print_only">{{condiment.amount}} {{condiment.unit}}</td>
<td class="td_center print_not">
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button"
[disabled]="!isCondimentSelected(condiment.id)"
[ngClass]="{'btn': true, 'btn-default': true, 'btn-primary': isCurrentRating(condiment, -1)}"
(click)="changeRating(condiment, -1);"><span
class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
</button>
<button type="button"
[disabled]="!isCondimentSelected(condiment.id)"
[ngClass]="{'btn': true, 'btn-default': true, 'btn-primary': isCurrentRating(condiment, 0)}"
(click)="changeRating(condiment, 0);"><span
class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
<button type="button"
[disabled]="!isCondimentSelected(condiment.id)"
[ngClass]="{'btn': true, 'btn-default': true, 'btn-primary': isCurrentRating(condiment, 1)}"
(click)="changeRating(condiment, 1);"><span
class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
</button>
</div>
</td>
</tr>
<tr *ngIf="condimentSettings[condiment.id.value].showDetails" class="print_not">
<td colspan="7">
<condimentStatisticChart
[statistic]="getCondimentStatistic(condiment)"
[unit]="condiment.unit"></condimentStatisticChart>
</td>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let condiment of category[1]">
<tr [ngClass]="{print_not: !isCondimentSelected(condiment.id)}">
<td class="td_center print_not"><input
id="condiment{{condiment.id.value}}"
name="condiment{{condiment.id.value}}"
[(ngModel)]="availableCondiments[condiment.id.value]"
type="checkbox"></td>
<td class="td_center">{{blendCondimentStatistic(condiment) | number: "1.1-1"}}</td>
<td>{{condiment.name}}</td>
<td class="td_right">{{amountPerPizza(condiment) | number: "1.1-1"}} {{condiment.unit}}
<a (click)="showCondimentDetails(condiment.id)"
style="cursor:pointer" class="print_not">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</a></td>
<td class="td_right">
{{amountCalculated(condiment) | number: "1.1-1"}}
{{condiment.unit}}
</td>
<td class="td_right print_not">
<div class="input-group input-group-sm input-100">
<input size="2" type="text"
class="form-control"
[(ngModel)]="condiment.amount"
[ngModelOptions]="{standalone: true}"
[disabled]="!isCondimentSelected(condiment.id)">
<span class="input-group-addon">{{condiment.unit}}</span>
</div>
</td>
<td class="td_right print_only">{{condiment.amount}} {{condiment.unit}}</td>
<td class="td_center print_not">
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button"
[disabled]="!isCondimentSelected(condiment.id)"
[ngClass]="{'btn': true, 'btn-default': true, 'btn-primary': isCurrentRating(condiment, -1)}"
(click)="changeRating(condiment, -1);"><span
class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
</button>
<button type="button"
[disabled]="!isCondimentSelected(condiment.id)"
[ngClass]="{'btn': true, 'btn-default': true, 'btn-primary': isCurrentRating(condiment, 0)}"
(click)="changeRating(condiment, 0);"><span
class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
<button type="button"
[disabled]="!isCondimentSelected(condiment.id)"
[ngClass]="{'btn': true, 'btn-default': true, 'btn-primary': isCurrentRating(condiment, 1)}"
(click)="changeRating(condiment, 1);"><span
class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
</button>
</div>
</td>
</tr>
<tr *ngIf="condimentSettings[condiment.id.value].showDetails" class="print_not">
<td colspan="7">
<condimentStatisticChart
[statistic]="getCondimentStatistic(condiment)"
[unit]="condiment.unit"></condimentStatisticChart>
</td>
</tr>
</ng-container>
</tbody>
</ng-container>
</table>
</div>
</tbody>
</ng-container>
</table>
</div>

<div class="form-group td_right">
Expand Down
14 changes: 6 additions & 8 deletions order-web-ui/app/event/PartyEditComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ export class PartyEditComponent {
this.party = <Party>this.routeParams.snapshot.data["party"];
this.condimentsStatistic = <Map<number, CondimentStatistic>>this.routeParams.snapshot.data["condimentsStatistic"];
this.orders = <Array<Order>>this.routeParams.snapshot.data["orders"];
let condiments = <Array<Condiment>>this.routeParams.snapshot.data["condiments"];

if (this.party === undefined) {
this.party = new Party();
this.party.blendStatistics = 50;
this.party.estimatedNumberOfPizzas = 8;
this.orders = [];
for (let condiment of condiments) {
this.availableCondiments[condiment.id.value] = true;
}
} else {
for (let condimentId of this.party.condiments) {
this.availableCondiments[condimentId.value] = true;
}
}
let condiments = <Array<Condiment>>this.routeParams.snapshot.data["condiments"];
this.categories = <Array<[string, Array<CondimentWithRating>]>>CondimentCategoryService.groupCondimentsByCategory(condiments);
for (let condiment of condiments) {
this.condimentSettings[condiment.id.value] = {
Expand All @@ -63,13 +68,6 @@ export class PartyEditComponent {
return this.availableCondiments[condimentId.value] === true;
}

changeEstimatedNumberOfPizzas(factor: number): void {
this.party.estimatedNumberOfPizzas = this.party.estimatedNumberOfPizzas + factor;
if (this.party.estimatedNumberOfPizzas < 0) {
this.party.estimatedNumberOfPizzas = 0;
}
}

blendCondimentStatistic(condiment: Condiment): number {
let numberOfOrdersWithCondiment = 0;
for (let order of this.orders) {
Expand Down