import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; import {RemoveProjectsComponent} from './remove-projects.component'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Title} from '@angular/platform-browser'; import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component"; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; import {properties} from "../../../environments/environment"; import {Subscriber} from "rxjs"; @Component({ selector: 'manage-projects', template: `
If you cannot find a funder that is relevant for your community, please contact us ({{properties.feedbackmailForMissingEntities}}) and we will try to get the funder on board!
` }) export class ManageProjectsComponent implements OnInit { @Input() communityProjects = []; @ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent; @ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent; public toggle: boolean = false; private subscriptions: any[] = []; public showLoadingInRemove: boolean = true; public body: string = "Send from page"; public properties: EnvProperties = properties; public communityId: string = ""; constructor(private element: ElementRef, private title: Title, private route: ActivatedRoute, private _router: Router) { } ngOnInit() { this.subscriptions.push(this.route.params.subscribe(params => { this.communityId = params['community']; if (this.communityId) { this.title.setTitle(this.communityId.toUpperCase() + ' | Projects'); this.body = "[Please write your message here]"; this.body = StringUtils.URIEncode(this.body); } this.fullscreen.title = "Search and Add Projects"; this.fullscreen.okButtonText = "Done"; this.fullscreen.okButton = true; })); } public ngOnDestroy() { this.subscriptions.forEach(sub => { if (sub instanceof Subscriber) { sub.unsubscribe(); } }); } public toggleAction() { if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], { queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); } else { HelperFunctions.scroll(); this.toggle = !this.toggle; if (this.toggle) { this.fullscreen.open(); } } } public communityProjectsChanged($event) { this.communityProjects = $event.value; this.showLoadingInRemove = false; if (this.toggle) { this.removeProjectsComponent.applyFilters(); this.removeProjectsComponent.createFunderFilter(); } } }