diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index f81219b0..c1b85d02 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -360,15 +360,18 @@ export class NewSearchPageComponent { //console.log("checkSelectedRangeFilters: yearFrom: " + yearFrom + " - yearTo: "+yearTo); if(yearFrom) { filter.selectedFromValue = yearFrom; - filter.selectedFromAndToValues = yearFrom; - } - if(yearFrom && yearTo) { - filter.selectedFromAndToValues += "-"; } if(yearTo) { filter.selectedToValue = yearTo; - filter.selectedFromAndToValues += yearTo; } + if(yearFrom && yearTo) { + filter.selectedFromAndToValues = yearFrom + "-" + yearTo; + } else if(yearFrom) { + filter.selectedFromAndToValues = "from " + yearFrom; + } else if(yearTo) { + filter.selectedFromAndToValues = "until " + yearTo; + } + if(!yearFrom && !yearTo) { validDates = false; } diff --git a/searchPages/searchUtils/searchFilter.component.html b/searchPages/searchUtils/searchFilter.component.html index ea3b809e..956eff5a 100644 --- a/searchPages/searchUtils/searchFilter.component.html +++ b/searchPages/searchUtils/searchFilter.component.html @@ -7,38 +7,56 @@ diff --git a/searchPages/searchUtils/searchFilter.component.ts b/searchPages/searchUtils/searchFilter.component.ts index 183ecd4a..c32577b6 100644 --- a/searchPages/searchUtils/searchFilter.component.ts +++ b/searchPages/searchUtils/searchFilter.component.ts @@ -22,7 +22,7 @@ export class SearchFilterComponent { @Output() modalChange = new EventEmitter(); @Output() onFilterChange = new EventEmitter(); keyword = ""; - sortBy = "num"; + sortBy = "name"; public isOpen:boolean=false; @@ -32,7 +32,7 @@ export class SearchFilterComponent { ngOnInit() {} public _formatTitle(title,length){ - return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title+" ("+((length >= 99)?length+"+":length)+")") + return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title+" ("+length+")") } public _formatName(value){ //let maxLineLength = 24; @@ -59,14 +59,14 @@ export class SearchFilterComponent { return true; } filterChange(selected:boolean){ - if(selected){ - this.filter.countSelectedValues++; - }else{ - this.filter.countSelectedValues--; - } - this.onFilterChange.emit({ - value: this.filter - }); + if(selected){ + this.filter.countSelectedValues++; + }else{ + this.filter.countSelectedValues--; + } + // this.onFilterChange.emit({ + // value: this.filter + // }); } uniqueFilterChange(value: Value) { let tmp = value.selected; @@ -78,9 +78,9 @@ export class SearchFilterComponent { this.filter.countSelectedValues--; } - this.onFilterChange.emit({ - value: this.filter - }); + // this.onFilterChange.emit({ + // value: this.filter + // }); } clearFilter() { for (var i=0; i < this.filter.values.length; i++){ @@ -91,6 +91,28 @@ export class SearchFilterComponent { value: this.filter }); } + + getSelectedAndTopValues(filter, topNum: number = 6):any{ + var values = []; + + for (let i=0; i < topNum; i++){ + if(filter.values.length <= i) { + break; + } + values.push(filter.values[i]); + } + + if(filter.countSelectedValues >0){ + for (let i=topNum; i < filter.values.length; i++){ + if(filter.values[i].selected){ + values.push(filter.values[i]); + } + } + } + + return values; + } + getSelectedValues(filter, sortBy:string = "num"):any{ var selected = []; if(filter.countSelectedValues >0){ @@ -141,6 +163,25 @@ export class SearchFilterComponent { return notSselected; } + sort(values: Value[]) { + let sorted: Value[] = values.slice(); + if(this.sortBy == "name"){ + + sorted.sort((n1,n2)=> { + if (n1.name > n2.name) { + return 1; + } + + if (n1.name < n2.name) { + return -1; + } + + return 0; + }); + } + return sorted; + } + toggle() { this.isOpen = !this.isOpen; }