Add collapsible prop

pull/41/head
cagataycivici 2019-07-28 16:44:43 +03:00
parent 587124a701
commit 3f6d7f291d
2 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,7 @@
<td :colspan="colspan"> <td :colspan="colspan">
<div :class="nodeContentClass" @click="onNodeClick"> <div :class="nodeContentClass" @click="onNodeClick">
<OrganizationChartNodeTemplate :node="node" :template="templates[node.type]||templates['default']" /> <OrganizationChartNodeTemplate :node="node" :template="templates[node.type]||templates['default']" />
<a v-if="collapsible && !leaf" tabindex="0" class="p-node-toggler" @click="toggleNode" @keydown.enter="toggleNode"> <a v-if="toggleable" tabindex="0" class="p-node-toggler" @click="toggleNode" @keydown.enter="toggleNode">
<i class="p-node-toggler-icon pi" :class="{'pi-chevron-down': expanded, 'pi-chevron-up': !expanded}"></i> <i class="p-node-toggler-icon pi" :class="{'pi-chevron-down': expanded, 'pi-chevron-up': !expanded}"></i>
</a> </a>
</div> </div>
@ -133,6 +133,9 @@ export default {
}, },
selected() { selected() {
return this.selectable && this.selectionKeys && this.selectionKeys[this.node.key] === true; return this.selectable && this.selectionKeys && this.selectionKeys[this.node.key] === true;
},
toggleable() {
return this.collapsible && this.node.collapsible !== false && !this.leaf;
} }
}, },
components: { components: {

View File

@ -105,6 +105,12 @@ export default {
<td>true</td> <td>true</td>
<td>Whether node is selectable when selection is enabled.</td> <td>Whether node is selectable when selection is enabled.</td>
</tr> </tr>
<tr>
<td>collapsible</td>
<td>boolean</td>
<td>true</td>
<td>Whether node is collapsible when node expansion is enabled.</td>
</tr>
<tr> <tr>
<td>children</td> <td>children</td>
<td>array</td> <td>array</td>