Newer
Older
Sébastien DA ROCHA
committed
<template>
<div class="fourteen wide column">
Sébastien DA ROCHA
committed
</h2>
v-if="user && user.can_create_project && isOffline() != true"
:to="{ name: 'project_create', params: { action: 'create' } }"
class="ui green basic button"
>
<i class="plus icon" /> Créer un nouveau projet
v-if="user && user.can_create_project && isOffline() != true"
:to="{
name: 'project_type_list',
}"
class="ui blue basic button"
>
<i class="copy icon" /> Accéder à la liste des modèles de projets
<!-- FILTRES DES PROJETS -->
@filter="setProjectsFilters"
<div
v-if="configuration.DISPLAY_FORBIDDEN_PROJECTS"
id="forbidden-projects"
class="ui toggle checkbox"
>
<input
v-model="displayForbiddenProjects"
type="checkbox"
<label>
N'afficher que les projets disponibles à la consultation
</label>
</div>
<div
v-if="projects"
class="ui divided items dimmable dimmed"
>
<div
:class="{ active: loading }"
class="ui inverted dimmer"
>
<div
v-for="project in projects"
:key="project.slug"
class="item"
>
Sébastien DA ROCHA
committed
<div class="ui tiny image">
<img
:src="
!project.thumbnail
? require('@/assets/img/default.png')
: DJANGO_BASE_URL + project.thumbnail + refreshId()
"
Sébastien DA ROCHA
committed
</div>
<div class="middle aligned content">
<router-link
:to="{
name: 'project_detail',
params: { slug: project.slug },
}"
class="header"
>
Sébastien DA ROCHA
committed
<div class="description">
<p>{{ project.description }}</p>
</div>
<div class="meta">
<span class="right floated">
<strong v-if="project.moderation">Projet modéré</strong>
<strong v-else>Projet non modéré</strong>
</span>
<span>Niveau d'autorisation requis :
{{ project.access_level_pub_feature }}</span><br>
Sébastien DA ROCHA
committed
Mon niveau d'autorisation :
<span v-if="USER_LEVEL_PROJECTS && project">{{
USER_LEVEL_PROJECTS[project.slug]
}}</span>
<span v-if="user && user.is_administrator">{{
"+ Gestionnaire métier"
}}</span>
</span>
</div>
<div class="meta">
<span class="right floated">
<i class="calendar icon" /> {{ project.created_on }}
Sébastien DA ROCHA
committed
</span>
<span data-tooltip="Membres">
{{ project.nb_contributors }} <i class="user icon" />
Sébastien DA ROCHA
committed
</span>
Sébastien DA ROCHA
committed
{{ project.nb_published_features }} <i
class="map marker icon"
Sébastien DA ROCHA
committed
</span>
<span data-tooltip="Commentaires">
{{ project.nb_published_features_comments }} <i
class="comment icon"
Sébastien DA ROCHA
committed
</span>
</div>
</div>
</div>
<span
v-if="!projects || projects.length === 0"
>Vous n'avez accès à aucun projet.</span>
Sébastien DA ROCHA
committed
Sébastien DA ROCHA
committed
</div>
Sébastien DA ROCHA
committed
</div>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex';
Sébastien DA ROCHA
committed
import ProjectsMenu from '@/components/Projects/ProjectsMenu.vue';
Sébastien DA ROCHA
committed
export default {
data() {
return {
displayForbiddenProjects: false
Sébastien DA ROCHA
committed
computed: {
'configuration',
'user',
'USER_LEVEL_PROJECTS'
]),
...mapState('projects', [
'projects',
'count',
'filters'
Sébastien DA ROCHA
committed
return this.$store.state.configuration.VUE_APP_APPLICATION_NAME;
},
Sébastien DA ROCHA
committed
return this.$store.state.configuration.VUE_APP_APPLICATION_ABSTRACT;
},
Sébastien DA ROCHA
committed
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
logo() {
return this.$store.state.configuration.VUE_APP_LOGO_PATH;
},
Sébastien DA ROCHA
committed
},
watch: {
filters: {
deep: true,
handler(newValue) {
if (newValue) {
this.getData();
}
}
},
displayForbiddenProjects(newValue) {
if (newValue) {
this.SET_PROJECTS_FILTER({
filter: 'accessible',
value: 'true'
});
} else {
this.SET_PROJECTS_FILTER({
filter: 'accessible',
value: null
});
}
this.getData();
}
},
created() {
this.$store.commit('projects/SET_PROJECT', null);
this.SET_PROJECTS_FILTER({
filter: 'accessible',
value: 'true'
});
this.displayForbiddenProjects = this.configuration.DISPLAY_FORBIDDEN_PROJECTS_DEFAULT;
Sébastien DA ROCHA
committed
methods: {
'SET_CURRENT_PAGE',
'SET_PROJECTS_FILTER'
]),
...mapActions('projects', [
'GET_PROJECTS'
isOffline() {
return navigator.onLine == false;
Sébastien DA ROCHA
committed
refreshId() {
//* change path of thumbnail to update image
Sébastien DA ROCHA
committed
},
getData(page) {
this.loading = true;
this.GET_PROJECTS(page)
.then(() => {
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
changePage(e) {
this.getData(e);
},
setProjectsFilters(e) {
this.SET_PROJECTS_FILTER(e);
Sébastien DA ROCHA
committed
};
<style lang="less" scoped>
.flex {
display: flex;
justify-content: space-between;
}
#filters-divider {
padding-top: 0;
color: gray !important;
}
#forbidden-projects.checkbox {
font-size: 1.2em;
font-weight: 600;
label {
color: rgb(94, 94, 94);
}
input:checked ~ label::before {
background-color: teal !important;
}
input:checked ~ label {
color: teal !important;
}
}