Add manage ranks i18n replacements

pull/46/head
HardiReady 2018-10-04 10:59:15 +02:00
parent ac604f4e08
commit 78abec80fd
16 changed files with 101 additions and 37 deletions

View File

@ -1,44 +1,43 @@
<form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview"> <form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview">
<h3 *ngIf="rank._id">Rang editieren</h3> <h3 *ngIf="rank._id">{{'ranks.submit.headline.edit' | translate}}</h3>
<h3 *ngIf="!rank._id">Neuen Rang hinzufügen</h3> <h3 *ngIf="!rank._id">{{'ranks.submit.headline.new' | translate}}</h3>
<div class="form-group"> <div class="form-group">
<label for="title">Name</label> <label for="title">{{'ranks.submit.field.name' | translate}}</label>
<input type="text" class="form-control" <input type="text" class="form-control"
[(ngModel)]="rank.name" [(ngModel)]="rank.name"
name="title" name="title"
id="title" id="title"
required maxlength="50"/> required maxlength="50"/>
<show-error displayName="{{'ranks.submit.field.name' | 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="fraction">Fraktion</label> <label for="fraction">{{'ranks.submit.field.fraction' | translate}}</label>
<select id="fraction" name="fraction" class="form-control btn dropdown-toggle" <select id="fraction" name="fraction" class="form-control btn dropdown-toggle"
required required
[(ngModel)]="rank.fraction"> [(ngModel)]="rank.fraction">
<option value="OPFOR">{{fraction.OPFOR}}</option> <option value="OPFOR">{{fraction.OPFOR}}</option>
<option value="BLUFOR">{{fraction.BLUFOR}}</option> <option value="BLUFOR">{{fraction.BLUFOR}}</option>
</select> </select>
<show-error displayName="Fraktion" controlPath="fraction"></show-error> <show-error displayName="{{'ranks.submit.field.fraction' | translate}}" controlPath="fraction"></show-error>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="level">Stufe</label> <label for="level">{{'ranks.submit.field.level' | translate}}</label>
<input id="level" name="level" type="number" class="form-control btn dropdown-toggle" <input id="level" name="level" type="number" class="form-control btn dropdown-toggle"
[(ngModel)]="rank.level"> [(ngModel)]="rank.level">
<show-error displayName="Stufe" controlPath="level"></show-error> <show-error displayName="{{'ranks.submit.field.level' | translate}}" controlPath="level"></show-error>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="logo">Bild</label> <label for="logo">{{'ranks.submit.field.image' | translate}}</label>
<input id="logo" name="logo" class="ui-button form-control" type="file" <input id="logo" name="logo" class="ui-button form-control" type="file"
accept="image/png" accept="image/png"
#fileInput #fileInput
(change)="fileChange($event)"> (change)="fileChange($event)">
<span class="label label-bg label-danger center-block" style="font-size:small" *ngIf="showImageError"> <span class="label label-bg label-danger center-block" style="font-size:small" *ngIf="showImageError">
Bild muss im PNG Format vorliegen {{'ranks.submit.field.image.error.format' | translate}}
</span> </span>
<img class="preview-image" src="{{imagePreviewSrc}}"> <img class="preview-image" src="{{imagePreviewSrc}}">
@ -47,7 +46,7 @@
<button id="cancel" <button id="cancel"
(click)="cancel()" (click)="cancel()"
class="btn btn-default"> class="btn btn-default">
Abbrechen {{'ranks.submit.button.cancel' | translate}}
</button> </button>
<button id="save" <button id="save"
@ -55,6 +54,6 @@
(click)="saveRank(fileInput)" (click)="saveRank(fileInput)"
class="btn btn-default" class="btn btn-default"
[disabled]="!form.valid"> [disabled]="!form.valid">
Bestätigen {{'ranks.submit.button.submit' | translate}}
</button> </button>
</form> </form>

View File

