Revision 58105
Added by Konstantina Galouni about 4 years ago
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/servicesUtils/refineResults.class.ts | ||
---|---|---|
18 | 18 |
filter.title = searchFields.getFieldName(fields[j],entityType); |
19 | 19 |
filter.filterId = fields[j]; |
20 | 20 |
filter.originalFilterId = fields[j]; |
21 |
filter.valueIsUnique = searchFields.fieldHasUniqueValue(fields[j], entityType, usedBy);
|
|
21 |
filter.filterType = searchFields.getFieldFilterType(fields[j], entityType, usedBy);
|
|
22 | 22 |
filter.filterOperator = searchFields.getFieldOperator(fields[j]); |
23 |
//console.info("filter.title: "+filter.title+" filter.valueIsUnique: "+filter.valueIsUnique);
|
|
23 |
//console.info("filter.title: "+filter.title+" filter.filterType: "+filter.filterType);
|
|
24 | 24 |
|
25 | 25 |
let field = data[fields[j]]; |
26 | 26 |
if(field){ |
... | ... | |
36 | 36 |
|
37 | 37 |
|
38 | 38 |
} |
39 |
filters.push(filter); |
|
39 |
|
|
40 |
filters.push(filter); |
|
40 | 41 |
} |
41 | 42 |
} |
42 | 43 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchDataProviders.component.ts | ||
---|---|---|
112 | 112 |
|
113 | 113 |
this.searchPage.fieldIds = this.fieldIds; |
114 | 114 |
this.selectedFields =[]; |
115 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, "datasource");
|
|
115 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "datasource");
|
|
116 | 116 |
|
117 | 117 |
// this.searchPage.selectedFields = this.selectedFields; |
118 | 118 |
// this.searchPage.fieldIdsMap = this.fieldIdsMap; |
... | ... | |
152 | 152 |
if (refine) { |
153 | 153 |
this.filters = this.searchPage.prepareFiltersToShow(data[2]); |
154 | 154 |
}else{ |
155 |
this.searchPage.buildPageURLParameters(this.filters, false); |
|
155 |
this.searchPage.buildPageURLParameters(this.filters, [], false);
|
|
156 | 156 |
} |
157 | 157 |
// this.searchPage.updateBaseUrlWithParameters(); |
158 | 158 |
//var errorCodes:ErrorCodes = new ErrorCodes(); |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchOrganizations.component.ts | ||
---|---|---|
114 | 114 |
// this.searchPage.fieldIdsMap = this.fieldIdsMap; |
115 | 115 |
// this.searchPage.customFilter = this.customFilter; |
116 | 116 |
// this.searchPage.getSelectedFiltersFromUrl(params); |
117 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, "organization"); |
|
117 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "organization");
|
|
118 | 118 |
|
119 | 119 |
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); |
120 | 120 |
|
... | ... | |
150 | 150 |
if (refine) { |
151 | 151 |
this.filters = this.searchPage.prepareFiltersToShow(data[2]); |
152 | 152 |
}else{ |
153 |
this.searchPage.buildPageURLParameters(this.filters, false); |
|
153 |
this.searchPage.buildPageURLParameters(this.filters, [],false);
|
|
154 | 154 |
} |
155 | 155 |
// this.searchPage.updateBaseUrlWithParameters(); |
156 | 156 |
//var errorCodes:ErrorCodes = new ErrorCodes(); |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchProjects.component.ts | ||
---|---|---|
8 | 8 |
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class'; |
9 | 9 |
import {EnvProperties} from '../utils/properties/env-properties'; |
10 | 10 |
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; |
11 |
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; |
|
11 | 12 |
|
12 | 13 |
@Component({ |
13 | 14 |
selector: 'search-projects', |
... | ... | |
27 | 28 |
[(openaireLink)]=openaireLink |
28 | 29 |
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix" |
29 | 30 |
searchFormClass="projectSearchForm" |
30 |
|
|
31 | 31 |
[(filters)]="filters" |
32 |
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields" |
|
32 | 33 |
[simpleView]="simpleView" formPlaceholderText="Search by title, author, doi, abstract content..." |
33 | 34 |
> |
34 | 35 |
</new-search-page> |
... | ... | |
43 | 44 |
@Input() customFilter:SearchCustomFilter= null; |
44 | 45 |
public results =[]; |
45 | 46 |
public filters =[]; |
47 |
public rangeFilters: RangeFilter[] = []; |
|
46 | 48 |
|
47 | 49 |
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); |
48 | 50 |
public searchFields:SearchFields = new SearchFields(); |
49 | 51 |
|
50 | 52 |
public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS; |
51 | 53 |
public fieldIdsMap = this.searchFields.PROJECT_FIELDS; |
54 |
public rangeFields:string[][] = this.searchFields.PROJECT_RANGE_FIELDS; |
|
52 | 55 |
public selectedFields:AdvancedField[] = []; |
53 | 56 |
properties:EnvProperties; |
54 | 57 |
|
... | ... | |
114 | 117 |
|
115 | 118 |
this.searchPage.fieldIds = this.fieldIds; |
116 | 119 |
this.selectedFields = []; |
117 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, "project"); |
|
120 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, "project");
|
|
118 | 121 |
// this.selectedFields =[]; |
119 | 122 |
// this.searchPage.selectedFields = this.selectedFields; |
120 | 123 |
// this.searchPage.fieldIdsMap = this.fieldIdsMap; |
121 | 124 |
// this.searchPage.customFilter = this.customFilter; |
122 | 125 |
// this.searchPage.getSelectedFiltersFromUrl(params); |
123 |
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); |
|
126 |
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
|
|
124 | 127 |
firstLoad = false; |
125 | 128 |
}); |
126 | 129 |
} |
... | ... | |
156 | 159 |
if (refine) { |
157 | 160 |
this.filters = this.searchPage.prepareFiltersToShow(data[2]); |
158 | 161 |
}else{ |
159 |
this.searchPage.buildPageURLParameters(this.filters, false); |
|
162 |
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
|
|
160 | 163 |
} |
161 |
//var errorCodes:ErrorCodes = new ErrorCodes(); |
|
164 |
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow(); |
|
165 |
|
|
166 |
//var errorCodes:ErrorCodes = new ErrorCodes(); |
|
162 | 167 |
this.searchUtils.status = this.errorCodes.DONE; |
163 | 168 |
if(this.searchUtils.totalResults == 0 ){ |
164 | 169 |
this.searchUtils.status = this.errorCodes.NONE; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/searchHelperClasses.class.ts | ||
---|---|---|
7 | 7 |
public values: Value[] = []; |
8 | 8 |
public filterOperator: string ='or'; |
9 | 9 |
public valueIsExact: boolean = true; // for search table view, if value is contained or is equal with column entry |
10 |
public valueIsUnique: boolean = false;
|
|
10 |
public filterType: string = "checkbox";
|
|
11 | 11 |
// public uniqueValueIdSelected: string; |
12 | 12 |
} |
13 | 13 |
|
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/searchFilter.component.html | ||
---|---|---|
1 |
|
|
2 |
<ul *ngIf= "filter.values.length >0" class="uk-list"> |
|
3 |
<li class="uk-open"> |
|
4 |
<h5 class="uk-margin-bottom-remove searchFilterTitle">{{_formatTitle(filter.title,filter.values.length)}} |
|
5 |
</h5> |
|
1 |
<div *ngIf= "filter.values.length >0" class="uk-margin-small-bottom"> |
|
2 |
<div class="uk-margin-small-top uk-margin-bottom uk-grid uk-flex uk-flex-bottom"> |
|
3 |
<h5 class="uk-margin-bottom-remove">{{_formatTitle(filter.title,filter.values.length)}}</h5> |
|
4 |
<a *ngIf="filter.countSelectedValues>0" (click)="clearFilter()" class="portal-link"> |
|
5 |
Clear |
|
6 |
</a> |
|
7 |
</div> |
|
6 | 8 |
<div aria-expanded="false"> |
7 |
<div [class]="showMoreInline ? '' : 'searchFilterBoxValues' "> |
|
8 |
<div *ngFor = "let value of getSelectedValues(filter,'num')" class="uk-animation-fade filterItem"> |
|
9 |
<div title = "{{value.name}}"> |
|
10 |
<input *ngIf="!filter.valueIsUnique" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" /> |
|
11 |
<input *ngIf="filter.valueIsUnique" type="radio" (click)="uniqueFilterChange(value)" |
|
12 |
[name]=filter.filterId checked/> |
|
13 |
{{' '+_formatName(value)}} |
|
14 |
<span *ngIf = "showResultCount === true" > |
|
15 |
{{' ('+(value.number|number)+')'}}</span> |
|
16 |
</div> |
|
17 |
</div> |
|
18 |
<!-- <hr *ngIf="filter.countSelectedValues > 0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small"--> |
|
9 |
<div> |
|
10 |
<ng-container *ngIf="!isOpen"> |
|
11 |
<div *ngFor = "let value of getSelectedValues(filter,'num')" class="uk-animation-fade filterItem searchFilterItem uk-text-small"> |
|
12 |
<div title = "{{value.name}}"> |
|
13 |
<ng-container *ngIf="filter.filterType == 'checkbox' || filter.filterType == 'radio'"> |
|
14 |
<input *ngIf="filter.filterType == 'checkbox'" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" /> |
|
15 |
<input *ngIf="filter.filterType == 'radio'" type="radio" (click)="uniqueFilterChange(value)" |
|
16 |
[name]=filter.filterId checked/> |
|
17 |
{{' '+_formatName(value)}} |
|
18 |
<span *ngIf = "showResultCount === true" > |
|
19 |
{{' ('+(value.number|number)+')'}}</span> |
|
20 |
</ng-container> |
|
21 |
</div> |
|
22 |
</div> |
|
19 | 23 |
|
20 |
<div *ngFor = "let value of getNotSelectedValues(filter,'num').slice(0,(!addShowMore?getNotSelectedValues(filter,'num').length:filterValuesNum-getSelectedValues(filter,'num').length))" class = "uk-animation-fade filterItem"> |
|
21 |
<div title = "{{value.name}}" [class]="(isDisabled || (showResultCount && value.number === 0))?'uk-text-muted':''" > |
|
22 |
<input *ngIf="!filter.valueIsUnique" [disabled]="isDisabled || (showResultCount && value.number === 0)" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" /> |
|
23 |
<input *ngIf="filter.valueIsUnique" [disabled]="isDisabled || (showResultCount && value.number === 0)" type="radio" (click)="uniqueFilterChange(value)" |
|
24 |
[name]=filter.filterId value=false /> |
|
25 |
{{' '+ _formatName(value) }} |
|
26 |
<span *ngIf = "showResultCount === true" [class]="(isDisabled || value.number === 0)?'uk-text-muted':''" > |
|
27 |
{{' ('+(value.number|number)+')'}} |
|
28 |
</span> |
|
29 |
</div> |
|
30 |
</div> |
|
24 |
<div *ngFor = "let value of getNotSelectedValues(filter,'num').slice(0,(!addShowMore?getNotSelectedValues(filter,'num').length:filterValuesNum-getSelectedValues(filter,'num').length))" class = "uk-animation-fade filterItem searchFilterItem uk-text-small"> |
|
25 |
<div title = "{{value.name}}" [class]="(isDisabled || (showResultCount && value.number === 0))?'uk-text-muted':''" > |
|
26 |
<input *ngIf="filter.filterType == 'checkbox'" [disabled]="isDisabled || (showResultCount && value.number === 0)" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" /> |
|
27 |
<input *ngIf="filter.filterType == 'radio'" [disabled]="isDisabled || (showResultCount && value.number === 0)" type="radio" (click)="uniqueFilterChange(value)" |
|
28 |
[name]=filter.filterId value=false /> |
|
29 |
{{' '+ _formatName(value) }} |
|
30 |
<span *ngIf = "showResultCount === true" [class]="(isDisabled || value.number === 0)?'uk-text-muted':''" > |
|
31 |
{{' ('+(value.number|number)+')'}} |
|
32 |
</span> |
|
33 |
</div> |
|
34 |
</div> |
|
35 |
</ng-container> |
|
31 | 36 |
|
32 |
<div *ngIf=" addShowMore && showMoreInline && (filter.values.length) > filterValuesNum">
|
|
33 |
<a [class]="(isDisabled)?'uk-disabled uk-link-muted ':''"
|
|
34 |
[attr.uk-toggle]="'target: #toggle-'+filter.filterId">View
|
|
35 |
<span *ngIf="filter.values.length >= 99">more</span>
|
|
36 |
<span *ngIf="filter.values.length < 99">all</span>
|
|
37 |
<div *ngIf=" addShowMore && (filter.values.length) > filterValuesNum"> |
|
38 |
<a *ngIf="!isOpen"
|
|
39 |
[class]="((isDisabled)?'uk-disabled uk-link-muted ':' portal-link ') + ' uk-margin-small-top'"
|
|
40 |
[attr.uk-toggle]="'target: #toggle-'+filter.filterId" (click)="toggle()">
|
|
41 |
+ View more
|
|
37 | 42 |
</a> |
38 |
<div hidden [id]="'toggle-'+filter.filterId"> |
|
39 |
<!-- <div *ngIf="filter.values.length >= 99" class="uk-alert uk-alert-primary uk-text-center uk-margin-right uk-margin-left uk-margin-small-top uk-margin-small-bottom ">Showing top {{filter.values.length}} values. </div>-->
|
|
43 |
|
|
44 |
<div hidden [id]="'toggle-'+filter.filterId" class="uk-text-small uk-margin-small-bottom">
|
|
40 | 45 |
<div class=""> |
46 |
<span *ngIf="filter.values.length >= 99">* only the Top 100 values are shown</span> |
|
41 | 47 |
<input class="uk-input uk-margin-small-bottom uk-width-1-1 " name="filter-keyword" placeholder="Search for {{filter.title}}" type="text" [(ngModel)]="keyword"> |
42 |
<select *ngIf = "showResultCount === true" [(ngModel)]="sortBy" |
|
43 |
class="uk-text-muted uk-select uk-margin-small-bottom uk-width-1-1" name="select_order" (ngModelChange)="sortByChanged = true;" > |
|
44 |
<option value="num">Sorted by results number</option> |
|
45 |
<option value="name">Sorted by name</option> |
|
46 |
</select> |
|
48 |
|
|
49 |
<span *ngIf = "showResultCount === true" class="uk-width-5-6@m uk-width-1-1@s uk-align-right uk-margin-small-bottom"> |
|
50 |
<span class="uk-width-1-4"> Sort by:</span> |
|
51 |
<select [(ngModel)]="sortBy" |
|
52 |
class="uk-select uk-width-3-4@m uk-width-auto" |
|
53 |
id="form-horizontal-select" name="select_order"> |
|
54 |
<option value="num">Results number</option> |
|
55 |
<option value="name">Name</option> |
|
56 |
</select> |
|
57 |
</span> |
|
47 | 58 |
</div> |
48 | 59 |
|
49 |
<div class="uk-modal-body uk-overflow-auto uk-height-small uk-padding-remove |
|
50 |
uk-margin-small-left uk-margin-small-right uk-margin-small-top uk-margin-bottom">
|
|
60 |
<div class="uk-modal-body uk-overflow-auto uk-height-max-small uk-padding-remove
|
|
61 |
uk-margin-small-left uk-margin-small-right uk-margin-small-top"> |
|
51 | 62 |
<ng-container *ngFor = "let value of getSelectedValues(filter, sortBy)"> |
52 |
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem"> |
|
63 |
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem searchFilterItem">
|
|
53 | 64 |
|
54 | 65 |
<div title = "{{value.name}}"> |
55 |
<input *ngIf="!filter.valueIsUnique" [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" />
|
|
56 |
<input *ngIf="filter.valueIsUnique" [disabled]="isDisabled" type="radio" (click)="uniqueFilterChange(value)"
|
|
57 |
[name]=filter.filterId checked/> |
|
66 |
<input *ngIf="filter.filterType == 'checkbox'" [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
|
|
67 |
<input *ngIf="filter.filterType == 'radio'" [disabled]="isDisabled" type="radio" (click)="uniqueFilterChange(value)"
|
|
68 |
[name]=filter.filterId checked/>
|
|
58 | 69 |
{{' ' + _formatName(value) + ' '}} |
59 | 70 |
<span class="filterNumber" *ngIf = "showResultCount === true" > ({{value.number|number}})</span> |
60 | 71 |
</div> |
61 | 72 |
|
62 | 73 |
</div> |
63 | 74 |
</ng-container> |
64 |
<hr *ngIf="filter.countSelectedValues > 0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small"> |
|
75 |
|
|
65 | 76 |
<ng-container *ngFor = "let value of getNotSelectedValues(filter, sortBy)"> |
66 |
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem"> |
|
77 |
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem searchFilterItem">
|
|
67 | 78 |
|
68 | 79 |
<div title = "{{value.name}}"> |
69 |
<input *ngIf="!filter.valueIsUnique" [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" />
|
|
70 |
<input *ngIf="filter.valueIsUnique" [disabled]="isDisabled" type="radio" (click)="uniqueFilterChange(value)"
|
|
71 |
[name]=filter.filterId value=false />
|
|
80 |
<input *ngIf="filter.filterType == 'checkbox'" [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
|
|
81 |
<input *ngIf="filter.filterType == 'radio'" [disabled]="isDisabled" type="radio" (click)="uniqueFilterChange(value)"
|
|
82 |
[name]=filter.filterId value=false /> |
|
72 | 83 |
{{' ' + _formatName(value) + ' '}} |
73 | 84 |
<span *ngIf = "showResultCount === true" > ({{value.number|number}})</span> |
74 | 85 |
</div> |
75 |
|
|
76 | 86 |
</div> |
77 | 87 |
</ng-container> |
78 | 88 |
</div> |
79 | 89 |
</div> |
90 |
<a [class]="(isDisabled)?'uk-disabled uk-link-muted ':' portal-link '" |
|
91 |
[attr.uk-toggle]="'target: #toggle-'+filter.filterId" (click)="toggle()"> |
|
92 |
<span *ngIf="isOpen">- View less</span> |
|
93 |
</a> |
|
80 | 94 |
</div> |
81 |
|
|
82 |
<a *ngIf=" addShowMore && !showMoreInline&& (filter.values.length) > filterValuesNum" (click)="open()" |
|
83 |
[class]="(isDisabled)?'uk-disabled uk-link-muted':''">View more |
|
84 |
</a> |
|
85 |
|
|
86 |
|
|
87 |
<div *ngIf="addShowMore && !showMoreInline" [class]="(!isOpen)?'uk-modal ':'uk-modal uk-open uk-animation-fade'" uk-modal [open]="!isOpen" id="modal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" bg-close="true"> |
|
88 |
<div class="filtersModal uk-modal-dialog uk-small-1-2 uk-width-medium-1-3 uk-width-1-3 uk-padding-small uk-padding-remove-top uk-padding-remove-horizontal"> |
|
89 |
|
|
90 |
<button type="button" class="uk-modal-close-default" uk-close (click)="close()"></button> |
|
91 |
<h5 class="uk-margin-remove uk-padding uk-padding-remove-bottom uk-text-center"> |
|
92 |
{{filter.title}} |
|
93 |
</h5> |
|
94 |
|
|
95 |
<div *ngIf="filter.values.length >= 99" class="uk-alert uk-alert-primary uk-text-center uk-margin-right uk-margin-left uk-margin-small-top uk-margin-small-bottom ">Showing top {{filter.values.length}} values. </div> |
|
96 |
<div class="uk-grid uk-margin-left uk-margin-right"> |
|
97 |
<input class="uk-input uk-margin-small-bottom uk-width-1-2 " name="filter-keyword" placeholder="Search for {{filter.title}}" type="text" [(ngModel)]="keyword"> |
|
98 |
<select *ngIf = "showResultCount === true" [(ngModel)]="sortBy" class="uk-select uk-margin-small-bottom uk-width-1-2 uk-padding-remove" name="select_order" (ngModelChange)="sortByChanged = true;" > |
|
99 |
<option value="num" >Sort by results number</option> |
|
100 |
<option value="name" >Sort by name</option> |
|
101 |
</select> |
|
102 |
</div> |
|
103 |
<div class="uk-modal-body uk-overflow-auto uk-height-medium uk-padding-remove |
|
104 |
uk-margin-medium-left uk-margin-medium-right uk-margin-small-top uk-margin-bottom"> |
|
105 |
<ng-container *ngFor = "let value of getSelectedValues(filter, sortBy)"> |
|
106 |
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem"> |
|
107 |
<div title = "{{value.name}}"> |
|
108 |
<input *ngIf="!filter.valueIsUnique" [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" /> |
|
109 |
<input *ngIf="filter.valueIsUnique" [disabled]="isDisabled" [(ngModel)]="value.selected" type="radio" [name]=filter.filterId (ngModelChange)="close(); filterChange(value.selected)" /> |
|
110 |
{{' ' + (value.name) + ' '}} |
|
111 |
<span *ngIf = "showResultCount === true" > ({{value.number|number}})</span> |
|
112 |
</div> |
|
113 |
|
|
114 |
</div> |
|
115 |
</ng-container> |
|
116 |
<hr *ngIf="filter.countSelectedValues > 0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small"> |
|
117 |
<ng-container *ngFor = "let value of getNotSelectedValues(filter, sortBy)"> |
|
118 |
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem"> |
|
119 |
|
|
120 |
<div title = "{{value.name}}"> |
|
121 |
<input *ngIf="!filter.valueIsUnique" [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" /> |
|
122 |
<input *ngIf="filter.valueIsUnique" [disabled]="isDisabled" [(ngModel)]="value.selected" type="radio" [name]=filter.filterId (ngModelChange)="close(); filterChange(value.selected)" /> |
|
123 |
{{' ' + (value.name) + ' '}} |
|
124 |
<span *ngIf = "showResultCount === true" > ({{value.number|number}})</span> |
|
125 |
</div> |
|
126 |
</div> |
|
127 |
</ng-container> |
|
128 |
</div> |
|
129 |
</div> |
|
130 |
</div> |
|
131 |
|
|
132 |
|
|
133 |
|
|
134 | 95 |
</div> |
135 | 96 |
</div> |
136 |
</li> |
|
137 |
</ul> |
|
97 |
</div> |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/newSearchPage.component.html | ||
---|---|---|
32 | 32 |
<div id="tm-main" class=" tm-middle"> |
33 | 33 |
<div uk-grid> |
34 | 34 |
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first "> |
35 |
<div class="uk-container"> |
|
35 |
<div class="uk-container uk-container-large">
|
|
36 | 36 |
<div> |
37 | 37 |
|
38 | 38 |
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" [texts]="pageContents['top']"></helper> |
... | ... | |
59 | 59 |
class="uk-width-1-2" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults"> |
60 | 60 |
</search-download> |
61 | 61 |
|
62 |
<div *ngIf="selectedFilters>0" class="uk-margin-small-bottom"> |
|
63 |
<div class="uk-grid uk-margin-bottom uk-margin-top"> |
|
64 |
<span class="uk-text-bold uk-text-large">Filters</span> |
|
65 |
<a *ngIf="selectedFilters>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'"> |
|
62 |
<div *ngIf="selectedRangeFilters > 0 || selectedFilters > 0" class="uk-margin-small-bottom"> |
|
63 |
<!-- <div class="uk-grid uk-margin-bottom uk-margin-top">--> |
|
64 |
<!-- <span class="uk-text-bold uk-text-large">Filters</span>--> |
|
65 |
<!-- <a *ngIf="selectedFilters>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'">--> |
|
66 |
<!-- Clear All--> |
|
67 |
<!-- </a>--> |
|
68 |
<!-- </div>--> |
|
69 |
<div class="uk-grid uk-flex uk-flex-bottom uk-margin-top"> |
|
70 |
<h5 class="uk-text-bold">Filters</h5> |
|
71 |
<a *ngIf="(selectedRangeFilters+selectedFilters)>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'"> |
|
66 | 72 |
Clear All |
67 | 73 |
</a> |
68 | 74 |
</div> |
75 |
</div> |
|
69 | 76 |
|
70 |
<span *ngIf = "searchUtils.keyword.length > 0"><span class="uk-text-bold">Keywords:</span>
|
|
71 |
<a (click) = "clearKeywords() " title="Remove keywords" [class]="((disableForms)?' uk-disabled':' ')+' uk-margin-small-right portal-color '"><span class=" clickable " aria-hidden="true"><span class="uk-icon ">
|
|
72 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
|
73 |
</span></span></a>
|
|
74 |
<span [innerHtml]="searchUtils.keyword"></span>
|
|
75 |
|
|
76 |
</span>
|
|
77 |
<div *ngFor="let filter of filters " >
|
|
78 |
<span *ngIf = "filter.countSelectedValues > 0"> <span class="uk-text-bold">{{filter.title}}:</span>
|
|
79 |
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " >
|
|
80 |
<a [title]="'Remove '+value.name"(click) = "removeFilter(value, filter) " [class]="((disableForms)?' uk-disabled':' ')+' portal-color '"><span class=" clickable" aria-hidden="true"><span class="uk-icon">
|
|
81 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
|
82 |
</span></span></a>
|
|
83 |
<span [innerHtml]="(value.name.length > 25)?value.name.substring(0,25)+'...':value.name" [title]="value.name"></span><span *ngIf="!end" class=" ">, </span>
|
|
77 |
<div *ngIf="selectedRangeFilters > 0 || selectedFilters>0" class="uk-margin-medium-bottom uk-grid uk-grid-small uk-text-small" uk-grid>
|
|
78 |
<ng-container *ngIf="selectedRangeFilters > 0">
|
|
79 |
<ng-container *ngFor="let filter of rangeFilters " >
|
|
80 |
<ng-container *ngIf = "filter.selectedFromAndToValues">
|
|
81 |
<span [title]="'Remove '+ filter.selectedFromAndToValues" (click) = "removeRangeFilter(filter) " >
|
|
82 |
<span class="selectedFilterLabel "> |
|
83 |
<a [class]="((disableForms)?' uk-disabled':' ')+' uk-link-text '">
|
|
84 |
<span class=" clickable" aria-hidden="true">
|
|
85 |
<span class="uk-icon">
|
|
86 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
|
87 |
</span>
|
|
88 |
</span>
|
|
89 |
<span class="uk-margin-small-left">{{filter.selectedFromAndToValues}}</span>
|
|
90 |
</a>
|
|
84 | 91 |
</span> |
85 | 92 |
</span> |
86 |
</div> |
|
93 |
</ng-container> |
|
94 |
</ng-container> |
|
95 |
</ng-container> |
|
96 |
<ng-container *ngFor="let filter of filters " > |
|
97 |
<ng-container *ngIf = "filter.countSelectedValues > 0"> |
|
87 | 98 |
|
99 |
<!-- <span class="uk-text-bold">{{filter.title}}:</span>--> |
|
100 |
<!-- uk-margin-small-top uk-margin-small-right--> <!-- if no grid on the div above, add it --> |
|
101 |
<!-- uk-label --> |
|
102 |
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " |
|
103 |
[title]="'Remove '+value.name" (click) = "removeFilter(value, filter) " > |
|
104 |
<!-- if no grid on the div above, remove it and move class 'selectedFilterLabel' on top span --> |
|
105 |
<span class="selectedFilterLabel "> |
|
106 |
<a [class]="((disableForms)?' uk-disabled':' ')+' uk-link-text '"> |
|
107 |
<span class=" clickable" aria-hidden="true"> |
|
108 |
<span class="uk-icon"> |
|
109 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg> |
|
110 |
</span> |
|
111 |
</span> |
|
112 |
<span class="uk-margin-small-left" [innerHtml]="(value.name.length > 34)?value.name.substring(0,34)+'...':value.name"></span> |
|
113 |
</a> |
|
114 |
</span> |
|
115 |
</span> |
|
116 |
</ng-container> |
|
117 |
</ng-container> |
|
88 | 118 |
|
119 |
|
|
89 | 120 |
</div> |
90 | 121 |
|
91 | 122 |
<!-- <div class="uk-margin-small-bottom uk-margin-small-top uk-grid">--> |
... | ... | |
96 | 127 |
<div *ngIf="filters.length === 0 && searchUtils.keyword.length === 0 && results.length > 0" class="uk-margin-top"> |
97 | 128 |
<span class="uk-text-meta">No filters available</span> |
98 | 129 |
</div> |
99 |
<div *ngIf="!showUnknownFilters"> |
|
100 |
<div class="uk-text-large">Filter By:</div> |
|
101 |
<search-filter *ngFor="let filter of filters " [addShowMore]=false [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" ></search-filter> |
|
102 |
</div> |
|
130 |
<ul *ngIf="!showUnknownFilters" class="uk-list uk-list-divider"> |
|
131 |
<ng-container *ngFor="let filter of rangeFilters"> |
|
132 |
<li> |
|
133 |
<range-filter [isDisabled]="disableForms" [filter]="filter" (onFilterChange)="filterChanged($event)"></range-filter> |
|
134 |
</li> |
|
135 |
</ng-container> |
|
136 |
<ng-container *ngFor="let filter of filters "> |
|
137 |
<li *ngIf= "filter.values.length >0"> |
|
138 |
<search-filter [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline" [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" ></search-filter> |
|
139 |
</li> |
|
140 |
</ng-container> |
|
141 |
</ul> |
|
103 | 142 |
</div> |
104 | 143 |
</div> |
105 | 144 |
|
... | ... | |
122 | 161 |
class="uk-width-1-2" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults"> |
123 | 162 |
</search-download> |
124 | 163 |
<div class="uk-width-1-1 uk-margin-small-bottom "> |
125 |
<div *ngIf="selectedFilters>0" class="uk-grid uk-margin-bottom uk-margin-top">
|
|
126 |
<span class="uk-text-bold uk-text-large">Filters</span>
|
|
127 |
<a *ngIf="selectedFilters>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'">
|
|
164 |
<div *ngIf="selectedRangeFilters > 0 || selectedFilters > 0" class="uk-grid uk-flex uk-flex-bottom uk-margin-top">
|
|
165 |
<h5 class="uk-text-bold">Filters</h5>
|
|
166 |
<a *ngIf="(selectedRangeFilters+selectedFilters)>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'">
|
|
128 | 167 |
Clear All |
129 | 168 |
</a> |
130 | 169 |
</div> |
170 |
<!-- uk-grid uk-grid-small" uk-grid--> |
|
171 |
<!-- uk-margin-left--> |
|
172 |
<div *ngIf="selectedRangeFilters > 0 || selectedFilters>0" class="uk-margin-medium-bottom uk-grid uk-grid-small uk-text-small" uk-grid> |
|
173 |
<ng-container *ngIf="selectedRangeFilters > 0"> |
|
174 |
<ng-container *ngFor="let filter of rangeFilters " > |
|
175 |
<ng-container *ngIf = "filter.selectedFromAndToValues"> |
|
176 |
<span [title]="'Remove '+ filter.selectedFromAndToValues" (click) = "removeRangeFilter(filter) " > |
|
177 |
<span class="selectedFilterLabel "> |
|
178 |
<a [class]="((disableForms)?' uk-disabled':' ')+' uk-link-text '"> |
|
179 |
<span class=" clickable" aria-hidden="true"> |
|
180 |
<span class="uk-icon"> |
|
181 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg> |
|
182 |
</span> |
|
183 |
</span> |
|
184 |
<span class="uk-margin-small-left">{{filter.selectedFromAndToValues}}</span> |
|
185 |
</a> |
|
186 |
</span> |
|
187 |
</span> |
|
188 |
</ng-container> |
|
189 |
</ng-container> |
|
190 |
</ng-container> |
|
191 |
<ng-container *ngFor="let filter of filters " > |
|
192 |
<ng-container *ngIf = "filter.countSelectedValues > 0"> |
|
131 | 193 |
|
132 |
<div *ngIf=" selectedFilters>0" class="uk-margin-small-bottom"> |
|
133 |
|
|
134 |
<!-- <span *ngIf = "searchUtils.keyword.length > 0"><span class="uk-text-bold">Keywords:</span> |
|
135 |
<a (click) = "clearKeywords() " title="Remove keywords" [class]="((disableForms)?' uk-disabled':' ')+' portal-color '"><span class=" clickable " aria-hidden="true"><span class="uk-icon "> |
|
136 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg> |
|
137 |
</span></span></a> |
|
138 |
<span [innerHtml]="searchUtils.keyword"></span> |
|
139 |
|
|
140 |
</span>--> |
|
141 |
<div *ngFor="let filter of filters " > |
|
142 |
<span *ngIf = "filter.countSelectedValues > 0" > <span class="uk-text-bold">{{filter.title}}:</span> |
|
143 |
<label *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " |
|
144 |
[title]="'Remove '+value.name" (click) = "removeFilter(value, filter) "> |
|
145 |
<a [class]="((disableForms)?' uk-disabled':' ')+' portal-color '"><span class=" clickable" aria-hidden="true"><span class="uk-icon"> |
|
146 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg> |
|
147 |
</span></span> |
|
148 |
</a> |
|
149 |
<span [innerHtml]="(value.name.length > 25)?value.name.substring(0,25)+'...':value.name"></span><span *ngIf="!end" class=" ">, </span> |
|
150 |
</label> |
|
151 |
</span> |
|
152 |
</div> |
|
194 |
<!-- <span class="uk-text-bold">{{filter.title}}:</span>--> |
|
195 |
<!-- uk-margin-small-top uk-margin-small-right--> <!-- if no grid on the div above, add it --> |
|
196 |
<!-- uk-label --> |
|
197 |
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " |
|
198 |
[title]="'Remove '+value.name" (click) = "removeFilter(value, filter) " > |
|
199 |
<!-- if no grid on the div above, remove it and move class 'selectedFilterLabel' on top span --> |
|
200 |
<span class="selectedFilterLabel "> |
|
201 |
<a [class]="((disableForms)?' uk-disabled':' ')+' uk-link-text '"> |
|
202 |
<span class=" clickable" aria-hidden="true"> |
|
203 |
<span class="uk-icon"> |
|
204 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg> |
|
205 |
</span> |
|
206 |
</span> |
|
207 |
<span class="uk-margin-small-left" [innerHtml]="(value.name.length > 34)?value.name.substring(0,34)+'...':value.name"></span> |
|
208 |
</a> |
|
209 |
</span> |
|
210 |
</span> |
|
211 |
</ng-container> |
|
212 |
</ng-container> |
|
153 | 213 |
</div> |
154 | 214 |
|
155 | 215 |
<!-- <div class="uk-margin-small-bottom uk-margin-small-top uk-grid">--> |
... | ... | |
159 | 219 |
<div *ngIf="filters.length === 0 && results.length > 0" class="uk-margin-top"> |
160 | 220 |
<span class="uk-text-meta">No filters available</span> |
161 | 221 |
</div> |
162 |
<div *ngIf="!showUnknownFilters"> |
|
163 |
<search-filter *ngFor="let filter of filters " [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline" [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" ></search-filter> |
|
164 |
</div> |
|
222 |
<ul *ngIf="!showUnknownFilters" class="uk-list uk-list-divider"> |
|
223 |
<ng-container *ngFor="let filter of rangeFilters"> |
|
224 |
<li> |
|
225 |
<range-filter [isDisabled]="disableForms" [filter]="filter" (onFilterChange)="filterChanged($event)"></range-filter> |
|
226 |
</li> |
|
227 |
</ng-container> |
|
228 |
<ng-container *ngFor="let filter of filters "> |
|
229 |
<li *ngIf= "filter.values.length >0"> |
|
230 |
<search-filter [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline" [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" ></search-filter> |
|
231 |
</li> |
|
232 |
</ng-container> |
|
233 |
</ul> |
|
165 | 234 |
</div> |
166 | 235 |
<div class="uk-width-expand@m uk-with-1-1@s"> |
167 | 236 |
<div *ngIf="openaireLink"> <a class="uk-margin-top uk-button uk-button-text" [href]=openaireLink target="_blank" >Results in OpenAIRE</a></div> |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/newSearchPage.module.ts | ||
---|---|---|
6 | 6 |
import{NewSearchPageComponent} from './newSearchPage.component'; |
7 | 7 |
import{SearchFormModule} from './searchForm.module'; |
8 | 8 |
import {SearchFilterModule} from './searchFilter.module'; |
9 |
import {RangeFilterModule} from 'app/openaireLibrary/utils/rangeFilter/rangeFilter.module'; |
|
9 | 10 |
import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; |
10 | 11 |
import {ReportsServiceModule} from '../../services/reportsService.module'; |
11 | 12 |
import{SearchPagingModule} from './searchPaging.module'; |
... | ... | |
28 | 29 |
imports: [ |
29 | 30 |
CommonModule, FormsModule, RouterModule, SearchFormModule, SearchResultsModule, CommunitySearchResultsModule, |
30 | 31 |
LoadingModalModule, ReportsServiceModule, SearchDataproviderMapModule, |
31 |
SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, SearchFilterModule, |
|
32 |
SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, |
|
33 |
SearchFilterModule, RangeFilterModule, |
|
32 | 34 |
PiwikServiceModule, HelperModule, Schema2jsonldModule, SEOServiceModule, SearchResultsModule, |
33 | 35 |
SearchResultsInDepositModule, AdvancedSearchFormModule |
34 | 36 |
], |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/searchFilter.component.ts | ||
---|---|---|
1 |
import {Component, Input, Output, EventEmitter} from '@angular/core'; |
|
2 |
import {Observable} from 'rxjs'; |
|
3 |
|
|
1 |
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; |
|
4 | 2 |
import { Filter, Value} from './searchHelperClasses.class'; |
5 |
import {Open} from '../../utils/modal/open.component'; |
|
6 | 3 |
|
7 | 4 |
@Component({ |
8 | 5 |
selector: 'search-filter', |
... | ... | |
11 | 8 |
|
12 | 9 |
export class SearchFilterComponent { |
13 | 10 |
|
14 |
@Input() filter:Filter;
|
|
15 |
@Input() showResultCount:boolean = true;
|
|
16 |
@Input() isDisabled:boolean = false;
|
|
17 |
@Input() addShowMore:boolean = true;
|
|
18 |
@Input() showMoreInline: boolean = false;
|
|
19 |
@Input() filterValuesNum: number = 5;
|
|
20 |
public showAll:boolean = false;
|
|
21 |
public _maxCharacters:number =28;
|
|
11 |
@Input() filter:Filter; |
|
12 |
@Input() showResultCount:boolean = true; |
|
13 |
@Input() isDisabled:boolean = false; |
|
14 |
@Input() addShowMore:boolean = true; |
|
15 |
@Input() showMoreInline: boolean = true;
|
|
16 |
@Input() filterValuesNum: number = 4;
|
|
17 |
public showAll:boolean = false; |
|
18 |
public _maxCharacters:number =28; |
|
22 | 19 |
|
23 |
@Output() toggleModal = new EventEmitter();
|
|
20 |
@Output() toggleModal = new EventEmitter(); |
|
24 | 21 |
|
25 |
@Output() modalChange = new EventEmitter();
|
|
26 |
@Output() onFilterChange = new EventEmitter();
|
|
27 |
keyword = "";
|
|
28 |
sortBy = "num";
|
|
22 |
@Output() modalChange = new EventEmitter(); |
|
23 |
@Output() onFilterChange = new EventEmitter(); |
|
24 |
keyword = ""; |
|
25 |
sortBy = "num"; |
|
29 | 26 |
|
27 |
public isOpen:boolean=false; |
|
30 | 28 |
|
31 |
public isOpen:boolean=false; |
|
32 |
|
|
33 |
// filterModalChange() { |
|
34 |
// console.info("Modal Changed"); |
|
35 |
// this.modalChange.emit({ |
|
36 |
// value: true |
|
37 |
// }); |
|
38 |
// //this.close(); |
|
39 |
// } |
|
40 |
|
|
41 |
constructor () { |
|
29 |
constructor () { |
|
42 | 30 |
} |
43 | 31 |
|
44 |
ngOnInit() { |
|
32 |
ngOnInit() {}
|
|
45 | 33 |
|
46 |
} |
|
47 | 34 |
public _formatTitle(title,length){ |
48 | 35 |
return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title+" ("+((length >= 99)?length+"+":length)+")") |
49 | 36 |
} |
50 | 37 |
public _formatName(value){ |
51 |
let maxLineLength = 24; |
|
38 |
//let maxLineLength = 24; |
|
39 |
let maxLineLength = 35; |
|
40 |
|
|
52 | 41 |
//1 space after checkbox |
53 | 42 |
//3 space before number + parenthesis |
54 | 43 |
if(!this.showResultCount && value.name.length+1 > maxLineLength ){ |
... | ... | |
59 | 48 |
} |
60 | 49 |
|
61 | 50 |
return value.name; |
62 |
//(((value.name+" ("+value.number+")").length >this._maxCharacters)?(value.name.substring(0,(this._maxCharacters - (" ("+value.number+")").length - ('...').length))+"..."):value.name) |
|
63 | 51 |
} |
64 |
// toggleShowAll(){ |
|
65 |
// this.showAll = !this.showAll; |
|
66 |
// if(this.showAll == false) { |
|
67 |
// this.reorderFilterValues(); |
|
68 |
// } |
|
69 |
// } |
|
70 | 52 |
|
71 |
|
|
72 | 53 |
filterKeywords(value){ |
73 | 54 |
if(this.keyword.length > 0){ |
74 | 55 |
if(value.toLowerCase().indexOf(this.keyword.toLowerCase()) ==-1){ |
... | ... | |
78 | 59 |
return true; |
79 | 60 |
} |
80 | 61 |
filterChange(selected:boolean){ |
81 |
//console.info("filter change: "+selected); |
|
82 | 62 |
if(selected){ |
83 | 63 |
this.filter.countSelectedValues++; |
84 |
// this.reorderFilterValues(); |
|
85 | 64 |
}else{ |
86 | 65 |
this.filter.countSelectedValues--; |
87 |
// this.reorderFilterValues(); |
|
88 | 66 |
} |
89 | 67 |
this.onFilterChange.emit({ |
90 | 68 |
value: this.filter |
... | ... | |
104 | 82 |
value: this.filter |
105 | 83 |
}); |
106 | 84 |
} |
85 |
clearFilter() { |
|
86 |
for (var i=0; i < this.filter.values.length; i++){ |
|
87 |
this.filter.values[i].selected = false; |
|
88 |
} |
|
89 |
this.filter.countSelectedValues = 0; |
|
90 |
this.onFilterChange.emit({ |
|
91 |
value: this.filter |
|
92 |
}); |
|
93 |
} |
|
107 | 94 |
getSelectedValues(filter, sortBy:string = "num"):any{ |
108 | 95 |
var selected = []; |
109 | 96 |
if(filter.countSelectedValues >0){ |
... | ... | |
132 | 119 |
} |
133 | 120 |
getNotSelectedValues(filter, sortBy:string = "num"):any{ |
134 | 121 |
var notSselected = []; |
135 |
//if(filter.countSelectedValues >0){ |
|
136 |
for (var i=0; i < filter.values.length; i++){ |
|
137 |
if(!filter.values[i].selected){ |
|
138 |
notSselected.push(filter.values[i]); |
|
139 |
} |
|
122 |
for (var i=0; i < filter.values.length; i++){ |
|
123 |
if(!filter.values[i].selected){ |
|
124 |
notSselected.push(filter.values[i]); |
|
140 | 125 |
} |
141 |
//}else { |
|
142 |
// notSselected = filter.values; |
|
143 |
//} |
|
126 |
} |
|
144 | 127 |
|
145 | 128 |
if(sortBy == "name"){ |
146 | 129 |
|
... | ... | |
148 | 131 |
if (n1.name > n2.name) { |
149 | 132 |
return 1; |
150 | 133 |
} |
151 |
|
|
152 | 134 |
if (n1.name < n2.name) { |
153 | 135 |
return -1; |
154 | 136 |
} |
... | ... | |
158 | 140 |
} |
159 | 141 |
return notSselected; |
160 | 142 |
} |
161 |
// reorderFilterValues() { |
|
162 |
// for(let value of this.filter.values) { |
|
163 |
// if(value.selected) { |
|
164 |
// let index: number = this.filter.values.indexOf(value); |
|
165 |
// let selectedValue:Value = this.filter.values[index]; |
|
166 |
// |
|
167 |
// this.filter.values.splice(index, 1); |
|
168 |
// this.filter.values.splice(0, 0, selectedValue); |
|
169 |
// } |
|
170 |
// } |
|
171 |
// } |
|
172 |
// sliceSelected() { |
|
173 |
// let values: Value[] = []; |
|
174 |
// |
|
175 |
// for(let value of this.filter.values) { |
|
176 |
// if(value.selected) { |
|
177 |
// let index: number = this.filter.values.indexOf(value); |
|
178 |
// let selectedValue:Value = this.filter.values[index]; |
|
179 |
// |
|
180 |
// this.filter.values.splice(index, 1); |
|
181 |
// this.filter.values.splice(0, 0, selectedValue); |
|
182 |
// } |
|
183 |
// } |
|
184 | 143 |
|
185 |
|
|
186 |
// toggle() { |
|
187 |
// this.toggleModal.emit({ |
|
188 |
// value: this.filter |
|
189 |
// }); |
|
190 |
// } |
|
191 |
|
|
192 |
|
|
193 |
open() { |
|
194 |
this.isOpen = true; |
|
144 |
toggle() { |
|
145 |
this.isOpen = !this.isOpen; |
|
195 | 146 |
} |
196 | 147 |
|
197 |
close() { |
|
198 |
this.isOpen = false; |
|
199 |
} |
|
200 |
|
|
201 |
// filterChange2(selected:boolean){ |
|
202 |
// |
|
203 |
// console.info("filter change2"); |
|
204 |
// if(selected){ |
|
205 |
// this.filter.countSelectedValues++; |
|
206 |
// // this.reorderFilterValues(); |
|
207 |
// }else{ |
|
208 |
// this.filter.countSelectedValues--; |
|
209 |
// // this.reorderFilterValues(); |
|
210 |
// } |
|
211 |
// this.close(); |
|
212 |
// } |
|
213 | 148 |
getFilterName(value){ |
214 | 149 |
let name = value.name +" ("+ value.number.format()+")"; |
215 |
console.log(name) |
|
216 |
|
|
217 |
|
|
218 |
// <span class="filterName"><div title = "{{value.name}}"> |
|
219 |
// <input [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterModalChange(value.selected)"> |
|
220 |
// {{value.name}} </div></span> |
|
221 |
// <span class="filterNumber" *ngIf = "showResultCount === true" > ({{value.number | number}})</span> |
|
150 |
console.log(name); |
|
222 | 151 |
return name; |
223 | 152 |
} |
224 | 153 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/newSearchPage.component.ts | ||
---|---|---|
16 | 16 |
import {HelperService} from "../../utils/helper/helper.service"; |
17 | 17 |
import {SearchFields} from "../../utils/properties/searchFields"; |
18 | 18 |
import {RefineResultsUtils} from "../../services/servicesUtils/refineResults.class"; |
19 |
import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class"; |
|
19 | 20 |
|
20 | 21 |
@Component({ |
21 | 22 |
selector: 'new-search-page', |
... | ... | |
45 | 46 |
@Input() sort: boolean = false; |
46 | 47 |
@Input() searchFormClass: string = "searchForm"; |
47 | 48 |
//From simple: |
49 |
@Input() rangeFilters: RangeFilter[] = []; |
|
50 |
@Input() rangeFields: string[][] = []; |
|
48 | 51 |
@Input() refineFields = []; |
49 | 52 |
@Input() filters = []; |
50 | 53 |
selectedFilters: number = 0; |
54 |
selectedRangeFilters: number = 0; |
|
51 | 55 |
private searchFieldsHelper: SearchFields = new SearchFields(); |
52 | 56 |
@Input() newQueryButton: boolean = true; |
53 | 57 |
public showUnknownFilters: boolean = false; // when a filter exists in query but has no results, so no filters returned from the query |
54 | 58 |
URLCreatedFilters: Filter[] = []; |
59 |
URLCreatedRangeFilters: RangeFilter[] = []; |
|
55 | 60 |
@Input() showRefine: boolean = true; |
56 | 61 |
@Input() tableViewLink: string; |
57 | 62 |
@Input() usedBy: string = "search"; |
58 | 63 |
@Input() showResultCount: boolean = true; |
59 |
@Input() showMoreFilterValuesInline: boolean = false;
|
|
64 |
@Input() showMoreFilterValuesInline: boolean = true;
|
|
60 | 65 |
@Input() filterValuesNum: number = 5; |
61 | 66 |
@Input() keywordFields = []; |
62 | 67 |
@Input() simpleView: boolean = true; |
... | ... | |
170 | 175 |
} |
171 | 176 |
} |
172 | 177 |
this.selectedFilters = 0; |
178 |
//<<<<<<< .mine |
|
179 |
|
|
180 |
for(let i = 0; i < this.rangeFilters.length; i++) { |
|
181 |
this.rangeFilters[i].selectedFromValue = null; |
|
182 |
this.rangeFilters[i].selectedToValue = null; |
|
183 |
} |
|
184 |
this.selectedRangeFilters = 0; |
|
185 |
//||||||| .r58066 |
|
186 |
//======= |
|
173 | 187 |
if (this.quickFilter) { |
174 | 188 |
this.removeValueFromQuickFilter(); |
175 | 189 |
} |
190 |
//>>>>>>> .r58095 |
|
176 | 191 |
this.goTo(1); |
177 | 192 |
// this.clearKeywords(); |
178 | 193 |
} |
179 | 194 |
|
180 | 195 |
goTo(page: number = 1) { |
181 | 196 |
this.searchUtils.page = page; |
182 |
this.buildPageURLParameters(this.filters, true); |
|
197 |
this.buildPageURLParameters(this.filters, this.rangeFilters, true);
|
|
183 | 198 |
this.router.navigate([this.searchUtils.baseUrl], {queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)}); |
184 | 199 |
/* Code For Piwik*/ |
185 | 200 |
if (typeof localStorage !== 'undefined') { |
... | ... | |
320 | 335 |
} |
321 | 336 |
|
322 | 337 |
/* |
338 |
* Mark as check the new range filters that are selected |
|
339 |
*/ |
|
340 |
public checkSelectedRangeFilters(filters: RangeFilter[]) { |
|
341 |
//console.log("checkSelectedRangeFilters: parameterNames.length: "+this.parameterNames.length); |
|
342 |
|
|
343 |
this.rangeFilters = filters; |
|
344 |
for (let i = 0; i < filters.length; i++) { |
|
345 |
let filter: RangeFilter = filters[i]; |
|
346 |
|
|
347 |
if (this.parameterNames.indexOf(filter.filterId) != -1) { |
|
348 |
//console.log(filter.filterId + " "+this.parameterNames.indexOf(filter.filterId) ); |
|
349 |
let values = (decodeURIComponent(this.parameterValues[this.parameterNames.indexOf(filter.filterId)])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1); |
|
350 |
let operators: string [] = (StringUtils.URIDecode(this.parameterValues[this.parameterNames.indexOf(filter.filterId)])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1); |
|
351 |
if (values.length == operators.length) { |
|
352 |
for (let j = 0; j < values.length; j++) { |
|
353 |
if (this.fieldIdsMap[filter.originalFilterIdFrom+"-range-"+filter.originalFilterIdTo].filterType == "range") { |
|
354 |
let value: string = StringUtils.unquote(values[j]); |
|
355 |
let validDates: boolean = true; |
|
356 |
|
|
357 |
let years: string[] = (value.substring(5)).split(":"); |
|
358 |
let yearFrom: string = (Dates.isValidYear(years[0]) ? years[0] : null); |
|
359 |
let yearTo: string = (Dates.isValidYear(years[1]) ? years[1] : null); |
|
360 |
//console.log("checkSelectedRangeFilters: yearFrom: " + yearFrom + " - yearTo: "+yearTo); |
|
361 |
if(yearFrom) { |
|
362 |
filter.selectedFromValue = yearFrom; |
|
363 |
filter.selectedFromAndToValues = yearFrom; |
|
364 |
} |
|
365 |
if(yearFrom && yearTo) { |
|
366 |
filter.selectedFromAndToValues += "-"; |
|
367 |
} |
|
368 |
if(yearTo) { |
|
369 |
filter.selectedToValue = yearTo; |
|
370 |
filter.selectedFromAndToValues += yearTo; |
|
371 |
} |
|
372 |
if(!yearFrom && !yearTo) { |
|
373 |
validDates = false; |
|
374 |
} |
|
375 |
|
|
376 |
// if (value.length < 14) { |
|
377 |
// validDates = false; |
|
378 |
// console.log("not valid (length<14)"); |
|
379 |
// } else { |
|
380 |
// if (!Dates.isValidYear(value.substring(5, 9)) || !Dates.isValidYear(value.substring(10, 14))) { |
|
381 |
// validDates = false; |
|
382 |
// console.log("not valid years"); |
|
383 |
// } else { |
|
384 |
// filter.selectedFromValue = value.substring(5, 9); |
|
385 |
// filter.selectedToValue = value.substring(10, 14); |
|
386 |
// console.log(filter); |
|
387 |
// } |
|
388 |
// } |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
} else { |
|
393 |
filter.selectedFromValue = null; |
|
394 |
filter.selectedToValue = null; |
|
395 |
} |
|
396 |
} |
|
397 |
return this.rangeFilters; |
|
398 |
} |
|
399 |
|
|
400 |
/* |
|
323 | 401 |
* For Funder filters - if funder selected |
324 | 402 |
*/ |
325 | 403 |
public filterFilterValues(filters: Filter[]) { |
... | ... | |
367 | 445 |
return this.selectedFilters; |
368 | 446 |
} |
369 | 447 |
|
448 |
public countSelectedRangeFilters(rangeFilters: RangeFilter[]) : number { |
|
449 |
this.selectedRangeFilters = 0; |
|
450 |
for(let filter of rangeFilters) { |
|
451 |
if(filter.selectedFromValue || filter.selectedToValue) { |
|
452 |
this.selectedRangeFilters++; |
|
453 |
} |
|
454 |
} |
|
455 |
return this.selectedRangeFilters; |
|
456 |
} |
|
457 |
|
|
370 | 458 |
private clearKeywords() { |
371 | 459 |
if (this.searchUtils.keyword.length > 0) { |
372 | 460 |
this.searchUtils.keyword = ''; |
... | ... | |
374 | 462 |
this.goTo(1); |
375 | 463 |
} |
376 | 464 |
|
377 |
private removeFilter(value: Value, filter: Filter) {
|
|
465 |
public removeFilter(value: Value, filter: Filter) {
|
|
378 | 466 |
filter.countSelectedValues--; |
379 | 467 |
this.selectedFilters--; |
380 | 468 |
if (value.selected == true) { |
... | ... | |
384 | 472 |
this.removeValueFromQuickFilter(); |
385 | 473 |
} |
386 | 474 |
this.goTo(1); |
475 |
} |
|
387 | 476 |
|
477 |
public removeRangeFilter(filter: RangeFilter) { |
|
478 |
filter.selectedFromValue = null; |
|
479 |
filter.selectedToValue = null; |
|
480 |
this.goTo(1); |
|
388 | 481 |
} |
389 | 482 |
|
390 | 483 |
getSelectedValues(filter): any { |
... | ... | |
401 | 494 |
} |
402 | 495 |
|
403 | 496 |
filterChanged($event) { |
404 |
if (this.quickFilter) { |
|
497 |
if (this.quickFilter && this.quickFilter.filter) {
|
|
405 | 498 |
this.removeValueFromQuickFilter(); |
406 | 499 |
} |
407 | 500 |
this.goTo(1); |
... | ... | |
645 | 738 |
} |
646 | 739 |
|
647 | 740 |
/** |
741 |
* Create Search API query based on the filters of refine fields |
|
742 |
* @param URLparams |
|
743 |
*/ |
|
744 |
getSearchAPIQueryForRangeFields(URLparams) { |
|
745 |
let allFqs = ""; |
|
746 |
for (let i = 0; i < this.rangeFields.length; i++) { |
|
747 |
let filterId = this.rangeFields[i][0]+"-range-"+this.rangeFields[i][1]; |
|
748 |
let filterParam = this.searchFieldsHelper.getFieldParam(filterId, this.entityType); |
|
749 |
|
|
750 |
if (URLparams[filterParam] != undefined) { |
|
751 |
let values = (StringUtils.URIDecode(StringUtils.URIDecode(URLparams[filterParam]))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1); |
|
752 |
var countvalues = 0; |
|
753 |
var fq = ""; |
|
754 |
var fqFrom = ""; |
|
755 |
var fqTo = ""; |
|
756 |
let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId); |
|
757 |
|
|
758 |
for (let value of values) { |
|
759 |
if (this.fieldIdsMap[filterId].filterType == "range") { |
|
760 |
|
|
761 |
let selectedFromValue; |
|
762 |
let selectedToValue; |
|
763 |
|
|
764 |
let years: string[] = (value.substring(5)).split(":"); |
|
765 |
let yearFrom: string = (Dates.isValidYear(years[0]) ? years[0] : null); |
|
766 |
//(Number.isInteger(parseInt(years[0], 10)) ? years[0] : null); |
|
767 |
let yearTo: string = (Dates.isValidYear(years[1]) ? years[1] : null); |
|
768 |
//console.log("getSearchAPIQueryForRangeFields: yearFrom: " + yearFrom + " - yearTo: "+yearTo); |
|
769 |
if(yearFrom) { |
|
770 |
selectedFromValue = yearFrom; |
|
771 |
} |
|
772 |
if(yearTo) { |
|
773 |
selectedToValue = yearTo; |
|
774 |
} |
|
775 |
if(yearFrom || yearTo) { |
|
776 |
|
|
777 |
// if (value.length <= 14) { |
|
778 |
// if(Dates.isValidYear(value.substring(5, 9))) { |
|
779 |
// selectedFromValue = value.substring(5, 9); |
|
780 |
// } |
|
781 |
// if(Dates.isValidYear(value.substring(10, 14))) { |
|
782 |
// selectedToValue = value.substring(10, 14); |
|
783 |
// } |
|
784 |
|
|
785 |
if(this.rangeFields[i][0] == this.rangeFields[i][1]) { |
|
786 |
//console.log(selectedFromValue + " - "+selectedToValue); |
|
787 |
if (selectedFromValue && selectedToValue) { |
|
788 |
let equalityOp = this.fieldIdsMap[filterId].equalityOperator; |
|
789 |
fq += (fq.length > 0 ? " " + filterOp + " " : "") + this.rangeFields[i][0] + equalityOp + "\"" + selectedFromValue + " " + selectedToValue + "\""; |
|
790 |
fq = "&fq=" + StringUtils.URIEncode(fq); |
|
791 |
} else if (selectedFromValue) { |
|
792 |
let equalityOp = this.fieldIdsMap[this.rangeFields[i][0]].equalityOperator; |
|
793 |
if(equalityOp == " = ") { |
|
794 |
equalityOp = " >= "; |
|
795 |
} |
|
796 |
fq += (fq.length > 0 ? " " + filterOp + " " : "") + this.rangeFields[i][0] + equalityOp + "\"" + selectedFromValue + "\""; |
|
797 |
fq = "&fq=" + StringUtils.URIEncode(fq); |
|
798 |
} else if (selectedToValue) { |
|
799 |
let equalityOp = this.fieldIdsMap[this.rangeFields[i][1]].equalityOperator; |
|
800 |
if(equalityOp == " = ") { |
|
801 |
equalityOp = " <= "; |
|
802 |
} |
|
803 |
fq += (fq.length > 0 ? " " + filterOp + " " : "") + this.rangeFields[i][0] + equalityOp + "\"" + selectedToValue + "\""; |
|
804 |
fq = "&fq=" + StringUtils.URIEncode(fq); |
|
805 |
} |
|
806 |
} else { |
|
807 |
let equalityOpFrom = this.fieldIdsMap[this.rangeFields[i][0]].equalityOperator; |
|
808 |
let equalityOpTo = this.fieldIdsMap[this.rangeFields[i][1]].equalityOperator; |
|
809 |
|
|
810 |
if (selectedFromValue) { |
|
811 |
fq += (fq.length > 0 ? " " + filterOp + " " : "") + this.rangeFields[i][0] + equalityOpFrom + "\"" + selectedFromValue + "\""; |
|
812 |
// fq = "&fq=" + StringUtils.URIEncode(fq); |
|
813 |
} |
|
814 |
if (selectedToValue) { |
|
815 |
fq += (fq.length > 0 ? " " + filterOp + " " : "") + this.rangeFields[i][1] + equalityOpTo + "\"" + selectedToValue + "\""; |
|
816 |
// fq = "&fq=" + StringUtils.URIEncode(fq); |
|
817 |
} |
|
818 |
if(selectedFromValue || selectedToValue) { |
|
819 |
fq = "&fq=" + StringUtils.URIEncode(fq); |
|
820 |
} |
|
821 |
} |
|
822 |
} |
|
823 |
} |
|
824 |
} |
|
825 |
allFqs += fq +fqFrom + fqTo; |
|
826 |
} |
|
827 |
} |
|
828 |
|
|
829 |
return allFqs; |
|
830 |
|
|
831 |
} |
|
832 |
|
|
833 |
/** |
|
648 | 834 |
* Sets parameterNames and parameterValues arrays |
649 | 835 |
* used in paging, advanced search link, Goto() |
650 | 836 |
* @param filters either query filters or filters defined by the URL parameters |
837 |
* @param rangeFilters defined by the URL parameters |
|
651 | 838 |
* @param includePage |
652 | 839 |
*/ |
653 |
buildPageURLParameters(filters: Filter[], includePage: boolean) { |
|
840 |
//<<<<<<< .mine |
|
841 |
buildPageURLParameters(filters:Filter[], rangeFilters: RangeFilter[], includePage: boolean) { |
|
842 |
//console.log("buildPageURLParameters"); |
|
843 |
// ||||||| .r58066 |
|
844 |
// buildPageURLParameters(filters:Filter[],includePage: boolean) { |
|
845 |
// ======= |
|
846 |
// buildPageURLParameters(filters: Filter[], includePage: boolean) { |
|
847 |
// >>>>>>> .r58095 |
|
654 | 848 |
this.parameterNames.splice(0, this.parameterNames.length); |
655 | 849 |
this.parameterValues.splice(0, this.parameterValues.length); |
656 | 850 |
var fields: { [key: string]: { values: string[], operators: string[] } } = {}; |
... | ... | |
710 | 904 |
} |
711 | 905 |
} |
712 | 906 |
} |
907 |
for (let filter of rangeFilters) { |
|
908 |
var filterLimits = ""; |
|
909 |
let yearFrom: string = (Dates.isValidYear(filter.selectedFromValue) ? filter.selectedFromValue : null); |
|
910 |
let yearTo: string = (Dates.isValidYear(filter.selectedToValue) ? filter.selectedToValue : null); |
|
911 |
if(yearFrom || yearTo) { |
|
912 |
this.parameterNames.push(filter.filterId); |
|
913 |
this.parameterValues.push("range" + (yearFrom ? yearFrom : "") + ":" + (yearTo ? yearTo : "")); |
|
914 |
} |
|
915 |
// if (filter.countSelectedValues > 0) { |
|
916 |
// for (let value of filter.values) { |
|
917 |
// if (value.selected == true) { |
|
918 |
// filterLimits += ((filterLimits.length == 0) ? '' : ',') + '"' + (value.id) + '"'; |
|
919 |
// } |
|
920 |
// } |
|
921 |
// if (filterLimits.length > 0) { |
|
922 |
// this.parameterNames.push(filter.filterId); |
|
923 |
// this.parameterValues.push(filterLimits); |
|
924 |
// } |
|
925 |
// } |
|
926 |
} |
|
713 | 927 |
if (this.searchUtils.keyword.length > 0) { |
714 | 928 |
this.parameterNames.push("keyword"); |
715 | 929 |
this.parameterValues.push(this.searchUtils.keyword); |
... | ... | |
785 | 999 |
if (this.quickFilter) { |
786 | 1000 |
if (this.entityType == "result" && (URLparams[this.quickFilter.filterId] == undefined) && (URLparams["qf"] == undefined || URLparams["qf"] == "true")) { |
787 | 1001 |
let filter = new Filter(); |
788 |
filter.title = fields.getFieldName(this.quickFilter.filterId, "publication");
|
|
1002 |
filter.title = fields.getFieldName(this.quickFilter.filterId, this.entityType);
|
|
789 | 1003 |
filter.filterId = this.quickFilter.filterId; |
790 | 1004 |
filter.originalFilterId = this.quickFilter.filterId; |
791 | 1005 |
filter.values = []; |
... | ... | |
824 | 1038 |
} |
825 | 1039 |
|
826 | 1040 |
/** |
1041 |
* create range filters based on URL params |
|
1042 |
* @param URLparams |
|
1043 |
*/ |
|
1044 |
getRangeFiltersFromURL(URLparams) { |
|
1045 |
let fields = new SearchFields(); |
|
1046 |
let filters: RangeFilter[] = []; |
|
1047 |
for (let i = 0; i < this.rangeFields.length; i++) { |
|
1048 |
let filterId = this.rangeFields[i][0]+"-range-"+this.rangeFields[i][1]; |
|
1049 |
let filterParam = fields.getFieldParam(filterId, this.entityType); |
|
1050 |
//console.log("rangeFilter (from url): filterId - filterParam"); |
|
1051 |
//console.log(filterId + " - "+ filterParam); |
|
1052 |
if (URLparams[filterParam] != undefined) { |
|
1053 |
let filter = new RangeFilter(); |
|
1054 |
filter.title = fields.getFieldName(filterId, this.entityType); |
|
1055 |
filter.filterId = filterParam; |
|
1056 |
filter.originalFilterIdFrom = this.rangeFields[i][0]; |
|
1057 |
filter.originalFilterIdTo = this.rangeFields[i][1]; |
|
1058 |
|
|
1059 |
|
|
1060 |
let values = (decodeURIComponent(URLparams[filterParam])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1); |
|
1061 |
for (let j = 0; j < values.length; j++) { |
|
1062 |
if (this.fieldIdsMap[filterId].filterType == "range") { |
|
1063 |
let value: string = StringUtils.unquote(values[j]); |
|
1064 |
let validDates: boolean = true; |
|
1065 |
// if (value.length < 14) { |
|
1066 |
// validDates = false; |
|
1067 |
// } else { |
|
1068 |
// if (!Dates.isValidYear(value.substring(5, 9)) || !Dates.isValidYear(value.substring(10, 14))) { |
|
1069 |
// validDates = false; |
|
1070 |
// } else { |
|
1071 |
// filter.selectedFromValue = value.substring(5, 9); |
|
1072 |
// filter.selectedToValue = value.substring(10, 14); |
|
1073 |
// } |
|
1074 |
// } |
|
1075 |
let years: string[] = (value.substring(5)).split(":"); |
|
1076 |
let yearFrom: string = (Dates.isValidYear(years[0]) ? years[0] : null); |
|
1077 |
let yearTo: string = (Dates.isValidYear(years[1]) ? years[1] : null); |
|
1078 |
//console.log("getRangeFiltersFromURL: yearFrom: " + yearFrom + " - yearTo: "+yearTo); |
|
1079 |
if(yearFrom) { |
|
1080 |
filter.selectedFromValue = yearFrom; |
|
1081 |
//filter.selectedFromAndToValues = yearFrom; |
|
1082 |
} |
|
1083 |
/*if(yearFrom && yearTo) { |
|
1084 |
filter.selectedFromAndToValues += "-"; |
|
1085 |
}*/ |
|
1086 |
if(yearTo) { |
|
1087 |
filter.selectedToValue = yearTo; |
|
1088 |
//filter.selectedFromAndToValues += yearTo; |
|
1089 |
} |
|
1090 |
//console.log("filter.selectedFromAndToValues: "+filter.selectedFromAndToValues); |
|
1091 |
if(!yearFrom && !yearTo) { |
|
1092 |
validDates = false; |
|
1093 |
} |
|
1094 |
|
|
1095 |
} |
|
1096 |
} |
|
1097 |
//console.log(filters); |
|
1098 |
filters.push(filter) |
|
1099 |
} |
|
1100 |
} |
|
1101 |
// console.log("Empty Filters"); |
|
1102 |
// console.log(filters); |
|
1103 |
this.URLCreatedRangeFilters = filters; |
|
1104 |
// return filters; |
|
1105 |
|
|
1106 |
} |
|
1107 |
|
|
1108 |
/** |
|
827 | 1109 |
* Checks if query has no results, display Filters from URL parameters |
828 | 1110 |
* Mark checked the selected filters |
829 | 1111 |
* Count the checked |
830 | 1112 |
* @param filters |
831 | 1113 |
*/ |
832 | 1114 |
public prepareFiltersToShow(filters: Filter[]): Filter[] { |
1115 |
//console.log("prepareFiltersToShow"); |
|
833 | 1116 |
if (this.URLCreatedFilters.length > 0 && this.searchUtils.totalResults == 0) { |
834 | 1117 |
this.showUnknownFilters = true; |
835 | 1118 |
this.filters = this.URLCreatedFilters; |
... | ... | |
837 | 1120 |
this.showUnknownFilters = false; |
838 | 1121 |
this.filters = filters; |
839 | 1122 |
} |
840 |
this.buildPageURLParameters(this.URLCreatedFilters, true); |
|
1123 |
this.buildPageURLParameters(this.URLCreatedFilters, this.URLCreatedRangeFilters, true); |
|
1124 |
//this.checkSelectedRangeFilters(this.rangeFilters); |
|
1125 |
|
|
841 | 1126 |
this.checkSelectedFilters(this.filters); |
842 | 1127 |
this.countSelectedFilters(this.filters); |
843 | 1128 |
return this.filters; |
844 | 1129 |
} |
845 | 1130 |
|
846 | 1131 |
/** |
1132 |
* Mark checked the selected range filters |
|
1133 |
*/ |
|
1134 |
public prepareRangeFiltersToShow() { |
|
1135 |
this.rangeFilters = RangeFilter.parse(this.rangeFields, this.entityType); // OK |
|
1136 |
|
|
1137 |
//this.buildPageURLRangeParameters(this.rangeFilters, true); |
|
1138 |
this.checkSelectedRangeFilters(this.rangeFilters); |
|
1139 |
this.countSelectedRangeFilters(this.rangeFilters); |
|
1140 |
return this.rangeFilters; |
|
1141 |
} |
|
1142 |
|
|
1143 |
/** |
|
847 | 1144 |
* Used to set the variables and search page, and prepare it before the getResults query |
848 | 1145 |
* @param fieldIds |
849 | 1146 |
* @param selectedFields |
... | ... | |
852 | 1149 |
* @param customFilter |
853 | 1150 |
* @param params |
854 | 1151 |
*/ |
855 |
prepareSearchPage(fieldIds, selectedFields, refineFields, fieldIdsMap, customFilter, params, entityType, quickFilter=null) { |
|
1152 |
//<<<<<<< .mine |
|
1153 |
prepareSearchPage(fieldIds, selectedFields, refineFields, rangeFields, fieldIdsMap, customFilter, params, entityType, quickFilter=null){ |
|
1154 |
//console.log("prepareSearchPage"); |
|
856 | 1155 |
this.entityType = entityType; |
857 | 1156 |
this.fieldIds = fieldIds; |
858 | 1157 |
this.selectedFields = selectedFields; |
859 | 1158 |
this.refineFields = refineFields; |
1159 |
this.rangeFields = rangeFields; |
|
860 | 1160 |
this.fieldIdsMap = fieldIdsMap; |
861 | 1161 |
this.customFilter = customFilter; |
862 | 1162 |
this.quickFilter = quickFilter; |
1163 |
this.getRangeFiltersFromURL(params); |
|
863 | 1164 |
this.getRefineFiltersFromURL(params); |
864 | 1165 |
this.createAdvancedSearchSelectedFiltersFromURLParameters(params); |
1166 |
// ||||||| .r58066 |
|
1167 |
// prepareSearchPage(fieldIds, selectedFields, refineFields,fieldIdsMap, customFilter, params){ |
|
1168 |
// this.fieldIds = fieldIds; |
|
1169 |
// this.selectedFields = selectedFields; |
|
1170 |
// this.refineFields = refineFields; |
|
1171 |
// this.fieldIdsMap = fieldIdsMap; |
|
1172 |
// this.customFilter = customFilter; |
|
1173 |
// this.getRefineFiltersFromURL(params); |
|
1174 |
// this.createAdvancedSearchSelectedFiltersFromURLParameters(params); |
|
1175 |
// ======= |
|
1176 |
// prepareSearchPage(fieldIds, selectedFields, refineFields, fieldIdsMap, customFilter, params, entityType, quickFilter=null) { |
|
1177 |
// this.entityType = entityType; |
|
1178 |
// this.fieldIds = fieldIds; |
|
1179 |
// this.selectedFields = selectedFields; |
|
1180 |
// this.refineFields = refineFields; |
|
1181 |
// this.fieldIdsMap = fieldIdsMap; |
|
1182 |
// this.customFilter = customFilter; |
|
1183 |
// this.quickFilter = quickFilter; |
|
1184 |
// this.getRefineFiltersFromURL(params); |
|
1185 |
// this.createAdvancedSearchSelectedFiltersFromURLParameters(params); |
|
865 | 1186 |
} |
1187 |
//>>>>>>> .r58095 |
|
866 | 1188 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/dataProviders/entityRegistries.component.ts | ||
---|---|---|
184 | 184 |
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} |
185 | 185 |
values.push(value); |
186 | 186 |
} |
187 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, valueIsUnique: false };
|
|
187 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" };
|
|
188 | 188 |
filters.push(filter); |
189 | 189 |
} |
190 | 190 |
return filters; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/dataProviders/journals.component.ts | ||
---|---|---|
188 | 188 |
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} |
189 | 189 |
values.push(value); |
190 | 190 |
} |
191 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, valueIsUnique: false };
|
|
191 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" };
|
|
192 | 192 |
filters.push(filter); |
193 | 193 |
} |
194 | 194 |
return filters; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts | ||
---|---|---|
250 | 250 |
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} |
251 | 251 |
values.push(value); |
252 | 252 |
} |
253 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: filter_valueIsExact[i], valueIsUnique: false };
|
|
253 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: filter_valueIsExact[i], filterType: "checkbox" };
|
|
254 | 254 |
filters.push(filter); |
255 | 255 |
} |
256 | 256 |
return filters; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts | ||
---|---|---|
255 | 255 |
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} |
256 | 256 |
values.push(value); |
257 | 257 |
} |
258 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: filter_valueIsExact[i], valueIsUnique: false };
|
|
258 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: filter_valueIsExact[i], filterType: "checkbox" };
|
|
259 | 259 |
filters.push(filter); |
260 | 260 |
} |
261 | 261 |
return filters; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/dataProviders/journalsTable.component.ts | ||
---|---|---|
210 | 210 |
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} |
211 | 211 |
values.push(value); |
212 | 212 |
} |
213 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, valueIsUnique: false };
|
|
213 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" };
|
|
214 | 214 |
filters.push(filter); |
215 | 215 |
} |
216 | 216 |
return filters; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts | ||
---|---|---|
194 | 194 |
var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} |
195 | 195 |
values.push(value); |
196 | 196 |
} |
197 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, valueIsUnique: false };
|
|
197 |
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" };
|
|
198 | 198 |
filters.push(filter); |
199 | 199 |
} |
200 | 200 |
return filters; |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchResearchResults.component.ts | ||
---|---|---|
8 | 8 |
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class'; |
9 | 9 |
import {EnvProperties} from '../utils/properties/env-properties'; |
10 | 10 |
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; |
11 |
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; |
|
11 | 12 |
|
12 | 13 |
|
13 | 14 |
@Component({ |
... | ... | |
30 | 31 |
searchFormClass="publicationsSearchForm" |
31 | 32 |
[(sort)]=sort |
32 | 33 |
[(filters)]="filters" [quickFilter]="quickFilter" |
34 |
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields" |
|
33 | 35 |
[simpleView]="simpleView" formPlaceholderText="Search by title, author, doi, abstract content..." |
34 | 36 |
> |
35 | 37 |
</new-search-page> |
... | ... | |
49 | 51 |
@Input() hasPrefix: boolean = true; |
50 | 52 |
public results = []; |
51 | 53 |
public filters = []; |
54 |
public rangeFilters: RangeFilter[] = []; |
|
52 | 55 |
|
53 | 56 |
public searchUtils: SearchUtilsClass = new SearchUtilsClass(); |
54 | 57 |
public searchFields: SearchFields = new SearchFields(); |
55 | 58 |
|
56 | 59 |
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; |
57 | 60 |
public fieldIdsMap = this.searchFields.RESULT_FIELDS; |
61 |
public rangeFields:string[][] = this.searchFields.RESULT_RANGE_FIELDS; |
|
58 | 62 |
public selectedFields: AdvancedField[] = []; |
59 | 63 |
public resourcesQuery = "((oaftype exact result) and (resulttypeid exact " + this.resultType + "))"; |
60 | 64 |
public csvParams: string; |
... | ... | |
85 | 89 |
} |
86 | 90 |
|
87 | 91 |
ngOnInit() { |
88 |
console.log(this.quickFilter) |
|
92 |
console.log(this.quickFilter);
|
|
89 | 93 |
//TODO add checks about which result types are enabled! |
90 | 94 |
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { |
91 | 95 |
this.properties = data.envSpecific; |
... | ... | |
124 | 128 |
} |
125 | 129 |
|
126 | 130 |
this.selectedFields = []; |
127 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter); |
|
128 |
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); |
|
129 |
firstLoad = false; |
|
130 |
|
|
131 |
// <<<<<<< .mine |
|
132 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter); |
|
133 |
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); |
|
134 |
// ||||||| .r58066 |
|
135 |
// this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params); |
|
136 |
// this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRefineFields(params)); |
|
137 |
// ======= |
|
138 |
// this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter); |
|
139 |
// this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); |
|
140 |
// firstLoad = false; |
|
141 |
// |
|
142 |
// >>>>>>> .r58095 |
|
131 | 143 |
}); |
132 | 144 |
} |
133 | 145 |
|
... | ... | |
157 | 169 |
data => { |
158 | 170 |
this.searchUtils.totalResults = data[0]; |
159 | 171 |
this.results = data[1]; |
172 |
|
|
160 | 173 |
if (refine) { |
161 | 174 |
this.filters = this.searchPage.prepareFiltersToShow(data[2]); |
162 | 175 |
}else{ |
163 |
this.searchPage.buildPageURLParameters(this.filters, false); |
|
176 |
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
|
|
164 | 177 |
} |
178 |
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow(); |
|
165 | 179 |
|
166 | 180 |
this.searchUtils.status = this.errorCodes.DONE; |
167 | 181 |
if (this.searchUtils.totalResults == 0) { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/utils/string-utils.class.ts | ||
---|---|---|
1 | 1 |
import {UrlSegment} from '@angular/router'; |
2 | 2 |
|
3 | 3 |
export class Dates { |
4 |
public static yearMin = 1800; |
|
5 |
public static yearMax = (new Date().getFullYear()) + 10; |
|
6 |
|
|
4 | 7 |
public static isValidYear(yearString){ |
5 | 8 |
// First check for the pattern |
6 | 9 |
if(!/^\d{4}$/.test(yearString)) |
... | ... | |
8 | 11 |
var year = parseInt(yearString, 10); |
9 | 12 |
|
10 | 13 |
// Check the ranges of month and year |
11 |
if(year < 1000 || year > 3000 )
|
|
14 |
if(year < this.yearMin || year > this.yearMax )
|
|
12 | 15 |
return false; |
13 | 16 |
return true; |
Also available in: Unified diff
[Trunk | Library]: Filters according to new UI/UX design.
1. utils/rangeFilter/: range filters added to describe year range queries (currently used in types: result & project).
2. utils/properties/searchFields.ts:
'uniqueValue: boolean' changed to 'filterType: string' with value among: null (if this is not a range/refine filter), radio, checkbox, range.
RANGE_FIELDS added for each type needed.
'fieldHasUniqueValue()' method renamed to 'getFieldFilterType()' method.
'getFieldParam()' method added.
3. utils/properties/searchFields.ts & services/servicesUtils/refineResults.class.ts & searchPages/searchUtils/searchHelperClasses.class.ts
& searchPages/dataProviders/ & searchPages/searchDataProviders.component.ts & searchPages/searchOrganizations.component.ts: 'filterType' field is used.
4. searchPages/searchProjects.component.ts & searchPages/searchResearchResults.component.ts: Initialize and use in calculations range filters.
5. searchPages/searchUtils/searchFilter.component: Update filters to match redesign & use them everywhere (not special case if search or deposit).
6. searchPages/searchUtils/newSearchPage.component: Update filters to match redesign and add range filters.