primevue-mirror/doc/confirmpopup/TemplateDoc.vue

159 lines
5.3 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">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center w-full gap-4 border-b border-surface-200 dark:border-surface-700 p-4 mb-4 pb-0">
2023-10-28 19:04:42 +00:00
<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>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2024-01-24 06:54:02 +00:00
<Button @click="showTemplate($event)" label="Save"></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">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center w-full gap-4 border-b border-surface-200 dark:border-surface-700 p-4 mb-4 pb-0">
2023-10-28 19:04:42 +00:00
<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>
2024-01-24 06:54:02 +00:00
<Button @click="showTemplate($event)" label="Save"></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">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center w-full gap-4 border-b border-surface-200 dark:border-surface-700 p-4 mb-4 pb-0">
2023-10-28 19:04:42 +00:00
<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>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2024-01-24 06:54:02 +00:00
<Button @click="showTemplate($event)" label="Save"></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',
2024-03-27 15:45:43 +00:00
rejectProps: {
icon: 'pi pi-times',
label: 'Cancel',
outlined: true
},
acceptProps: {
icon: 'pi pi-check',
label: 'Confirm'
},
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">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center w-full gap-4 border-b border-surface-200 dark:border-surface-700 p-4 mb-4 pb-0">
2023-10-28 19:04:42 +00:00
<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>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2024-01-24 06:54:02 +00:00
<Button @click="showTemplate($event)" label="Save"></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',
2024-03-27 15:45:43 +00:00
rejectProps: {
icon: 'pi pi-times',
label: 'Cancel',
outlined: true
},
acceptProps: {
icon: 'pi pi-check',
label: 'Confirm'
},
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',
2024-03-27 15:45:43 +00:00
rejectProps: {
icon: 'pi pi-times',
label: 'Cancel',
outlined: true
},
acceptProps: {
icon: 'pi pi-check',
label: 'Confirm'
},
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>