Cleanup optionalparameter from BaseComponent

This commit is contained in:
FinnStutzenstein 2019-03-11 10:38:18 +01:00
parent 0419ea629f
commit 64eab79d3b
6 changed files with 31 additions and 14 deletions

View File

@ -50,11 +50,9 @@ export abstract class BaseComponent {
link image charmap | code fullscreen` link image charmap | code fullscreen`
}; };
public constructor(protected titleService?: Title, protected translate?: TranslateService) { 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_url = '/assets/tinymce/langs/' + this.translate.currentLang + '.js'; this.tinyMceSettings.language = this.translate.currentLang;
this.tinyMceSettings.language = this.translate.currentLang;
}
} }
/** /**

View File

@ -1,4 +1,7 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { BaseComponent } from '../../../base.component'; import { BaseComponent } from '../../../base.component';
import { ViewportService } from 'app/core/ui-services/viewport.service'; import { ViewportService } from 'app/core/ui-services/viewport.service';
@ -15,7 +18,7 @@ export class MetaTextBlockComponent extends BaseComponent {
@Input() @Input()
public showActionRow: boolean; public showActionRow: boolean;
public constructor(public vp: ViewportService) { public constructor(title: Title, translate: TranslateService, public vp: ViewportService) {
super(); super(title, translate);
} }
} }

View File

@ -1,6 +1,7 @@
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { FormGroup, Validators, FormBuilder } from '@angular/forms'; import { FormGroup, Validators, FormBuilder } from '@angular/forms';
import { Title } from '@angular/platform-browser';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { TranslateService } from '@ngx-translate/core'; 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 * @param loginDataService provide information about the legal notice and privacy policy
*/ */
public constructor( public constructor(
protected translate: TranslateService, title: Title,
translate: TranslateService,
private authService: AuthService, private authService: AuthService,
private operator: OperatorService, private operator: OperatorService,
private router: Router, private router: Router,
@ -84,7 +86,7 @@ export class LoginMaskComponent extends BaseComponent implements OnInit, OnDestr
private OpenSlides: OpenSlidesService, private OpenSlides: OpenSlidesService,
private loginDataService: LoginDataService private loginDataService: LoginDataService
) { ) {
super(); super(title, translate);
this.createForm(); this.createForm();
} }

View File

@ -1,5 +1,8 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms'; 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 { BaseComponent } from 'app/base.component';
import { MotionPdfExportService } from 'app/site/motions/services/motion-pdf-export.service'; import { MotionPdfExportService } from 'app/site/motions/services/motion-pdf-export.service';
@ -40,11 +43,13 @@ export class PersonalNoteComponent extends BaseComponent {
* @param pdfService * @param pdfService
*/ */
public constructor( public constructor(
title: Title,
translate: TranslateService,
private personalNoteService: PersonalNoteService, private personalNoteService: PersonalNoteService,
formBuilder: FormBuilder, formBuilder: FormBuilder,
private pdfService: MotionPdfExportService private pdfService: MotionPdfExportService
) { ) {
super(); super(title, translate);
this.personalNoteForm = formBuilder.group({ this.personalNoteForm = formBuilder.group({
note: [''] note: ['']
}); });

View File

@ -33,7 +33,7 @@
<mat-nav-list> <mat-nav-list>
<a mat-list-item [matMenuTriggerFor]="languageMenu"> <a mat-list-item [matMenuTriggerFor]="languageMenu">
<mat-icon>language</mat-icon> <mat-icon>language</mat-icon>
<span> {{ getLangName(this.translate.currentLang) }} </span> <span>{{ getLangName() }}</span>
</a> </a>
<div *ngIf="isLoggedIn"> <div *ngIf="isLoggedIn">
<a [routerLink]="operator.user ? ['/users/', operator.user.id] : []" (click)="mobileAutoCloseNav()" mat-list-item> <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 { Router, NavigationEnd } from '@angular/router';
import { FormGroup, FormControl } from '@angular/forms'; import { FormGroup, FormControl } from '@angular/forms';
import { MatDialog, MatSidenav } from '@angular/material'; import { MatDialog, MatSidenav } from '@angular/material';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -57,17 +58,18 @@ export class SiteComponent extends BaseComponent implements OnInit {
* @param timeTravel * @param timeTravel
*/ */
public constructor( public constructor(
title: Title,
translate: TranslateService,
private authService: AuthService, private authService: AuthService,
private router: Router, private router: Router,
public operator: OperatorService, public operator: OperatorService,
public vp: ViewportService, public vp: ViewportService,
public translate: TranslateService,
public dialog: MatDialog, public dialog: MatDialog,
public mainMenuService: MainMenuService, public mainMenuService: MainMenuService,
public OSStatus: OpenSlidesStatusService, public OSStatus: OpenSlidesStatusService,
public timeTravel: TimeTravelService public timeTravel: TimeTravelService
) { ) {
super(); super(title, translate);
this.operator.getViewUserObservable().subscribe(user => { this.operator.getViewUserObservable().subscribe(user => {
if (user) { if (user) {
@ -132,8 +134,15 @@ export class SiteComponent extends BaseComponent implements OnInit {
/** /**
* Get the name of a Language by abbreviation. * 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') { if (abbreviation === 'en') {
return 'English'; return 'English';
} else if (abbreviation === 'de') { } else if (abbreviation === 'de') {