diff --git a/flatisfy/web/js_src/store/getters.js b/flatisfy/web/js_src/store/getters.js index f633416..97f3dee 100644 --- a/flatisfy/web/js_src/store/getters.js +++ b/flatisfy/web/js_src/store/getters.js @@ -1,77 +1,88 @@ import { findFlatGPS, costFilter } from '../tools' export default { - allFlats: state => state.flats, + allFlats: (state) => state.flats, - flat: (state, getters) => id => state.flats.find(flat => flat.id === id), + flat: (state, getters) => (id) => + state.flats.find((flat) => flat.id === id), - isLoading: state => state.loading > 0, + isLoading: (state) => state.loading > 0, - postalCodesFlatsBuckets: (state, getters) => filter => { - const postalCodeBuckets = {} + inseeCodesFlatsBuckets: (state, getters) => (filter) => { + const buckets = {}; - state.flats.forEach(flat => { + state.flats.forEach((flat) => { if (!filter || filter(flat)) { - const postalCode = flat.flatisfy_postal_code.postal_code - if (!postalCodeBuckets[postalCode]) { - postalCodeBuckets[postalCode] = { - 'name': flat.flatisfy_postal_code.name, - 'flats': [] - } + const insee = flat.flatisfy_postal_code.insee_code; + if (!buckets[insee]) { + buckets[insee] = { + name: flat.flatisfy_postal_code.name, + flats: [], + }; } - postalCodeBuckets[postalCode].flats.push(flat) + buckets[insee].flats.push(flat); } - }) + }); - return postalCodeBuckets + return buckets; }, flatsMarkers: (state, getters) => (router, filter) => { - const markers = [] - state.flats.forEach(flat => { + const markers = []; + state.flats.forEach((flat) => { if (filter && filter(flat)) { - const gps = findFlatGPS(flat) + const gps = findFlatGPS(flat); if (gps) { const previousMarker = markers.find( - marker => marker.gps[0] === gps[0] && marker.gps[1] === gps[1] - ) + (marker) => + marker.gps[0] === gps[0] && marker.gps[1] === gps[1] + ); if (previousMarker) { - // randomize position a bit - // gps[0] += (Math.random() - 0.5) / 500 - // gps[1] += (Math.random() - 0.5) / 500 + // randomize position a bit + // gps[0] += (Math.random() - 0.5) / 500 + // gps[1] += (Math.random() - 0.5) / 500 } - const href = router.resolve({ name: 'details', params: { id: flat.id }}).href + const href = router.resolve({ + name: "details", + params: { id: flat.id }, + }).href; const cost = flat.cost ? costFilter(flat.cost, flat.currency) - : '' + : ""; markers.push({ - 'title': '', - 'content': '' + flat.title + '' + cost, - 'gps': gps, - 'flat_id': flat.id - }) + title: "", + content: + '' + + flat.title + + "" + + cost, + gps: gps, + flat_id: flat.id, + }); } } - }) + }); - return markers + return markers; }, - allTimeToPlaces: state => { - const places = {} - Object.keys(state.timeToPlaces).forEach(constraint => { - const constraintTimeToPlaces = state.timeToPlaces[constraint] - Object.keys(constraintTimeToPlaces).forEach(name => { - places[name] = constraintTimeToPlaces[name] - }) - }) - return places + allTimeToPlaces: (state) => { + const places = {}; + Object.keys(state.timeToPlaces).forEach((constraint) => { + const constraintTimeToPlaces = state.timeToPlaces[constraint]; + Object.keys(constraintTimeToPlaces).forEach((name) => { + places[name] = constraintTimeToPlaces[name]; + }); + }); + return places; }, timeToPlaces: (state, getters) => (constraintName) => { - return state.timeToPlaces[constraintName] + return state.timeToPlaces[constraintName]; }, - metadata: state => state.metadata -} + metadata: (state) => state.metadata, +}; diff --git a/flatisfy/web/js_src/views/home.vue b/flatisfy/web/js_src/views/home.vue index d6f44a1..c71a5f0 100644 --- a/flatisfy/web/js_src/views/home.vue +++ b/flatisfy/web/js_src/views/home.vue @@ -15,16 +15,16 @@ -