Revision 57555
Added by Konstantinos Triantafyllou over 4 years ago
topic.component.ts | ||
---|---|---|
2 | 2 |
import {ActivatedRoute, Router} from '@angular/router'; |
3 | 3 |
import {Title} from '@angular/platform-browser'; |
4 | 4 |
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; |
5 |
|
|
6 |
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes'; |
|
7 |
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component'; |
|
8 | 5 |
import {Category, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder"; |
9 | 6 |
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service"; |
10 | 7 |
import {StakeholderService} from "../services/stakeholder.service"; |
... | ... | |
17 | 14 |
templateUrl: './topic.component.html', |
18 | 15 |
}) |
19 | 16 |
export class TopicComponent implements OnInit, OnDestroy { |
20 |
public status: number;
|
|
17 |
public properties: EnvProperties;
|
|
21 | 18 |
public loading: boolean = true; |
22 |
public errorCodes: ErrorCodes; |
|
23 | 19 |
public stakeholder: Stakeholder; |
24 |
private errorMessages: ErrorMessagesComponent; |
|
25 | 20 |
public topicIndex: number = -1; |
26 | 21 |
public topic: Topic = null; |
27 | 22 |
public categoryIndex: number = -1; |
23 |
public selectedCategoryIndex: number = -1; |
|
28 | 24 |
public copyCategory: Category = null; |
29 | 25 |
public subCategoryIndex: number = -1; |
30 | 26 |
public copySubCategory: SubCategory = null; |
31 | 27 |
public valid = true; |
32 | 28 |
public edit: boolean = false; |
33 | 29 |
public toggle: boolean = false; |
34 |
public unsaved: boolean = false; |
|
35 |
public properties: EnvProperties; |
|
36 |
public chartType: string = null; |
|
37 |
public isPublic: boolean = null; |
|
38 |
public isActive: boolean = null; |
|
39 |
grid: boolean = true; |
|
40 | 30 |
|
41 | 31 |
constructor( |
42 | 32 |
private route: ActivatedRoute, |
... | ... | |
44 | 34 |
private title: Title, |
45 | 35 |
private sideBarService: SideBarService, |
46 | 36 |
private stakeholderService: StakeholderService) { |
47 |
this.errorCodes = new ErrorCodes(); |
|
48 |
this.errorMessages = new ErrorMessagesComponent(); |
|
49 |
this.status = this.errorCodes.LOADING; |
|
50 | 37 |
} |
51 | 38 |
|
52 | 39 |
public ngOnInit() { |
... | ... | |
63 | 50 |
this.navigateToError(); |
64 | 51 |
} else { |
65 | 52 |
this.title.setTitle(stakeholder.index_name); |
53 |
this.categoryIndex = 0; |
|
54 |
this.selectedCategoryIndex = 0; |
|
55 |
this.subCategoryIndex = 0; |
|
56 |
this.toggle = true; |
|
66 | 57 |
} |
67 | 58 |
} |
68 | 59 |
}); |
... | ... | |
83 | 74 |
UIkit.drop(element).show(); |
84 | 75 |
} |
85 | 76 |
|
86 |
get open(): boolean { |
|
87 |
return this.sideBarService.open; |
|
88 |
} |
|
89 |
|
|
90 |
public toggleOpen(event = null) { |
|
91 |
if (!event) { |
|
92 |
this.sideBarService.setOpen(!this.open); |
|
93 |
} else if (event && event['value'] === true) { |
|
94 |
this.sideBarService.setOpen(false); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 | 77 |
public toggleCategory(index: number) { |
99 |
if(this.categoryIndex !== index) {
|
|
100 |
this.categoryIndex = index;
|
|
78 |
if(this.selectedCategoryIndex !== index) {
|
|
79 |
this.selectedCategoryIndex = index;
|
|
101 | 80 |
this.toggle = true; |
102 | 81 |
} else { |
103 | 82 |
this.toggle = !this.toggle; |
... | ... | |
127 | 106 |
this.stakeholder.topics[this.topicIndex].categories[index] = Tools.copy(this.copyCategory); |
128 | 107 |
} |
129 | 108 |
this.hide(element); |
130 |
this.unsaved = true; |
|
131 | 109 |
} else { |
132 | 110 |
this.valid = false; |
133 | 111 |
} |
134 | 112 |
} |
135 | 113 |
|
136 |
public editTopicOpen(element) { |
|
137 |
if(element.className.indexOf('uk-open') !== -1) { |
|
138 |
this.hide(element); |
|
139 |
} else { |
|
140 |
this.topic = Tools.copy(this.stakeholder.topics[this.topicIndex]); |
|
141 |
this.valid = true; |
|
142 |
this.show(element); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 | 114 |
public editSubCategoryOpen(index:number = -1, element = null) { |
147 | 115 |
if(index === -1) { |
148 | 116 |
this.copySubCategory = new SubCategory(null, null, null, true, true); |
... | ... | |
162 | 130 |
if(this.copySubCategory.name && this.copySubCategory.name !== '') { |
163 | 131 |
this.copySubCategory.alias = this.copySubCategory.name.toLowerCase(); |
164 | 132 |
if(index === -1) { |
165 |
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].
|
|
133 |
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].
|
|
166 | 134 |
subCategories.push(this.copySubCategory); |
167 | 135 |
} else { |
168 |
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].
|
|
136 |
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].
|
|
169 | 137 |
subCategories[index] = Tools.copy(this.copySubCategory); |
170 | 138 |
} |
171 | 139 |
this.hide(element); |
172 |
this.unsaved = true; |
|
173 | 140 |
} else { |
174 | 141 |
this.valid = false; |
175 | 142 |
} |
176 | 143 |
} |
177 | 144 |
|
145 |
public editTopicOpen(element) { |
|
146 |
if(element.className.indexOf('uk-open') !== -1) { |
|
147 |
this.hide(element); |
|
148 |
} else { |
|
149 |
this.topic = Tools.copy(this.stakeholder.topics[this.topicIndex]); |
|
150 |
this.valid = true; |
|
151 |
this.show(element); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
178 | 155 |
public saveTopic(element) { |
179 | 156 |
if(this.topic.name && this.topic.name !== '') { |
180 | 157 |
this.topic.alias = this.topic.name.toLowerCase(); |
181 | 158 |
this.stakeholder.topics[this.topicIndex] = Tools.copy(this.topic); |
182 | 159 |
this.hide(element); |
183 |
this.unsaved = true; |
|
184 | 160 |
} else { |
185 | 161 |
this.valid = false; |
186 | 162 |
} |
... | ... | |
192 | 168 |
this.back();*/ |
193 | 169 |
} |
194 | 170 |
|
195 |
public changeGrid(value) { |
|
196 |
this.grid = value; |
|
197 |
} |
|
198 |
|
|
199 | 171 |
private navigateToError() { |
200 | 172 |
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}}); |
201 | 173 |
} |
202 | 174 |
|
175 |
public getDefaultSubcategoryIndex(categoryIndex: number) { |
|
176 |
return this.stakeholder.topics[this.topicIndex].categories[categoryIndex]. |
|
177 |
subCategories.findIndex(subcategory => subcategory.alias === null); |
|
178 |
} |
|
179 |
|
|
203 | 180 |
back() { |
204 | 181 |
this.router.navigate(['../'], { |
205 | 182 |
relativeTo: this.route |
206 | 183 |
}); |
207 | 184 |
} |
185 |
|
|
186 |
chooseSubcategory(categoryIndex: number, subcategoryIndex: number) { |
|
187 |
/*let topic: Topic = this.stakeholder.topics[this.topicIndex]; |
|
188 |
let category: Category = topic.categories[this.categoryIndex]; |
|
189 |
let subCatetegory: SubCategory = category.subCategories[index];*/ |
|
190 |
this.categoryIndex = categoryIndex; |
|
191 |
this.subCategoryIndex = subcategoryIndex; |
|
192 |
} |
|
208 | 193 |
} |
Also available in: Unified diff
[MonitorDashboard]: Make custom css for sidebar width and header height. Add indicators on page. Remove global save. Add indicator filters