Skip to content
Snippets Groups Projects
Commit f714c215 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

Filter available status & fix table style

parent e0201fa2
No related branches found
No related tags found
2 merge requests!295Version 3.0.0,!232REDMINE_ISSUE-11834
<template> <template>
<div data-tab="list" class="dataTables_wrapper no-footer"> <div data-tab="list" class="dataTables_wrapper no-footer">
<table id="table-features" class="ui compact table"> <table id="table-features" class="ui compact table dataTable">
<thead> <thead>
<tr> <tr>
<th class="center"></th> <th class="dt-center"></th>
<th class="center"> <th class="dt-center">
Statut Statut
<i <i
:class="{ :class="{
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
@click="changeSort('status')" @click="changeSort('status')"
/> />
</th> </th>
<th class="center"> <th class="dt-center">
Type Type
<i <i
:class="{ :class="{
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
@click="changeSort('feature_type')" @click="changeSort('feature_type')"
/> />
</th> </th>
<th class="center"> <th class="dt-center">
Nom Nom
<i <i
:class="{ :class="{
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
@click="changeSort('title')" @click="changeSort('title')"
/> />
</th> </th>
<th class="center"> <th class="dt-center">
Dernière modification Dernière modification
<i <i
:class="{ :class="{
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
@click="changeSort('updated_on')" @click="changeSort('updated_on')"
/> />
</th> </th>
<th class="center" v-if="user"> <th class="dt-center" v-if="user">
Auteur Auteur
<i <i
:class="{ :class="{
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
@click="changeSort('display_creator')" @click="changeSort('display_creator')"
/> />
</th> </th>
<th class="center" v-if="user"> <th class="dt-center" v-if="user">
Dernier éditeur Dernier éditeur
<i <i
:class="{ :class="{
...@@ -76,27 +76,25 @@ ...@@ -76,27 +76,25 @@
</thead> </thead>
<tbody> <tbody>
<tr v-for="(feature, index) in paginatedFeatures" :key="index"> <tr v-for="(feature, index) in paginatedFeatures" :key="index">
<td class="center"> <td class="dt-center">
<div <div
:class="['ui checkbox', {disabled: isEditDisabled(feature)}]" :class="['ui checkbox', {disabled: !canEditFeature(feature)}]"
> >
<!-- :class="['ui checkbox', {disabled: canDeleteFeature(feature)}]" -->
<input <input
type="checkbox" type="checkbox"
v-model="checked"
@input="storeClickedFeature(feature)" @input="storeClickedFeature(feature)"
:id="feature.id" :id="feature.id"
:value="feature.id" :value="feature.id"
v-model="checked" :disabled="!canEditFeature(feature)"
:disabled="isEditDisabled(feature)"
name="select" name="select"
/> />
<label for="select"></label> <label for="select"></label>
<!-- :disabled="canDeleteFeature(feature)" -->
</div> </div>
{{canDeleteFeature(feature)}} {{canDeleteFeature(feature)}}
</td> </td>
<td class="center"> <td class="dt-center">
<div <div
v-if="feature.properties.status.value === 'archived'" v-if="feature.properties.status.value === 'archived'"
data-tooltip="Archivé" data-tooltip="Archivé"
...@@ -122,7 +120,7 @@ ...@@ -122,7 +120,7 @@
<i class="orange pencil alternate icon"></i> <i class="orange pencil alternate icon"></i>
</div> </div>
</td> </td>
<td class="center"> <td class="dt-center">
<router-link <router-link
:to="{ :to="{
name: 'details-type-signalement', name: 'details-type-signalement',
...@@ -134,7 +132,7 @@ ...@@ -134,7 +132,7 @@
{{ feature.properties.feature_type.title }} {{ feature.properties.feature_type.title }}
</router-link> </router-link>
</td> </td>
<td class="center"> <td class="dt-center">
<router-link <router-link
:to="{ :to="{
name: 'details-signalement', name: 'details-signalement',
...@@ -146,13 +144,13 @@ ...@@ -146,13 +144,13 @@
>{{ getFeatureDisplayName(feature) }}</router-link >{{ getFeatureDisplayName(feature) }}</router-link
> >
</td> </td>
<td class="center"> <td class="dt-center">
{{ feature.properties.updated_on }} {{ feature.properties.updated_on }}
</td> </td>
<td class="center" v-if="user"> <td class="dt-center" v-if="user">
{{ getUserName(feature) }} {{ getUserName(feature) }}
</td> </td>
<td class="center" v-if="user"> <td class="dt-center" v-if="user">
{{ feature.properties.display_last_editor }} {{ feature.properties.display_last_editor }}
</td> </td>
</tr> </tr>
...@@ -325,7 +323,7 @@ export default { ...@@ -325,7 +323,7 @@ export default {
!this.permissions.is_project_administrator !this.permissions.is_project_administrator
}, },
isEditDisabled(feature) { canEditFeature(feature) {
const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug]; const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug];
const access = { const access = {
"Administrateur projet" : ["draft", "published", "archived"], "Administrateur projet" : ["draft", "published", "archived"],
...@@ -334,11 +332,15 @@ export default { ...@@ -334,11 +332,15 @@ export default {
"Contributeur" : ["draft", this.project.moderation ? "pending" : "published"], "Contributeur" : ["draft", this.project.moderation ? "pending" : "published"],
}; };
if (userStatus === "Contributeur") { //if (userStatus === "Super Contributeur" || userStatus === "Contributeur") { //? should super contributeur behave the same, I don't think so
//if (userStatus === "Super Contributeur" || userStatus === "Contributeur") { if (userStatus === "Contributeur" && feature.properties.creator.username !== this.user.username) {
if (feature.properties.creator.username !== this.user.username) return true; return false;
} else if (access[userStatus]) {
return access[userStatus].includes(feature.properties.status.value);
} else {
return false
} }
return !access[userStatus].includes(feature.properties.status.value);
}, },
getUserName(feature) { getUserName(feature) {
...@@ -381,6 +383,9 @@ export default { ...@@ -381,6 +383,9 @@ export default {
position: relative; position: relative;
clear: both; clear: both;
} }
table.dataTable th.dt-center, table.dataTable td.dt-center, table.dataTable td.dataTables_empty {
text-align: center;
}
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_info,
...@@ -533,8 +538,8 @@ and also iPads specifically. ...@@ -533,8 +538,8 @@ and also iPads specifically.
content: "Auteur"; content: "Auteur";
} }
.center { table.dataTable th.dt-center, table.dataTable td.dt-center, table.dataTable td.dataTables_empty {
text-align: right !important; text-align: right;
} }
#table-features { #table-features {
......
...@@ -330,6 +330,7 @@ export default { ...@@ -330,6 +330,7 @@ export default {
}, },
computed: { computed: {
...mapState(["user", "USER_LEVEL_PROJECTS"]),
...mapGetters([ ...mapGetters([
'project', 'permissions' 'project', 'permissions'
]), ]),
...@@ -355,7 +356,55 @@ export default { ...@@ -355,7 +356,55 @@ export default {
}, },
availableStatus() { //* attente de réponse sur le ticket availableStatus() { //* attente de réponse sur le ticket
return this.statusChoices.filter((status) => status) //return this.statusChoices.filter((status) => status)
if (this.project) {
const isModerate = this.project.moderation;
const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug];
const isOwnFeature = this.feature
? this.feature.creator === this.user.id //* prevent undefined feature
: false; //* si le contributeur est l'auteur du signalement
if (
//* si admin, modérateur ou super contributeur, statuts toujours disponible: Brouillon, Publié, Archivé
userStatus === "Administrateur projet" ||
(userStatus === "Super Contributeur" && !isModerate)
) {
return this.statusChoices.filter((el) => el.value !== "pending");
} else if (userStatus === "Super Contributeur" && isModerate) {
return this.statusChoices.filter(
(el) => el.value === "draft" || el.value === "pending"
);
} else if (userStatus === "Modérateur") {
return this.statusChoices.filter(
(el) => el.value === "draft" || el.value === "published"
);
} else if (userStatus === "Contributeur") {
//* cas particuliers du contributeur
if (
this.currentRouteName === "ajouter-signalement" ||
!isOwnFeature
) {
//* même cas à l'ajout d'une feature ou si feature n'a pas été créé par le contributeur
return isModerate
? this.statusChoices.filter(
(el) => el.value === "draft" || el.value === "pending"
)
: this.statusChoices.filter(
(el) => el.value === "draft" || el.value === "published"
);
} else {
//* à l'édition d'une feature et si le contributeur est l'auteur de la feature
return isModerate
? this.statusChoices.filter(
(el) => el.value !== "published" //* toutes sauf "Publié"
)
: this.statusChoices.filter(
(el) => el.value !== "pending" //* toutes sauf "En cours de publication"
);
}
}
}
return [];
}, },
featureTypeChoices() { featureTypeChoices() {
...@@ -668,10 +717,6 @@ export default { ...@@ -668,10 +717,6 @@ export default {
z-index: 1; z-index: 1;
} }
.center {
text-align: center !important;
}
#feature-list-container { #feature-list-container {
justify-content: flex-start; justify-content: flex-start;
} }
...@@ -703,15 +748,14 @@ export default { ...@@ -703,15 +748,14 @@ export default {
width: 75% !important; width: 75% !important;
} }
} }
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
#feature-list-container > .mobile-fullwidth { #feature-list-container > .mobile-fullwidth {
width: 100% !important; width: 100% !important;
} }
.no-margin-mobile { .no-margin-mobile {
margin: 0 !important; margin: 0 !important;
} }
.no-padding-mobile { .no-padding-mobile {
padding-top: 0 !important; padding-top: 0 !important;
padding-bottom: 0 !important; padding-bottom: 0 !important;
...@@ -719,10 +763,12 @@ export default { ...@@ -719,10 +763,12 @@ export default {
.mobile-column { .mobile-column {
flex-direction: column !important; flex-direction: column !important;
} }
#button-dropdown {
transform: translate(-50px, -60px);
}
#form-filters > .field.column { #form-filters > .field.column {
width: 100% !important; width: 100% !important;
} }
.map-container { .map-container {
width: 100%; width: 100%;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment