diff --git a/canapGEST/DB/Valeurs de tests/table_file.sql b/canapGEST/DB/Valeurs de tests/table_file.sql index 4c31535167eca11faef58a534df5ea70b74c5d3c..a11739d433b0b328e1b9abbae8f61a5e681b9e03 100644 --- a/canapGEST/DB/Valeurs de tests/table_file.sql +++ b/canapGEST/DB/Valeurs de tests/table_file.sql @@ -1,11 +1,11 @@ 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 (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 (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 (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 (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 (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 (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 (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', 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', 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', 3); diff --git a/canapGEST/Documentation/Rapport.docx b/canapGEST/Documentation/Rapport.docx index 79c1afcf0d562b4d473f0909c4748c2a0e49bee2..c3d582ae0883d84c1f0612a36a0da2c75cb0695c 100644 Binary files a/canapGEST/Documentation/Rapport.docx and b/canapGEST/Documentation/Rapport.docx differ diff --git a/canapGEST/Documentation/journal_travail.xlsx b/canapGEST/Documentation/journal_travail.xlsx index 45071f932b428fbd8c2264fab2ce2e41d9258378..105b73685b19ba42054b2555df4de5e21baabefc 100644 Binary files a/canapGEST/Documentation/journal_travail.xlsx and b/canapGEST/Documentation/journal_travail.xlsx differ diff --git a/canapGEST/Site/src/components/application/applicationCommentItem.vue b/canapGEST/Site/src/components/application/applicationCommentItem.vue new file mode 100644 index 0000000000000000000000000000000000000000..2adf4fc17e0629289d449f9af3314fcc415cc14f --- /dev/null +++ b/canapGEST/Site/src/components/application/applicationCommentItem.vue @@ -0,0 +1,120 @@ +<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> diff --git a/canapGEST/Site/src/components/application/applicationComments.vue b/canapGEST/Site/src/components/application/applicationComments.vue index dcb5c4e7f0389d86988b930f0ce688791c7c2d0c..594928d576df74f40cc9bbfb70f4c9c49f5740b6 100644 --- a/canapGEST/Site/src/components/application/applicationComments.vue +++ b/canapGEST/Site/src/components/application/applicationComments.vue @@ -7,70 +7,31 @@ <v-divider></v-divider> <v-card-text> <v-list subheader three-line> - <v-textarea v-model="newComment" label="Ajouter un commentaire..." box></v-textarea> - <v-btn block color="primary" @click="comment">Ajouter</v-btn> + <div v-if="!$store.getters['moduleUser/userIsResponsible']"> + <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-list-tile - v-for="comment in $store.state.moduleApplications.currentApplication.comments.public" - avatar + <applicationCommentItem + v-for="comment in $store.getters['moduleApplications/getSortedPublicComments']" + :comment="comment" :key="comment.comment_id" - > - <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> + ></applicationCommentItem> </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-list-tile - v-for="comment in $store.state.moduleApplications.currentApplication.comments.private" - avatar + <applicationCommentItem + v-for="comment in $store.getters['moduleApplications/getSortedPrivateComments']" + :comment="comment" :key="comment.comment_id" - > - <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> + ></applicationCommentItem> </v-list> </v-card-text> </v-card> @@ -78,26 +39,29 @@ </template> <script> +import applicationCommentItem from '@/components/application/applicationCommentItem.vue' export default { name: 'application-comments', data() { return { - newComment: '' + newComment: { + 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() - }, - editComment(id) { - console.log(id) - }, 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> diff --git a/canapGEST/Site/src/store/modules/applications/actions.js b/canapGEST/Site/src/store/modules/applications/actions.js index 0f31731cea3577c71d30c6db75715e2af11c068e..14769aea72d4fd58450add7c5ac23cf78c26669b 100644 --- a/canapGEST/Site/src/store/modules/applications/actions.js +++ b/canapGEST/Site/src/store/modules/applications/actions.js @@ -168,4 +168,52 @@ export function deleteMarker(context, data) { method: 'delete', 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 diff --git a/canapGEST/Site/src/store/modules/applications/getters.js b/canapGEST/Site/src/store/modules/applications/getters.js index e7c123e764d58b9c8eab947fdb2e099b4f34bb11..989f18d1dc064b95c0be40d7ff5b47bb4c7fe10d 100644 --- a/canapGEST/Site/src/store/modules/applications/getters.js +++ b/canapGEST/Site/src/store/modules/applications/getters.js @@ -34,4 +34,12 @@ export function getResponsibleNewApplications(state) { export function getFormateurNewApplications(state, getters, rootState) { 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 diff --git a/canapGEST/Site/src/store/modules/user/actions.js b/canapGEST/Site/src/store/modules/user/actions.js index 9647182eeb9d91e876f9ce471249f5e926754434..7ed267ac9d4d5e32b4f84c1fbb393ef3afe836e5 100644 --- a/canapGEST/Site/src/store/modules/user/actions.js +++ b/canapGEST/Site/src/store/modules/user/actions.js @@ -23,6 +23,7 @@ export function logout(context, fullLogout) { if (fullLogout) { window.location = 'https://tequila.epfl.ch/logout' } + location.reload() }) }