primevue-mirror/apps/showcase/doc/organizationchart/SelectionDoc.vue

253 lines
8.6 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>
Selection is enabled by defining the <i>selectionMode</i> to either "single" or "multiple" and specifying the <i>selectionKeys</i> with the v-model directive. Note that selection on a particular node can be disabled if the
<i>selectable</i> is false on the node instance.
</p>
</DocSectionText>
<div class="card overflow-x-auto">
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
<template #person="slotProps">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-4 w-12 h-12" />
2023-02-28 08:29:30 +00:00
<span class="font-bold mb-2">{{ slotProps.node.data.name }}</span>
<span>{{ slotProps.node.data.title }}</span>
</div>
</div>
</template>
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
</OrganizationChart>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
data: {
key: '0',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png',
name: 'Amy Elsner',
title: 'CEO'
},
children: [
{
key: '0_0',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/annafali.png',
name: 'Anna Fali',
title: 'CMO'
},
children: [
{
key: '0_0_0',
label: 'Sales'
},
{
key: '0_0_"1',
label: 'Marketing'
}
]
},
{
key: '0_1',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/stephenshaw.png',
name: 'Stephen Shaw',
title: 'CTO'
},
children: [
{
key: '0_1_0',
label: 'Development'
},
{
key: '0_1_1',
label: 'UI/UX Design'
}
]
}
]
},
selection: {},
code: {
2023-09-22 12:54:14 +00:00
basic: `
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
2023-02-28 08:29:30 +00:00
<template #person="slotProps">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-4 w-12 h-12" />
2023-02-28 08:29:30 +00:00
<span class="font-bold mb-2">{{ slotProps.node.data.name }}</span>
<span>{{ slotProps.node.data.title }}</span>
</div>
</div>
</template>
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
2023-10-15 09:38:39 +00:00
</OrganizationChart>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
<template #person="slotProps">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-4 w-12 h-12" />
2023-02-28 08:29:30 +00:00
<span class="font-bold mb-2">{{ slotProps.node.data.name }}</span>
<span>{{ slotProps.node.data.title }}</span>
</div>
</div>
</template>
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
</OrganizationChart>
</template>
<script>
export default {
data() {
return {
data: {
key: '0',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png',
name: 'Amy Elsner',
title: 'CEO'
},
children: [
{
key: '0_0',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/annafali.png',
name: 'Anna Fali',
title: 'CMO'
},
children: [
{
key: '0_0_0',
label: 'Sales'
},
{
key: '0_0_"1',
label: 'Marketing'
}
]
},
{
key: '0_1',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/stephenshaw.png',
name: 'Stephen Shaw',
title: 'CTO'
},
children: [
{
key: '0_1_0',
label: 'Development'
},
{
key: '0_1_1',
label: 'UI/UX Design'
}
]
}
]
},
selection: {}
};
},
};
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
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
<template #person="slotProps">
2024-05-20 12:14:38 +00:00
<div class="flex flex-col">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-4 w-12 h-12" />
2023-02-28 08:29:30 +00:00
<span class="font-bold mb-2">{{ slotProps.node.data.name }}</span>
<span>{{ slotProps.node.data.title }}</span>
</div>
</div>
</template>
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
</OrganizationChart>
</template>
<script setup>
import { ref } from "vue";
const data = ref({
key: '0',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png',
name: 'Amy Elsner',
title: 'CEO'
},
children: [
{
key: '0_0',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/annafali.png',
name: 'Anna Fali',
title: 'CMO'
},
children: [
{
key: '0_0_0',
label: 'Sales'
},
{
key: '0_0_"1',
label: 'Marketing'
}
]
},
{
key: '0_1',
type: 'person',
data: {
image: 'https://primefaces.org/cdn/primevue/images/avatar/stephenshaw.png',
name: 'Stephen Shaw',
title: 'CTO'
},
children: [
{
key: '0_1_0',
label: 'Development'
},
{
key: '0_1_1',
label: 'UI/UX Design'
}
]
}
]
});
const selection = ref({});
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>