Newer
Older
<template>
<div class="red card">
<div class="content">
<div class="center aligned header">
Derniers signalements
</div>
<div class="center aligned description">
<div
:class="{ active: loading }"
class="ui inverted dimmer"
>
<div class="ui text loader">
Récupération des signalements en cours...
</div>
</div>
<div class="ui relaxed list">

Timothee P
committed
<div

Timothee P
committed
v-for="(item, index) in features.slice(0,5)"

Timothee P
committed
class="item"
>
<div class="content">
<div>
<FeatureFetchOffsetRoute
:feature-id="item.id"
:properties="item.properties"
/>
</div>
<div class="description">
<em>
[{{ item.properties.created_on }}
<span v-if="user && item.properties.creator">
, par
{{
item.properties.creator.full_name
? item.properties.creator.full_name
: item.properties.creator.username
}}
</span>
]
</em>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex';

Timothee P
committed
import FeatureFetchOffsetRoute from '@/components/Feature/FeatureFetchOffsetRoute';

Timothee P
committed

Timothee P
committed
components: {

Timothee P
committed
FeatureFetchOffsetRoute,

Timothee P
committed
},
data() {
return {
loading: true,
};
},
computed: {
...mapState('feature', [
'features'
]),

Timothee P
committed
...mapState([
'user'
]),

Timothee P
committed
},
mounted() {
this.fetchLastFeatures();
},
methods: {
fetchLastFeatures() {
this.loading = true;
this.$store.dispatch('feature/GET_PROJECT_FEATURES', {
project_slug: this.$route.params.slug,
ordering: '-created_on',
limit: 5,
})
.then(() => {
this.loading = false;
})
.catch((err) => {
console.error(err);
this.loading = false;
});
}
}