From 8d954f2b1a8fb8a0edbb8ac7038dee3a6f5951c9 Mon Sep 17 00:00:00 2001 From: Henry Taeschner Date: Tue, 30 Jan 2024 11:48:47 +0100 Subject: [PATCH] fix: testing --- src/app/shared/label.resolver.ts | 6 ++- .../theme-designer.component.ts | 50 ++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/app/shared/label.resolver.ts b/src/app/shared/label.resolver.ts index c09047b..9d2f623 100644 --- a/src/app/shared/label.resolver.ts +++ b/src/app/shared/label.resolver.ts @@ -1,15 +1,19 @@ import { Injectable } from '@angular/core' import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router' import { TranslateService } from '@ngx-translate/core' -import { Observable, map } from 'rxjs' +import { Observable } from 'rxjs' //dont use `providedIn root` - wont work when we are in shell @Injectable() export class LabelResolver implements Resolve { constructor(private translate: TranslateService) {} + resolve(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): string | Observable | Promise { + return route.data['breadcrumb'] ? this.translate.instant(route.data['breadcrumb']) : route.routeConfig?.path + /* TODO: use this if tests are running with it. resolve(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): string | Observable | Promise { return route.data['breadcrumb'] ? this.translate.get(route.data['breadcrumb']).pipe(map((t) => t.toString())) : route.routeConfig?.path ?? '' + */ } } diff --git a/src/app/theme/theme-designer/theme-designer.component.ts b/src/app/theme/theme-designer/theme-designer.component.ts index 95bb288..dfcc826 100644 --- a/src/app/theme/theme-designer/theme-designer.component.ts +++ b/src/app/theme/theme-designer/theme-designer.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms' -import { Observable, debounceTime, map, switchMap } from 'rxjs' +import { Observable, debounceTime, switchMap } from 'rxjs' import { TranslateService } from '@ngx-translate/core' import { ConfirmationService, SelectItem } from 'primeng/api' @@ -66,7 +66,20 @@ export class ThemeDesignerComponent implements OnInit { this.mode = route.snapshot.paramMap.has('id') ? 'EDIT' : 'NEW' this.themeId = route.snapshot.paramMap.get('id') this.themeIsCurrentUsedTheme = this.themeId === this.appStateService.currentPortal$.getValue()?.themeId - this.prepareActionButtons() + //this.prepareActionButtons() + this.translate + .get([ + 'ACTIONS.CANCEL', + 'ACTIONS.TOOLTIPS.CANCEL_AND_CLOSE', + 'ACTIONS.SAVE', + 'ACTIONS.TOOLTIPS.SAVE', + 'ACTIONS.SAVE_AS', + 'ACTIONS.TOOLTIPS.SAVE_AS' + ]) + .subscribe((data) => { + this.prepareActionButtons_old(data) + }) + this.fontForm = new FormGroup({}) this.topbarForm = new FormGroup({}) this.generalForm = new FormGroup({}) @@ -161,7 +174,39 @@ export class ThemeDesignerComponent implements OnInit { this.loadThemeTemplates() } + private prepareActionButtons_old(data: any): void { + this.actions = [] // provoke change event + this.actions.push( + { + label: data['ACTIONS.CANCEL'], + title: data['ACTIONS.TOOLTIPS.CANCEL_AND_CLOSE'], + actionCallback: () => this.close(), + icon: 'pi pi-times', + show: 'always', + permission: 'THEME#VIEW' + }, + { + label: data['ACTIONS.SAVE'], + title: data['ACTIONS.TOOLTIPS.SAVE'], + actionCallback: () => this.updateTheme(), + icon: 'pi pi-save', + show: 'always', + conditional: true, + showCondition: this.mode === 'EDIT', + permission: 'THEME#SAVE' + }, + { + label: data['ACTIONS.SAVE_AS'], + title: data['ACTIONS.TOOLTIPS.SAVE_AS'], + actionCallback: () => this.saveAsNewPopup(), + icon: 'pi pi-plus-circle', + show: 'always', + permission: 'THEME#CREATE' + } + ) + } private prepareActionButtons(): void { + /* TODO: use this this.actions$ = this.translate .get([ 'ACTIONS.CANCEL', @@ -203,6 +248,7 @@ export class ThemeDesignerComponent implements OnInit { ] }) ) + */ } // DropDown Theme Template