From a5497aefff3a5b854ab00c0d269ea013309e4524 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Mon, 5 Mar 2018 14:18:00 +0200 Subject: [PATCH 1/3] Make listing geolocation optional --- src/util/types.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/types.js b/src/util/types.js index d444498c..feec3558 100644 --- a/src/util/types.js +++ b/src/util/types.js @@ -146,7 +146,7 @@ const LISTING_STATES = [ const listingAttributes = shape({ title: string.isRequired, description: string.isRequired, - geolocation: propTypes.latlng.isRequired, + geolocation: propTypes.latlng, deleted: propTypes.value(false).isRequired, state: oneOf(LISTING_STATES).isRequired, price: propTypes.money, @@ -156,7 +156,7 @@ const listingAttributes = shape({ const ownListingAttributes = shape({ title: string.isRequired, description: string.isRequired, - geolocation: propTypes.latlng.isRequired, + geolocation: propTypes.latlng, deleted: propTypes.value(false).isRequired, state: oneOf(LISTING_STATES).isRequired, price: propTypes.money, From 709ddf61d830e77e21b7e1f1b868f67c84c87255 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Mon, 5 Mar 2018 14:18:41 +0200 Subject: [PATCH 2/3] Filter out listings without location for the SearchMap --- src/components/SearchMap/SearchMap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/SearchMap/SearchMap.js b/src/components/SearchMap/SearchMap.js index e9cedce1..6c1f456b 100644 --- a/src/components/SearchMap/SearchMap.js +++ b/src/components/SearchMap/SearchMap.js @@ -241,9 +241,10 @@ export class SearchMapComponent extends Component { const classes = classNames(rootClassName || css.root, className); const mapClasses = mapRootClassName || css.mapRoot; + const listingsWithLocation = originalListings.filter(l => !!l.attributes.geolocation); const listings = coordinatesConfig.fuzzy - ? withCoordinatesObfuscated(originalListings) - : originalListings; + ? withCoordinatesObfuscated(listingsWithLocation) + : listingsWithLocation; // container element listens clicks so that opened SearchMapInfoCard can be closed /* eslint-disable jsx-a11y/no-static-element-interactions */ From 7cf93b0d12ae4d3daf1fd5e4e035bf0f38a53c82 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Mon, 5 Mar 2018 14:34:16 +0200 Subject: [PATCH 3/3] Allow accessing wizard tabs in edit more with missing data --- src/components/EditListingWizard/EditListingWizard.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/EditListingWizard/EditListingWizard.js b/src/components/EditListingWizard/EditListingWizard.js index a12992a4..8bb20934 100644 --- a/src/components/EditListingWizard/EditListingWizard.js +++ b/src/components/EditListingWizard/EditListingWizard.js @@ -77,16 +77,18 @@ const tabCompleted = (tab, listing) => { /** * Check which wizard tabs are active and which are not yet available. Tab is active if previous - * tab is completed. + * tab is completed. In edit mode all tabs are active. * + * @param isNew flag if a new listing is being created or an old one being edited * @param listing data to be checked * * @return object containing activity / editability of different tabs of this wizard */ -const tabsActive = listing => { +const tabsActive = (isNew, listing) => { return TABS.reduce((acc, tab) => { const previousTabIndex = TABS.findIndex(t => t === tab) - 1; - const isActive = previousTabIndex >= 0 ? tabCompleted(TABS[previousTabIndex], listing) : true; + const isActive = + previousTabIndex >= 0 ? !isNew || tabCompleted(TABS[previousTabIndex], listing) : true; return { ...acc, [tab]: isActive }; }, {}); }; @@ -198,7 +200,7 @@ class EditListingWizard extends Component { const rootClasses = rootClassName || css.root; const classes = classNames(rootClasses, className); const currentListing = ensureListing(listing); - const tabsStatus = tabsActive(currentListing); + const tabsStatus = tabsActive(isNew, currentListing); // If selectedTab is not active, redirect to the beginning of wizard if (!tabsStatus[selectedTab]) {