1 |
54074
|
konstantin
|
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, ElementRef } from '@angular/core';
|
2 |
53735
|
konstantin
|
import { ActivatedRoute, Router } from "@angular/router";
|
3 |
53600
|
argiro.kok
|
|
4 |
|
|
import {RemoveProjectsComponent} from './remove-projects.component';
|
5 |
|
|
import {AddProjectsComponent} from './add-projects.component';
|
6 |
|
|
|
7 |
53735
|
konstantin
|
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
8 |
|
|
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
9 |
|
|
|
10 |
53600
|
argiro.kok
|
@Component({
|
11 |
|
|
selector: 'manage-projects',
|
12 |
|
|
template: `
|
13 |
|
|
<div id="manage-projects">
|
14 |
|
|
<div class="menubar uk-margin-bottom ">
|
15 |
|
|
<a *ngIf="!toggle" (click)="updateCommunityProjects()" uk-toggle="target: .toggle-usage" class="uk-button uk-button-primary uk-float-right">{{toggleLinkMessage}}</a>
|
16 |
|
|
<div class="manage-projects-title uk-text-large">{{pageTitle}}</div>
|
17 |
|
|
</div>
|
18 |
|
|
|
19 |
|
|
<div class="toggle-usage">
|
20 |
|
|
<remove-projects (communityProjectsChanged)="communityProjectsChanged($event)"></remove-projects>
|
21 |
|
|
<fab (clicked)="updateCommunityProjects()" uk-toggle="target: .toggle-usage"></fab>
|
22 |
|
|
</div>
|
23 |
|
|
<div class="toggle-usage" hidden>
|
24 |
|
|
<!-- (updateCommunityProjects)="updateCommunityProjects($event)" -->
|
25 |
|
|
<add-projects [(communityProjects)]="communityProjects"></add-projects>
|
26 |
|
|
</div>
|
27 |
|
|
</div>
|
28 |
|
|
`
|
29 |
|
|
})
|
30 |
|
|
|
31 |
|
|
export class ManageProjectsComponent implements OnInit {
|
32 |
|
|
private community: string = '';
|
33 |
|
|
|
34 |
|
|
@Input() communityProjects =[];
|
35 |
|
|
@ViewChild (RemoveProjectsComponent) removeProjectsComponent : RemoveProjectsComponent ;
|
36 |
|
|
@ViewChild (AddProjectsComponent) addProjectsComponent : AddProjectsComponent ;
|
37 |
|
|
|
38 |
|
|
public warningMessage = "";
|
39 |
|
|
public infoMessage = "";
|
40 |
|
|
|
41 |
|
|
public toggle: boolean = true;
|
42 |
|
|
public updateCommunityProjectsOnToggle: boolean = false;
|
43 |
|
|
public pageTitle: string = "Manage projects";
|
44 |
|
|
public toggleLinkMessage: string = "Manage projects";
|
45 |
|
|
|
46 |
|
|
ngOnInit() {
|
47 |
|
|
this.route.queryParams.subscribe(params => {
|
48 |
|
|
if(params['communityId']) {
|
49 |
|
|
this.community = params['communityId'];
|
50 |
|
|
}
|
51 |
|
|
});
|
52 |
|
|
}
|
53 |
|
|
|
54 |
54074
|
konstantin
|
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router) {}
|
55 |
53600
|
argiro.kok
|
|
56 |
|
|
public ngOnDestroy() {}
|
57 |
|
|
|
58 |
|
|
public updateCommunityProjects() {
|
59 |
53735
|
konstantin
|
if(!Session.isLoggedIn()){
|
60 |
|
|
console.info(this._router.url);
|
61 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
62 |
|
|
} else {
|
63 |
54074
|
konstantin
|
this.scroll();
|
64 |
|
|
|
65 |
53735
|
konstantin
|
this.toggle = !this.toggle;
|
66 |
|
|
if(this.toggle) {
|
67 |
|
|
this.pageTitle = "Manage projects";
|
68 |
|
|
// this.toggleLinkMessage = "Missing projects?";
|
69 |
53600
|
argiro.kok
|
|
70 |
53735
|
konstantin
|
//if(this.updateCommunityProjectsOnToggle) {
|
71 |
|
|
this.removeProjectsComponent._getCommunityProjects();
|
72 |
|
|
this.addProjectsComponent.undo = {};
|
73 |
|
|
//}
|
74 |
|
|
} else {
|
75 |
|
|
this.updateCommunityProjectsOnToggle = false;
|
76 |
|
|
this.pageTitle = "Search projects";
|
77 |
|
|
//this.toggleLinkMessage = "Manage projects";
|
78 |
|
|
}
|
79 |
53600
|
argiro.kok
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
public communityProjectsChanged($event) {
|
83 |
|
|
this.communityProjects = $event.value;
|
84 |
|
|
}
|
85 |
|
|
|
86 |
54074
|
konstantin
|
public scroll() {
|
87 |
|
|
console.info("scroll into view");
|
88 |
|
|
if (typeof document !== 'undefined') {
|
89 |
|
|
this.element.nativeElement.scrollIntoView();
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
|
93 |
53600
|
argiro.kok
|
// public updateCommunityProjects($event) {
|
94 |
|
|
// this.updateCommunityProjectsOnToggle = true;
|
95 |
|
|
// }
|
96 |
|
|
}
|