primevue-mirror/doc/confirmpopup/TemplateDoc.vue

144 lines
5.0 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
2023-10-28 19:04:42 +00:00
<p>Templating allows customizing the message content.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
2023-10-28 19:04:42 +00:00
<ConfirmPopup group="templating">
2023-02-28 08:29:30 +00:00
<template #message="slotProps">
2023-10-28 19:04:42 +00:00
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border p-3 mb-3">
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmPopup>
2023-10-28 19:04:42 +00:00
<div class="card flex justify-content-center">
<Button @click="showTemplate($event)" icon="pi pi-check" label="Confirm"></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: `
2023-10-28 19:04:42 +00:00
<ConfirmPopup group="templating">
2023-02-28 08:29:30 +00:00
<template #message="slotProps">
2023-10-28 19:04:42 +00:00
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border p-3 mb-3">
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmPopup>
2023-10-28 19:04:42 +00:00
<Button @click="showTemplate($event)" icon="pi pi-check" label="Confirm"></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 />
2023-10-28 19:04:42 +00:00
<ConfirmPopup group="templating">
2023-02-28 08:29:30 +00:00
<template #message="slotProps">
2023-10-28 19:04:42 +00:00
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border p-3 mb-3">
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmPopup>
2023-10-28 19:04:42 +00:00
<div class="card flex justify-content-center">
<Button @click="showTemplate($event)" icon="pi pi-check" label="Confirm"></Button>
2023-02-28 08:29:30 +00:00
</div>
</template>
<script>
export default {
methods: {
showTemplate(event) {
this.$confirm.require({
target: event.currentTarget,
2023-10-28 19:04:42 +00:00
group: 'templating',
message: 'Please confirm to proceed moving forward.',
icon: 'pi pi-exclamation-circle',
2023-02-28 08:29:30 +00:00
acceptIcon: 'pi pi-check',
rejectIcon: 'pi pi-times',
2023-10-28 19:04:42 +00:00
rejectClass: 'p-button-sm',
acceptClass: 'p-button-outlined p-button-sm',
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 });
}
});
}
}
};
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 />
2023-10-28 19:04:42 +00:00
<ConfirmPopup group="templating">
2023-02-28 08:29:30 +00:00
<template #message="slotProps">
2023-10-28 19:04:42 +00:00
<div class="flex flex-column align-items-center w-full gap-3 border-bottom-1 surface-border p-3 mb-3">
<i :class="slotProps.message.icon" class="text-6xl text-primary-500"></i>
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmPopup>
2023-10-28 19:04:42 +00:00
<div class="card flex justify-content-center">
<Button @click="showTemplate($event)" icon="pi pi-check" label="Confirm"></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 showTemplate = (event) => {
confirm.require({
target: event.currentTarget,
2023-10-28 19:04:42 +00:00
group: 'templating',
message: 'Please confirm to proceed moving forward.',
icon: 'pi pi-exclamation-circle',
2023-02-28 08:29:30 +00:00
acceptIcon: 'pi pi-check',
rejectIcon: 'pi pi-times',
2023-10-28 19:04:42 +00:00
rejectClass: 'p-button-sm',
acceptClass: 'p-button-outlined p-button-sm',
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});
}
});
}
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
showTemplate(event) {
this.$confirm.require({
target: event.currentTarget,
2023-10-28 19:04:42 +00:00
group: 'templating',
message: 'Please confirm to proceed moving forward.',
icon: 'pi pi-exclamation-circle',
2023-02-28 08:29:30 +00:00
acceptIcon: 'pi pi-check',
rejectIcon: 'pi pi-times',
2023-10-28 19:04:42 +00:00
rejectClass: 'p-button-sm',
acceptClass: 'p-button-outlined p-button-sm',
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 });
}
});
}
}
};
</script>