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">
<h3 *ngIf="rank._id">Rang editieren</h3>
<h3 *ngIf="!rank._id">Neuen Rang hinzufügen</h3>
<h3 *ngIf="rank._id">{{'ranks.submit.headline.edit' | translate}}</h3>
<h3 *ngIf="!rank._id">{{'ranks.submit.headline.new' | translate}}</h3>
<div class="form-group">
<label for="title">Name</label>
<label for="title">{{'ranks.submit.field.name' | translate}}</label>
<input type="text" class="form-control"
[(ngModel)]="rank.name"
name="title"
id="title"
required maxlength="50"/>
<show-error displayName="Name" controlPath="title"></show-error>
<show-error displayName="{{'ranks.submit.field.name' | translate}}" controlPath="title"></show-error>
</div>
<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"
required
[(ngModel)]="rank.fraction">
<option value="OPFOR">{{fraction.OPFOR}}</option>
<option value="BLUFOR">{{fraction.BLUFOR}}</option>
</select>
<show-error displayName="Fraktion" controlPath="fraction"></show-error>
<show-error displayName="{{'ranks.submit.field.fraction' | translate}}" controlPath="fraction"></show-error>
</div>
<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"
[(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 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"
accept="image/png"
#fileInput
(change)="fileChange($event)">
<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>
<img class="preview-image" src="{{imagePreviewSrc}}">
@ -47,7 +46,7 @@
<button id="cancel"
(click)="cancel()"
class="btn btn-default">
Abbrechen
{{'ranks.submit.button.cancel' | translate}}
</button>
<button id="save"
@ -55,6 +54,6 @@
(click)="saveRank(fileInput)"
class="btn btn-default"
[disabled]="!form.valid">
Bestätigen
{{'ranks.submit.button.submit' | translate}}
</button>
</form>

View File

@ -7,6 +7,7 @@ import {Subscription} from 'rxjs/Subscription';
import {Fraction} from '../../utils/fraction.enum';
import {Message} from '../../i18n/de.messages';
import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service';
import {TranslateService} from '@ngx-translate/core';
@Component({
@ -34,7 +35,8 @@ export class EditRankComponent implements OnInit, OnDestroy {
constructor(private route: ActivatedRoute,
private router: Router,
private rankService: RankService,
private snackBarService: SnackBarService) {
private snackBarService: SnackBarService,
private translate: TranslateService) {
}
ngOnInit() {
@ -73,7 +75,12 @@ export class EditRankComponent implements OnInit, OnDestroy {
this.router.navigate(['..'], {relativeTo: this.route});
});
} 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 {
if (this.fileList) {
@ -95,12 +102,4 @@ export class EditRankComponent implements OnInit, OnDestroy {
this.router.navigate([this.rank._id ? '../..' : '..'], {relativeTo: this.route});
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>
<small *ngIf="rank.fraction == 'OPFOR'">{{fraction.OPFOR}}</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 class="col-xs-4">
<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>

View File

@ -2,7 +2,7 @@
<cc-list-filter
[filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'},
{label: fraction.OPFOR, value: 'OPFOR'}]"
[addButton]="{svgIcon: 'add', tooltip: 'Neuen Rang hinzufügen'}"
[addButton]="{svgIcon: 'add', tooltip: 'ranks.list.button.add'}"
(executeSearch)="filterRanks($event)"
(openAddFrom)="openNewRankForm()">
</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 {RankService} from '../services/army-management/rank.service';
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({
declarations: ranksRoutingComponents,
imports: [CommonModule, SharedModule, rankRouterModule],
providers: [RankStore, RankService]
imports: [
CommonModule,
SharedModule,
rankRouterModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
},
isolate: true
})
],
providers: [
RankStore,
RankService
]
})
export class RanksModule {
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 {RankItemComponent} from './rank-list/rank-item.component';
import {ModuleWithProviders} from '@angular/core';
import {RanksComponent} from './ranks.component';
export const ranksRoutes: Routes = [
{
path: '',
component: RanksComponent,
},
{
path: '',
component: RankListComponent,
@ -23,5 +28,4 @@ export const ranksRoutes: Routes = [
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});
});
} 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',
{fieldName: fieldNameLogfile}).subscribe((message) => {
return window.alert(message);
{fieldName: fieldNameLogo}).subscribe((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('public.error.message.required',
{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;
}
}
}

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.min.length": "{{fieldName}} muss mindestens {{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.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten",
"public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten",