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

187 lines
9.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>The <i>position</i> property of the confirm options specifies the location of the Dialog.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
2023-10-28 13:59:59 +00:00
<ConfirmDialog group="positioned"></ConfirmDialog>
2023-02-28 08:29:30 +00:00
<div class="card">
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('left')" icon="pi pi-arrow-right" label="Left" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('right')" icon="pi pi-arrow-left" label="Right" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('topleft')" icon="pi pi-arrow-down-right" label="TopLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('top')" icon="pi pi-arrow-down" label="Top" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('topright')" icon="pi pi-arrow-down-left" label="TopRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('bottomleft')" icon="pi pi-arrow-up-right" label="BottomLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottom')" icon="pi pi-arrow-up" label="Bottom" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottomright')" icon="pi pi-arrow-up-left" label="BottomRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
</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="positioned"></ConfirmDialog>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('left')" icon="pi pi-arrow-right" label="Left" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('right')" icon="pi pi-arrow-left" label="Right" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('topleft')" icon="pi pi-arrow-down-right" label="TopLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('top')" icon="pi pi-arrow-down" label="Top" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('topright')" icon="pi pi-arrow-down-left" label="TopRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('bottomleft')" icon="pi pi-arrow-up-right" label="BottomLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottom')" icon="pi pi-arrow-up" label="Bottom" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottomright')" icon="pi pi-arrow-up-left" label="BottomRight" severity="secondary" style="min-width: 10rem"></Button>
2023-10-15 09:38:39 +00:00
</div>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<Toast />
2023-10-28 13:59:59 +00:00
<ConfirmDialog group="positioned"></ConfirmDialog>
2023-02-28 08:29:30 +00:00
<div class="card">
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('left')" icon="pi pi-arrow-right" label="Left" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('right')" icon="pi pi-arrow-left" label="Right" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('topleft')" icon="pi pi-arrow-down-right" label="TopLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('top')" icon="pi pi-arrow-down" label="Top" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('topright')" icon="pi pi-arrow-down-left" label="TopRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('bottomleft')" icon="pi pi-arrow-up-right" label="BottomLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottom')" icon="pi pi-arrow-up" label="Bottom" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottomright')" icon="pi pi-arrow-up-left" label="BottomRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
<script>
export default {
methods: {
confirmPosition(position) {
this.$confirm.require({
2023-10-28 13:59:59 +00:00
group: 'positioned',
message: 'Are you sure you want to proceed?',
header: 'Confirmation',
2023-02-28 08:29:30 +00:00
icon: 'pi pi-info-circle',
position: position,
2024-01-24 06:54:02 +00:00
rejectClass: 'p-button-secondary p-button-text',
2024-03-27 15:45:43 +00:00
rejectProps: {
label: 'Cancel',
severity: 'secondary',
text: true
},
acceptProps: {
label: 'Save',
text: true
},
2023-02-28 08:29:30 +00:00
accept: () => {
2023-10-28 13:59:59 +00:00
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Request submitted', life: 3000 });
2023-02-28 08:29:30 +00:00
},
reject: () => {
2023-10-28 13:59:59 +00:00
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'Process incomplete', life: 3000 });
2023-02-28 08:29:30 +00:00
}
});
},
}
};
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 13:59:59 +00:00
<ConfirmDialog group="positioned"></ConfirmDialog>
2023-02-28 08:29:30 +00:00
<div class="card">
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('left')" icon="pi pi-arrow-right" label="Left" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('right')" icon="pi pi-arrow-left" label="Right" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2 mb-4">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('topleft')" icon="pi pi-arrow-down-right" label="TopLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('top')" icon="pi pi-arrow-down" label="Top" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('topright')" icon="pi pi-arrow-down-left" label="TopRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-wrap justify-center gap-2">
2024-01-24 06:54:02 +00:00
<Button @click="confirmPosition('bottomleft')" icon="pi pi-arrow-up-right" label="BottomLeft" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottom')" icon="pi pi-arrow-up" label="Bottom" severity="secondary" style="min-width: 10rem"></Button>
<Button @click="confirmPosition('bottomright')" icon="pi pi-arrow-up-left" label="BottomRight" severity="secondary" style="min-width: 10rem"></Button>
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
<script setup>
import { useConfirm } from "primevue/useconfirm";
import { useToast } from "primevue/usetoast";
const confirm = useConfirm();
const toast = useToast();
const confirmPosition = (position) => {
confirm.require({
2023-10-28 13:59:59 +00:00
group: 'positioned',
message: 'Are you sure you want to proceed?',
header: 'Confirmation',
2023-02-28 08:29:30 +00:00
icon: 'pi pi-info-circle',
position: position,
2024-03-27 15:45:43 +00:00
rejectProps: {
label: 'Cancel',
severity: 'secondary',
text: true
},
acceptProps: {
label: 'Save',
text: true
},
2023-02-28 08:29:30 +00:00
accept: () => {
2023-10-28 13:59:59 +00:00
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Request submitted', life: 3000 });
2023-02-28 08:29:30 +00:00
},
reject: () => {
2023-10-28 13:59:59 +00:00
toast.add({ severity: 'error', summary: 'Rejected', detail: 'Process incomplete', life: 3000 });
2023-02-28 08:29:30 +00:00
}
});
};
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
confirmPosition(position) {
this.$confirm.require({
2023-10-28 13:59:59 +00:00
group: 'positioned',
message: 'Are you sure you want to proceed?',
header: 'Confirmation',
2023-02-28 08:29:30 +00:00
icon: 'pi pi-info-circle',
position: position,
2024-03-27 15:45:43 +00:00
rejectProps: {
label: 'Cancel',
severity: 'secondary',
text: true
},
acceptProps: {
label: 'Save',
text: true
},
2023-02-28 08:29:30 +00:00
accept: () => {
2023-10-28 13:59:59 +00:00
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Request submitted', life: 3000 });
2023-02-28 08:29:30 +00:00
},
reject: () => {
2023-10-28 13:59:59 +00:00
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'Process incomplete', life: 3000 });
2023-02-28 08:29:30 +00:00
}
});
}
}
};
</script>