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

conflit resolved

parents fa190d20 7a2c808a
No related branches found
No related tags found
No related merge requests found
......@@ -74,7 +74,9 @@
v-if="user && user.is_administrator"
class="item ui label vertical"
>
<span> {{ USER_LEVEL_PROJECTS }}</span>
<span v-if="project">
{{ USER_LEVEL_PROJECTS[project.slug] }}</span
>
<br />
<span v-if="user.is_administrator"> Gestionnaire métier </span>
</div>
......@@ -95,26 +97,26 @@
<div class="ui stackable grid centered container">
<!-- // todo : add messages -->
<!-- {% if messages %} -->
<!-- <div v-if="false" class="row">
<div class="fourteen wide column">
{% for message in messages %}
{% if message.tags == 'success'%}
<div class="ui positive message">
{% else %}
<div v-if="messages" class="row">
<div class="fourteen wide column">
<div
v-for="(message, index) in messages"
:key="'message-' + index"
class="ui positive message"
>
<div class="ui info message">
{% endif %}
{% endfor %}
<div class="header">
<i class="info circle icon"></i> Informations
<div class="header">
<i class="info circle icon"></i> Informations
</div>
<ul class="list">
{{
message.comment
}}
</ul>
</div>
</div>
<ul class="list">
{% for message in messages %}
{{ message }}
{% endfor %}
</ul>
</div>
</div>
</div> -->
<!-- {% endif %} -->
<router-view />
<!-- //* Les views sont injectées ici -->
......@@ -141,6 +143,7 @@ export default {
data() {
return {
menuIsOpen: false,
messages: null,
};
},
......
......@@ -101,7 +101,7 @@ const routes = [
name: 'ajouter-signalement',
component: () => import('../views/feature/Feature_edit.vue')
},
{ // todo : créer le template
{
path: '/projet/:slug/type-signalement/:slug_type_signal/signalement/:slug_signal',
name: 'details-signalement',
component: () => import('../views/feature/Feature_detail.vue')
......
......@@ -35,6 +35,7 @@ export default new Vuex.Store({
user: false,
project_slug: null,
projects: [],
last_comments: [],
staticPages: null,
SSO_SETTED: false,
USER_LEVEL_PROJECTS: null
......@@ -68,6 +69,9 @@ export default new Vuex.Store({
SET_LOGGED(state, value) {
state.logged = value
},
SET_PROJECT_COMMENTS(state, last_comments) {
state.last_comments = last_comments
},
},
getters: {
......@@ -109,7 +113,6 @@ export default new Vuex.Store({
password: payload.password,
})
.then((response) => {
console.log(router.options.routerHistory)
// * use stored previous route to go back after login if page not open on login at first
const routerHistory = router.options.routerHistory[0].name !== "login" ? router.options.routerHistory : "/"
commit("SET_USER", response.data.user);
......@@ -117,47 +120,79 @@ export default new Vuex.Store({
dispatch("GET_USER_LEVEL_PROJECTS");
})
.catch(() => {
commit("SET_USER", false)
commit("SET_USER", false);
});
}
},
USER_INFO({ commit }) { // ? not used currently ?
USER_INFO({ commit }) {
axios
.get(`${DJANGO_API_BASE}user_info/`)
.then((response) => {
const user = response.data.user;
commit("SET_USER", user)
window.localStorage.setItem("user", JSON.stringify(user))
commit("SET_USER", user);
window.localStorage.setItem("user", JSON.stringify(user));
}) // todo: ajouter au localestorage
.catch(() => {
router.push({ name: "login" });
});
},
LOGOUT({ commit }) { // ? logout dans django ?
LOGOUT({ commit }) { // ? logout bien dans django ?
axios
.get(`${DJANGO_API_BASE}logout/`)
.then((response) => {
console.log(response)
commit("SET_USER", false) // ? better false or null
commit("SET_USER_LEVEL_PROJECTS", null)
console.log(response);
commit("SET_USER", false); // ? better false or null
commit("SET_USER_LEVEL_PROJECTS", null);
})
.catch((error) => {
throw error
throw error;
});
},
GET_USER_LEVEL_PROJECTS({ commit }) {
commit("SET_USER_LEVEL_PROJECTS", "Administrateur projet") // todo : use authentification)
/* axios
axios
.get(`${DJANGO_API_BASE}user_level_project/`)
.then((response) => (commit("SET_USER_LEVEL_PROJECTS", response.data)))
.catch((error) => {
throw error;
}); */
});
},
GET_PROJECT_INFO({ commit, dispatch }, slug) {
commit("SET_PROJECT_SLUG", slug);
dispatch("GET_PROJECT_LAST_MESSAGES", slug);
dispatch("GET_PROJECT_FEATURES", slug);
dispatch("GET_PROJECT_FEATURE_TYPES", slug);
},
GET_PROJECT_LAST_MESSAGES({ commit }, project_slug) {
axios
.get(`${DJANGO_API_BASE}projet/${project_slug}/comments`)
.then((response) => commit("SET_PROJECT_COMMENTS", response.data.last_comments))
.catch((error) => {
throw error;
});
},
GET_PROJECT_FEATURES({ commit }, project_slug) {
axios
.get(`${DJANGO_API_BASE}projet/${project_slug}/feature`)
.then((response) => commit("feature/SET_FEATURES", response.data.features))
.catch((error) => {
throw error;
});
},
GET_PROJECT_FEATURE_TYPES({ commit }, project_slug) {
axios
.get(`${DJANGO_API_BASE}projet/${project_slug}/feature_types`)
.then((response) => commit("feature_type/SET_FEATURE_TYPES", response.data.feature_types))
.catch((error) => {
throw error;
});
},
/* GET_PROJECT({ commit }, project_slug) {
axios
......
......@@ -110,6 +110,9 @@ const feature = {
]
},
mutations: {
SET_FEATURES(state, features) {
state.features = features;
},
UPDATE_FORM(state, payload) {
state.form = payload;
},
......
......@@ -76,6 +76,9 @@ const feature_type = {
],
},
mutations: {
SET_FEATURE_TYPES(state, feature_types) {
state.feature_types = feature_types;
},
SET_CURRENT_FEATURE_TYPE_SLUG(state, payload) {
state.current_feature_type_slug = payload;
},
......
......@@ -70,7 +70,7 @@
Mon niveau d'autorisation :
<!-- //todo: get this value -->
<!-- {{ USER_LEVEL_PROJECTS|lookup:project.slug }} -->
{{ USER_LEVEL_PROJECTS }}
{{ USER_LEVEL_PROJECTS[project.slug] }}
{{ user && user.is_administrator ? "+ Gestionnaire métier" : "" }}
</span>
</div>
......@@ -115,11 +115,5 @@ export default {
APPLICATION_NAME: () => process.env.VUE_APP_APPLICATION_NAME,
APPLICATION_ABSTRACT: () => process.env.VUE_APP_APPLICATION_ABSTRACT,
},
created() {
// * delete selected project to hide project menu in header
if (this.$store.getters.project) {
this.$store.commit("SET_PROJECT_SLUG", null);
}
},
};
</script>
\ No newline at end of file
......@@ -475,8 +475,10 @@ export default {
computed: {
...mapState(["user"]),
feature: function () {
return this.$store.state.feature.features.find(
(el) => el.title === this.$route.params.slug_signal
return (
this.$store.state.feature.features.find(
(el) => el.feature_id === this.$route.params.slug_signal
) || []
);
},
linked_features: function () {
......@@ -513,8 +515,9 @@ export default {
},
created() {
console.log;
if (!this.project) {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}
this.$store.commit(
"feature_type/SET_CURRENT_FEATURE_TYPE_SLUG",
......
......@@ -405,7 +405,7 @@ export default {
},
created() {
if (!this.project) {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}
this.$store.commit(
"feature_type/SET_CURRENT_FEATURE_TYPE_SLUG",
......
......@@ -277,7 +277,7 @@ export default {
created() {
if (!this.project) {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_MESSAGES", this.$route.params.slug);
}
},
mounted() {
......
......@@ -259,7 +259,7 @@ export default {
created() {
if (!this.project) {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}
this.getImports();
},
......
......@@ -241,7 +241,7 @@ export default {
created() {
if (!this.project) {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}
this.$store.commit(
"feature_type/SET_CURRENT_FEATURE_TYPE_SLUG",
......
......@@ -42,7 +42,7 @@
<!-- {% endif %} {% if project and
permissions|lookup:'can_update_project' %} -->
<router-link
v-if="$store.state.user"
v-if="user"
:to="{ name: 'project_edit', params: { slug: project.slug } }"
class="ui button button-hover-orange"
data-tooltip="Modifier le projet"
......@@ -188,47 +188,45 @@
</router-link>
</div>
<div class="nouveau-type-signalement">
<div
class="ui compact basic button button-hover-green"
>
<div
onclick="document.getElementById('json_file').click()"
>
<label
class="ui "
for="json_file"
>
<i class="ui plus icon"></i>
<span class="label">Créer un nouveau type de signalement avec un geojson</span>
</label>
<input
type="file"
accept="application/json, .json, .geojson"
style="display: none"
name="json_file"
id="json_file"
@change="onFileChange"
<div class="ui compact basic button button-hover-green">
<div onclick="document.getElementById('json_file').click()">
<label class="ui" for="json_file">
<i class="ui plus icon"></i>
<span class="label"
>Créer un nouveau type de signalement avec un geojson</span
>
</label>
<input
type="file"
accept="application/json, .json, .geojson"
style="display: none"
name="json_file"
id="json_file"
@change="onFileChange"
/>
</div>
</div>
<br />
<div id="button-import" v-if="filenameToImport.size > 0">
<button
:disabled="filenameToImport.size == 0"
@click="importGeoJson"
class="ui fluid teal icon button"
>
<i class="upload icon"></i> Lancer l'import avec le fichier
{{ filenameToImport.name }}
</button>
</div>
</div>
<br>
<div id="button-import" v-if="filenameToImport.size>0">
<button
:disabled="filenameToImport.size == 0"
@click="importGeoJson" class="ui fluid teal icon button">
<i class="upload icon"></i> Lancer l'import avec le fichier {{filenameToImport.name}}
</button>
</div>
</div>
</div>
<div class="seven wide column">
<router-link
:to="{ name: 'liste-signalements', params: { slug: project.slug } }"
class="item"
>
<div id="map"></div>
</router-link>
</div>
<div class="seven wide column">
<router-link
:to="{ name: 'liste-signalements', params: { slug: project.slug } }"
class="item"
>
<div id="map"></div>
</router-link>
</div>
</div>
<div class="row">
......@@ -251,6 +249,7 @@
:to="{
name: 'details-signalement',
params: {
slug: project.slug,
slug_type_signal: item.feature_type.title,
slug_signal: item.title,
},
......@@ -260,23 +259,18 @@
</div>
<div class="description">
<i
>[{{ item.created_on }}
{{
$store.state.user
? `, par
${item.display_creator}`
: ""
}}
>[{{ item.created_on
}}<span v-if="user"
>, par {{ item.display_creator }}
</span>
]</i
>
</div>
</div>
</div>
<!-- {% empty %} -->
<i v-if="last_features.length === 0"
>Aucun signalement pour le moment.</i
>
<!-- {% endfor %} -->
</div>
</div>
</div>
......@@ -287,23 +281,23 @@
<div class="center aligned description">
<div class="ui relaxed list">
<div
v-for="item in last_comments"
:key="item.id"
v-for="(item, index) in last_comments"
:key="'comment ' + index"
class="item"
>
// ? item.id exists ?
<div class="content">
<div>
<!-- // todo : adapt -->
<a href="item.related_feature.feature_url"
>"{{ item.comment }}"</a
<router-link
:to="item.related_feature.feature_url"
>"{{ item.comment }}"</router-link
>
</div>
<div class="description">
<i
>[ {{ item.created_on }}
<span v-if="user.is_authenticated">
, par {{ item.display_user }}
>[ {{ item.created_on
}}<span v-if="user"
>, par {{ item.display_author }}
</span>
]</i
>
......@@ -395,7 +389,7 @@
</div>
</div>
<!-- {% else %} -->
<span v-else>
<span v-else-if="!permissions.can_view_project">
<i class="icon exclamation triangle"></i>
<span
>Vous ne disposez pas des droits nécessaires pour consulter ce
......@@ -482,7 +476,6 @@ export default {
slug: this.$route.params.slug,
isModalOpen: false,
is_suscriber: false,
last_comments: [],
permissions: {
can_view_project: true,
can_create_feature: true,
......@@ -492,13 +485,14 @@ export default {
computed: {
...mapGetters(["project"]),
...mapState("feature_type", ["form", "customForms", "feature_types"]),
...mapState(["last_comments", "user"]),
BASE_URL: () => process.env.VUE_APP_BASE_URL,
last_features: function () {
return this.$store.state.feature.features;
},
},
created() {
this.$store.commit("SET_PROJECT_SLUG", this.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.slug);
},
mounted() {
......@@ -597,6 +591,9 @@ export default {
subsribeProject() {
console.log("Subsribe to project");
},
getFeatureSlug(url) {
return url.split("type-signalement")[1].split("signalement");
},
},
};
</script>
......@@ -618,11 +615,11 @@ export default {
float: right;
margin: 0 0 0 1em;
}
.nouveau-type-signalement{
.nouveau-type-signalement {
padding-top: 1em;
}
#button-import{
#button-import {
padding-top: 0.5em;
}
</style>
\ No newline at end of file
......@@ -259,7 +259,7 @@ export default {
created() {
this.definePageType();
if (!this.project && this.action !== "create") {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}
},
};
......
......@@ -95,7 +95,6 @@ export default {
.post(`${DJANGO_API_BASE}projet/${payload.slug}/utilisateurs/`, payload.data)
.then((response) => {
const user = response.data.user;
})
.catch(() => {
router.push({ name: "login" });
......@@ -125,7 +124,7 @@ export default {
created() {
if (!this.project) {
this.$store.commit("SET_PROJECT_SLUG", this.$route.params.slug);
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}
this.populateMembers();
},
......
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