Skip to content
Snippets Groups Projects
Commit 7ea742c6 authored by leandro's avatar leandro
Browse files

add levelPermissions dynamic

parent c393899e
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,7 @@ let onConfigLoaded = function(config){
store.dispatch("GET_USER_LEVEL_PROJECTS"),
store.dispatch("map/GET_AVAILABLE_LAYERS"),
store.dispatch("GET_USER_LEVEL_PERMISSIONS"),
store.dispatch("GET_LEVELS_PERMISSIONS"),
]).then(axios.spread(function () {
new Vue({
router,
......
......@@ -46,6 +46,7 @@ export default new Vuex.Store({
SSO_SETTED: false,
USER_LEVEL_PROJECTS: null,
user_permissions: null,
levelsPermissions: [],
messages: [],
events: null,
loader: {
......@@ -95,6 +96,9 @@ export default new Vuex.Store({
SET_USER_PERMISSIONS(state, userPermissions) {
state.user_permissions = userPermissions;
},
SET_LEVELS_PERMISSIONS(state, levelsPermissions) {
state.levelsPermissions = levelsPermissions;
},
SET_EVENTS(state, events) {
state.events = events;
},
......@@ -280,6 +284,18 @@ export default new Vuex.Store({
throw error;
});
},
GET_LEVELS_PERMISSIONS({ commit }) {
return axios
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}levels-permissions/`)
.then((response) => {
if (response && response.status === 200) {
commit("SET_LEVELS_PERMISSIONS", response.data);
}
})
.catch((error) => {
throw error;
});
},
async GET_PROJECT_INFO({ state, commit, dispatch }, slug) {
commit("SET_PROJECT_SLUG", slug);
......
......@@ -194,7 +194,7 @@
import axios from '@/axios-client.js';
import Dropdown from "@/components/Dropdown.vue";
import { mapGetters } from "vuex";
import { mapState, mapGetters } from "vuex";
// axios.defaults.headers.common["X-CSRFToken"] = ((name) => {
// var re = new RegExp(name + "=([^;]+)");
......@@ -213,11 +213,6 @@ export default {
return {
loading: false,
action: "create",
levelPermissions: [
{ name: "Utilisateur anonyme", value: "anonymous" },
{ name: "Utilisateur connecté", value: "logged_user" },
{ name: "Contributeur", value: "contributor" },
],
fileToImport: {
name: "Sélectionner une image ...",
size: 0,
......@@ -255,10 +250,25 @@ export default {
},
computed: {
...mapState([
"levelsPermissions",
]),
...mapGetters(["project"]),
DJANGO_BASE_URL: function () {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
levelPermissions(){
let self = this;
let levels = []
this.levelsPermissions.map(function(item) {
if (item.user_type_id != "super_contributor")
levels.push({
'name': self.traslateRoleToFrench(item.user_type_id),
'value': item.user_type_id,
})
});
return levels
}
},
methods: {
......@@ -271,6 +281,14 @@ export default {
this.action = "create_from";
}
},
traslateRoleToFrench(role){
if (role == "admin") return "Administrateur de projet";
if (role == "moderator") return "Modérateur";
if (role == "contributor") return "Contributeur";
if (role == "logged_user") return "Utilisateur connecté";
if (role == "anonymous") return "Utilisateur anonyme";
},
truncate(n, len) {
let ext = n.substring(n.lastIndexOf(".") + 1, n.length).toLowerCase();
......
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