2023-10-28 19:04:42 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>Headless mode is enabled by defining a <i>container</i> slot that lets you implement entire confirmation UI instead of the default elements.</p>
|
|
|
|
</DocSectionText>
|
|
|
|
<ConfirmPopup group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="rounded p-4">
|
2023-10-28 19:04:42 +00:00
|
|
|
<span>{{ message.message }}</span>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-4">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" size="small"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" severity="secondary" size="small" text></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmPopup>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation($event)" label="Save"></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code: {
|
|
|
|
basic: `
|
|
|
|
<ConfirmPopup group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="rounded p-4">
|
2023-10-28 19:04:42 +00:00
|
|
|
<span>{{ message.message }}</span>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-4">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" size="small"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" severity="secondary" size="small" text></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmPopup>
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation($event)" label="Save"></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
`,
|
|
|
|
options: `
|
|
|
|
<template>
|
|
|
|
<Toast />
|
|
|
|
<ConfirmPopup group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="rounded p-4">
|
2023-10-28 19:04:42 +00:00
|
|
|
<span>{{ message.message }}</span>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-4">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" size="small"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" severity="secondary" size="small" text></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmPopup>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation($event)" label="Save"></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
requireConfirmation(event) {
|
|
|
|
this.$confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
group: 'headless',
|
2024-01-24 06:54:02 +00:00
|
|
|
message: 'Save your current process?',
|
2023-10-28 19:04:42 +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 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
<\/script>
|
|
|
|
`,
|
|
|
|
composition: `
|
|
|
|
<template>
|
|
|
|
<Toast />
|
|
|
|
<ConfirmPopup group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="rounded p-4">
|
2023-10-28 19:04:42 +00:00
|
|
|
<span>{{ message.message }}</span>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-4">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" size="small"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" severity="secondary" size="small" text></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmPopup>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation($event)" label="Save"></Button>
|
2023-10-28 19:04:42 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { useConfirm } from "primevue/useconfirm";
|
|
|
|
import { useToast } from "primevue/usetoast";
|
|
|
|
|
|
|
|
const confirm = useConfirm();
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
const requireConfirmation = (event) => {
|
|
|
|
confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
group: 'headless',
|
2024-01-24 06:54:02 +00:00
|
|
|
message: 'Save your current process?',
|
2023-10-28 19:04:42 +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});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
<\/script>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
requireConfirmation(event) {
|
|
|
|
this.$confirm.require({
|
|
|
|
target: event.currentTarget,
|
|
|
|
group: 'headless',
|
2024-01-24 06:54:02 +00:00
|
|
|
message: 'Save your current process?',
|
2023-10-28 19:04:42 +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 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|