Skip to content

Commit

Permalink
Merge pull request #595 from Gid733/stable
Browse files Browse the repository at this point in the history
Fix issue with table headers translates
  • Loading branch information
renemadsen authored Feb 3, 2024
2 parents 4438903 + 7eb442c commit a7775c5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
import { AfterContentInit, Component, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { translates } from './../i18n/translates';
import { AuthStateService } from 'src/app/common/store';
import {AfterContentInit, Component, OnInit} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {translates} from './../i18n/translates';
import {Store} from '@ngrx/store';
import {selectCurrentUserLocale} from 'src/app/state/auth/auth.selector';
import {addPluginToVisited, selectPluginsVisitedPlugins} from 'src/app/state';
import {take} from 'rxjs';

@Component({
selector: 'app-time-planning-pn-layout',
template: `<router-outlet></router-outlet>`,
template: `
<router-outlet></router-outlet>`,
})
export class TimePlanningPnLayoutComponent
implements AfterContentInit, OnInit {
private selectCurrentUserLocale$ = this.store.select(selectCurrentUserLocale);
export class TimePlanningPnLayoutComponent implements AfterContentInit, OnInit {
private pluginName = 'time-planning';

constructor(
private store: Store,
private translateService: TranslateService,
private authStateService: AuthStateService
) {}
store: Store
) {
store.select(selectPluginsVisitedPlugins)
.pipe(take(1))
.subscribe(x => {
// check current plugin in activated plugin
if (x.findIndex(y => y === this.pluginName) === -1) {
// add all plugin translates one time
Object.keys(translates).forEach(locale => {
this.translateService.setTranslation(locale, translates[locale], true);
});
// add plugin to visited plugins
store.dispatch(addPluginToVisited(this.pluginName));
}
});
}

ngOnInit() {}
ngOnInit() {
}

ngAfterContentInit() {
this.selectCurrentUserLocale$.subscribe((locale) => {
const i18n = translates[locale];
this.translateService.setTranslation(locale, i18n, true);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
AfterViewInit,
Component,
EventEmitter,
Input,
Expand All @@ -9,19 +8,23 @@ import {
SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation,
} from '@angular/core';
import {AbstractControl, FormArray, FormControl, FormGroup} from '@angular/forms';
import {Observable, Subscription} from 'rxjs';
import {SiteDto, TableHeaderElementModel} from 'src/app/common/models';
import {Subscription} from 'rxjs';
import {SiteDto} from 'src/app/common/models';
import {TimePlanningModel, TimePlanningsRequestModel} from '../../../../models';
import {MtxGridColumn, MtxGridRowClassFormatter} from '@ng-matero/extensions/grid';
import {TranslateService} from '@ngx-translate/core';
import {DaysOfWeekEnum, HOURS_PICKER_ARRAY, STANDARD_DANISH_DATE_FORMAT} from 'src/app/common/const';
import { messages } from '../../../../consts/messages';
import {format, parseISO} from 'date-fns'
import {messages} from '../../../../consts/messages';
import {format} from 'date-fns';
import {MatDialog} from '@angular/material/dialog';
import {Overlay} from '@angular/cdk/overlay';
import {WorkingHoursCommentOfficeUpdateModalComponent} from 'src/app/plugins/modules/time-planning-pn/modules/working-hours/components';
import {WorkingHoursCommentOfficeUpdateModalComponent} from '../';
import {dialogConfigHelper} from 'src/app/common/helpers';
import {selectCurrentUserLocale} from 'src/app/state';
import {Store} from '@ngrx/store';
import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';

@AutoUnsubscribe()
@Component({
selector: 'app-working-hours-table',
templateUrl: './working-hours-table.component.html',
Expand All @@ -44,6 +47,8 @@ export class WorkingHoursTableComponent implements OnInit, OnChanges, OnDestroy
@Output() filtersChanged: EventEmitter<TimePlanningsRequestModel> = new EventEmitter<TimePlanningsRequestModel>();
@Output() updateWorkingHours: EventEmitter<void> = new EventEmitter<void>();
messages: { id: number; value: string }[] = [];
private selectCurrentUserLocale$ = this.store.select(selectCurrentUserLocale);
selectCurrentUserLocaleSub$: Subscription;

get columns() {
return this.tableHeaders.map(x => x.field);
Expand All @@ -57,8 +62,9 @@ export class WorkingHoursTableComponent implements OnInit, OnChanges, OnDestroy
private translateService: TranslateService,
private dialog: MatDialog,
private overlay: Overlay,
private store: Store,
) {
this.messages = messages(translateService);
this.selectCurrentUserLocaleSub$ = this.selectCurrentUserLocale$.subscribe(() => this.messages = messages(translateService));
}

getIsWeekend(workingHoursModel: AbstractControl): boolean {
Expand Down

0 comments on commit a7775c5

Please sign in to comment.