@ -7,6 +7,7 @@ import {Subscription} from 'rxjs/Subscription';
import {Fraction} from '../../utils/fraction.enum'; import {Fraction} from '../../utils/fraction.enum';
import {Message} from '../../i18n/de.messages'; import {Message} from '../../i18n/de.messages';
import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service'; import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service';
import {TranslateService} from '@ngx-translate/core';
@Component({ @Component({
@ -34,7 +35,8 @@ export class EditRankComponent implements OnInit, OnDestroy {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private rankService: RankService, private rankService: RankService,
private snackBarService: SnackBarService) { private snackBarService: SnackBarService,
private translate: TranslateService) {
} }
ngOnInit() { ngOnInit() {
@ -73,7 +75,12 @@ export class EditRankComponent implements OnInit, OnDestroy {
this.router.navigate(['..'], {relativeTo: this.route}); this.router.navigate(['..'], {relativeTo: this.route});
}); });
} else { } else {
return window.alert(`Bild ist ein Pflichtfeld`); this.translate.get('ranks.submit.field.image').subscribe((fieldNameIMage) => {
this.translate.get('public.error.message.required',
{fieldName: fieldNameIMage}).subscribe((message) => {
this.snackBarService.showError(message, 4000);
})
});
} }
} else { } else {
if (this.fileList) { if (this.fileList) {
@ -95,12 +102,4 @@ export class EditRankComponent implements OnInit, OnDestroy {
this.router.navigate([this.rank._id ? '../..' : '..'], {relativeTo: this.route}); this.router.navigate([this.rank._id ? '../..' : '..'], {relativeTo: this.route});
return false; return false;
} }
canDeactivate(): boolean {
if (this.saved || !this.form.dirty) {
return true;
}
return window.confirm(`Ihr Formular besitzt ungespeicherte Änderungen, möchten Sie die Seite wirklich verlassen?`);
}
} }

View File

@ -8,12 +8,13 @@
<br> <br>
<small *ngIf="rank.fraction == 'OPFOR'">{{fraction.OPFOR}}</small> <small *ngIf="rank.fraction == 'OPFOR'">{{fraction.OPFOR}}</small>
<small *ngIf="rank.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small> <small *ngIf="rank.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small>
<small> - Stufe {{rank.level}}</small> <small>{{'ranks.list.item.label.level' | translate:{level: rank.level} }}</small>
</div> </div>
<div class="col-xs-4"> <div class="col-xs-4">
<img src="{{imageSrc}}" class="rank-list-preview"> <img src="{{imageSrc}}" class="rank-list-preview">
<span (click)="delete(); $event.stopPropagation()" matTooltip="Löschen" class="glyphicon glyphicon-trash trash"></span> <span (click)="delete(); $event.stopPropagation()" matTooltip="{{'ranks.list.button.delete' | translate}}"
class="glyphicon glyphicon-trash trash"></span>
</div> </div>
</div> </div>

View File

@ -2,7 +2,7 @@
<cc-list-filter <cc-list-filter
[filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'}, [filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'},
{label: fraction.OPFOR, value: 'OPFOR'}]" {label: fraction.OPFOR, value: 'OPFOR'}]"
[addButton]="{svgIcon: 'add', tooltip: 'Neuen Rang hinzufügen'}" [addButton]="{svgIcon: 'add', tooltip: 'ranks.list.button.add'}"
(executeSearch)="filterRanks($event)" (executeSearch)="filterRanks($event)"
(openAddFrom)="openNewRankForm()"> (openAddFrom)="openNewRankForm()">
</cc-list-filter> </cc-list-filter>

View File

@ -0,0 +1 @@
<router-outlet></router-outlet>

View File

@ -0,0 +1,14 @@
import { Component } from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'cc-ranks-root',
templateUrl: './ranks.component.html',
styleUrls: ['./ranks.component.scss']
})
export class RanksComponent {
constructor(private translate: TranslateService) {
translate.setDefaultLang('de');
}
}

View File

