Merge edit and add war into one component and add i18n

pull/46/head
HardiReady 2018-10-03 11:49:17 +02:00
parent 8ad9000766
commit ccbcece0ab
10 changed files with 78 additions and 164 deletions

View File

@ -1,5 +1,5 @@
<div class="fade-in player-campaign-detail-container" xmlns="http://www.w3.org/1999/html"> <div class="fade-in player-campaign-detail-container" xmlns="http://www.w3.org/1999/html">
<h2 class="pull-left">{{'stats.player.detail.headline' | translate}} {{campaignPlayer.name}}</h2> <h2 class="pull-left">{{'stats.player.detail.headline' | translate:{name: campaignPlayer.name} }}</h2>
<button class="btn-back" mat-raised-button (click)="navigateBack()"> <button class="btn-back" mat-raised-button (click)="navigateBack()">
<mat-icon svgIcon="chevron-left"></mat-icon> <mat-icon svgIcon="chevron-left"></mat-icon>

View File

@ -20,7 +20,7 @@ export class CampaignPlayerDetailComponent implements OnInit {
@Output() switchTab = new EventEmitter(); @Output() switchTab = new EventEmitter();
campaignPlayer: CampaignPlayer = {campaign: {}, players: []}; campaignPlayer: CampaignPlayer = {name: '', campaign: {}, players: []};
graphData: any[] = []; graphData: any[] = [];
sumData: any[] = []; sumData: any[] = [];

View File

@ -10,7 +10,6 @@ import {WarSubmitComponent} from './war/war-submit/war-submit.component';
import {FractionStatsComponent} from './war/fraction-stats/fraction-stats.component'; import {FractionStatsComponent} from './war/fraction-stats/fraction-stats.component';
import {StatisticHighScoreComponent} from './campaign/highscore/highscore.component'; import {StatisticHighScoreComponent} from './campaign/highscore/highscore.component';
import {WarHeaderComponent} from './war/war-header/war-header.component'; import {WarHeaderComponent} from './war/war-header/war-header.component';
import {WarEditComponent} from './war/war-edit/war-edit.component';
import {LoginGuardMT} from '../login'; import {LoginGuardMT} from '../login';
import {CampaignNavigationComponent} from './campaign/campaign-navigation/campaign-navigation.component'; import {CampaignNavigationComponent} from './campaign/campaign-navigation/campaign-navigation.component';
import {StatisticOverviewComponent} from './campaign/overview/campaign-overview.component'; import {StatisticOverviewComponent} from './campaign/overview/campaign-overview.component';
@ -61,7 +60,7 @@ export const statsRoutes: Routes = [
}, },
{ {
path: 'submit-war/:id', path: 'submit-war/:id',
component: WarEditComponent, component: WarSubmitComponent,
outlet: 'right', outlet: 'right',
canActivate: [LoginGuardMT] canActivate: [LoginGuardMT]
}]; }];
@ -69,7 +68,6 @@ export const statsRoutes: Routes = [
export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes); export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes);
export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, StatisticHighScoreComponent, export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, StatisticHighScoreComponent,
CampaignSubmitComponent, WarListComponent, WarSubmitComponent, WarEditComponent, WarHeaderComponent, CampaignSubmitComponent, WarListComponent, WarSubmitComponent, WarHeaderComponent, ScoreboardComponent,
ScoreboardComponent, FractionStatsComponent, CampaignPlayerDetailComponent, WarItemComponent, FractionStatsComponent, CampaignPlayerDetailComponent, WarItemComponent, CampaignNavigationComponent];
CampaignNavigationComponent];

View File

@ -1,3 +0,0 @@
form {
margin-top: 45px;
}

View File

