2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
2023-10-28 19:04:42 +00:00
|
|
|
<p>ConfirmPopup is displayed by calling the <i>require</i> method of the <i>$confirm</i> instance by passing the options to customize the Popup. The <i>target</i> attribute is mandatory to align the popup to its referrer.</p>
|
2023-02-28 08:29:30 +00:00
|
|
|
</DocSectionText>
|
|
|
|
<ConfirmPopup></ConfirmPopup>
|
|
|
|
<div class="card flex flex-wrap gap-2 justify-content-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="confirm1($event)" label="Save" outlined></Button>
|
|
|
|
<Button @click="confirm2($event)" label="Delete" severity="danger" outlined></Button>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<ConfirmPopup></ConfirmPopup>
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="confirm1($event)" label="Save" outlined></Button>
|
|
|
|
<Button @click="confirm2($event)" label="Delete" severity="danger" outlined></Button>
|
2023-10-15 09:38:39 +00:00
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<Toast />
|
|
|
|
<ConfirmPopup></ConfirmPopup>
|
|
|
|
<div class="card flex flex-wrap gap-2 justify-content-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="confirm1($event)" label="Save" outlined></Button>
|
|
|
|
<Button @click="confirm2($event)" label="Delete" severity="danger" outlined></Button>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
confirm1(event) {
|
|
|
|
this.$confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
message: 'Are you sure you want to proceed?',
|
|
|
|
icon: 'pi pi-exclamation-triangle',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectClass: 'p-button-secondary p-button-outlined p-button-sm',
|
|
|
|
acceptClass: 'p-button-sm',
|
|
|
|
rejectLabel: 'Cancel',
|
|
|
|
acceptLabel: 'Save',
|
2023-02-28 08:29:30 +00:00
|
|
|
accept: () => {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
confirm2(event) {
|
|
|
|
this.$confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
message: 'Do you want to delete this record?',
|
|
|
|
icon: 'pi pi-info-circle',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectClass: 'p-button-secondary p-button-outlined p-button-sm',
|
2023-10-28 19:04:42 +00:00
|
|
|
acceptClass: 'p-button-danger p-button-sm',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectLabel: 'Cancel',
|
|
|
|
acceptLabel: 'Delete',
|
2023-02-28 08:29:30 +00:00
|
|
|
accept: () => {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Record deleted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<Toast />
|
|
|
|
<ConfirmPopup></ConfirmPopup>
|
|
|
|
<div class="card flex flex-wrap gap-2 justify-content-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="confirm1($event)" label="Save" outlined></Button>
|
|
|
|
<Button @click="confirm2($event)" label="Delete" severity="danger" outlined></Button>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { useConfirm } from "primevue/useconfirm";
|
|
|
|
import { useToast } from "primevue/usetoast";
|
|
|
|
|
|
|
|
const confirm = useConfirm();
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
const confirm1 = (event) => {
|
|
|
|
confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
message: 'Are you sure you want to proceed?',
|
|
|
|
icon: 'pi pi-exclamation-triangle',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectClass: 'p-button-secondary p-button-outlined p-button-sm',
|
|
|
|
acceptClass: 'p-button-sm',
|
|
|
|
rejectLabel: 'Cancel',
|
|
|
|
acceptLabel: 'Save',
|
2023-02-28 08:29:30 +00:00
|
|
|
accept: () => {
|
|
|
|
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const confirm2 = (event) => {
|
|
|
|
confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
message: 'Do you want to delete this record?',
|
|
|
|
icon: 'pi pi-info-circle',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectClass: 'p-button-secondary p-button-outlined p-button-sm',
|
2023-10-28 19:04:42 +00:00
|
|
|
acceptClass: 'p-button-danger p-button-sm',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectLabel: 'Cancel',
|
|
|
|
acceptLabel: 'Delete',
|
2023-02-28 08:29:30 +00:00
|
|
|
accept: () => {
|
|
|
|
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Record deleted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
confirm1(event) {
|
|
|
|
this.$confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
message: 'Are you sure you want to proceed?',
|
|
|
|
icon: 'pi pi-exclamation-triangle',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectClass: 'p-button-secondary p-button-outlined p-button-sm',
|
|
|
|
acceptClass: 'p-button-sm',
|
|
|
|
rejectLabel: 'Cancel',
|
|
|
|
acceptLabel: 'Save',
|
2023-02-28 08:29:30 +00:00
|
|
|
accept: () => {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
confirm2(event) {
|
|
|
|
this.$confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
message: 'Do you want to delete this record?',
|
|
|
|
icon: 'pi pi-info-circle',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectClass: 'p-button-secondary p-button-outlined p-button-sm',
|
2023-10-28 19:04:42 +00:00
|
|
|
acceptClass: 'p-button-danger p-button-sm',
|
2024-01-24 06:54:02 +00:00
|
|
|
rejectLabel: 'Cancel',
|
|
|
|
acceptLabel: 'Delete',
|
2023-02-28 08:29:30 +00:00
|
|
|
accept: () => {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Record deleted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|