Skip to content

Commit

Permalink
fix: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryT-CG committed Jan 30, 2024
1 parent ed79062 commit 8d954f2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/app/shared/label.resolver.ts
Original file line number Diff line number Diff line change
@@ -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<string> {
constructor(private translate: TranslateService) {}
resolve(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): string | Observable<string> | Promise<string> {
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<string> | Promise<string> {
return route.data['breadcrumb']
? this.translate.get(route.data['breadcrumb']).pipe(map((t) => t.toString()))
: route.routeConfig?.path ?? ''
*/
}
}
50 changes: 48 additions & 2 deletions src/app/theme/theme-designer/theme-designer.component.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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({})
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -203,6 +248,7 @@ export class ThemeDesignerComponent implements OnInit {
]
})
)
*/
}

// DropDown Theme Template
Expand Down

0 comments on commit 8d954f2

Please sign in to comment.