primevue-mirror/apps/showcase/doc/confirmdialog/TemplateDoc.vue

165 lines
5.3 KiB
Vue
Raw Permalink Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
2023-10-28 13:59:59 +00:00
<p>Templating allows customizing the message content.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
2023-10-28 13:59:59 +00:00
<ConfirmDialog 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">
2024-07-01 14:23:54 +00:00
<i :class="slotProps.message.icon" class="!text-6xl text-primary-500"></i>
2023-10-28 13:59:59 +00:00
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmDialog>
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()" 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 13:59:59 +00:00
<ConfirmDialog 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">
2024-07-01 14:23:54 +00:00
<i :class="slotProps.message.icon" class="!text-6xl text-primary-500"></i>
2023-10-28 13:59:59 +00:00
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmDialog>
2024-01-24 06:54:02 +00:00
<Button @click="showTemplate()" label="Save"></Button>
2023-10-15 09:38:39 +00:00
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-10-28 13:59:59 +00:00
<ConfirmDialog 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">
2024-07-01 14:23:54 +00:00
<i :class="slotProps.message.icon" class="!text-6xl text-primary-500"></i>
2023-10-28 13:59:59 +00:00
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmDialog>
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()" label="Save"></Button>
2023-02-28 08:29:30 +00:00
</div>
2023-09-20 08:14:24 +00:00
<Toast />
2023-02-28 08:29:30 +00:00
</template>
<script>
export default {
methods: {
showTemplate() {
this.$confirm.require({
group: 'templating',
2023-10-28 13:59:59 +00:00
header: 'Confirmation',
message: 'Please confirm to proceed moving forward.',
icon: 'pi pi-exclamation-circle',
2024-03-27 15:45:43 +00:00
rejectProps: {
label: 'Cancel',
icon: 'pi pi-times',
outlined: true,
size: 'small'
},
acceptProps: {
label: 'Save',
icon: 'pi pi-check',
size: 'small'
},
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-10-28 13:59:59 +00:00
<ConfirmDialog 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">
2024-07-01 14:23:54 +00:00
<i :class="slotProps.message.icon" class="!text-6xl text-primary-500"></i>
2023-10-28 13:59:59 +00:00
<p>{{ slotProps.message.message }}</p>
2023-02-28 08:29:30 +00:00
</div>
</template>
</ConfirmDialog>
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()" label="Save"></Button>
2023-02-28 08:29:30 +00:00
</div>
2023-09-20 08:14:24 +00:00
<Toast />
2023-02-28 08:29:30 +00:00
</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',
2023-10-28 13:59:59 +00:00
header: 'Confirmation',
message: 'Please confirm to proceed moving forward.',
icon: 'pi pi-exclamation-circle',
2024-03-27 15:45:43 +00:00
rejectProps: {
label: 'Cancel',
icon: 'pi pi-times',
outlined: true,
size: 'small'
},
acceptProps: {
label: 'Save',
icon: 'pi pi-check',
size: 'small'
},
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() {
this.$confirm.require({
group: 'templating',
2023-10-28 13:59:59 +00:00
header: 'Confirmation',
message: 'Please confirm to proceed moving forward.',
icon: 'pi pi-exclamation-circle',
2024-03-27 15:45:43 +00:00
rejectProps: {
label: 'Cancel',
icon: 'pi pi-times',
outlined: true,
size: 'small'
},
acceptProps: {
label: 'Save',
icon: 'pi pi-check',
size: 'small'
},
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>