Merge pull request #4493 from FinnStutzenstein/baseComponent

Cleanup optional parameter from BaseComponent
This commit is contained in:
Finn Stutzenstein 2019-03-12 12:41:09 +01:00 committed by GitHub
commit 6d66ec5b5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 14 deletions

View File

@ -50,12 +50,10 @@ export abstract class BaseComponent {
link image charmap | code fullscreen`
};
public constructor(protected titleService?: Title, protected translate?: TranslateService) {
if (this.translate) {
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;
}
}
/**
* Set the title in web browser using angulars TitleService

View File

@ -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);
}
}

View File

@ -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';
@ -72,7 +73,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,
@ -81,7 +83,7 @@ export class LoginMaskComponent extends BaseComponent implements OnInit, OnDestr
private httpService: HttpService,
private loginDataService: LoginDataService
) {
super();
super(title, translate);
this.createForm();
}

View File

@ -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: ['']
});

View File

@ -33,7 +33,7 @@
<mat-nav-list>
<a mat-list-item [matMenuTriggerFor]="languageMenu">
<mat-icon>language</mat-icon>
<span> {{ getLangName(this.translate.currentLang) }} </span>
<span>{{ getLangName() }}</span>
</a>
<div *ngIf="isLoggedIn">
<a [routerLink]="operator.user ? ['/users/', operator.user.id] : []" (click)="mobileAutoCloseNav()" mat-list-item>

View File

@ -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') {