1 |
61381
|
k.triantaf
|
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
2 |
|
|
import {SearchResult} from "../../../utils/entities/searchResult";
|
3 |
|
|
import {ErrorCodes} from "../../../utils/properties/errorCodes";
|
4 |
|
|
import {RouterHelper} from "../../../utils/routerHelper.class";
|
5 |
|
|
import {ResultPreview} from "../../../utils/result-preview/result-preview";
|
6 |
|
|
import {AlertModal} from "../../../utils/modal/alert";
|
7 |
|
|
import {EnvProperties} from "../../../utils/properties/env-properties";
|
8 |
|
|
|
9 |
|
|
@Component({
|
10 |
|
|
selector: 'modal-result',
|
11 |
|
|
template: `
|
12 |
|
|
<errorMessages [status]="[status]" [type]="type" tab_error_class=true></errorMessages>
|
13 |
|
|
<div *ngIf="status == errorCodes.DONE">
|
14 |
|
|
<no-load-paging *ngIf="totalResults > pageSize" [type]="type"
|
15 |
|
|
(pageChange)="update($event)"
|
16 |
|
|
[page]="page" [pageSize]="pageSize"
|
17 |
|
|
[totalResults]="totalResults">
|
18 |
|
|
</no-load-paging>
|
19 |
|
|
<ul class="uk-list uk-list-divider uk-margin">
|
20 |
|
|
<li *ngFor="let result of results">
|
21 |
|
|
<result-preview [modal]="modal" [properties]="properties"
|
22 |
|
|
[result]="getResultPreview(result)"
|
23 |
|
|
[showSubjects]="showSubjects"
|
24 |
|
|
[showOrganizations]="showOrganizations"></result-preview>
|
25 |
|
|
</li>
|
26 |
|
|
</ul>
|
27 |
|
|
<no-load-paging *ngIf="totalResults > pageSize" [type]="type"
|
28 |
|
|
(pageChange)="update($event)"
|
29 |
|
|
[page]="page" [pageSize]="pageSize"
|
30 |
|
|
[totalResults]="totalResults">
|
31 |
|
|
</no-load-paging>
|
32 |
|
|
</div>
|
33 |
|
|
`
|
34 |
|
|
})
|
35 |
|
|
export class ModalResultComponent {
|
36 |
|
|
@Input() results: SearchResult[];
|
37 |
|
|
@Input() totalResults: number = 0;
|
38 |
|
|
@Input() type: string;
|
39 |
|
|
@Input() resultType: string;
|
40 |
|
|
@Input() showOrganizations: boolean = true;
|
41 |
|
|
@Input() showSubjects: boolean = false;
|
42 |
|
|
@Input() modal: AlertModal;
|
43 |
|
|
@Input() properties: EnvProperties;
|
44 |
|
|
@Input() status: number;
|
45 |
|
|
@Input() pageSize: number = 1;
|
46 |
|
|
@Output() updatePage: EventEmitter<any> = new EventEmitter<any>();
|
47 |
|
|
|
48 |
|
|
public page: number = 1;
|
49 |
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
50 |
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
51 |
|
|
public errorMessage: string = "No results found";
|
52 |
|
|
|
53 |
|
|
constructor() {
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
ngOnInit() {
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
public getResultPreview(result: SearchResult): ResultPreview {
|
60 |
|
|
return ResultPreview.searchResultConvert(result, this.resultType);
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
public update(event) {
|
64 |
|
|
this.page = event.value;
|
65 |
|
|
this.updatePage.emit({
|
66 |
|
|
value: event.value
|
67 |
|
|
});
|
68 |
|
|
}
|
69 |
|
|
}
|