Add manage user i18n replacements

pull/46/head
HardiReady 2018-10-04 10:33:15 +02:00
parent e902ed5ec4
commit ac604f4e08
21 changed files with 157 additions and 49 deletions

View File

@ -1,7 +1,8 @@
<div class="input-group list-header pull-left"> <div class="input-group list-header pull-left">
<mat-button-toggle-group #group="matButtonToggleGroup"> <mat-button-toggle-group #group="matButtonToggleGroup">
<mat-button-toggle *ngFor="let button of filterButtons" value="{{button.value}}" (change)="execute(group)"> <mat-button-toggle *ngFor="let button of filterButtons" value="{{button.value}}" (change)="execute(group)">
{{button.label}} <span *ngIf="button.label !== fraction.BLUFOR && button.label !== fraction.OPFOR">{{button.label | translate}}</span>
<span *ngIf="button.label === fraction.BLUFOR || button.label === fraction.OPFOR">{{button.label}}</span>
</mat-button-toggle> </mat-button-toggle>
</mat-button-toggle-group> </mat-button-toggle-group>
<button mat-icon-button <button mat-icon-button

View File

@ -1,4 +1,5 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import {Fraction} from '../../../utils/fraction.enum';
@Component({ @Component({
selector: 'cc-list-filter', selector: 'cc-list-filter',
@ -15,6 +16,8 @@ export class ListFilterComponent {
@Output() openAddFrom = new EventEmitter(); @Output() openAddFrom = new EventEmitter();
readonly fraction = Fraction;
constructor() { constructor() {
} }

View File

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

View File

@ -9,7 +9,7 @@ import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core'; import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
export function createTranslateLoader(http: HttpClient) { export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/squad/', '.json'); return new TranslateHttpLoader(http, './assets/i18n/squads/', '.json');
} }
@NgModule({ @NgModule({

View File

@ -3,12 +3,12 @@ import {SquadListComponent} from './squad-list/squad-list.component';
import {EditSquadComponent} from './edit-squad/edit-squad.component'; import {EditSquadComponent} from './edit-squad/edit-squad.component';
import {ModuleWithProviders} from '@angular/core'; import {ModuleWithProviders} from '@angular/core';
import {SquadItemComponent} from './squad-list/squad-item.component'; import {SquadItemComponent} from './squad-list/squad-item.component';
import {SquadComponent} from './squad.component'; import {SquadsComponent} from './squads.component';
export const squadsRoutes: Routes = [ export const squadsRoutes: Routes = [
{ {
path: '', path: '',
component: SquadComponent component: SquadsComponent
}, },
{ {
path: '', path: '',
@ -29,5 +29,5 @@ export const squadsRoutes: Routes = [
export const squadRouterModule: ModuleWithProviders = RouterModule.forChild(squadsRoutes); export const squadRouterModule: ModuleWithProviders = RouterModule.forChild(squadsRoutes);
export const squadsRoutingComponents = [SquadComponent, SquadItemComponent, SquadListComponent, EditSquadComponent]; export const squadsRoutingComponents = [SquadsComponent, SquadItemComponent, SquadListComponent, EditSquadComponent];

View File

@ -1,8 +1,8 @@
<form #form="ngForm" class="overview"> <form #form="ngForm" class="overview">
<h3>Teilnehmer auszeichnen</h3> <h3>{{'users.award.headline' | translate}}</h3>
<div class="form-group"> <div class="form-group">
<label for="decoration">Auszeichnung</label> <label for="decoration">{{'users.award.field.decoration' | translate}}</label>
<select class="form-control" <select class="form-control"
name="decoration" name="decoration"
id="decoration" id="decoration"
@ -11,14 +11,13 @@
[ngModel]="0" [ngModel]="0"
required required
style="min-width: 200px;"> style="min-width: 200px;">
<option [value]="0">Auswählen...</option> <option [value]="0">{{'users.award.field.decoration.placeholder' | translate}}</option>
<option *ngFor="let deco of decorations" [value]="deco._id"> <option *ngFor="let deco of decorations" [value]="deco._id">
{{deco.fraction == 'BLUFOR'? fraction.BLUFOR : deco.fraction == 'OPFOR'? fraction.OPFOR : 'Global'}}: {{deco.fraction == 'BLUFOR'? fraction.BLUFOR : deco.fraction == 'OPFOR'? fraction.OPFOR : 'Global'}}:
{{deco.name}} {{deco.name}}
</option> </option>
</select> </select>
<show-error displayName="{{'users.award.field.decoration' | translate}}" controlPath="decoration"></show-error>
<show-error displayName="Auszeichnung" controlPath="decoration"></show-error>
</div> </div>
<div class="div-table-row" [style.display]="decoPreviewDisplay" style="margin-top: 5px; margin-bottom:10px"> <div class="div-table-row" [style.display]="decoPreviewDisplay" style="margin-top: 5px; margin-bottom:10px">
@ -38,37 +37,40 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="reason">Begründung</label> <label for="reason">{{'users.award.field.reason' | translate}}</label>
<textarea class="form-control center-block" name="reason" [ngModel]="undefined" required <textarea class="form-control center-block" name="reason" [ngModel]="undefined" required
id="reason" placeholder="Begründung eingeben..." rows="3" #awardTextArea></textarea> id="reason" placeholder="{{'users.award.field.reason.placeholder' | translate}}"
<show-error displayName="Begründung" controlPath="reason"></show-error> rows="3" #awardTextArea>
</textarea>
<show-error displayName="{{'users.award.field.reason' | translate}}" controlPath="reason"></show-error>
</div> </div>
<button id="cancel" <button id="cancel"
(click)="cancel()" (click)="cancel()"
class="btn btn-default"> class="btn btn-default">
Abbrechen {{'users.award.button.cancel' | translate}}
</button> </button>
<button id="save" <button id="save"
(click)="addAwarding(decorationField, awardTextArea, decoPreview, decoDescription)" (click)="addAwarding(decorationField, awardTextArea, decoPreview, decoDescription)"
class="btn btn-default" class="btn btn-default"
[disabled]="decorationField.value === '0' || !form.valid"> [disabled]="decorationField.value === '0' || !form.valid">
Bestätigen {{'users.award.button.submit' | translate}}
</button> </button>
<div class="table-container"> <div class="table-container">
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th class="col-sm-1">Bild</th> <th class="col-sm-1">{{'users.award.table.head.image' | translate}}</th>
<th class="col-sm-2">Bezeichnung</th> <th class="col-sm-2">{{'users.award.table.head.name' | translate}}</th>
<th class="col-sm-2">Begründung</th> <th class="col-sm-2">{{'users.award.table.head.reason' | translate}}</th>
<th class="col-sm-1 text-right">Datum</th> <th class="col-sm-1 text-right">{{'users.award.table.head.date' | translate}}</th>
<th class="col-sm-1 text-center">Status</th> <th class="col-sm-1 text-center">{{'users.award.table.head.status' | translate}}</th>
<th class="col-sm-1 text-center"> <th class="col-sm-1 text-center">
<span class="btn btn-default" (click)="deleteAwarding()">Löschen</span> <span class="btn btn-default" (click)="deleteAwarding()">
{{'users.award.table.button.delete' | translate}}
</span>
</th> </th>
</tr> </tr>
</thead> </thead>
@ -90,7 +92,9 @@
<a class="small text-nowrap">{{award.date | date: 'dd.MM.yyyy'}}</a> <a class="small text-nowrap">{{award.date | date: 'dd.MM.yyyy'}}</a>
</td> </td>
<td class="text-center"> <td class="text-center">
{{award.confirmed === 0 ? 'In Bearbeitung' : (award.confirmed === 1 ? 'Genehmigt' : 'Abgelehnt')}} {{award.confirmed === 0 ?
awardStatus['users.award.table.status.in.progress'] : (award.confirmed === 1 ?
awardStatus['users.award.table.status.approved']: awardStatus['users.award.table.status.rejected'])}}
</td> </td>
<td class="text-center"> <td class="text-center">
<label> <label>

View File

@ -7,6 +7,7 @@ import {DecorationService} from '../../services/army-management/decoration.servi
import {Fraction} from '../../utils/fraction.enum'; import {Fraction} from '../../utils/fraction.enum';
import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service'; import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service';
import {Message} from '../../i18n/de.messages'; import {Message} from '../../i18n/de.messages';
import {TranslateService} from '@ngx-translate/core';
@Component({ @Component({
@ -23,6 +24,8 @@ export class AwardUserComponent implements OnInit {
awards: Award[]; awards: Award[];
awardStatus = {};
decoPreviewDisplay = 'none'; decoPreviewDisplay = 'none';
readonly fraction = Fraction; readonly fraction = Fraction;
@ -31,10 +34,18 @@ export class AwardUserComponent implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private awardingService: AwardingService, private awardingService: AwardingService,
private decorationService: DecorationService, private decorationService: DecorationService,
private snackBarService: SnackBarService) { private snackBarService: SnackBarService,
private translate: TranslateService) {
} }
ngOnInit() { ngOnInit() {
['users.award.table.status.in.progress',
'users.award.table.status.approved',
'users.award.table.status.rejected'].forEach((i18n) => {
this.translate.get(i18n).subscribe((translated) => {
this.awardStatus[i18n] = translated;
})
});
this.decorationService.findDecorations().subscribe(decorations => { this.decorationService.findDecorations().subscribe(decorations => {
this.decorations = decorations; this.decorations = decorations;

View File

@ -1,38 +1,36 @@
<form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview"> <form #form="ngForm" (keydown.enter)="$event.preventDefault()" class="overview">
<h3 *ngIf="user._id">Teilnehmer editieren</h3> <h3 *ngIf="user._id">{{'user.submit.headline.edit' | translate}}</h3>
<h3 *ngIf="!user._id">Neuen Teilnehmer hinzufügen</h3> <h3 *ngIf="!user._id">{{'user.submit.headline.new' | translate}}</h3>
<div class="form-group"> <div class="form-group">
<label for="title">Name</label> <label for="title">{{'user.submit.field.name' | translate}}</label>
<input class="form-control" <input class="form-control"
[(ngModel)]="user.username" [(ngModel)]="user.username"
name="title" name="title"
id="title" id="title"
required required
maxlength="50"/> maxlength="50"/>
<show-error displayName="{{'user.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="squad">Squad</label> <label for="squad">{{'user.submit.field.squad' | translate}}</label>
<select class="form-control" <select class="form-control"
name="squad" name="squad"
id="squad" id="squad"
[(ngModel)]="user.squadId" [(ngModel)]="user.squadId"
[compareWith]="equals" [compareWith]="equals"
(change)="toggleRanks()"> (change)="toggleRanks()">
<option [value]="0">Ohne Fraktion/ Squad</option> <option [value]="0">{{'user.submit.field.squad.not.assigned' | translate}}</option>
<option *ngFor="let squad of squads" [ngValue]="squad"> <option *ngFor="let squad of squads" [ngValue]="squad">
{{squad.fraction == 'BLUFOR'? fraction.BLUFOR : fraction.OPFOR}}: {{squad.name}} {{squad.fraction == 'BLUFOR'? fraction.BLUFOR : fraction.OPFOR}}: {{squad.name}}
</option> </option>
</select> </select>
<show-error displayName="{{'user.submit.field.squad' | translate}}" controlPath="squad"></show-error>
<show-error displayName="Squad" controlPath="squad"></show-error>
</div> </div>
<div class="form-group" [style.display]="ranksDisplay"> <div class="form-group" [style.display]="ranksDisplay">
<label for="rank">Rang</label> <label for="rank">{{'user.submit.field.rank' | translate}}</label>
<select class="form-control" <select class="form-control"
name="rank" name="rank"
id="rank" [ngModel]="user.rankLvl" id="rank" [ngModel]="user.rankLvl"
@ -40,14 +38,13 @@
style="min-width: 200px;"> style="min-width: 200px;">
<option *ngFor="let rank of ranks" [value]="rank.level">{{rank.name}}</option> <option *ngFor="let rank of ranks" [value]="rank.level">{{rank.name}}</option>
</select> </select>
<show-error displayName="{{'user.submit.field.rank' | translate}}" controlPath="rank"></show-error>
<show-error displayName="Rang" controlPath="rank"></show-error>
</div> </div>
<button id="cancel" <button id="cancel"
(click)="cancel()" (click)="cancel()"
class="btn btn-default"> class="btn btn-default">
Abbrechen {{'user.submit.button.cancel' | translate}}
</button> </button>
<button id="save" <button id="save"
@ -55,6 +52,6 @@
(click)="saveUser(rankLevel.value)" (click)="saveUser(rankLevel.value)"
class="btn btn-default" class="btn btn-default"
[disabled]="!form.valid"> [disabled]="!form.valid">
Bestätigen {{'user.submit.button.submit' | translate}}
</button> </button>
</form> </form>

View File

@ -9,12 +9,14 @@
<small *ngIf="user.squadId && user.squadId.fraction == 'OPFOR'">{{fraction.OPFOR}} - {{user.squadId.name}}</small> <small *ngIf="user.squadId && user.squadId.fraction == 'OPFOR'">{{fraction.OPFOR}} - {{user.squadId.name}}</small>
<small *ngIf="user.squadId && user.squadId.fraction == 'BLUFOR'">{{fraction.BLUFOR}} - {{user.squadId.name}} <small *ngIf="user.squadId && user.squadId.fraction == 'BLUFOR'">{{fraction.BLUFOR}} - {{user.squadId.name}}
</small> </small>
<small *ngIf="!user.squadId">ohne Squad/Fraktion</small> <small *ngIf="!user.squadId">{{'users.list.item.label.no.squad' | translate}}</small>
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<mat-icon (click)="delete(); $event.stopPropagation()" matTooltip="Löschen" class="pull-right" style="margin-top: 8px;" svgIcon="delete"></mat-icon> <mat-icon (click)="delete(); $event.stopPropagation()" matTooltip="{{'users.list.tooltip.delete' | translate}}"
<mat-icon (click)="award(); $event.stopPropagation()" matTooltip="Auszeichnungen" class="icon-award pull-right" svgIcon="award"></mat-icon> class="pull-right" style="margin-top: 8px;" svgIcon="delete"></mat-icon>
<mat-icon (click)="award(); $event.stopPropagation()" matTooltip="{{'users.list.tooltip.awards' | translate}}"
class="icon-award pull-right" svgIcon="award"></mat-icon>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,8 +2,8 @@
<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'},
{label: 'Ohne Squad', value: 'UNASSIGNED'}]" {label: 'users.list.filter.no.squad', value: 'UNASSIGNED'}]"
[addButton]="{svgIcon: 'add-user', tooltip: 'Neuen Teilnehmer hinzufügen'}" [addButton]="{svgIcon: 'add-user', tooltip: 'users.list.tooltip.new'}"
(executeSearch)="filterUsers(undefined, $event)" (executeSearch)="filterUsers(undefined, $event)"
(openAddFrom)="openNewUserForm()"> (openAddFrom)="openNewUserForm()">
</cc-list-filter> </cc-list-filter>

View File

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

View File

@ -2,11 +2,11 @@ import {Component} from '@angular/core';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
@Component({ @Component({
selector: 'cc-squad-root', selector: 'cc-users-root',
templateUrl: './squad.component.html', templateUrl: './users.component.html',
styleUrls: ['./squad.component.scss'] styleUrls: ['./users.component.scss']
}) })
export class SquadComponent { export class UsersComponent {
constructor(private translate: TranslateService) { constructor(private translate: TranslateService) {
this.translate.setDefaultLang('de'); this.translate.setDefaultLang('de');

View File

@ -3,10 +3,32 @@ import {usersRouterModule, usersRoutingComponents} from './users.routing';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {SharedModule} from '../shared.module'; import {SharedModule} from '../shared.module';
import {InfiniteScrollModule} from 'ngx-infinite-scroll'; import {InfiniteScrollModule} from 'ngx-infinite-scroll';
import {HttpClient} from '@angular/common/http';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/users/', '.json');
}
@NgModule({ @NgModule({
declarations: usersRoutingComponents, declarations: usersRoutingComponents,
imports: [CommonModule, SharedModule, InfiniteScrollModule, usersRouterModule],
imports: [
CommonModule,
SharedModule,
InfiniteScrollModule,
usersRouterModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
},
isolate: true
})
],
}) })
export class UsersModule { export class UsersModule {
static routes = usersRouterModule; static routes = usersRouterModule;

View File

@ -4,8 +4,13 @@ import {UserListComponent} from './user-list/user-list.component';
import {AwardUserComponent} from './award-user/award-user.component'; import {AwardUserComponent} from './award-user/award-user.component';
import {ModuleWithProviders} from '@angular/core'; import {ModuleWithProviders} from '@angular/core';
import {UserItemComponent} from './user-list/user-item.component'; import {UserItemComponent} from './user-list/user-item.component';
import {UsersComponent} from './users.component';
export const usersRoutes: Routes = [ export const usersRoutes: Routes = [
{
path: '',
component: UsersComponent,
},
{ {
path: '', path: '',
component: UserListComponent, component: UserListComponent,
@ -30,4 +35,5 @@ export const usersRoutes: Routes = [
export const usersRouterModule: ModuleWithProviders = RouterModule.forChild(usersRoutes); export const usersRouterModule: ModuleWithProviders = RouterModule.forChild(usersRoutes);
export const usersRoutingComponents = [UserItemComponent, UserListComponent, EditUserComponent, AwardUserComponent]; export const usersRoutingComponents = [UsersComponent, UserItemComponent, UserListComponent, EditUserComponent,
AwardUserComponent];

View File

@ -0,0 +1,44 @@
{
"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",
"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",
"users.list.tooltip.new": "Neuen Teilnehmer hinzufügen",
"users.list.tooltip.delete": "Löschen",
"users.list.tooltip.awards": "Auszeichnungen",
"users.list.filter.no.squad": "Ohne Squad",
"users.list.item.label.no.squad": "ohne Squad/Fraktion",
"users.award.headline": "Teilnehmer auszeichnen",
"users.award.field.decoration": "Auszeichnung",
"users.award.field.decoration.placeholder": "Auswählen...",
"users.award.field.reason": "Begründung",
"users.award.field.reason.placeholder": "Begründung eingeben...",
"users.award.button.submit": "Bestätigen",
"users.award.button.cancel": "Abbrechen",
"users.award.table.head.image": "Bild",
"users.award.table.head.name": "Bezeichnung",
"users.award.table.head.reason": "Begründung",
"users.award.table.head.date": "Datum",
"users.award.table.head.status": "Status",
"users.award.table.button.delete": "Löschen",
"users.award.table.status.in.progress": "In Bearbeitung",
"users.award.table.status.approved": "Genehmigt",
"users.award.table.status.rejected": "Abgelehnt",
"user.submit.headline.new": "Neuen Teilnehmer hinzufügen",
"user.submit.headline.edit": "Teilnehmer bearbeiten",
"user.submit.field.name": "Name",
"user.submit.field.squad": "Squad",
"user.submit.field.squad.not.assigned": "Ohne Fraktion/ Squad",
"user.submit.field.rank": "Rang",
"user.submit.button.submit": "Bestätigen",
"user.submit.button.cancel": "Abbrechen"
}

View File

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