253 lines
8.6 KiB
Vue
253 lines
8.6 KiB
Vue
<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">
|
|
<div class="flex flex-column">
|
|
<div class="flex flex-column align-items-center">
|
|
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-3 w-3rem h-3rem" />
|
|
<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: {
|
|
basic: `
|
|
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
|
|
<template #person="slotProps">
|
|
<div class="flex flex-column">
|
|
<div class="flex flex-column align-items-center">
|
|
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-3 w-3rem h-3rem" />
|
|
<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>
|
|
`,
|
|
options: `
|
|
<template>
|
|
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
|
|
<template #person="slotProps">
|
|
<div class="flex flex-column">
|
|
<div class="flex flex-column align-items-center">
|
|
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-3 w-3rem h-3rem" />
|
|
<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: {}
|
|
};
|
|
},
|
|
};
|
|
<\/script>
|
|
`,
|
|
composition: `
|
|
<template>
|
|
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
|
|
<template #person="slotProps">
|
|
<div class="flex flex-column">
|
|
<div class="flex flex-column align-items-center">
|
|
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-3 w-3rem h-3rem" />
|
|
<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({});
|
|
<\/script>
|
|
`
|
|
}
|
|
};
|
|
}
|
|
};
|
|
</script>
|