Fixed problem with project dialog
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import {Component, computed, inject, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {MatCardModule} from '@angular/material/card';
|
||||
import {MatChipsModule} from '@angular/material/chips';
|
||||
import {MatIcon} from '@angular/material/icon';
|
||||
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AssetsConstants} from '../../constants/AssetsConstants';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {ProjectDialogComponent} from './dialog/project-dialog.component';
|
||||
|
||||
import {Component, computed, inject, CUSTOM_ELEMENTS_SCHEMA, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Subscription} from "rxjs";
|
||||
import {MatCardModule} from "@angular/material/card";
|
||||
import {MatChipsModule} from "@angular/material/chips";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {TranslatePipe} from "@ngx-translate/core";
|
||||
import {MatButtonModule} from "@angular/material/button";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {ProjectDialogComponent} from "./dialog/project-dialog.component";
|
||||
import {AssetsConstants} from "../../constants/AssetsConstants";
|
||||
|
||||
export interface Projects {
|
||||
identifier: string;
|
||||
@@ -32,6 +32,7 @@ export interface Projects {
|
||||
|
||||
@Component({
|
||||
selector: 'app-projects',
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatChipsModule,
|
||||
@@ -43,10 +44,12 @@ export interface Projects {
|
||||
styleUrl: './projects.component.scss',
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
})
|
||||
export class ProjectsComponent {
|
||||
export class ProjectsComponent implements OnInit, OnDestroy {
|
||||
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
private readonly router = inject(Router);
|
||||
private queryParamSub: Subscription | undefined;
|
||||
|
||||
allProjects: Projects[] = [
|
||||
{
|
||||
@@ -174,8 +177,20 @@ export class ProjectsComponent {
|
||||
featuredProject = computed(() => this.allProjects.find(p => p.isFeatured));
|
||||
otherProjects = computed(() => this.allProjects.filter(p => !p.isFeatured));
|
||||
|
||||
constructor() {
|
||||
this.route.queryParamMap.subscribe(params => {
|
||||
ngOnInit(): void {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
setTimeout(() =>{ this.dialogOpenFunction(); },10);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.queryParamSub) {
|
||||
this.queryParamSub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
private dialogOpenFunction() : void
|
||||
{
|
||||
this.queryParamSub = this.route.queryParamMap.subscribe(params => {
|
||||
const projectIdentifier = params.get('project');
|
||||
if (projectIdentifier) {
|
||||
const project = this.allProjects.find(p => p.identifier === projectIdentifier);
|
||||
@@ -191,6 +206,8 @@ export class ProjectsComponent {
|
||||
data: project,
|
||||
width: '90vw',
|
||||
maxWidth: '900px',
|
||||
autoFocus: false,
|
||||
restoreFocus: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user