@ -4,11 +4,34 @@ import {SharedModule} from '../shared.module';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {RankService} from '../services/army-management/rank.service'; import {RankService} from '../services/army-management/rank.service';
import {RankStore} from '../services/stores/rank.store'; import {RankStore} from '../services/stores/rank.store';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {HttpClient} from '@angular/common/http';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/ranks/', '.json');
}
@NgModule({ @NgModule({
declarations: ranksRoutingComponents, declarations: ranksRoutingComponents,
imports: [CommonModule, SharedModule, rankRouterModule], imports: [
providers: [RankStore, RankService] CommonModule,
SharedModule,
rankRouterModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
},
isolate: true
})
],
providers: [
RankStore,
RankService
]
}) })
export class RanksModule { export class RanksModule {
static routes = rankRouterModule; static routes = rankRouterModule;

View File

@ -3,8 +3,13 @@ import {RankListComponent} from './rank-list/rank-list.component';
import {EditRankComponent} from './edit-rank/edit-rank.component'; import {EditRankComponent} from './edit-rank/edit-rank.component';
import {RankItemComponent} from './rank-list/rank-item.component'; import {RankItemComponent} from './rank-list/rank-item.component';
import {ModuleWithProviders} from '@angular/core'; import {ModuleWithProviders} from '@angular/core';
import {RanksComponent} from './ranks.component';
export const ranksRoutes: Routes = [ export const ranksRoutes: Routes = [
{
path: '',
component: RanksComponent,
},
{ {
path: '', path: '',
component: RankListComponent, component: RankListComponent,
@ -23,5 +28,4 @@ export const ranksRoutes: Routes = [
export const rankRouterModule: ModuleWithProviders = RouterModule.forChild(ranksRoutes); export const rankRouterModule: ModuleWithProviders = RouterModule.forChild(ranksRoutes);
export const ranksRoutingComponents = [RankItemComponent, RankListComponent, EditRankComponent]; export const ranksRoutingComponents = [RanksComponent, RankItemComponent, RankListComponent, EditRankComponent];

View File

@ -75,10 +75,10 @@ export class EditSquadComponent implements OnInit, OnDestroy {
this.router.navigate(['..'], {relativeTo: this.route}); this.router.navigate(['..'], {relativeTo: this.route});
}); });
} else { } else {
this.translate.get('squad.submit.field.logo').subscribe((fieldNameLogfile) => { this.translate.get('squad.submit.field.logo').subscribe((fieldNameLogo) => {
this.translate.get('public.error.message.required', this.translate.get('public.error.message.required',
{fieldName: fieldNameLogfile}).subscribe((message) => { {fieldName: fieldNameLogo}).subscribe((message) => {
return window.alert(message); this.snackBarService.showError(message, 4000);
}) })
}); });
} }

View File

@ -66,7 +66,7 @@ export class WarSubmitComponent {
this.translate.get('stats.war.submit.logfile').subscribe((fieldNameLogfile) => { this.translate.get('stats.war.submit.logfile').subscribe((fieldNameLogfile) => {
this.translate.get('public.error.message.required', this.translate.get('public.error.message.required',
{fieldName: fieldNameLogfile}).subscribe((message) => { {fieldName: fieldNameLogfile}).subscribe((message) => {
return window.alert(message); this.snackBarService.showError(message, 4000);
}) })
}) })
} }

View File

@ -130,5 +130,4 @@ export class EditUserComponent implements OnInit {
return o1._id === o2._id; return o1._id === o2._id;
} }
} }
} }

View File

@ -0,0 +1,23 @@
{
"public.error.message.required": "{{fieldName}} ist ein Pflichtfeld",
"public.error.message.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten",
"public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten",
"public.error.message.email": "Bitte geben Sie eine gültige E-Mail Adresse an",
"public.error.message.no.user": "Der eingetragene Benutzer existiert nicht.",
"public.error.message.default": "{{fieldName}} ist nicht valide",
"public.common.search.button": "Suchen",
"ranks.list.button.add": "Neuen Rank hinzufügen",
"ranks.list.button.delete": "Löschen",
"ranks.list.item.label.level": " - Stufe {{level}}",
"ranks.submit.headline.new": "Neuen Rang hinzufügen",
"ranks.submit.headline.edit": "Rang bearbeiten",
"ranks.submit.field.name": "Name",
"ranks.submit.field.fraction": "Fraktion",
"ranks.submit.field.level": "Stufe",
"ranks.submit.field.image": "Bild",
"ranks.submit.field.image.error.format": "Bild muss im PNG Format vorliegen",
"ranks.submit.button.submit": "Bestätigen",
"ranks.submit.button.cancel": "Abbrechen"
}

View File

@ -0,0 +1,3 @@
{
}

View File

@ -1,5 +1,4 @@
{ {
"public.error.headline": "Oops, diese Seite kennen wir nicht...",
"public.error.message.required": "{{fieldName}} ist ein Pflichtfeld", "public.error.message.required": "{{fieldName}} ist ein Pflichtfeld",
"public.error.message.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten", "public.error.message.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten",
"public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten", "public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten",

View File

@ -1,5 +1,4 @@
{ {
"public.error.headline": "Oops, diese Seite kennen wir nicht...",
"public.error.message.required": "{{fieldName}} ist ein Pflichtfeld", "public.error.message.required": "{{fieldName}} ist ein Pflichtfeld",
"public.error.message.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten", "public.error.message.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten",
"public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten", "public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten",