Fix advanced search

This commit is contained in:
Patrick Gebhardt 2020-06-25 22:18:21 +02:00
parent eaaee3c14a
commit 67ea0587db
3 changed files with 17 additions and 4 deletions

View File

@ -108,7 +108,7 @@
<span class="title">Financial</span>
<span class="desc">| sweetspot selection (€/day)</span>
</div>
<app-toggle-slider [(model)]="costPerDay" [label]="'Cost'" [max]="400" [min]="0"></app-toggle-slider>
<app-toggle-slider [(model)]="costPerDay" [label]="'Total cost'" [max]="400" [min]="0"></app-toggle-slider>
<app-toggle-slider [(model)]="accommodation" [label]="'Accommodation'" [max]="200"
[min]="0"></app-toggle-slider>
<app-toggle-slider [(model)]="localTransport" [label]="'Local transport'" [max]="20"

View File

@ -6,6 +6,7 @@ import {PresetService} from '../../services/preset.service';
import {Preset} from '../../interfaces/preset.interface';
import {formatDate} from '@angular/common';
import {SearchService} from '../../services/search.service';
import {toMinMaxArray} from '../../utils/toMinMaxArray';
@Component({
selector: 'app-search-input',
@ -137,9 +138,14 @@ export class SearchInputComponent implements OnInit {
query.textfilter = this.textFilter;
}
query.temperature_mean_max = this.temperatureMeanMax ? [this.temperatureMeanMax, this.temperatureMeanMax] : undefined;
query.precipitation = this.precipitation ? [this.precipitation, this.precipitation] : undefined;
query.accommodation_costs = this.accommodation ? [this.accommodation, this.accommodation] : undefined;
query.temperature_mean_max = toMinMaxArray(this.temperatureMeanMax);
query.precipitation = toMinMaxArray(this.precipitation);
query.sun_hours = toMinMaxArray(this.sunHours);
query.rain_days = toMinMaxArray(this.rainDays);
query.average_per_day_costs = toMinMaxArray(this.costPerDay);
query.accommodation_costs = toMinMaxArray(this.accommodation);
query.entertainment_costs = toMinMaxArray(this.entertainment);
query.local_transportation_costs = toMinMaxArray(this.localTransport);
return query;
}

View File

@ -0,0 +1,7 @@
/**
* Transforms a value into a min max array.
* @param value The value
*/
export function toMinMaxArray(value: number): number[] {
return value ? [value, value] : undefined;
}