import {AfterViewInit, Component, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from '@angular/core'; import { CoreService, Form, LayoutComponent, ServiceHeaderComponent, SidenavService, WorkflowSectionComponent, CoreI18nService } from 'bpm-core'; import {DynamicComponentInjectorToken} from 'ng-dynamic-component'; import {RequestDetailsSectionComponent} from "./page-components/request-details-section/request-details-section.component"; import {SegmentDynamicLoaderService} from './shared/services/segment-dynamic-loader.service'; import {DOCUMENT, isPlatformBrowser} from "@angular/common"; import { Inject, PLATFORM_ID} from '@angular/core'; import {Router} from "@angular/router"; import {PrintSectionComponent} from "./templates/print-section/print-section.component"; import {I18nService} from "./shared/services/i18n.service"; import { TranslatePipe } from './shared/pipes/translate.pipe'; @Component({ selector: 'app-wm-root', standalone: true, templateUrl: './app.component.html', styleUrl: './app.component.scss', imports: [ LayoutComponent, ServiceHeaderComponent, WorkflowSectionComponent, RequestDetailsSectionComponent, PrintSectionComponent, TranslatePipe ], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], providers: [ {provide: DynamicComponentInjectorToken, useValue: { /* your value here */}} ] }) export class AppComponent implements AfterViewInit { loading = { form: false } form: Form noError = true; errorMessage: []; constructor( public segmentDynamicLoader: SegmentDynamicLoaderService, @Inject(DOCUMENT) private readonly document: Document, private readonly router: Router, private readonly sidenavService: SidenavService, public i18n: I18nService, private readonly coreService: CoreService, @Inject(PLATFORM_ID) private readonly platformId: any ) { this.loading['form'] = true this.coreService.loadForm().subscribe({ next: (form: any) => { if (form instanceof Form) { this.form = form; } else { this.noError = false; } this.loading['form'] = false; }, error: (err) => { this.noError = false; this.loading['form'] = false; this.errorMessage = err?.error?.meta?.messages; } }); } ngAfterViewInit() { if (isPlatformBrowser(this.platformId)) { const direction = this.i18n.getLanguage() == 'en' ? 'ltr' : 'rtl'; document.documentElement.setAttribute('dir', direction); } } }