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

Merge branch 'develop' into redmine-issues/14053-fast_edition

parents 7d3c8ac4 e996b3ca
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<h1 class="ui header"> <h1 class="ui header">
<div class="content"> <div class="content">
<span <span
v-if="fastEditionMode && form" v-if="fastEditionMode && form && canEditFeature"
class="form ui half-block" class="form ui half-block"
> >
<input <input
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</button> </button>
<button <button
v-if="fastEditionMode && userCanFastEdit" v-if="fastEditionMode && canEditFeature"
id="save-fast-edit" id="save-fast-edit"
:class="['ui button button-hover-orange tiny-margin', { disabled: false }]" :class="['ui button button-hover-orange tiny-margin', { disabled: false }]"
data-tooltip="Enregistrer les modifications" data-tooltip="Enregistrer les modifications"
...@@ -106,11 +106,7 @@ ...@@ -106,11 +106,7 @@
</router-link> </router-link>
<router-link <router-link
v-if="slugSignal && v-if="slugSignal && canEditFeature"
((permissions && permissions.can_update_feature) ||
isFeatureCreator ||
isModerator)
"
id="edit-feature" id="edit-feature"
:to="{ :to="{
name: 'editer-signalement', name: 'editer-signalement',
...@@ -147,7 +143,7 @@ ...@@ -147,7 +143,7 @@
<div class="ui hidden divider" /> <div class="ui hidden divider" />
<div class="sub header prewrap"> <div class="sub header prewrap">
<span <span
v-if="fastEditionMode && form" v-if="fastEditionMode && canEditFeature && form"
class="form ui half-block" class="form ui half-block"
> >
<textarea <textarea
...@@ -196,12 +192,19 @@ export default { ...@@ -196,12 +192,19 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isFeatureCreator: {
type: Boolean,
default: false,
},
canEditFeature: {
type: Boolean,
default: false,
},
}, },
computed: { computed: {
...mapState([ ...mapState([
'user', 'user',
'USER_LEVEL_PROJECTS',
'isOnline', 'isOnline',
]), ]),
...mapState('feature', [ ...mapState('feature', [
...@@ -212,24 +215,6 @@ export default { ...@@ -212,24 +215,6 @@ export default {
'permissions', 'permissions',
]), ]),
isFeatureCreator() {
if (this.currentFeature && this.user) {
return this.currentFeature.creator === this.user.id;
}
return false;
},
isModerator() {
return this.USER_LEVEL_PROJECTS && this.USER_LEVEL_PROJECTS[this.$route.params.slug] === 'Modérateur';
},
userCanFastEdit() {
const superiorRoles = ['contributor', 'super_contributor', 'moderator', 'admin'];
return this.USER_LEVEL_PROJECTS &&
superiorRoles.includes(this.USER_LEVEL_PROJECTS[this.$route.params.slug]) ||
this.user.is_superuser;
},
queryparams() { queryparams() {
return this.$route.query.offset >= 0 ? { return this.$route.query.offset >= 0 ? {
previous: parseInt(this.$route.query.offset) - 1, previous: parseInt(this.$route.query.offset) - 1,
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<td> <td>
<strong class="ui form"> <strong class="ui form">
<span <span
v-if="fastEditionMode && extra_forms.length > 0" v-if="fastEditionMode && canEditFeature && extra_forms.length > 0"
:id="field.label" :id="field.label"
> >
<FeatureExtraForm <FeatureExtraForm
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
aria-hidden="true" aria-hidden="true"
/> />
<FeatureEditStatusField <FeatureEditStatusField
v-if="fastEditionMode && form" v-if="fastEditionMode && canEditFeature && form"
:status="form.status.value" :status="form.status.value"
class="inline" class="inline"
/> />
...@@ -162,7 +162,11 @@ export default { ...@@ -162,7 +162,11 @@ export default {
fastEditionMode: { fastEditionMode: {
type: Boolean, type: Boolean,
default: false, default: false,
} },
canEditFeature: {
type: Boolean,
default: false,
},
}, },
computed: { computed: {
......
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
allowedStatusChoices() { allowedStatusChoices() {
if (this.project && this.currentFeature && this.user) { if (this.project && this.currentFeature && this.user) {
const isModerate = this.project.moderation; const isModerate = this.project.moderation;
const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug]; const userStatus = this.USER_LEVEL_PROJECTS && this.USER_LEVEL_PROJECTS[this.project.slug];
const isOwnFeature = this.currentFeature.creator === this.user.id; //* si le contributeur est l'auteur du signalement const isOwnFeature = this.currentFeature.creator === this.user.id; //* si le contributeur est l'auteur du signalement
return allowedStatus2change(this.user, isModerate, userStatus, isOwnFeature, /* this.currentRouteName */); return allowedStatus2change(this.user, isModerate, userStatus, isOwnFeature, /* this.currentRouteName */);
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
:feature-type="featureType" :feature-type="featureType"
:fast-edition-mode="project.fast_edition_mode" :fast-edition-mode="project.fast_edition_mode"
:display-to-list-button="displayToListButton" :display-to-list-button="displayToListButton"
:is-feature-creator="isFeatureCreator"
:can-edit-feature="canEditFeature"
@setIsCancelling="isCanceling = true" @setIsCancelling="isCanceling = true"
@tofeature="pushNgo" @tofeature="pushNgo"
/> />
...@@ -24,6 +26,7 @@ ...@@ -24,6 +26,7 @@
v-if="project" v-if="project"
:feature-type="featureType" :feature-type="featureType"
:fast-edition-mode="project.fast_edition_mode" :fast-edition-mode="project.fast_edition_mode"
:can-edit-feature="canEditFeature"
@tofeature="pushNgo" @tofeature="pushNgo"
/> />
</div> </div>
...@@ -101,7 +104,7 @@ ...@@ -101,7 +104,7 @@
</template> </template>
<script> <script>
import { mapState, mapActions, mapMutations } from 'vuex'; import { mapState, mapActions, mapMutations, mapGetters } from 'vuex';
import mapService from '@/services/map-service'; import mapService from '@/services/map-service';
import axios from '@/axios-client.js'; import axios from '@/axios-client.js';
...@@ -177,6 +180,9 @@ export default { ...@@ -177,6 +180,9 @@ export default {
}, },
computed: { computed: {
...mapState([
'USER_LEVEL_PROJECTS',
]),
...mapState('projects', [ ...mapState('projects', [
'project' 'project'
]), ]),
...@@ -188,6 +194,9 @@ export default { ...@@ -188,6 +194,9 @@ export default {
'currentFeature', 'currentFeature',
'form', 'form',
]), ]),
...mapGetters([
'permissions',
]),
hasUnsavedChange() { hasUnsavedChange() {
if (this.form) { if (this.form) {
...@@ -200,6 +209,23 @@ export default { ...@@ -200,6 +209,23 @@ export default {
} }
} }
return false; return false;
},
isFeatureCreator() {
if (this.currentFeature && this.user) {
return this.currentFeature.creator === this.user.id;
}
return false;
},
isModerator() {
return this.USER_LEVEL_PROJECTS && this.USER_LEVEL_PROJECTS[this.$route.params.slug] === 'Modérateur';
},
canEditFeature() {
return (this.permissions && this.permissions.can_update_feature) ||
this.isFeatureCreator ||
this.isModerator;
} }
}, },
......
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