144 lines
5.0 KiB
Vue
144 lines
5.0 KiB
Vue
<template>
|
|
<DocSectionText v-bind="$attrs">
|
|
<p>Templating allows customizing the message content.</p>
|
|
</DocSectionText>
|
|
<ConfirmDialog group="templating">
|
|
<template #message="slotProps">
|
|
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border">
|
|
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
|
|
<p>{{ slotProps.message.message }}</p>
|
|
</div>
|
|
</template>
|
|
</ConfirmDialog>
|
|
<div class="card flex justify-content-center">
|
|
<Button @click="showTemplate()" icon="pi pi-check" label="Confirm"></Button>
|
|
</div>
|
|
<DocSectionCode :code="code" />
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
code: {
|
|
basic: `
|
|
<ConfirmDialog group="templating">
|
|
<template #message="slotProps">
|
|
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border">
|
|
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
|
|
<p>{{ slotProps.message.message }}</p>
|
|
</div>
|
|
</template>
|
|
</ConfirmDialog>
|
|
<Button @click="showTemplate()" icon="pi pi-check" label="Confirm"></Button>
|
|
`,
|
|
options: `
|
|
<template>
|
|
<ConfirmDialog group="templating">
|
|
<template #message="slotProps">
|
|
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border">
|
|
<i :class="slotProps.message.icon" class="text-5xl text-primary-500"></i>
|
|
<p>{{ slotProps.message.message }}</p>
|
|
</div>
|
|
</template>
|
|
</ConfirmDialog>
|
|
<div class="card flex justify-content-center">
|
|
<Button @click="showTemplate()" icon="pi pi-check" label="Confirm"></Button>
|
|
</div>
|
|
<Toast />
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
methods: {
|
|
showTemplate() {
|
|
this.$confirm.require({
|
|
group: 'templating',
|
|
header: 'Confirmation',
|
|
message: 'Please confirm to proceed moving forward.',
|
|
icon: 'pi pi-exclamation-circle',
|
|
acceptIcon: 'pi pi-check',
|
|
rejectIcon: 'pi pi-times',
|
|
rejectClass: 'p-button-sm',
|
|
acceptClass: 'p-button-outlined p-button-sm',
|
|
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>
|
|
<ConfirmDialog group="templating">
|
|
<template #message="slotProps">
|
|
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border">
|
|
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
|
|
<p>{{ slotProps.message.message }}</p>
|
|
</div>
|
|
</template>
|
|
</ConfirmDialog>
|
|
<div class="card flex justify-content-center">
|
|
<Button @click="showTemplate()" icon="pi pi-check" label="Confirm"></Button>
|
|
</div>
|
|
<Toast />
|
|
</template>
|
|
|
|
<script setup>
|
|
import { useConfirm } from "primevue/useconfirm";
|
|
import { useToast } from "primevue/usetoast";
|
|
|
|
const confirm = useConfirm();
|
|
const toast = useToast();
|
|
|
|
const showTemplate = () => {
|
|
confirm.require({
|
|
group: 'templating',
|
|
header: 'Confirmation',
|
|
message: 'Please confirm to proceed moving forward.',
|
|
icon: 'pi pi-exclamation-circle',
|
|
acceptIcon: 'pi pi-check',
|
|
rejectIcon: 'pi pi-times',
|
|
rejectClass: 'p-button-sm',
|
|
acceptClass: 'p-button-outlined p-button-sm',
|
|
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: {
|
|
showTemplate() {
|
|
this.$confirm.require({
|
|
group: 'templating',
|
|
header: 'Confirmation',
|
|
message: 'Please confirm to proceed moving forward.',
|
|
icon: 'pi pi-exclamation-circle',
|
|
acceptIcon: 'pi pi-check',
|
|
rejectIcon: 'pi pi-times',
|
|
rejectClass: 'p-button-sm',
|
|
acceptClass: 'p-button-outlined p-button-sm',
|
|
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>
|