From 037484134b078eb3bc551ead8166ce49820792fa Mon Sep 17 00:00:00 2001 From: Gabriel Dutra Date: Wed, 18 Sep 2019 19:41:52 -0300 Subject: [PATCH] Use simpler separator for DateRange url param --- .../app/services/parameters/DateRangeParameter.js | 15 +++++++-------- client/app/services/parameters/EnumParameter.js | 2 -- client/app/services/parameters/Parameter.js | 2 -- .../parameters/QueryBasedDropdownParameter.js | 2 -- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/client/app/services/parameters/DateRangeParameter.js b/client/app/services/parameters/DateRangeParameter.js index f24e4ee458..9a052bd1fb 100644 --- a/client/app/services/parameters/DateRangeParameter.js +++ b/client/app/services/parameters/DateRangeParameter.js @@ -135,9 +135,7 @@ class DateRangeParameter extends Parameter { const prefix = this.urlPrefix; if (isObject(this.value) && this.value.start && this.value.end) { return { - [`${prefix}${this.name}`]: null, - [`${prefix}${this.name}.start`]: this.value.start, - [`${prefix}${this.name}.end`]: this.value.end, + [`${prefix}${this.name}`]: `${this.value.start}--${this.value.end}`, }; } return super.toUrlParams(); @@ -146,12 +144,13 @@ class DateRangeParameter extends Parameter { fromUrlParams(query) { const prefix = this.urlPrefix; const key = `${prefix}${this.name}`; - const keyStart = `${prefix}${this.name}.start`; - const keyEnd = `${prefix}${this.name}.end`; if (has(query, key)) { - this.setValue(query[key]); - } else if (has(query, keyStart) && has(query, keyEnd)) { - this.setValue([query[keyStart], query[keyEnd]]); + const dates = query[key].split('--'); + if (dates.length === 2) { + this.setValue(dates); + } else { + this.setValue(query[key]); + } } } diff --git a/client/app/services/parameters/EnumParameter.js b/client/app/services/parameters/EnumParameter.js index 952bc3a126..6999df730e 100644 --- a/client/app/services/parameters/EnumParameter.js +++ b/client/app/services/parameters/EnumParameter.js @@ -48,8 +48,6 @@ class EnumParameter extends Parameter { return { [`${prefix}${this.name}`]: !this.isEmpty ? urlParam : null, - [`${prefix}${this.name}.start`]: null, - [`${prefix}${this.name}.end`]: null, }; } diff --git a/client/app/services/parameters/Parameter.js b/client/app/services/parameters/Parameter.js index d08ececa9c..05ee72cd46 100644 --- a/client/app/services/parameters/Parameter.js +++ b/client/app/services/parameters/Parameter.js @@ -124,8 +124,6 @@ class Parameter { // `null` removes the parameter from the URL in case it exists return { [`${prefix}${this.name}`]: !this.isEmpty ? this.value : null, - [`${prefix}${this.name}.start`]: null, - [`${prefix}${this.name}.end`]: null, }; } diff --git a/client/app/services/parameters/QueryBasedDropdownParameter.js b/client/app/services/parameters/QueryBasedDropdownParameter.js index 86200513ca..7bad235184 100644 --- a/client/app/services/parameters/QueryBasedDropdownParameter.js +++ b/client/app/services/parameters/QueryBasedDropdownParameter.js @@ -32,8 +32,6 @@ class QueryBasedDropdownParameter extends Parameter { return { [`${prefix}${this.name}`]: !this.isEmpty ? urlParam : null, - [`${prefix}${this.name}.start`]: null, - [`${prefix}${this.name}.end`]: null, }; }