From 64eab79d3b351bf769f87c751b44dc44fe1a259a Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Mon, 11 Mar 2019 10:38:18 +0100 Subject: [PATCH] Cleanup optionalparameter from BaseComponent --- client/src/app/base.component.ts | 8 +++----- .../meta-text-block/meta-text-block.component.ts | 7 +++++-- .../components/login-mask/login-mask.component.ts | 6 ++++-- .../personal-note/personal-note.component.ts | 7 ++++++- client/src/app/site/site.component.html | 2 +- client/src/app/site/site.component.ts | 15 ++++++++++++--- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/client/src/app/base.component.ts b/client/src/app/base.component.ts index 99658eba9..df2a8b7a4 100644 --- a/client/src/app/base.component.ts +++ b/client/src/app/base.component.ts @@ -50,11 +50,9 @@ export abstract class BaseComponent { link image charmap | code fullscreen` }; - public constructor(protected titleService?: Title, protected translate?: TranslateService) { - if (this.translate) { - this.tinyMceSettings.language_url = '/assets/tinymce/langs/' + this.translate.currentLang + '.js'; - this.tinyMceSettings.language = this.translate.currentLang; - } + public constructor(protected titleService: Title, protected translate: TranslateService) { + this.tinyMceSettings.language_url = '/assets/tinymce/langs/' + this.translate.currentLang + '.js'; + this.tinyMceSettings.language = this.translate.currentLang; } /** diff --git a/client/src/app/shared/components/meta-text-block/meta-text-block.component.ts b/client/src/app/shared/components/meta-text-block/meta-text-block.component.ts index b9c11a600..ce293a25a 100644 --- a/client/src/app/shared/components/meta-text-block/meta-text-block.component.ts +++ b/client/src/app/shared/components/meta-text-block/meta-text-block.component.ts @@ -1,4 +1,7 @@ import { Component, Input } from '@angular/core'; +import { Title } from '@angular/platform-browser'; + +import { TranslateService } from '@ngx-translate/core'; import { BaseComponent } from '../../../base.component'; import { ViewportService } from 'app/core/ui-services/viewport.service'; @@ -15,7 +18,7 @@ export class MetaTextBlockComponent extends BaseComponent { @Input() public showActionRow: boolean; - public constructor(public vp: ViewportService) { - super(); + public constructor(title: Title, translate: TranslateService, public vp: ViewportService) { + super(title, translate); } } diff --git a/client/src/app/site/login/components/login-mask/login-mask.component.ts b/client/src/app/site/login/components/login-mask/login-mask.component.ts index 76c9a4d4b..952cca89c 100644 --- a/client/src/app/site/login/components/login-mask/login-mask.component.ts +++ b/client/src/app/site/login/components/login-mask/login-mask.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { FormGroup, Validators, FormBuilder } from '@angular/forms'; +import { Title } from '@angular/platform-browser'; import { Subscription } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; @@ -74,7 +75,8 @@ export class LoginMaskComponent extends BaseComponent implements OnInit, OnDestr * @param loginDataService provide information about the legal notice and privacy policy */ public constructor( - protected translate: TranslateService, + title: Title, + translate: TranslateService, private authService: AuthService, private operator: OperatorService, private router: Router, @@ -84,7 +86,7 @@ export class LoginMaskComponent extends BaseComponent implements OnInit, OnDestr private OpenSlides: OpenSlidesService, private loginDataService: LoginDataService ) { - super(); + super(title, translate); this.createForm(); } diff --git a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts index 8cfdc882f..41defd24f 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/personal-note/personal-note.component.ts @@ -1,5 +1,8 @@ import { Component, Input } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; +import { Title } from '@angular/platform-browser'; + +import { TranslateService } from '@ngx-translate/core'; import { BaseComponent } from 'app/base.component'; import { MotionPdfExportService } from 'app/site/motions/services/motion-pdf-export.service'; @@ -40,11 +43,13 @@ export class PersonalNoteComponent extends BaseComponent { * @param pdfService */ public constructor( + title: Title, + translate: TranslateService, private personalNoteService: PersonalNoteService, formBuilder: FormBuilder, private pdfService: MotionPdfExportService ) { - super(); + super(title, translate); this.personalNoteForm = formBuilder.group({ note: [''] }); diff --git a/client/src/app/site/site.component.html b/client/src/app/site/site.component.html index 2e759e3b3..76141a7fe 100644 --- a/client/src/app/site/site.component.html +++ b/client/src/app/site/site.component.html @@ -33,7 +33,7 @@ language - {{ getLangName(this.translate.currentLang) }} + {{ getLangName() }}
diff --git a/client/src/app/site/site.component.ts b/client/src/app/site/site.component.ts index 374d3bb2a..73aaa0cd7 100644 --- a/client/src/app/site/site.component.ts +++ b/client/src/app/site/site.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { FormGroup, FormControl } from '@angular/forms'; import { MatDialog, MatSidenav } from '@angular/material'; +import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; @@ -57,17 +58,18 @@ export class SiteComponent extends BaseComponent implements OnInit { * @param timeTravel */ public constructor( + title: Title, + translate: TranslateService, private authService: AuthService, private router: Router, public operator: OperatorService, public vp: ViewportService, - public translate: TranslateService, public dialog: MatDialog, public mainMenuService: MainMenuService, public OSStatus: OpenSlidesStatusService, public timeTravel: TimeTravelService ) { - super(); + super(title, translate); this.operator.getViewUserObservable().subscribe(user => { if (user) { @@ -132,8 +134,15 @@ export class SiteComponent extends BaseComponent implements OnInit { /** * Get the name of a Language by abbreviation. + * + * @param abbreviation The abbreviation of the languate or null, if the current + * language should be used. */ - public getLangName(abbreviation: string): string { + public getLangName(abbreviation?: string): string { + if (!abbreviation) { + abbreviation = this.translate.currentLang; + } + if (abbreviation === 'en') { return 'English'; } else if (abbreviation === 'de') {