[plugins-functionality | WIP] move affiliations component to be used in library - plugins
This commit is contained in:
parent
aa0da38de9
commit
d6dc2b040d
|
@ -0,0 +1,69 @@
|
|||
<ng-template #card let-organization="organization" let-fullView="fullView">
|
||||
<div [class]="fullView?'uk-card-body uk-height-1-1 uk-flex uk-flex-column uk-flex-around':''">
|
||||
<div class="affiliation-logo">
|
||||
<img *ngIf="organization.logo_url"
|
||||
[src]="organization.logo_url | urlPrefix"
|
||||
alt="{{(organization.name)?organization.name:''}} logo"
|
||||
class="uk-blend-multiply uk-height-max-xsmall" loading="lazy">
|
||||
</div>
|
||||
<div class="affiliation-name multi-line-ellipsis lines-3" *ngIf="organization.name && fullView">
|
||||
<p class="uk-text-emphasis uk-text-bold uk-margin-remove">
|
||||
{{organization.name}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-container *ngIf="affiliations.length > 0">
|
||||
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert">
|
||||
<span class="loading-gif uk-align-center"></span>
|
||||
</div>
|
||||
<div *ngIf="longView"
|
||||
class="uk-child-width-1-5@xl uk-child-width-1-4@l uk-child-width-1-3@m uk-child-width-1-2@s uk-text-center uk-grid"
|
||||
uk-height-match="target: .affiliation-logo, .affiliation-name"
|
||||
uk-scrollspy="cls: uk-animation-fade; target: .uk-card; repeat: false"
|
||||
uk-grid>
|
||||
<div *ngFor="let affiliation of affiliations;">
|
||||
<div>
|
||||
<div class="uk-card uk-card-default uk-card-hover affiliationCard">
|
||||
<a *ngIf="affiliation.website_url" target="_blank" [href]="affiliation.website_url | urlPrefix" class="uk-link-reset">
|
||||
<ng-container *ngTemplateOutlet="card; context: { organization: affiliation, fullView: true}"></ng-container>
|
||||
</a>
|
||||
<span *ngIf="!affiliation.website_url" class="uk-link-reset">
|
||||
<ng-container *ngTemplateOutlet="card; context: { organization: affiliation, fullView: true}"></ng-container>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="affiliations.length > 0 && communityFirstPage && !longView" class="uk-grid uk-grid-large" uk-grid>
|
||||
<div class="uk-width-1-3@m">
|
||||
<h2 class="uk-h1">
|
||||
Supporting Organizations
|
||||
</h2>
|
||||
<a class="uk-display-inline-block uk-text-uppercase uk-button uk-button-text uk-text-default uk-margin-top"
|
||||
routerLinkActive="router-link-active" routerLink="/organizations">
|
||||
<span class="uk-flex uk-flex-middle">
|
||||
<span>Browse all</span>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="uk-width-2-3@m">
|
||||
<div class="uk-grid uk-grid-large uk-child-width-1-3@m uk-child-width-1-2@s supportingOrganizations" uk-grid>
|
||||
<div *ngFor="let affiliation of affiliations.slice(0,9);">
|
||||
<a *ngIf="affiliation.website_url" target="_blank" [href]="affiliation.website_url | urlPrefix" class="uk-link-reset">
|
||||
<ng-container *ngTemplateOutlet="card; context: {organization: affiliation, fullView: false}"></ng-container>
|
||||
</a>
|
||||
<span *ngIf="!affiliation.website_url" class="uk-link-reset">
|
||||
<ng-container *ngTemplateOutlet="card; context: {organization: affiliation, fullView: false}"></ng-container>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<!--<div *ngIf="affiliations.length == 0 && longView" class="uk-animation-fade uk-alert uk-alert-primary" role="alert">-->
|
||||
<!-- No affiliations available-->
|
||||
<!--</div>-->
|
|
@ -0,0 +1,18 @@
|
|||
.affiliationCard {
|
||||
width: 260px !important;
|
||||
height: 260px !important;
|
||||
}
|
||||
|
||||
.supportingOrganizations a {
|
||||
img, svg {
|
||||
-webkit-filter: grayscale(1);
|
||||
filter: grayscale(1);
|
||||
transition-duration: 0.3s;
|
||||
}
|
||||
|
||||
&:hover img, svg {
|
||||
-webkit-filter: grayscale(0);
|
||||
filter: grayscale(0);
|
||||
transition-duration: 0.3s;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {AffiliationService} from "./affiliation.service";
|
||||
import {Affiliation} from "../../utils/entities/CuratorInfo";
|
||||
import {ConnectHelper} from "../connectHelper";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
|
||||
@Component({
|
||||
selector: 'affiliations',
|
||||
templateUrl: './affiliations.component.html',
|
||||
styleUrls: ['./affiliations.component.less']
|
||||
})
|
||||
export class AffiliationsComponent {
|
||||
@Input() getAffiliationsFromAPI: boolean = false;
|
||||
@Input() longView: boolean = false;
|
||||
@Input() communityFirstPage: boolean = false;
|
||||
@Input() affiliationsInSlider: number = 5;
|
||||
@Input() affiliations: Affiliation[] = [];
|
||||
@Input() sliderOptions = '';
|
||||
@Input() arrows = true;
|
||||
|
||||
public showLoading: boolean = false;
|
||||
public communityId: string;
|
||||
public properties: EnvProperties = properties;
|
||||
private subscriptions = [];
|
||||
|
||||
constructor(private route: ActivatedRoute, private affiliationService: AffiliationService) {
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain);
|
||||
if (this.getAffiliationsFromAPI) {
|
||||
this.showLoading = true;
|
||||
this.affiliationService.initAffiliations(this.communityId);
|
||||
this.subscriptions.push(this.affiliationService.affiliations.subscribe(
|
||||
affiliations => {
|
||||
this.affiliations = affiliations.filter((affiliation) => this.longView || !!affiliation['logo_url']);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => {
|
||||
console.error("Affiliations Component: Error getting affiliations for community with id: " + this.communityId, error);
|
||||
this.showLoading = false;
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
this.affiliationService.clearSubscriptions();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
|
||||
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
import {AffiliationsComponent} from './affiliations.component';
|
||||
import {CommonModule} from "@angular/common";
|
||||
import {UrlPrefixModule} from "../../utils/pipes/url-prefix.module";
|
||||
import {AffiliationService} from "./affiliation.service";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, RouterModule, UrlPrefixModule
|
||||
],
|
||||
declarations: [
|
||||
AffiliationsComponent
|
||||
],
|
||||
providers:[PreviousRouteRecorder, IsRouteEnabled, AffiliationService],
|
||||
exports: [
|
||||
AffiliationsComponent
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
export class AffiliationsModule{}
|
|
@ -6,7 +6,6 @@ import { RouterModule } from '@angular/router';
|
|||
import {CuratorsComponent} from './curators.component';
|
||||
import {CuratorService} from "../../curators/curator.service";
|
||||
import {CuratorsRoutingModule} from "./curators-routing.module";
|
||||
import {AffiliationsModule} from "../../../../pages/affiliations/affiliations.module";
|
||||
import {HelperModule} from "../../../utils/helper/helper.module";
|
||||
import {Schema2jsonldModule} from "../../../sharedComponents/schema2jsonld/schema2jsonld.module";
|
||||
import {SEOServiceModule} from "../../../sharedComponents/SEO/SEOService.module";
|
||||
|
@ -15,6 +14,7 @@ import {BreadcrumbsModule} from "../../../utils/breadcrumbs/breadcrumbs.module";
|
|||
import {UrlPrefixModule} from "../../../utils/pipes/url-prefix.module";
|
||||
import {LoadingModule} from '../../../utils/loading/loading.module';
|
||||
import {FullScreenModalModule} from '../../../utils/modal/full-screen-modal/full-screen-modal.module';
|
||||
import {AffiliationsModule} from "../../affiliations/affiliations.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
|
Loading…
Reference in New Issue