Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COM-2553 - can remove customer absence #1396

Merged
merged 3 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
KennyCallegari marked this conversation as resolved.
Show resolved Hide resolved
},
resetCustomerAbsenceEditionForm () {
this.$v.editedCustomerAbsence.$reset();
Expand Down