1
|
import { Component, ViewChild, OnInit, ViewEncapsulation, Input } from '@angular/core';
|
2
|
import { ActivatedRoute } from "@angular/router";
|
3
|
|
4
|
import {RemoveProjectsComponent} from './remove-projects.component';
|
5
|
import {AddProjectsComponent} from './add-projects.component';
|
6
|
|
7
|
@Component({
|
8
|
selector: 'manage-projects',
|
9
|
template: `
|
10
|
<div id="manage-projects">
|
11
|
<div class="menubar ">
|
12
|
<div class="manage-projects-title uk-article-title">{{pageTitle}}</div>
|
13
|
</div>
|
14
|
|
15
|
<div class="uk-card uk-card-default uk-card-body uk-margin-bottom" uk-sticky="show-on-up: true; animation: uk-animation-slide-top; bottom: #bottom">
|
16
|
{{toggleMessage}}
|
17
|
<a (click)="updateCommunityProjects()" uk-toggle="target: .toggle-usage">{{toggleLinkMessage}}</a>
|
18
|
<!-- <button class="uk-button" type="button" uk-toggle="target: .toggle-usage">Add More</button> -->
|
19
|
</div>
|
20
|
|
21
|
<div class="toggle-usage">
|
22
|
<remove-projects (communityProjectsChanged)="communityProjectsChanged($event)"></remove-projects>
|
23
|
</div>
|
24
|
<!-- {{communityProjects.length}} -->
|
25
|
<div class="toggle-usage" hidden>
|
26
|
<!-- (updateCommunityProjects)="updateCommunityProjects($event)" -->
|
27
|
<add-projects [(communityProjects)]="communityProjects"></add-projects>
|
28
|
</div>
|
29
|
</div>
|
30
|
`
|
31
|
})
|
32
|
|
33
|
export class ManageProjectsComponent implements OnInit {
|
34
|
private community: string = '';
|
35
|
|
36
|
@Input() communityProjects =[];
|
37
|
@ViewChild (RemoveProjectsComponent) removeProjectsComponent : RemoveProjectsComponent ;
|
38
|
@ViewChild (AddProjectsComponent) addProjectsComponent : AddProjectsComponent ;
|
39
|
|
40
|
public warningMessage = "";
|
41
|
public infoMessage = "";
|
42
|
|
43
|
public toggle: boolean = true;
|
44
|
public updateCommunityProjectsOnToggle: boolean = false;
|
45
|
public pageTitle: string = "Manage the projects of your community";
|
46
|
public toggleMessage: string = "Do you want to add more projects to your community?";
|
47
|
public toggleLinkMessage: string = "Find and Add them!";
|
48
|
|
49
|
ngOnInit() {
|
50
|
this.route.queryParams.subscribe(params => {
|
51
|
if(params['communityId']) {
|
52
|
this.community = params['communityId'];
|
53
|
}
|
54
|
});
|
55
|
}
|
56
|
|
57
|
constructor(private route: ActivatedRoute) {}
|
58
|
|
59
|
public ngOnDestroy() {}
|
60
|
|
61
|
public updateCommunityProjects() {
|
62
|
this.toggle = !this.toggle;
|
63
|
console.info(this.toggle);
|
64
|
if(this.toggle) {
|
65
|
this.pageTitle = "Manage the projects of your community";
|
66
|
this.toggleMessage = "Do you want to add more projects to your community?";
|
67
|
this.toggleLinkMessage = "Find and Add them!";
|
68
|
|
69
|
//if(this.updateCommunityProjectsOnToggle) {
|
70
|
this.removeProjectsComponent._getCommunityProjects();
|
71
|
this.addProjectsComponent.undo = {};
|
72
|
//}
|
73
|
} else {
|
74
|
this.updateCommunityProjectsOnToggle = false;
|
75
|
this.pageTitle = "Add more projects to your community";
|
76
|
this.toggleMessage = "Do you want to manage projects of your community?";
|
77
|
this.toggleLinkMessage = "Manage them!";
|
78
|
}
|
79
|
}
|
80
|
|
81
|
public communityProjectsChanged($event) {
|
82
|
this.communityProjects = $event.value;
|
83
|
}
|
84
|
|
85
|
// public updateCommunityProjects($event) {
|
86
|
// this.updateCommunityProjectsOnToggle = true;
|
87
|
// }
|
88
|
}
|