2017-04-13 23:24:31 +02:00
|
|
|
|
<template>
|
|
|
|
|
<div>
|
2017-05-12 16:27:31 +02:00
|
|
|
|
<FlatsMap :flats="flatsMarkers" :places="timeToPlaces"></FlatsMap>
|
2017-04-13 23:24:31 +02:00
|
|
|
|
|
2018-09-28 19:22:43 +02:00
|
|
|
|
<h2>
|
|
|
|
|
{{ $t("home.new_available_flats") }}
|
|
|
|
|
<label class="show-expired-flats-label">
|
|
|
|
|
<input type="checkbox" class="show-expired-flats-checkbox" v-model="showExpiredFlats" />
|
|
|
|
|
Show expired flats
|
|
|
|
|
</label>
|
|
|
|
|
</h2>
|
2017-05-12 16:27:31 +02:00
|
|
|
|
|
|
|
|
|
<template v-if="Object.keys(postalCodesFlatsBuckets).length > 0">
|
|
|
|
|
<template v-for="(postal_code_data, postal_code) in postalCodesFlatsBuckets">
|
2018-09-07 15:06:59 +02:00
|
|
|
|
<h3>{{ postal_code_data.name || $t('common.Unknown') }}
|
|
|
|
|
<span v-if="postal_code !== 'undefined'">
|
|
|
|
|
({{ postal_code }})
|
|
|
|
|
</span>
|
|
|
|
|
- {{ postal_code_data.flats.length }} {{ $tc("common.flats", postal_code_data.flats.length) }}
|
|
|
|
|
</h3>
|
2018-09-28 19:22:43 +02:00
|
|
|
|
<FlatsTable :flats="postal_code_data.flats" :key="postal_code"></FlatsTable>
|
2017-04-13 23:24:31 +02:00
|
|
|
|
</template>
|
|
|
|
|
</template>
|
2017-05-12 16:27:31 +02:00
|
|
|
|
<template v-else-if="isLoading">
|
2017-04-13 23:24:31 +02:00
|
|
|
|
<p>{{ $t("common.loading") }}</p>
|
|
|
|
|
</template>
|
2017-05-12 16:27:31 +02:00
|
|
|
|
<template v-else>
|
|
|
|
|
<p>{{ $t("flatListing.no_available_flats") }}</p>
|
|
|
|
|
</template>
|
2017-04-13 23:24:31 +02:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import FlatsMap from '../components/flatsmap.vue'
|
|
|
|
|
import FlatsTable from '../components/flatstable.vue'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
FlatsMap,
|
|
|
|
|
FlatsTable
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
created () {
|
2017-05-09 17:36:17 +02:00
|
|
|
|
document.title = 'Flatisfy' // Set title
|
2017-05-09 15:29:21 +02:00
|
|
|
|
|
2017-04-13 23:24:31 +02:00
|
|
|
|
// Fetch flats when the component is created
|
|
|
|
|
this.$store.dispatch('getAllFlats')
|
|
|
|
|
// Fetch time to places when the component is created
|
|
|
|
|
this.$store.dispatch('getAllTimeToPlaces')
|
|
|
|
|
},
|
|
|
|
|
|
2018-09-28 19:22:43 +02:00
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
showExpiredFlats: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
2017-04-13 23:24:31 +02:00
|
|
|
|
computed: {
|
|
|
|
|
postalCodesFlatsBuckets () {
|
2018-09-28 19:22:43 +02:00
|
|
|
|
return this.$store.getters.postalCodesFlatsBuckets(flat =>
|
|
|
|
|
flat.status === 'new' &&
|
|
|
|
|
(this.showExpiredFlats || !flat.is_expired)
|
|
|
|
|
)
|
2017-04-13 23:24:31 +02:00
|
|
|
|
},
|
|
|
|
|
flatsMarkers () {
|
2018-09-28 19:22:43 +02:00
|
|
|
|
return this.$store.getters.flatsMarkers(this.$router, flat =>
|
|
|
|
|
flat.status === 'new' &&
|
|
|
|
|
(this.showExpiredFlats || !flat.is_expired)
|
|
|
|
|
)
|
2017-04-13 23:24:31 +02:00
|
|
|
|
},
|
|
|
|
|
timeToPlaces () {
|
|
|
|
|
return this.$store.getters.allTimeToPlaces
|
2017-05-12 16:27:31 +02:00
|
|
|
|
},
|
|
|
|
|
isLoading () {
|
|
|
|
|
return this.$store.getters.isLoading
|
2017-04-13 23:24:31 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2018-09-28 19:22:43 +02:00
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
h2 {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.show-expired-flats-label {
|
|
|
|
|
font-weight: initial;
|
|
|
|
|
font-size: initial;
|
|
|
|
|
}
|
|
|
|
|
</style>
|