@ -1,84 +0,0 @@
<form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview">
<h3>{{'stats.war.submit.headline' | translate}}</h3>
<div class="form-group">
<label for="title">{{'stats.war.submit.title' | translate}}</label>
<input type="text" class="form-control"
[(ngModel)]="war.title"
name="title"
id="title"
required maxlength="50"/>
<show-error displayName="{{'stats.war.submit.title' | translate}}" controlPath="title"></show-error>
</div>
<div class="form-group">
<label for="campaign">{{'stats.war.submit.campaign' | translate}}</label>
<select class="form-control"
name="campaign"
id="campaign"
[(ngModel)]="war.campaign"
required>
<option *ngFor="let campaign of campaignService.campaigns" [ngValue]="campaign._id">
{{campaign.title}}
</option>
</select>
</div>
<div class="form-group">
<label for="ptBlufor">{{'stats.war.submit.points' | translate}} {{fraction.BLUFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.ptBlufor"
name="ptBlufor"
id="ptBlufor"
required min="0"/>
<show-error displayName="{{'stats.war.submit.points' | translate}} {{fraction.BLUFOR}}"
controlPath="ptBlufor"></show-error>
</div>
<div class="form-group">
<label for="ptOpfor">{{'stats.war.submit.points' | translate}} {{fraction.OPFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.ptOpfor"
name="ptOpfor"
id="ptOpfor"
required min="0"/>
<show-error displayName="{{'stats.war.submit.points' | translate}} {{fraction.OPFOR}}"
controlPath="ptOpfor"></show-error>
</div>
<div class="form-group">
<label for="endBudgetBlufor">{{'stats.war.submit.final.budget' | translate}} {{fraction.BLUFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.endBudgetBlufor"
name="endBudgetBlufor"
id="endBudgetBlufor"
required/>
<show-error displayName="{{'stats.war.submit.final.budget' | translate}} {{fraction.BLUFOR}}"
controlPath="endBudgetBlufor"></show-error>
</div>
<div class="form-group">
<label for="endBudgetOpfor">{{'stats.war.submit.final.budget' | translate}} {{fraction.OPFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.endBudgetOpfor"
name="endBudgetOpfor"
id="endBudgetOpfor"
required/>
<show-error displayName="{{'stats.war.submit.final.budget' | translate}} {{fraction.OPFOR}}"
controlPath="endBudgetOpfor"></show-error>
</div>
<button id="cancel"
(click)="cancel()"
class="btn btn-default">
Abbrechen
</button>
<button id="save"
type="submit"
(click)="updateWar()"
class="btn btn-default"
[disabled]="!form.valid">
Bestätigen
</button>
</form>

View File

@ -1,55 +0,0 @@
import {Component, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {NgForm} from '@angular/forms';
import {WarService} from '../../../services/logs/war.service';
import {War} from '../../../models/model-interfaces';
import {CampaignService} from '../../../services/logs/campaign.service';
import {Subscription} from 'rxjs/Subscription';
import {SnackBarService} from '../../../services/user-interface/snack-bar/snack-bar.service';
import {Message} from '../../../i18n/de.messages';
import {Fraction} from '../../../utils/fraction.enum';
@Component({
selector: 'war-edit',
templateUrl: './war-edit.component.html',
styleUrls: ['./war-edit.component.css', '../../../style/entry-form.css', '../../../style/overview.css']
})
export class WarEditComponent {
war: War = {players: []};
subscription: Subscription;
readonly fraction = Fraction;
@ViewChild(NgForm) form: NgForm;
constructor(private route: ActivatedRoute,
private router: Router,
private warService: WarService,
private snackBarService: SnackBarService,
public campaignService: CampaignService) {
this.subscription = this.route.params
.map(params => params['id'])
.filter(id => id !== undefined)
.flatMap(id => this.warService.getWar(id))
.subscribe(war => {
this.war = war;
});
}
updateWar() {
this.warService.updateWar(this.war)
.subscribe(war => {
this.snackBarService.showSuccess(Message.SUCCESS_SAVE);
this.router.navigate(['../../war/' + war._id], {relativeTo: this.route});
},
error => this.snackBarService.showError(error._body.error.message, 15000));
}
cancel() {
this.router.navigate(['..'], {relativeTo: this.route});
return false;
}
}

View File

@ -1,9 +1,9 @@
<div class="war-list-header" *ngIf="!collapsed && loginService.hasPermission(3)"> <div class="war-list-header" *ngIf="!collapsed && loginService.hasPermission(3)">
<button mat-stroked-button (click)="selectNewCampaign()"> <button mat-stroked-button (click)="selectNewCampaign()">
{{'stats.campaign.manage.add' | translate}} {{'stats.sidebar.campaign.add' | translate}}
</button> </button>
<button mat-stroked-button (click)="selectNewWar()"> <button mat-stroked-button (click)="selectNewWar()">
Schlacht hinzufügen {{'stats.sidebar.battle.add' | translate}}
</button> </button>
</div> </div>

View File

@ -1,19 +1,19 @@
<form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview"> <form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview">
<h3>Neue Schlacht hinzufügen</h3> <h3 *ngIf="!war._id">{{'stats.war.submit.headline.new' | translate}}</h3>
<h3 *ngIf="war._id">{{'stats.war.submit.headline.edit' | translate}}</h3>
<div class="form-group"> <div class="form-group">
<label for="title">Titel</label> <label for="title">{{'stats.war.submit.title' | translate}}</label>
<input type="text" class="form-control" <input type="text" class="form-control"
[(ngModel)]="war.title" [(ngModel)]="war.title"
name="title" name="title"
id="title" id="title"
required maxlength="50"/> required maxlength="50"/>
<show-error displayName="{{'stats.war.submit.title' | translate}}" controlPath="title"></show-error>
<show-error displayName="Name" controlPath="title"></show-error>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="campaign">Kampagne</label> <label for="campaign">{{'stats.war.submit.campaign' | translate}}</label>
<select class="form-control" <select class="form-control"
name="campaign" name="campaign"
id="campaign" id="campaign"
@ -25,7 +25,7 @@
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group" *ngIf="!war._id">
<label for="log">Logfile</label> <label for="log">Logfile</label>
<input id="log" name="log" class="ui-button form-control" type="file" <input id="log" name="log" class="ui-button form-control" type="file"
(change)="fileChange($event)"> (change)="fileChange($event)">
@ -34,19 +34,63 @@
</span> </span>
</div> </div>
<div class="form-group" *ngIf="war._id">
<label for="ptBlufor">{{'stats.war.submit.points' | translate}} {{fraction.BLUFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.ptBlufor"
name="ptBlufor"
id="ptBlufor"
required min="0"/>
<show-error displayName="{{'stats.war.submit.points' | translate}} {{fraction.BLUFOR}}"
controlPath="ptBlufor"></show-error>
</div>
<div class="form-group" *ngIf="war._id">
<label for="ptOpfor">{{'stats.war.submit.points' | translate}} {{fraction.OPFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.ptOpfor"
name="ptOpfor"
id="ptOpfor"
required min="0"/>
<show-error displayName="{{'stats.war.submit.points' | translate}} {{fraction.OPFOR}}"
controlPath="ptOpfor"></show-error>
</div>
<div class="form-group" *ngIf="war._id">
<label for="endBudgetBlufor">{{'stats.war.submit.final.budget' | translate}} {{fraction.BLUFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.endBudgetBlufor"
name="endBudgetBlufor"
id="endBudgetBlufor"
required/>
<show-error displayName="{{'stats.war.submit.final.budget' | translate}} {{fraction.BLUFOR}}"
controlPath="endBudgetBlufor"></show-error>
</div>
<div class="form-group" *ngIf="war._id">
<label for="endBudgetOpfor">{{'stats.war.submit.final.budget' | translate}} {{fraction.OPFOR}}</label>
<input type="number" class="form-control"
[(ngModel)]="war.endBudgetOpfor"
name="endBudgetOpfor"
id="endBudgetOpfor"
required/>
<show-error displayName="{{'stats.war.submit.final.budget' | translate}} {{fraction.OPFOR}}"
controlPath="endBudgetOpfor"></show-error>
</div>
<button id="cancel" <button id="cancel"
*ngIf="!loading" *ngIf="!loading"
(click)="cancel()" (click)="cancel()"
class="btn btn-default"> class="btn btn-default">
Abbrechen {{'stats.war.submit.button.cancel' | translate}}
</button> </button>
<button id="save" <button id="save"
type="submit" type="submit"
*ngIf="!loading" *ngIf="!loading"
(click)="saveWar()" (click)="war._id ? editWar() : saveWar()"
class="btn btn-default" class="btn btn-default"
[disabled]="!form.valid"> [disabled]="!form.valid">
Bestätigen {{'stats.war.submit.button.submit' | translate}}
</button> </button>
</form> </form>

View File

@ -6,6 +6,8 @@ import {War} from '../../../models/model-interfaces';
import {CampaignService} from '../../../services/logs/campaign.service'; import {CampaignService} from '../../../services/logs/campaign.service';
import {SnackBarService} from '../../../services/user-interface/snack-bar/snack-bar.service'; import {SnackBarService} from '../../../services/user-interface/snack-bar/snack-bar.service';
import {SpinnerService} from '../../../services/user-interface/spinner/spinner.service'; import {SpinnerService} from '../../../services/user-interface/spinner/spinner.service';
import {Subscription} from 'rxjs';
import {Fraction} from '../../../utils/fraction.enum';
@Component({ @Component({
@ -17,10 +19,14 @@ export class WarSubmitComponent {
war: War = {players: []}; war: War = {players: []};
subscription: Subscription;
fileList: FileList; fileList: FileList;
readonly validExtensions = ['.rpt', '.log', '.txt']; readonly validExtensions = ['.rpt', '.log', '.txt'];
readonly fraction = Fraction;
showFileError = false; showFileError = false;
loading = false; loading = false;
@ -33,6 +39,13 @@ export class WarSubmitComponent {
private snackBarService: SnackBarService, private snackBarService: SnackBarService,
private spinnerService: SpinnerService, private spinnerService: SpinnerService,
public campaignService: CampaignService) { public campaignService: CampaignService) {
this.subscription = this.route.params
.map(params => params['id'])
.filter(id => id !== undefined)
.flatMap(id => this.warService.getWar(id))
.subscribe(war => {
this.war = war;
});
} }
fileChange(event) { fileChange(event) {

View File

@ -1,14 +1,14 @@
{ {
"stats.campaign.manage.add": "Kampagne hinzufügen",
"stats.campaign.manage.edit": "Bearbeiten", "stats.campaign.manage.edit": "Bearbeiten",
"stats.campaign.manage.delete": "Löschen", "stats.campaign.manage.delete": "Löschen",
"stats.campaign.manage.delete.confirm": "Soll die Kampagne \"{{title}}\" wirklich gelöscht werden?", "stats.campaign.manage.delete.confirm": "Soll die Kampagne \"{{title}}\" wirklich gelöscht werden?",
"stats.campaign.title.all.time.overview": "Ewige Übersicht", "stats.campaign.title.all.time.overview": "Ewige Übersicht",
"stats.sidebar.campaign.add": "Kampagne hinzufügen",
"stats.sidebar.battle.add": "Schlacht hinzufügen",
"stats.sidebar.overview": "Übersicht", "stats.sidebar.overview": "Übersicht",
"stats.sidebar.highscore": "Highscore", "stats.sidebar.highscore": "Highscore",
"stats.sidebar.battles": "Schlachten", "stats.sidebar.battles": "Schlachten",
"stats.sidebar.battles.battle.from.date": "vom", "stats.sidebar.battles.battle.from.date": "vom",
"stats.sidebar.battle.manage.edit": "Bearbeiten", "stats.sidebar.battle.manage.edit": "Bearbeiten",
"stats.sidebar.battle.manage.delete": "Löschen", "stats.sidebar.battle.manage.delete": "Löschen",
@ -28,7 +28,7 @@
"stats.fraction.select.stabilize": "Stabilisiert", "stats.fraction.select.stabilize": "Stabilisiert",
"stats.fraction.select.flag": "Flaggenbesitz", "stats.fraction.select.flag": "Flaggenbesitz",
"stats.player.detail.headline": "Kampagnendetails -", "stats.player.detail.headline": "Kampagnendetails - {{name}}",
"stats.player.detail.button.back": "Zurück", "stats.player.detail.button.back": "Zurück",
"stats.player.detail.kill.death.ratio": "Kill/Death", "stats.player.detail.kill.death.ratio": "Kill/Death",
"stats.player.detail.respawn.death.ratio": "Respawn/Death", "stats.player.detail.respawn.death.ratio": "Respawn/Death",
@ -59,7 +59,8 @@
"stats.highscore.filter.button": "Filter", "stats.highscore.filter.button": "Filter",
"stats.highscore.header.name": "Name", "stats.highscore.header.name": "Name",
"stats.war.submit.headline": "Schlacht bearbeiten", "stats.war.submit.headline.new": "Neue Schlacht hinzufügen",
"stats.war.submit.headline.edit": "Schlacht bearbeiten",
"stats.war.submit.title": "Titel", "stats.war.submit.title": "Titel",
"stats.war.submit.campaign": "Kampagne", "stats.war.submit.campaign": "Kampagne",
"stats.war.submit.points": "Punkte", "stats.war.submit.points": "Punkte",