mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
translate title on steps creation and on lang change
This commit is contained in:
parent
ba3cd5e8e2
commit
34da989c9b
@ -14,6 +14,10 @@ import { PollService } from './core/services/poll.service';
|
|||||||
import { PrimeNGConfig } from 'primeng/api';
|
import { PrimeNGConfig } from 'primeng/api';
|
||||||
import { ApiService } from './core/services/api.service';
|
import { ApiService } from './core/services/api.service';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
import { Poll } from './core/models/poll.model';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { ToastService } from './core/services/toast.service';
|
||||||
|
import { StorageService } from './core/services/storage.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -30,15 +34,19 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
public isSidebarOpened = false;
|
public isSidebarOpened = false;
|
||||||
public devModeEnabled = !environment.production;
|
public devModeEnabled = !environment.production;
|
||||||
public environment = environment;
|
public environment = environment;
|
||||||
|
|
||||||
public onHomePage = false;
|
public onHomePage = false;
|
||||||
private themeSubscription: Subscription;
|
private themeSubscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private titleService: Title,
|
private titleService: Title,
|
||||||
|
private translate: TranslateService,
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
private pollService: PollService,
|
private pollService: PollService,
|
||||||
|
private storageService: StorageService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
|
private toastService: ToastService,
|
||||||
private config: PrimeNGConfig,
|
private config: PrimeNGConfig,
|
||||||
@Inject(DOCUMENT) private document: any,
|
@Inject(DOCUMENT) private document: any,
|
||||||
private languageService: LanguageService // private mockingService: MockingService
|
private languageService: LanguageService // private mockingService: MockingService
|
||||||
@ -57,6 +65,7 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.languageService.getPrimeNgStrings().subscribe((resp) => {
|
this.languageService.getPrimeNgStrings().subscribe((resp) => {
|
||||||
this.config.setTranslation(resp);
|
this.config.setTranslation(resp);
|
||||||
|
this.pollService.updateTitle();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.printpath('', this.router.config);
|
this.printpath('', this.router.config);
|
||||||
@ -64,9 +73,9 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
if (!(evt instanceof NavigationEnd)) {
|
if (!(evt instanceof NavigationEnd)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('evt', evt);
|
|
||||||
|
|
||||||
this.onHomePage = evt.url === '/';
|
this.onHomePage = evt.url === '/';
|
||||||
|
this.pollService.updateTitle();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}, 10);
|
}, 10);
|
||||||
@ -76,12 +85,6 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.appTitle += ' [DEV]';
|
this.appTitle += ' [DEV]';
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadedPoll;
|
|
||||||
if (this.pollService.poll) {
|
|
||||||
loadedPoll = this.pollService.poll;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.titleService.setTitle(this.appTitle + ' - ' + loadedPoll.title);
|
|
||||||
this.languageService.configureAndInitTranslations();
|
this.languageService.configureAndInitTranslations();
|
||||||
this.themeSubscription = this.themeService.theme.subscribe((theme: Theme) => {
|
this.themeSubscription = this.themeService.theme.subscribe((theme: Theme) => {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
@ -98,12 +101,23 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.themeClass = 'theme-light-watermelon';
|
this.themeClass = 'theme-light-watermelon';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// debug cors
|
|
||||||
// this.apiService.getAllAvailablePolls();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
|
this.setupShortcuts();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (this.themeSubscription) {
|
||||||
|
this.themeSubscription.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareRoute(outlet: any) {
|
||||||
|
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private setupShortcuts() {
|
||||||
this.shortcuts.push(
|
this.shortcuts.push(
|
||||||
{
|
{
|
||||||
key: '?',
|
key: '?',
|
||||||
@ -127,14 +141,4 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
if (this.themeSubscription) {
|
|
||||||
this.themeSubscription.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareRoute(outlet: any) {
|
|
||||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import { ApiService } from '../../services/api.service';
|
|||||||
import { ToastService } from '../../services/toast.service';
|
import { ToastService } from '../../services/toast.service';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
|
import { PollService } from '../../services/poll.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
@ -24,12 +26,15 @@ export class HomeComponent implements OnInit {
|
|||||||
public toastService: ToastService,
|
public toastService: ToastService,
|
||||||
public titleService: Title,
|
public titleService: Title,
|
||||||
private api: ApiService,
|
private api: ApiService,
|
||||||
|
private pollService: PollService,
|
||||||
|
private translate: TranslateService,
|
||||||
private cd: ChangeDetectorRef
|
private cd: ChangeDetectorRef
|
||||||
) {
|
) {}
|
||||||
this.titleService.setTitle(environment.appTitle + ' - Landing ');
|
|
||||||
}
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// this.openModalFindPoll();
|
// this.openModalFindPoll();
|
||||||
|
this.pollService.step_current = null;
|
||||||
|
this.pollService.updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
searchMyPolls() {
|
searchMyPolls() {
|
||||||
|
@ -3,6 +3,7 @@ import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
|
|||||||
|
|
||||||
import { LanguageEnum } from '../enums/language.enum';
|
import { LanguageEnum } from '../enums/language.enum';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
|
import { environment } from '../../../environments/environment';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -52,7 +53,7 @@ export class LanguageService {
|
|||||||
|
|
||||||
// set default language
|
// set default language
|
||||||
if (!this.translate.currentLang) {
|
if (!this.translate.currentLang) {
|
||||||
this.setLanguage(LanguageEnum.fr);
|
this.setLanguage(LanguageEnum[environment.defaultLanguage]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,54 @@ export class PollService implements Resolve<Poll> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitle() {
|
||||||
|
let suppl = environment.production ? ' [DEV]' : '';
|
||||||
|
let apptitle = environment.appTitle + suppl;
|
||||||
|
let step_current;
|
||||||
|
if (this.step_current) {
|
||||||
|
// in creation tunnel
|
||||||
|
let stepsTitle = {
|
||||||
|
date: [
|
||||||
|
'creation.title',
|
||||||
|
'creation.want',
|
||||||
|
'dates.title',
|
||||||
|
'hours.title',
|
||||||
|
'advanced.title',
|
||||||
|
'owner.title',
|
||||||
|
'resume.title',
|
||||||
|
],
|
||||||
|
text: [
|
||||||
|
'creation.title',
|
||||||
|
'creation.want',
|
||||||
|
'dates.title',
|
||||||
|
'hours.title',
|
||||||
|
'advanced.title',
|
||||||
|
'owner.title',
|
||||||
|
'resume.title',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
let kind = 'date';
|
||||||
|
step_current = this.step_current | 1;
|
||||||
|
if (this.form.value.isAboutDate) {
|
||||||
|
kind = 'text';
|
||||||
|
}
|
||||||
|
let keyToTranslate = stepsTitle[kind][(step_current - 1) | 0];
|
||||||
|
|
||||||
|
this.translate.get(keyToTranslate).subscribe(
|
||||||
|
(resp) => {
|
||||||
|
this.titleService.setTitle(environment.appTitle + ' - ' + resp + ' - ' + this.form.value.title);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.error(err);
|
||||||
|
this.toastService.display(err.message);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.titleService.setTitle(apptitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add example values to the form for demo env
|
* add example values to the form for demo env
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,6 @@ import { DateChoice, defaultTimeOfDay, TimeSlices } from '../../../../mocks/old-
|
|||||||
import { Poll } from '../models/poll.model';
|
import { Poll } from '../models/poll.model';
|
||||||
import { Owner } from '../models/owner.model';
|
import { Owner } from '../models/owner.model';
|
||||||
import { DateUtilitiesService } from './date.utilities.service';
|
import { DateUtilitiesService } from './date.utilities.service';
|
||||||
import { ToastService } from './toast.service';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -51,7 +50,7 @@ export class StorageService {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) {
|
constructor(public dateUtilities: DateUtilitiesService) {
|
||||||
if (environment.autofill_participation) {
|
if (environment.autofill_participation) {
|
||||||
this.userPolls.push(new Poll(new Owner(), 'Démo: Anniversaire de tonton Patrick', 'aujourdhui-ou-demain'));
|
this.userPolls.push(new Poll(new Owner(), 'Démo: Anniversaire de tonton Patrick', 'aujourdhui-ou-demain'));
|
||||||
this.userPolls.push(new Poll(new Owner(), 'Démo: Atelier cuisine du quartier', 'aujourdhui-ou-demain'));
|
this.userPolls.push(new Poll(new Owner(), 'Démo: Atelier cuisine du quartier', 'aujourdhui-ou-demain'));
|
||||||
|
@ -10,6 +10,7 @@ import { DateUtilitiesService } from '../../../../../core/services/date.utilitie
|
|||||||
import { ApiService } from '../../../../../core/services/api.service';
|
import { ApiService } from '../../../../../core/services/api.service';
|
||||||
import { environment } from '../../../../../../environments/environment';
|
import { environment } from '../../../../../../environments/environment';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-step-two',
|
selector: 'app-step-two',
|
||||||
@ -37,6 +38,7 @@ export class StepTwoComponent implements OnInit {
|
|||||||
public pollService: PollService,
|
public pollService: PollService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private titleService: Title,
|
private titleService: Title,
|
||||||
|
private translate: TranslateService,
|
||||||
public dateUtilities: DateUtilitiesService,
|
public dateUtilities: DateUtilitiesService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
@Inject(DOCUMENT) private document: any
|
@Inject(DOCUMENT) private document: any
|
||||||
|
@ -44,6 +44,7 @@ export class NavStepsComponent implements OnInit {
|
|||||||
this.pollService.createPoll().then(
|
this.pollService.createPoll().then(
|
||||||
(resp) => {
|
(resp) => {
|
||||||
this.router.navigate(['/administration/success']);
|
this.router.navigate(['/administration/success']);
|
||||||
|
this.pollService.step_current = null;
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.error('oops err', err);
|
console.error('oops err', err);
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import { ChangeDetectorRef, Component, Inject, Input } from '@angular/core';
|
import { ChangeDetectorRef, Component, Inject, Input, OnInit } from '@angular/core';
|
||||||
import { PollService } from '../../../core/services/poll.service';
|
import { PollService } from '../../../core/services/poll.service';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
import { Title } from '@angular/platform-browser';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { ToastService } from '../../../core/services/toast.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-stepper',
|
selector: 'app-stepper',
|
||||||
templateUrl: './stepper.component.html',
|
templateUrl: './stepper.component.html',
|
||||||
styleUrls: ['./stepper.component.scss'],
|
styleUrls: ['./stepper.component.scss'],
|
||||||
})
|
})
|
||||||
export class StepperComponent {
|
export class StepperComponent implements OnInit {
|
||||||
@Input()
|
@Input()
|
||||||
public stepperConfirm: HTMLElement;
|
public stepperConfirm: HTMLElement;
|
||||||
|
|
||||||
@ -25,10 +28,12 @@ export class StepperComponent {
|
|||||||
public pollService: PollService,
|
public pollService: PollService,
|
||||||
@Inject(DOCUMENT) private document: any,
|
@Inject(DOCUMENT) private document: any,
|
||||||
private cd: ChangeDetectorRef,
|
private cd: ChangeDetectorRef,
|
||||||
|
private titleService: Title,
|
||||||
|
private toastService: ToastService,
|
||||||
|
private translate: TranslateService,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {
|
) {}
|
||||||
this.step_current = this.pollService.step_current;
|
ngOnInit() {}
|
||||||
}
|
|
||||||
|
|
||||||
showCancelDialog() {
|
showCancelDialog() {
|
||||||
this.display_cancel_dialog = true;
|
this.display_cancel_dialog = true;
|
||||||
@ -41,6 +46,7 @@ export class StepperComponent {
|
|||||||
console.log('not found');
|
console.log('not found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
focusOnCancelButton() {
|
focusOnCancelButton() {
|
||||||
this.display_cancel_dialog = false;
|
this.display_cancel_dialog = false;
|
||||||
let buttonClose = this.document.querySelector('#display_cancel_popup_button');
|
let buttonClose = this.document.querySelector('#display_cancel_popup_button');
|
||||||
|
@ -4,6 +4,7 @@ import { LanguageEnum } from '../../../../core/enums/language.enum';
|
|||||||
import { LanguageService } from '../../../../core/services/language.service';
|
import { LanguageService } from '../../../../core/services/language.service';
|
||||||
import { StorageService } from '../../../../core/services/storage.service';
|
import { StorageService } from '../../../../core/services/storage.service';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
import { PollService } from '../../../../core/services/poll.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-language-selector',
|
selector: 'app-language-selector',
|
||||||
@ -21,6 +22,7 @@ export class LanguageSelectorComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private languageService: LanguageService,
|
private languageService: LanguageService,
|
||||||
private storageService: StorageService,
|
private storageService: StorageService,
|
||||||
|
private pollService: PollService,
|
||||||
@Inject(DOCUMENT) private document: any
|
@Inject(DOCUMENT) private document: any
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -39,6 +41,7 @@ export class LanguageSelectorComponent implements OnInit {
|
|||||||
this.currentLang = newlang;
|
this.currentLang = newlang;
|
||||||
this.languageService.setLanguage(newlang);
|
this.languageService.setLanguage(newlang);
|
||||||
this.storageService.language = this.currentLang;
|
this.storageService.language = this.currentLang;
|
||||||
|
this.pollService.updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
focusOnCancelButton() {
|
focusOnCancelButton() {
|
||||||
|
Loading…
Reference in New Issue
Block a user