Skip to content

Commit

Permalink
Merge pull request #1396 from sophiemoustard/COM-2553
Browse files Browse the repository at this point in the history
COM-2553 - can remove customer absence
  • Loading branch information
KennyCallegari authored Dec 16, 2021
2 parents b1fe8cc + 9952961 commit 2d4bdad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/api/CustomerAbsences.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export default {
async updateById (id, payload) {
await alenviAxios.put(`${process.env.API_HOSTNAME}/customerabsences/${id}`, payload);
},
async remove (id) {
await alenviAxios.delete(`${process.env.API_HOSTNAME}/customerabsences/${id}`);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ni-planning-modal-header :selected-person="editedCustomerAbsence.customer" @close="close" />
<div class="modal-subtitle">
<q-btn rounded unelevated color="primary" label="Absence" />
<ni-button class="q-mx-sm" icon="delete" color="copper-grey-400" @click="validateCustomerAbsenceDeletion" />
</div>
<ni-select caption="Motif" :value="editedCustomerAbsence.absenceType" :options="customerAbsenceOptions"
required-field @input="update($event, 'absenceType')" />
Expand All @@ -22,6 +23,9 @@
<script>
import Select from '@components/form/Select';
import DateRange from '@components/form/DateRange';
import Button from '@components/Button';
import { NotifyPositive, NotifyNegative } from '@components/popup/notify';
import CustomerAbsences from '@api/CustomerAbsences';
import { CUSTOMER_ABSENCE_TYPES } from '@data/constants';
import PlanningModalHeader from './PlanningModalHeader';
Expand All @@ -31,6 +35,7 @@ export default {
'ni-select': Select,
'ni-planning-modal-header': PlanningModalHeader,
'ni-date-range': DateRange,
'ni-button': Button,
},
data () {
return {
Expand All @@ -56,6 +61,26 @@ export default {
submit () {
this.$emit('submit');
},
validateCustomerAbsenceDeletion () {
this.$q.dialog({
title: 'Confirmation',
message: 'Êtes-vous sûr(e) de vouloir supprimer cette absence ?',
ok: 'OK',
cancel: 'Annuler',
}).onOk(this.deleteCustomerAbsence)
.onCancel(() => NotifyPositive('Suppression annulée.'));
},
async deleteCustomerAbsence () {
try {
await CustomerAbsences.remove(this.editedCustomerAbsence._id);
this.close();
NotifyPositive('Absence supprimée.');
} catch (e) {
console.error(e);
NotifyNegative('Erreur lors de la suppression de l\'absence bénéficiaire.');
}
},
},
};
Expand Down
3 changes: 2 additions & 1 deletion src/modules/client/pages/ni/planning/CustomerPlanning.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ export default {
};
this.customerAbsenceModal = true;
},
closeCustomerAbsenceModal () {
async closeCustomerAbsenceModal () {
this.customerAbsenceModal = false;
await this.refresh();
},
resetCustomerAbsenceEditionForm () {
this.$v.editedCustomerAbsence.$reset();
Expand Down

0 comments on commit 2d4bdad

Please sign in to comment.