Skip to content

Commit

Permalink
Merge pull request #2938 from bahadirsofuoglu/confirmdialog-hide-call…
Browse files Browse the repository at this point in the history
…back

ConfirmDialog: Hide callback added
  • Loading branch information
tugcekucukoglu authored Sep 8, 2022
2 parents 445a715 + 25443fc commit 6822ec0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/confirmationoptions/ConfirmationOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export interface ConfirmationOptions {
* Callback to execute when action is rejected.
*/
reject?: () => void;
/**
* Callback to execute when dialog is hidden.
*/
onHide?: () => void;
/**
* Label of the accept button. Defaults to PrimeVue Locale configuration.
*/
Expand Down
11 changes: 9 additions & 2 deletions src/components/confirmdialog/ConfirmDialog.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<CDialog v-model:visible="visible" :modal="true" :header="header" :blockScroll="blockScroll" :position="position" class="p-confirm-dialog" :breakpoints="breakpoints" :closeOnEscape="closeOnEscape">
<CDialog v-model:visible="visible" :modal="true" :header="header" :blockScroll="blockScroll" :position="position" class="p-confirm-dialog" :breakpoints="breakpoints" :closeOnEscape="closeOnEscape" @update:visible="onHide">
<template v-if="!$slots.message">
<i :class="iconClass" />
<span class="p-confirm-dialog-message">{{ message }}</span>
Expand All @@ -13,9 +13,9 @@
</template>

<script>
import Button from 'primevue/button';
import ConfirmationEventBus from 'primevue/confirmationeventbus';
import Dialog from 'primevue/dialog';
import Button from 'primevue/button';
export default {
name: 'ConfirmDialog',
Expand Down Expand Up @@ -71,6 +71,13 @@ export default {
this.confirmation.reject();
}
this.visible = false;
},
onHide() {
if (this.confirmation.onHide) {
this.confirmation.onHide();
}
this.visible = false;
}
},
Expand Down
12 changes: 12 additions & 0 deletions src/views/confirmdialog/ConfirmDialogDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default {
},
reject: () => {
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
},
onHide: () => {
this.$toast.add({ severity: 'error', summary: 'Hide', detail: 'You have hidden', life: 3000 });
}
});
},
Expand All @@ -81,6 +84,9 @@ export default {
},
reject: () => {
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
},
onHide: () => {
this.$toast.add({ severity: 'error', summary: 'Hide', detail: 'You have hidden', life: 3000 });
}
});
},
Expand All @@ -96,6 +102,9 @@ export default {
},
reject: () => {
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
},
onHide: () => {
this.$toast.add({ severity: 'error', summary: 'Hide', detail: 'You have hidden', life: 3000 });
}
});
},
Expand All @@ -112,6 +121,9 @@ export default {
},
reject: () => {
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
},
onHide: () => {
this.$toast.add({ severity: 'error', summary: 'Hide', detail: 'You have hidden', life: 3000 });
}
});
}
Expand Down
42 changes: 42 additions & 0 deletions src/views/confirmdialog/ConfirmDialogDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export default {
},
reject: () => {
//callback to execute when user rejects the action
},
onHide: () => {
//Callback to execute when dialog is hidden
}
});
},
Expand All @@ -75,6 +78,9 @@ export default defineComponent({
},
reject: () => {
//callback to execute when user rejects the action
},
onHide: () => {
//Callback to execute when dialog is hidden
}
});
}
Expand Down Expand Up @@ -387,6 +393,9 @@ export default {
},
reject: () => {
this.$toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
},
Expand All @@ -401,6 +410,9 @@ export default {
},
reject: () => {
this.$toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
},
Expand All @@ -416,6 +428,9 @@ export default {
},
reject: () => {
this.$toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
},
Expand All @@ -432,6 +447,9 @@ export default {
},
reject: () => {
this.$toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand Down Expand Up @@ -506,6 +524,9 @@ export default defineComponent({
},
reject: () => {
toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand All @@ -521,6 +542,9 @@ export default defineComponent({
},
reject: () => {
toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand All @@ -537,6 +561,9 @@ export default defineComponent({
},
reject: () => {
toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand All @@ -554,6 +581,9 @@ export default defineComponent({
},
reject: () => {
this.$toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand Down Expand Up @@ -631,6 +661,9 @@ export default defineComponent({
},
reject: () => {
toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand All @@ -646,6 +679,9 @@ export default defineComponent({
},
reject: () => {
toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand All @@ -662,6 +698,9 @@ export default defineComponent({
},
reject: () => {
toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand All @@ -679,6 +718,9 @@ export default defineComponent({
},
reject: () => {
this.$toast.add({severity:'error', summary:'Rejected', detail:'You have rejected', life: 3000});
},
onHide: () => {
this.$toast.add({severity:'error', summary:'Hide', detail:'You have hidden', life: 3000});
}
});
}
Expand Down

0 comments on commit 6822ec0

Please sign in to comment.