56 lines
2.3 KiB
TypeScript
56 lines
2.3 KiB
TypeScript
import { afterNextRender, Component, inject, viewChild } from '@angular/core';
|
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
|
import { MatAccordion } from '@angular/material/expansion';
|
|
import { UserPreferences } from '../../core/models/user-preference';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { UserPreferencesService } from '../../core/services/user-preference.service';
|
|
import { ReactiveFormsModule } from '@angular/forms';
|
|
import { ApplicationComponent } from '../application/application.component';
|
|
import { GoodsComponent } from '../goods/goods.component';
|
|
import { HolderComponent } from '../holder/holder.component';
|
|
import { ShippingComponent } from '../shipping/shipping.component';
|
|
import { TravelPlanComponent } from '../travel-plan/travel-plan.component';
|
|
import { ReplacementSetComponent } from '../replacement-set/replacement-set.component';
|
|
|
|
@Component({
|
|
selector: 'app-view-carnet',
|
|
imports: [AngularMaterialModule, CommonModule, ReactiveFormsModule,
|
|
ApplicationComponent, HolderComponent, GoodsComponent, TravelPlanComponent, ShippingComponent, ReplacementSetComponent],
|
|
templateUrl: './view-carnet.component.html',
|
|
styleUrl: './view-carnet.component.scss'
|
|
})
|
|
export class ViewCarnetComponent {
|
|
accordion = viewChild.required(MatAccordion);
|
|
isViewMode = true;
|
|
headerid: number = 0;
|
|
applicationName: string = '';
|
|
userPreferences: UserPreferences;
|
|
applicationType: 'new' | 'edit' | 'additional' | 'duplicate' | 'extend' | null = 'edit';
|
|
|
|
private route = inject(ActivatedRoute);
|
|
|
|
constructor(userPrefenceService: UserPreferencesService) {
|
|
this.userPreferences = userPrefenceService.getPreferences();
|
|
|
|
// set application type based on the route url
|
|
const urlSegments = this.route.snapshot.url.map(segment => segment.path);
|
|
|
|
if (urlSegments.includes('view-extend-carnet')) {
|
|
this.applicationType = 'extend';
|
|
}
|
|
|
|
afterNextRender(() => {
|
|
// Open all panels
|
|
this.accordion().openAll();
|
|
});
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
const idParam = this.route.snapshot.paramMap.get('headerid');
|
|
this.headerid = idParam ? parseInt(idParam, 10) : 0;
|
|
|
|
this.applicationName = this.route.snapshot.queryParamMap.get('applicationname') || '';
|
|
}
|
|
}
|