[Connect & Library | develop]: [Bug fix] Refactor code for showing help button or not.

1. app-routing.module.ts: Set for routes with no help button, data: {hasQuickContact: false} | Set in landing routes data: {hasMenuSearchBar: true} to show search bar in menu.
2. communities.component.ts: Removed field "showQuickContact" | In constructor set quickContactService.setDisplay(false) | Refactor intersectionObserver.
3. app.component.ts: Updated checks for <quick-contact> | Added public bottomNotIntersecting: boolean; and public displayQuickContact: boolean; (check if intersecting with specific section in home page) | Added disconnect in ngOnDestroy for IntersectionObserver subscriptions.
This commit is contained in:
Konstantina Galouni 2023-07-07 10:12:25 +03:00
parent fc44d3acb0
commit deff734962
4 changed files with 172 additions and 79 deletions

View File

@ -6,8 +6,16 @@ import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.
const routes: Routes = [ const routes: Routes = [
// ORCID Pages // ORCID Pages
{path: 'orcid', loadChildren: () => import('./orcid/orcid.module').then(m => m.LibOrcidModule)}, {
{path: 'my-orcid-links', loadChildren: () => import('./orcid/my-orcid-links/myOrcidLinks.module').then(m => m.LibMyOrcidLinksModule)}, path: 'orcid',
loadChildren: () => import('./orcid/orcid.module').then(m => m.LibOrcidModule),
data: {hasQuickContact: false}
},
{
path: 'my-orcid-links',
loadChildren: () => import('./orcid/my-orcid-links/myOrcidLinks.module').then(m => m.LibMyOrcidLinksModule),
data: {hasQuickContact: false}
},
/** Other Pages */ /** Other Pages */
{ {
@ -18,46 +26,60 @@ const routes: Routes = [
{path: 'about/learn-how', loadChildren: () => import('./learn-how/learn-how.module').then(m => m.LearnHowModule)}, {path: 'about/learn-how', loadChildren: () => import('./learn-how/learn-how.module').then(m => m.LearnHowModule)},
{path: 'about/faq', loadChildren: () => import('./learn-how/faqs/faqs.module').then(m => m.FaqsModule)}, {path: 'about/faq', loadChildren: () => import('./learn-how/faqs/faqs.module').then(m => m.FaqsModule)},
{path: 'get-started', loadChildren: () => import('./get-started/get-started.module').then(m => m.GetStartedModule)}, {path: 'get-started', loadChildren: () => import('./get-started/get-started.module').then(m => m.GetStartedModule)},
{path: 'contact-us', loadChildren: () => import('./contact/contact.module').then(m => m.ContactModule)}, {
{path: 'invite', loadChildren: () => import('./utils/subscribe/invite/invite.module').then(m => m.InviteModule)}, path: 'contact-us',
loadChildren: () => import('./contact/contact.module').then(m => m.ContactModule),
data: {hasQuickContact: false}
},
{
path: 'invite',
loadChildren: () => import('./utils/subscribe/invite/invite.module').then(m => m.InviteModule),
data: {hasQuickContact: false}
},
{ {
path: 'content', path: 'content',
loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule), loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
},
{
path: 'sdgs',
loadChildren: () => import('./sdg/sdg.module').then(m => m.LibSdgModule),
data: {hasQuickContact: false}
}, },
{path: 'sdgs', loadChildren: () => import('./sdg/sdg.module').then(m => m.LibSdgModule)},
{ {
path: 'fields-of-science', path: 'fields-of-science',
loadChildren: () => import('./fos/fos.module').then(m => m.LibFosModule), loadChildren: () => import('./fos/fos.module').then(m => m.LibFosModule),
data: {extraOffset: 100} data: {extraOffset: 100, hasQuickContact: false}
}, },
{ {
path: 'organizations', path: 'organizations',
loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule), loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'publications', path: 'publications',
loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule), loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'projects', path: 'projects',
loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule), loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'national-bulletins', path: 'national-bulletins',
loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule), loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'faqs', path: 'faqs',
loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule), loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
data: {hasQuickContact: false}
}, },
{ {
path: 'roadmap', path: 'roadmap',
loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule), loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
data: {hasQuickContact: false}
}, },
// { // {
// path: 'featured', // path: 'featured',
@ -65,24 +87,24 @@ const routes: Routes = [
// { // {
// path: '', // path: '',
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule), // loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
// canActivateChild: [IsCommunity], // data: {hasQuickContact: false}, canActivateChild: [IsCommunity],
// }, // },
// { // {
// path: '**', // path: '**',
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule), // loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
// canActivateChild: [IsCommunity], // data: {hasQuickContact: false}, canActivateChild: [IsCommunity],
// }, // },
// ] // ]
// }, // },
{ {
path: 'curators', path: 'curators',
loadChildren: () => import('./curators/curators.module').then(m => m.CuratorsModule), loadChildren: () => import('./curators/curators.module').then(m => m.CuratorsModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'subjects', path: 'subjects',
loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule), loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'myCommunities', path: 'myCommunities',
@ -90,7 +112,8 @@ const routes: Routes = [
}, },
{ {
path: 'develop', path: 'develop',
loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule), canActivate: [IsCommunity] loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
/** Testing Page for help contents */ /** Testing Page for help contents */
{path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)}, {path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)},
@ -98,42 +121,41 @@ const routes: Routes = [
{ {
path: 'search/result', path: 'search/result',
loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule), loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/publication', path: 'search/publication',
loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule), loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/dataset', path: 'search/dataset',
loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule), loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/software', path: 'search/software',
loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule), loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
},
{
path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
}, },
{path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule), canActivate: [IsCommunity]},
{ {
path: 'search/project', path: 'search/project',
loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule), loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/dataprovider', path: 'search/dataprovider',
loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule), loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/organization', path: 'search/organization',
loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule), loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule),
canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
},
{
path: 'project-report',
loadChildren: () => import('./landingPages/htmlProjectReport/libHtmlProjectReport.module').then(m => m.LibHtmlProjectReportModule)
}, },
/** Search Pages */ /** Search Pages */
{path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'}, {path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'},
@ -145,46 +167,86 @@ const routes: Routes = [
{ {
path: 'search/find/research-outcomes', path: 'search/find/research-outcomes',
loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule), loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
},
{
path: 'search/find/publications',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
},
{
path: 'search/find/datasets',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
},
{
path: 'search/find/software',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
},
{
path: 'search/find/other',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [IsCommunity]
}, },
{path: 'search/find/publications', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{path: 'search/find/datasets', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{path: 'search/find/software', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{path: 'search/find/other', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{ {
path: 'search/find/projects', path: 'search/find/projects',
loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule), loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/find/dataproviders', path: 'search/find/dataproviders',
loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule), loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
/** Advanced Search Pages */ /** Advanced Search Pages */
{ {
path: 'search/advanced/research-outcomes', path: 'search/advanced/research-outcomes',
loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule), loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
},
{
path: 'search/advanced/publications',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
},
{
path: 'search/advanced/datasets',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
},
{
path: 'search/advanced/software',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
},
{
path: 'search/advanced/other',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [IsCommunity]
}, },
{path: 'search/advanced/publications', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{path: 'search/advanced/datasets', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{path: 'search/advanced/software', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{path: 'search/advanced/other', component: PageURLResolverComponent, canActivate: [IsCommunity]},
{ {
path: 'search/advanced/organizations', path: 'search/advanced/organizations',
loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule), loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/advanced/dataproviders', path: 'search/advanced/dataproviders',
loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule), loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'search/advanced/projects', path: 'search/advanced/projects',
loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule), loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
/** Deposit Pages */ /** Deposit Pages */
{ path: 'participate/deposit-datasets', { path: 'participate/deposit-datasets',
@ -208,41 +270,56 @@ const routes: Routes = [
{ {
path: 'participate/deposit/learn-how', path: 'participate/deposit/learn-how',
loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule), loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'participate/deposit/search', path: 'participate/deposit/search',
loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule), loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'participate/deposit/zenodo', path: 'participate/deposit/zenodo',
loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule), loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
/** Linking Pages */ /** Linking Pages */
{path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule), canActivate: [IsCommunity]}, {
path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
},
{ {
path: 'participate/claim', path: 'participate/claim',
loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule), loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'participate/direct-claim', path: 'participate/direct-claim',
loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule), loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
{ {
path: 'preview', path: 'preview',
loadChildren: () => import('./demo/demo.module').then(m => m.DemoModule), loadChildren: () => import('./demo/demo.module').then(m => m.DemoModule),
canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [IsCommunity]
}, },
/** help pages - do not exist in Admin portal/api/db */ /** help pages - do not exist in Admin portal/api/db */
{path: 'reload', loadChildren: () => import('./reload/libReload.module').then(m => m.LibReloadModule)}, {
{path: 'user-info', loadChildren: () => import('./login/libUser.module').then(m => m.LibUserModule)}, path: 'reload',
{path: 'error', component: OpenaireErrorPageComponent}, loadChildren: () => import('./reload/libReload.module').then(m => m.LibReloadModule),
{path: 'theme', loadChildren: () => import('./openaireLibrary/utils/theme/theme.module').then(m => m.ThemeModule)}, data: {hasQuickContact: false}
{path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent} },
{
path: 'user-info',
loadChildren: () => import('./login/libUser.module').then(m => m.LibUserModule),
data: {hasQuickContact: false}
},
{path: 'error', component: OpenaireErrorPageComponent, data: {hasQuickContact: false}},
{
path: 'theme',
loadChildren: () => import('./openaireLibrary/utils/theme/theme.module').then(m => m.ThemeModule),
data: {hasQuickContact: false}
},
{path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent, data: {hasQuickContact: false}}
]; ];
@NgModule({ @NgModule({

View File

@ -1,4 +1,5 @@
import { import {
ChangeDetectorRef,
Component, Component,
ElementRef, ElementRef,
Inject, Inject,
@ -40,6 +41,7 @@ import {NotificationHandler} from "./openaireLibrary/utils/notification-handler"
import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields"; import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields";
import {DOCUMENT, isPlatformServer} from "@angular/common"; import {DOCUMENT, isPlatformServer} from "@angular/common";
import {AdvancedAsyncSubject} from "./openaireLibrary/utils/AdvancedAsyncSubject"; import {AdvancedAsyncSubject} from "./openaireLibrary/utils/AdvancedAsyncSubject";
import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -101,12 +103,16 @@ import {AdvancedAsyncSubject} from "./openaireLibrary/utils/AdvancedAsyncSubject
points="7 4 13 10 7 16"></polyline></svg> points="7 4 13 10 7 16"></polyline></svg>
</span></a> </span></a>
</cookie-law> </cookie-law>
<bottom #bottom *ngIf="properties && isClient && showMenu && !community" [grantAdvance]="false" <bottom #bottom *ngIf="properties && isClient && showMenu && !community" [grantAdvance]="false"
[properties]="properties"></bottom> [properties]="properties"></bottom>
<bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground " <bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground "
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true" [showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
[communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties" [centered]="true"></bottom> [communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties"
<quick-contact #quickContact *ngIf="showQuickContact && contactForm" (sendEmitter)="send($event)" [centered]="true"></bottom>
<quick-contact #quickContact
*ngIf="!community && bottomNotIntersecting && displayQuickContact && showQuickContact && contactForm"
(sendEmitter)="send($event)"
[contact]="'Help'" [images]="images" [background]="{class: 'uk-background-primary', dark: false}" [contact]="'Help'" [images]="images" [background]="{class: 'uk-background-primary', dark: false}"
[contactForm]="contactForm" [sending]="sending"></quick-contact> [contactForm]="contactForm" [sending]="sending"></quick-contact>
<modal-alert #modal [overflowBody]="false"></modal-alert> <modal-alert #modal [overflowBody]="false"></modal-alert>
@ -130,9 +136,11 @@ export class AppComponent implements OnInit, OnDestroy {
communityId: string = ""; communityId: string = "";
header: Header; header: Header;
logoPath: string = 'assets/common-assets/logo-services/connect/'; logoPath: string = 'assets/common-assets/logo-services/connect/';
public showGetStarted: boolean = true;
/* Contact */ /* Contact */
public showQuickContact: boolean; public showQuickContact: boolean;
public showGetStarted: boolean = true; public bottomNotIntersecting: boolean;
public displayQuickContact: boolean; // intersecting with specific section in home page
public contactForm: UntypedFormGroup; public contactForm: UntypedFormGroup;
public sending = false; public sending = false;
public images: string[] = []; public images: string[] = [];
@ -157,12 +165,14 @@ export class AppComponent implements OnInit, OnDestroy {
private configurationService: ConfigurationService, private _communityService: CommunityService, private configurationService: ConfigurationService, private _communityService: CommunityService,
private customizationService: CustomizationService, private _meta: Meta, private seoService: SEOService, private customizationService: CustomizationService, private _meta: Meta, private seoService: SEOService,
private quickContactService: QuickContactService, private quickContactService: QuickContactService,
private layoutService: LayoutService,
private fb: UntypedFormBuilder, private fb: UntypedFormBuilder,
private emailService: EmailService, private emailService: EmailService,
@Inject(DOCUMENT) private document, @Inject(DOCUMENT) private document,
private transferState: TransferState, private transferState: TransferState,
@Inject(PLATFORM_ID) private platformId: any, @Inject(PLATFORM_ID) private platformId: any,
private rendererFactory: RendererFactory2 private rendererFactory: RendererFactory2,
private cdr: ChangeDetectorRef
) { ) {
this.subscriptions.push(router.events.forEach((event) => { this.subscriptions.push(router.events.forEach((event) => {
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
@ -199,8 +209,17 @@ export class AppComponent implements OnInit, OnDestroy {
}, error => { }, error => {
this.init(); this.init();
})); }));
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.subscriptions.push(this.quickContactService.isDisplayed.subscribe(display => {
this.showQuickContact = display; if (this.displayQuickContact !== display) {
this.displayQuickContact = display;
this.cdr.detectChanges();
}
})); }));
} }
@ -208,6 +227,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.subscriptions.forEach(subscription => { this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) { if (subscription instanceof Subscriber) {
subscription.unsubscribe(); subscription.unsubscribe();
} else if (typeof IntersectionObserver !== "undefined" && subscription instanceof IntersectionObserver) {
subscription.disconnect();
} }
}); });
this._communitiesService.clearSubscriptions(); this._communitiesService.clearSubscriptions();
@ -225,18 +246,17 @@ export class AppComponent implements OnInit, OnDestroy {
}; };
let intersectionObserver = new IntersectionObserver(entries => { let intersectionObserver = new IntersectionObserver(entries => {
entries.forEach(entry => { entries.forEach(entry => {
if (entry.isIntersecting && this.showQuickContact) { if (this.bottomNotIntersecting !== (!entry.isIntersecting)) {
this.showQuickContact = false; this.bottomNotIntersecting = !entry.isIntersecting;
this.quickContactService.setDisplay(this.showQuickContact); this.cdr.detectChanges();
} else if (!entry.isIntersecting && !this.showQuickContact) {
this.showQuickContact = true;
this.quickContactService.setDisplay(this.showQuickContact);
} }
}); });
}, options); }, options);
if (this.bottom) {
intersectionObserver.observe(this.bottom.nativeElement); intersectionObserver.observe(this.bottom.nativeElement);
this.subscriptions.push(intersectionObserver); this.subscriptions.push(intersectionObserver);
} }
}
get isManager() { get isManager() {
return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user)) return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user))
@ -505,7 +525,8 @@ export class AppComponent implements OnInit, OnDestroy {
restrictedData ? "" : "/myCommunities", false, [], [], {})); restrictedData ? "" : "/myCommunities", false, [], [], {}));
} }
this.showMenu = true; this.showMenu = true;
if (typeof document !== "undefined" && this.bottom) { // if (typeof document !== "undefined" && this.bottom) {
if (typeof document !== "undefined" && properties && this.isClient && this.showMenu) {
setTimeout(() => { setTimeout(() => {
this.createObservers(); this.createObservers();
}); });

View File

@ -39,7 +39,6 @@ export class CommunitiesComponent implements OnInit, OnDestroy, AfterViewInit {
public subscriberErrorMessage: string = ""; public subscriberErrorMessage: string = "";
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
public showQuickContact: boolean = true;
@ViewChildren('scrolling_element') elements: QueryList<ElementRef>; @ViewChildren('scrolling_element') elements: QueryList<ElementRef>;
@ViewChild('contact') contact: ElementRef; @ViewChild('contact') contact: ElementRef;
public entities = OpenaireEntities; public entities = OpenaireEntities;
@ -70,6 +69,7 @@ export class CommunitiesComponent implements OnInit, OnDestroy, AfterViewInit {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.quickContactService.setDisplay(false);
} }
public ngOnInit() { public ngOnInit() {
@ -98,6 +98,7 @@ export class CommunitiesComponent implements OnInit, OnDestroy, AfterViewInit {
subscription.disconnect(); subscription.disconnect();
} }
}); });
this.quickContactService.setDisplay(true);
} }
ngAfterViewInit() { ngAfterViewInit() {
@ -126,13 +127,7 @@ export class CommunitiesComponent implements OnInit, OnDestroy, AfterViewInit {
}; };
let intersectionObserver = new IntersectionObserver(entries => { let intersectionObserver = new IntersectionObserver(entries => {
entries.forEach(entry => { entries.forEach(entry => {
if (entry.isIntersecting && this.showQuickContact) { this.quickContactService.setDisplay(!entry.isIntersecting);
this.showQuickContact = false;
this.quickContactService.setDisplay(this.showQuickContact);
} else if (!entry.isIntersecting && !this.showQuickContact) {
this.showQuickContact = true;
this.quickContactService.setDisplay(this.showQuickContact);
}
}); });
}, options); }, options);
intersectionObserver.observe(this.contact.nativeElement); intersectionObserver.observe(this.contact.nativeElement);

@ -1 +1 @@
Subproject commit e3d26f138dfe4f501d77439b0c73eb6217eb272b Subproject commit 3aee0bcca2c39d35ee7a94fd57896059842d5f65