Skip to content
Snippets Groups Projects
Commit e9b90b48 authored by nicrausaz's avatar nicrausaz
Browse files

Design, ajout, modif et suppr. des commentaires

parent 0d557fa8
No related branches found
No related tags found
No related merge requests found
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (280, 'photo-passeport.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\photo-passeport.pdf', 1); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (280, 'photo-passeport.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\photo-passeport.pdf', 1);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (289, 'photo-passeport.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\photo-passeport.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (289, 'photo-passeport.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\photo-passeport.pdf', 3);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (283, 'lettre-motivation.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\lettre-motivation.pdf', 1); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (283, 'lettre-motivation.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\lettre-motivation.pdf', 1);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (292, 'lettre-motivation.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\lettre-motivation.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (292, 'lettre-motivation.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\lettre-motivation.pdf', 3);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (282, 'curriculum-vitae.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\curriculum-vitae.pdf', 1); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (282, 'curriculum-vitae.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\curriculum-vitae.pdf', 1);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (291, 'curriculum-vitae.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\curriculum-vitae.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (291, 'curriculum-vitae.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\curriculum-vitae.pdf', 3);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (281, 'carte-identite.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\carte-identite.pdf', 1); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (281, 'carte-identite.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\1\\carte-identite.pdf', 1);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (290, 'carte-identite.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\carte-identite.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (290, 'carte-identite.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\carte-identite.pdf', 3);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (295, 'annexe3.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\annexe3.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (295, 'annexe3.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\annexe3.pdf', 3);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (294, 'annexe2.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\annexe2.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (294, 'annexe2.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\annexe2.pdf', 3);
INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (293, 'annexe1.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\annexe1.pdf', 2); INSERT INTO `file` (`file_id`, `file_name`, `file_path`, `fk_applicant_id`) VALUES (293, 'annexe1.pdf', '\\\\scxdata.epfl.ch\\apprentis$\\candidatures\\nouvelles\\test-Nicolas-Crausaz\\2\\annexe1.pdf', 3);
No preview for this file type
No preview for this file type
<template>
<v-list-tile avatar style="border-bottom: solid 1px lightgray" class="pt-2 pb-2">
<v-list-tile-avatar
v-if="comment.comment_id !== editingComment.id"
id="application-comment-item"
>
<img
:src="'https://people.epfl.ch/private/common/photos/links/' + comment.comment_owner_sciper + '.jpg'"
onerror="this.onerror=null;this.src='https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png';"
alt="avatar"
>
</v-list-tile-avatar>
<v-list-tile-avatar v-else>
<v-layout align-center>
<v-flex xs12 sm4 text-xs-center>
<v-btn flat icon color="success" @click="updateComment">
<v-icon>check</v-icon>
</v-btn>
<v-btn flat icon color="primary" @click="deleteComment">
<v-icon>delete</v-icon>
</v-btn>
</v-flex>
</v-layout>
</v-list-tile-avatar>
<v-list-tile-content v-if="editingComment.id === comment.comment_id">
<v-list-tile-title style="height: 100px;">
<v-textarea v-model="editingComment.text" solo box></v-textarea>
</v-list-tile-title>
<v-list-tile-sub-title style="height: 100px;">
<v-checkbox v-model="editingComment.isPrivate" label="Privé" color="primary"></v-checkbox>
</v-list-tile-sub-title>
</v-list-tile-content>
<v-list-tile-content v-else>
{{ comment.comment_content }}
<v-list-tile-sub-title>{{comment.ownerData.displayname}}</v-list-tile-sub-title>
</v-list-tile-content>
<v-list-tile-action>
<div v-if="comment.comment_owner_sciper === $store.state.moduleUser.userData.tequila.sciper">
<v-tooltip bottom v-if="comment.comment_id !== editingComment.id">
<template v-slot:activator="{ on }">
<v-chip
v-on="on"
color="primary"
outline
small
@click="toggleEditComment(comment.comment_id, comment.comment_content, comment.comment_is_private)"
>
<v-icon small>edit</v-icon>
</v-chip>
</template>
<span>Editer</span>
</v-tooltip>
<v-tooltip bottom v-else>
<template v-slot:activator="{ on }">
<v-icon small>edit</v-icon>
<v-chip
v-on="on"
color="primary"
outline
small
@click="toggleEditComment(null, '', false)"
>
<v-icon small>cancel</v-icon>
</v-chip>
</template>
<span>Annuler</span>
</v-tooltip>
</div>
<small>{{getFormatedDate(comment.comment_date)}}</small>
</v-list-tile-action>
</v-list-tile>
</template>
<script>
export default {
name: 'application-comment-item',
props: {
comment: {}
},
data() {
return {
editingComment: {
id: null,
text: '',
isPrivate: false
}
}
},
methods: {
getFormatedDate(value) {
let dateTimeParts = value.split(/[- :]/)
dateTimeParts[1]--
let date = new Date(...dateTimeParts)
return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' à ' + date.getHours() + ':' + date.getMinutes()
},
toggleEditComment(id, content, isPrivate) {
this.editingComment.id = id
this.editingComment.text = content
this.editingComment.isPrivate = isPrivate
},
updateComment() {
this.$store.dispatch('moduleApplications/updateComment', { id: this.editingComment.id, content: this.editingComment.text, isPrivate: this.editingComment.isPrivate })
.then(() => {
this.$store.dispatch('moduleApplications/getCurrentApplicationComments', { id: this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_id })
this.toggleEditComment(null, '', false)
})
},
deleteComment() {
this.$store.dispatch('moduleApplications/deleteComment', { id: this.editingComment.id })
.then(() => {
this.$store.dispatch('moduleApplications/getCurrentApplicationComments', { id: this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_id })
this.toggleEditComment(null, '', false)
})
}
}
}
</script>
...@@ -7,70 +7,31 @@ ...@@ -7,70 +7,31 @@
<v-divider></v-divider> <v-divider></v-divider>
<v-card-text> <v-card-text>
<v-list subheader three-line> <v-list subheader three-line>
<v-textarea v-model="newComment" label="Ajouter un commentaire..." box></v-textarea> <div v-if="!$store.getters['moduleUser/userIsResponsible']">
<v-btn block color="primary" @click="comment">Ajouter</v-btn> <v-textarea v-model="newComment.text" label="Ajouter un commentaire..." box></v-textarea>
<v-checkbox
v-model="newComment.isPrivate"
label="Commentaire privé"
color="primary"
class="ma-0 pa-0"
></v-checkbox>
<v-btn block color="primary" @click="comment">Ajouter</v-btn>
</div>
<v-divider></v-divider>
<v-subheader>Commentaires publics</v-subheader> <v-subheader>Commentaires publics</v-subheader>
<v-list-tile <applicationCommentItem
v-for="comment in $store.state.moduleApplications.currentApplication.comments.public" v-for="comment in $store.getters['moduleApplications/getSortedPublicComments']"
avatar :comment="comment"
:key="comment.comment_id" :key="comment.comment_id"
> ></applicationCommentItem>
<v-list-tile-avatar>
<img
:src="'https://people.epfl.ch/private/common/photos/links/' + comment.comment_owner_sciper + '.jpg'"
onerror="this.onerror=null;this.src='https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png';"
alt="avatar"
>
</v-list-tile-avatar>
<v-list-tile-content>
{{ comment.comment_content }}
<v-list-tile-sub-title>{{comment.ownerData.displayname}}</v-list-tile-sub-title>
</v-list-tile-content>
<v-list-tile-action>
<v-chip
outline
color="red"
small
style="cursor: pointer;"
@click="editComment(comment.comment_id)"
>
<v-icon small>edit</v-icon>
</v-chip>
<small>{{getFormatedDate(comment.comment_date)}}</small>
</v-list-tile-action>
</v-list-tile>
<v-divider></v-divider>
</v-list> </v-list>
<v-list subheader three-line> <v-list subheader three-line v-if="!$store.getters['moduleUser/userIsResponsible']">
<v-subheader>Vos commentaires privés</v-subheader> <v-subheader>Vos commentaires privés</v-subheader>
<v-list-tile <applicationCommentItem
v-for="comment in $store.state.moduleApplications.currentApplication.comments.private" v-for="comment in $store.getters['moduleApplications/getSortedPrivateComments']"
avatar :comment="comment"
:key="comment.comment_id" :key="comment.comment_id"
> ></applicationCommentItem>
<v-list-tile-avatar>
<img
:src="'https://people.epfl.ch/private/common/photos/links/' + comment.comment_owner_sciper + '.jpg'"
onerror="this.onerror=null;this.src='https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png';"
alt="avatar"
>
</v-list-tile-avatar>
<v-list-tile-content>
{{ comment.comment_content }}
<v-list-tile-sub-title>{{comment.ownerData.displayname}}</v-list-tile-sub-title>
</v-list-tile-content>
<v-list-tile-action>
<v-chip outline color="red" small>
<v-icon small>edit</v-icon>
</v-chip>
<small>{{getFormatedDate(comment.comment_date)}}</small>
</v-list-tile-action>
</v-list-tile>
</v-list> </v-list>
</v-card-text> </v-card-text>
</v-card> </v-card>
...@@ -78,26 +39,29 @@ ...@@ -78,26 +39,29 @@
</template> </template>
<script> <script>
import applicationCommentItem from '@/components/application/applicationCommentItem.vue'
export default { export default {
name: 'application-comments', name: 'application-comments',
data() { data() {
return { return {
newComment: '' newComment: {
text: '',
isPrivate: false
}
} }
}, },
methods: { methods: {
getFormatedDate(value) {
let dateTimeParts = value.split(/[- :]/)
dateTimeParts[1]--
let date = new Date(...dateTimeParts)
return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' à ' + date.getHours() + ':' + date.getMinutes()
},
editComment(id) {
console.log(id)
},
comment() { comment() {
console.log('comment') this.$store.dispatch('moduleApplications/addComment', { content: this.newComment.text, is_private: this.newComment.isPrivate, applicant_id: this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_id })
.then(() => {
this.$store.dispatch('moduleApplications/getCurrentApplicationComments', { id: this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_id })
this.newComment.text = ''
this.newComment.isPrivate = false
})
} }
},
components: {
applicationCommentItem
} }
} }
</script> </script>
...@@ -168,4 +168,52 @@ export function deleteMarker(context, data) { ...@@ -168,4 +168,52 @@ export function deleteMarker(context, data) {
method: 'delete', method: 'delete',
url: '/marker/' + data.id url: '/marker/' + data.id
}) })
}
export function addComment(context, data) {
return new Promise((resolve) => {
axios({
method: 'put',
url: '/comment',
data: {
applicant_id: data.applicant_id,
content: data.content,
is_private: data.is_private
}
})
.then(response => {
context.commit('moduleSnackbar/toggle', { open: true, message: response.data.message, type: 'success' }, { root: true })
resolve()
})
})
}
export function deleteComment(context, data) {
return new Promise((resolve) => {
axios({
method: 'delete',
url: '/comment/' + data.id
})
.then(response => {
context.commit('moduleSnackbar/toggle', { open: true, message: response.data.message, type: 'success' }, { root: true })
resolve()
})
})
}
export function updateComment(context, data) {
return new Promise((resolve) => {
axios({
method: 'patch',
url: '/comment/' + data.id,
data: {
content: data.content,
is_private: data.isPrivate
}
})
.then(response => {
context.commit('moduleSnackbar/toggle', { open: true, message: response.data.message, type: 'success' }, { root: true })
resolve()
})
})
} }
\ No newline at end of file
...@@ -34,4 +34,12 @@ export function getResponsibleNewApplications(state) { ...@@ -34,4 +34,12 @@ export function getResponsibleNewApplications(state) {
export function getFormateurNewApplications(state, getters, rootState) { export function getFormateurNewApplications(state, getters, rootState) {
return state.applications.filter(x => x.applicant_application_date > rootState.moduleUser.lastConnection.last_connection_date) return state.applications.filter(x => x.applicant_application_date > rootState.moduleUser.lastConnection.last_connection_date)
}
export function getSortedPublicComments(state) {
return state.currentApplication.comments.public.sort((a, b) => new Date(b.comment_date) - new Date(a.comment_date))
}
export function getSortedPrivateComments(state) {
return state.currentApplication.comments.private.sort((a, b) => new Date(b.comment_date) - new Date(a.comment_date))
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ export function logout(context, fullLogout) { ...@@ -23,6 +23,7 @@ export function logout(context, fullLogout) {
if (fullLogout) { if (fullLogout) {
window.location = 'https://tequila.epfl.ch/logout' window.location = 'https://tequila.epfl.ch/logout'
} }
location.reload()
}) })
} }
......
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