1
|
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from "@angular/router";
|
3
|
|
4
|
import {RemoveProjectsComponent} from './remove-projects.component';
|
5
|
|
6
|
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
7
|
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
8
|
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
9
|
import {Title} from '@angular/platform-browser';
|
10
|
import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component";
|
11
|
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
|
12
|
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
|
13
|
import {properties} from "../../../environments/environment";
|
14
|
import {Subscriber} from "rxjs";
|
15
|
|
16
|
@Component({
|
17
|
selector: 'manage-projects',
|
18
|
template: `
|
19
|
<remove-projects (toggleView)="toggleAction()" [communityProjects]="communityProjects"
|
20
|
[showLoading]="showLoadingInRemove"
|
21
|
(communityProjectsChanged)="communityProjectsChanged($event)" [toggle]="toggle">
|
22
|
</remove-projects>
|
23
|
<fs-modal #fsModal (cancelEmitter)="toggleAction()">
|
24
|
<div actions class="uk-flex uk-flex-middle uk-height-1-1">
|
25
|
<span class="uk-button uk-text-secondary" uk-icon="icon: info; ratio: 1.3"></span>
|
26
|
<div *ngIf="communityId" uk-drop="mode: hover">
|
27
|
<div class="uk-card uk-card-body uk-card-default">
|
28
|
If you cannot find a funder that is relevant for your community, please contact us
|
29
|
(<a
|
30
|
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ communityId + '] report missing Funder' + '&body=' + body"
|
31
|
target="_top">{{properties.feedbackmailForMissingEntities}}</a>)
|
32
|
and we will try to get the funder on board!
|
33
|
</div>
|
34
|
</div>
|
35
|
</div>
|
36
|
|
37
|
<add-projects [communityProjects]="communityProjects"
|
38
|
(communityProjectsChanged)="communityProjectsChanged($event)"></add-projects>
|
39
|
</fs-modal>
|
40
|
`
|
41
|
})
|
42
|
|
43
|
export class ManageProjectsComponent implements OnInit {
|
44
|
@Input() communityProjects = [];
|
45
|
@ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent;
|
46
|
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
|
47
|
|
48
|
public toggle: boolean = false;
|
49
|
|
50
|
private subscriptions: any[] = [];
|
51
|
|
52
|
public showLoadingInRemove: boolean = true;
|
53
|
|
54
|
public body: string = "Send from page";
|
55
|
public properties: EnvProperties = properties;
|
56
|
public communityId: string = "";
|
57
|
|
58
|
constructor(private element: ElementRef,
|
59
|
private title: Title,
|
60
|
private route: ActivatedRoute, private _router: Router) {
|
61
|
}
|
62
|
|
63
|
ngOnInit() {
|
64
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
65
|
this.communityId = params['community'];
|
66
|
|
67
|
if (this.communityId) {
|
68
|
this.title.setTitle(this.communityId.toUpperCase() + ' | Projects');
|
69
|
this.body = "[Please write your message here]";
|
70
|
this.body = StringUtils.URIEncode(this.body);
|
71
|
}
|
72
|
this.fullscreen.title = "Search and Add Projects";
|
73
|
this.fullscreen.okButtonText = "Done";
|
74
|
this.fullscreen.okButton = true;
|
75
|
}));
|
76
|
}
|
77
|
|
78
|
public ngOnDestroy() {
|
79
|
this.subscriptions.forEach(sub => {
|
80
|
if (sub instanceof Subscriber) {
|
81
|
sub.unsubscribe();
|
82
|
}
|
83
|
});
|
84
|
}
|
85
|
|
86
|
public toggleAction() {
|
87
|
if (!Session.isLoggedIn()) {
|
88
|
this._router.navigate(['/user-info'], {
|
89
|
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
|
90
|
});
|
91
|
} else {
|
92
|
HelperFunctions.scroll();
|
93
|
|
94
|
this.toggle = !this.toggle;
|
95
|
if (this.toggle) {
|
96
|
this.fullscreen.open();
|
97
|
}
|
98
|
}
|
99
|
}
|
100
|
|
101
|
public communityProjectsChanged($event) {
|
102
|
this.communityProjects = $event.value;
|
103
|
this.showLoadingInRemove = false;
|
104
|
|
105
|
if (this.toggle) {
|
106
|
this.removeProjectsComponent.applyFilters();
|
107
|
this.removeProjectsComponent.createFunderFilter();
|
108
|
}
|
109
|
}
|
110
|
}
|