Interactive interface for browsing global, full-resolution satellite imagery
fix issue with date url params
Jason Kent252873556045
diff --git a/web/js/components/sidebar/events-filter.js b/web/js/components/sidebar/events-filter.jsindex ffc1753e8..3cb9c951b 100644--- a/web/js/components/sidebar/events-filter.js+++ b/web/js/components/sidebar/events-filter.js@@ -54,7 +54,7 @@ function EventsFilter (props) {setAllNone(!allNone);};- const disableApply = !categories.length || (!startDate && endDate) || (!endDate && startDate);+ const disableApply = !categories.length || !!(!startDate && endDate) || !!(!endDate && startDate);const getDisableApplyMsg = () => {let msg = '';diff --git a/web/js/location.js b/web/js/location.jsindex 08bb1a029..06549d1e9 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -316,17 +316,22 @@ const getParameters = function(config, parameters) {},efd: {stateKey: 'events.selectedDates',- type: 'string',- initialState: eventsReducerState.selectedDates,+ type: 'object',+ initialState: {+ start: undefined,+ end: undefined,+ },options: {parse: parseEventFilterDates,serialize: serializeEventFilterDates,+ serializeNeedsGlobalState: true,+ setAsEmptyItem: true,},},efc: {stateKey: 'events.selectedCategories',type: 'array',- initialState: [],+ initialState: eventsReducerState.selectedCategories,options: {serialize: serializeCategories,serializeNeedsGlobalState: true,diff --git a/web/js/modules/natural-events/util.js b/web/js/modules/natural-events/util.jsindex 6b2dd9997..046f74b8d 100644--- a/web/js/modules/natural-events/util.js+++ b/web/js/modules/natural-events/util.js@@ -37,10 +37,13 @@ export function parseEventFilterDates(eventFilterDatesString) {};}-export function serializeEventFilterDates(currentItemState) {+export function serializeEventFilterDates(currentItemState, state) {const selectedStartDate = get(currentItemState, 'start');const selectedEndDate = get(currentItemState, 'end');- return selectedStartDate && selectedEndDate && `${selectedStartDate},${selectedEndDate}`;+ const eventsTabActive = state.events.active;+ return eventsTabActive && selectedStartDate && selectedEndDate+ ? `${selectedStartDate},${selectedEndDate}`+ : undefined;}export function serializeCategories(categories, state) {@@ -50,15 +53,25 @@ export function serializeCategories(categories, state) {export function mapLocationToEventFilterState(parameters, stateFromLocation, state) {const allCategories = state.config.naturalEvents.categories;+ const { selected, selectedDates } = stateFromLocation.events;const selectedIds = parameters.efc? parameters.efc.split(','): allCategories.map(({ id }) => id);const selectedCategories = !allCategories.length? []: selectedIds.map((id) => allCategories.find((c) => c.id === id));- const [selectedStartDate, selectedEndDate] = parameters.efd++ let [selectedStartDate, selectedEndDate] = parameters.efd? parameters.efd.split(',')- : [undefined, undefined];+ : [selectedDates.start, selectedDates.end];++ const eventIsSelected = selected.id && selected.date;+ const filterDatesAreSet = selectedStartDate && selectedEndDate;+ if (eventIsSelected && !filterDatesAreSet) {+ selectedStartDate = selected.date;+ selectedEndDate = selected.date;+ }+return update(stateFromLocation, {events: {selectedCategories: {