Skip to content

Commit

Permalink
Refactor #3965 - Refactor on OrganizationChart
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Jul 6, 2023
1 parent a4529e5 commit b1eb42a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
6 changes: 3 additions & 3 deletions components/lib/organizationchart/BaseOrganizationChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const styles = `
const classes = {
root: 'p-organizationchart p-component',
table: 'p-organizationchart-table',
node: ({ props, instance }) => ['p-organizationchart-node-content', props.node.styleClass, { 'p-organizationchart-selectable-node': instance.selectable, 'p-highlight': instance.selected }],
node: ({ instance }) => ['p-organizationchart-node-content', { 'p-organizationchart-selectable-node': instance.selectable, 'p-highlight': instance.selected }],
nodeToggler: 'p-node-toggler',
nodeTogglerIcon: 'p-node-toggler-icon',
lines: 'p-organizationchart-lines',
lineDown: 'p-organizationchart-line-down',
lines: 'p-organizationchart-lines',
lineLeft: ({ i }) => ['p-organizationchart-line-left', { 'p-organizationchart-line-top': !(i === 0) }],
lineRight: ({ props, i }) => ['p-organizationchart-line-right', { 'p-organizationchart-line-top': !(i === props.node.children.length - 1) }],
lineLeft: ({ index }) => ['p-organizationchart-line-left', { 'p-organizationchart-line-top': !(index === 0) }],
lineRight: ({ props, index }) => ['p-organizationchart-line-right', { 'p-organizationchart-line-top': !(index === props.node.children.length - 1) }],
nodes: 'p-organizationchart-nodes'
};
Expand Down
24 changes: 3 additions & 21 deletions components/lib/organizationchart/OrganizationChartNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<tbody v-bind="ptm('body')">
<tr v-if="node" v-bind="ptm('row')">
<td :colspan="colspan" v-bind="ptm('cell')">
<div :class="cx('node')" @click="onNodeClick" v-bind="getPTOptions('node')">
<div :class="[cx('node'), node.styleClass]" @click="onNodeClick" v-bind="getPTOptions('node')">
<component :is="templates[node.type] || templates['default']" :node="node" />
<a v-if="toggleable" tabindex="0" :class="cx('nodeToggler')" @click="toggleNode" @keydown="onKeydown" v-bind="getPTOptions('nodeToggler')">
<component v-if="templates.togglericon" :is="templates.togglericon" :expanded="expanded" class="p-node-toggler-icon" />
Expand All @@ -25,26 +25,8 @@
</template>
<template v-if="node.children && node.children.length > 1">
<template v-for="(child, i) of node.children" :key="child.key">
<td
:class="
cx('lineLeft', {
i
})
"
v-bind="getNodeOptions(!(i === 0), 'lineLeft')"
>
&nbsp;
</td>
<td
:class="
cx('lineRight', {
i
})
"
v-bind="getNodeOptions(!(i === node.children.length - 1), 'lineRight')"
>
&nbsp;
</td>
<td :class="cx('lineLeft', { index: i })" v-bind="getNodeOptions(!(i === 0), 'lineLeft')">&nbsp;</td>
<td :class="cx('lineRight', { index: i })" v-bind="getNodeOptions(!(i === node.children.length - 1), 'lineRight')">&nbsp;</td>
</template>
</template>
</tr>
Expand Down

0 comments on commit b1eb42a

Please sign in to comment.