From b6de9c6d70b3e8d502790c449a0cd82d7c5f5b64 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 6 Jul 2023 15:28:53 +0300 Subject: [PATCH] [Monitor & Library | develop]: [Bug fix] Refactor code for showing help button or not. 1. quick-contact.service.ts: Initialize display to true (assume it is not intersecting, otherwise in pages without this section, it can't be initialized correctly). 2. home.component.ts: Removed field "showQuickContact" | In constructor set quickContactService.setDisplay(false) | Refactor intersectionObserver. 3. app-routing.module.ts: In "contact-us" route, set data: {hasQuickContact: false}. 4. app.component.ts: Updated checks for | Added public showQuickContact: boolean; to be initialized by layoutService.hasQuickContact. --- src/app/app-routing.module.ts | 3 ++- src/app/app.component.ts | 31 +++++++++++++++++++++---------- src/app/home/home.component.ts | 11 ++--------- src/app/openaireLibrary | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 744024d..482faad 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -27,7 +27,8 @@ const routes: Routes = [ }, { path: 'contact-us', - loadChildren: () => import('./contact/contact.module').then(m => m.ContactModule) + loadChildren: () => import('./contact/contact.module').then(m => m.ContactModule), + data: {hasQuickContact: false} }, { path: 'get-started', diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d2e0857..f1f6ed9 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import {Component, ElementRef, ViewChild} from '@angular/core'; +import {ChangeDetectorRef, Component, ElementRef, ViewChild} from '@angular/core'; import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; @@ -21,6 +21,7 @@ import {QuickContactComponent} from "./openaireLibrary/sharedComponents/quick-co import {AlertModal} from "./openaireLibrary/utils/modal/alert"; import {StakeholderEntities} from './openaireLibrary/monitor/entities/stakeholder'; import {ResourcesService} from "./openaireLibrary/monitor/services/resources.service"; +import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; @Component({ selector: 'app-root', @@ -60,7 +61,7 @@ import {ResourcesService} from "./openaireLibrary/monitor/services/resources.ser - { if (event instanceof NavigationEnd) { - if (event.url === '/contact-us') { - this.quickContactService.setDisplay(false); - } else if (event.url !== '/contact-us' && (!this.bottomNotIntersecting || !this.displayQuickContact)) { - this.quickContactService.setDisplay(true); - } this.showGetStarted = event.url !== '/get-started'; } @@ -136,8 +135,17 @@ export class AppComponent { this.buildMenu(); this.reset(); })); + this.subscriptions.push(this.layoutService.hasQuickContact.subscribe(hasQuickContact => { + if(this.showQuickContact !== hasQuickContact) { + this.showQuickContact = hasQuickContact; + this.cdr.detectChanges(); + } + })); this.subscriptions.push(this.quickContactService.isDisplayed.subscribe(display => { - this.displayQuickContact = display; + if(this.displayQuickContact !== display) { + this.displayQuickContact = display; + this.cdr.detectChanges(); + } })); } @@ -151,7 +159,10 @@ export class AppComponent { let intersectionObserver = new IntersectionObserver(entries => { entries.forEach(entry => { // if (entry.isIntersecting && this.showQuickContact) { - this.bottomNotIntersecting = !entry.isIntersecting; + if(this.bottomNotIntersecting !== (!entry.isIntersecting)) { + this.bottomNotIntersecting = !entry.isIntersecting; + this.cdr.detectChanges(); + } }); }, options); intersectionObserver.observe(this.bottom.nativeElement); diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index b3b0dff..c732c3c 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -66,8 +66,6 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit, IDeactiv public softwareSize: any = null; public otherSize: any = null; public fundersSize: any = null; - public showQuickContact: boolean = true; - @ViewChild('AlertModal') modal; private errorMessages: ErrorMessagesComponent; private subscriptions = []; private mutationObserver: MutationObserver; @@ -102,6 +100,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit, IDeactiv this.errorMessages = new ErrorMessagesComponent(); this.status = this.errorCodes.LOADING; this.isServer = isPlatformServer(this.platform); + this.quickContactService.setDisplay(false); } public ngOnInit() { @@ -161,13 +160,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit, IDeactiv }; let intersectionObserver = new IntersectionObserver(entries => { entries.forEach(entry => { - if (entry.isIntersecting && this.showQuickContact) { - this.showQuickContact = false; - this.quickContactService.setDisplay(this.showQuickContact); - } else if (!entry.isIntersecting && !this.showQuickContact) { - this.showQuickContact = true; - this.quickContactService.setDisplay(this.showQuickContact); - } + this.quickContactService.setDisplay(!entry.isIntersecting); }); }, options); if(this.contact) { diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 76cb586..8b14aaf 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 76cb586ebd44c3b6aef3cf29ddc21b944398e26d +Subproject commit 8b14aaf325c4c18691be36a89dca882b945d8eb0