diff --git a/api-generator/components/organizationchart.js b/api-generator/components/organizationchart.js index b5fce2de9..244a0b017 100644 --- a/api-generator/components/organizationchart.js +++ b/api-generator/components/organizationchart.js @@ -78,11 +78,19 @@ const OrganizationChartEvents = [ } ]; +const OrganizationChartSlots = [ + { + name: 'togglericon', + description: 'Custom toggler icon template.' + } +]; + module.exports = { organizationchart: { name: 'OrganizationChart', description: 'OrganizationChart visualizes hierarchical organization data.', props: OrganizationChartProps, - events: OrganizationChartEvents + events: OrganizationChartEvents, + slots: OrganizationChartSlots } }; diff --git a/components/lib/organizationchart/OrganizationChart.d.ts b/components/lib/organizationchart/OrganizationChart.d.ts index b39eec1aa..69f002836 100755 --- a/components/lib/organizationchart/OrganizationChart.d.ts +++ b/components/lib/organizationchart/OrganizationChart.d.ts @@ -104,6 +104,16 @@ export interface OrganizationChartSlots { * @todo */ [key: string]: (node: any) => VNode[]; + /** + * Custom toggler icon template. + * @param {Object} scope - togglericon slot's params. + */ + togglericon(scope: { + /** + * Curent state of the node + */ + expanded: boolean; + }): VNode[]; } /** diff --git a/components/lib/organizationchart/OrganizationChart.spec.js b/components/lib/organizationchart/OrganizationChart.spec.js index ed019fa5c..077b25edc 100644 --- a/components/lib/organizationchart/OrganizationChart.spec.js +++ b/components/lib/organizationchart/OrganizationChart.spec.js @@ -124,20 +124,17 @@ describe('OrganizationChart.vue', () => { expect(wrapper.find('.p-organizationchart.p-component').exists()).toBe(true); expect(wrapper.find('table.p-organizationchart-table').exists()).toBe(true); expect(wrapper.findAll('.p-node-toggler-icon').length).toBe(5); - expect(wrapper.find('.p-node-toggler-icon').classes()).toContain('pi-chevron-down'); }); it('should collapsed and expand', async () => { await wrapper.vm.onNodeToggle(wrapper.vm.value); - expect(wrapper.find('.p-node-toggler-icon').classes()).toContain('pi-chevron-up'); expect(wrapper.emitted()['node-collapse'][0]).toEqual([wrapper.vm.value]); expect(wrapper.emitted()['update:collapsedKeys'][0]).toEqual([{ 0: true }]); expect(wrapper.vm.d_collapsedKeys).toEqual({ 0: true }); await wrapper.vm.onNodeToggle(wrapper.vm.value); - expect(wrapper.find('.p-node-toggler-icon').classes()).toContain('pi-chevron-down'); expect(wrapper.emitted()['node-expand'][0]).toEqual([wrapper.vm.value]); expect(wrapper.emitted()['update:collapsedKeys'][0]).toEqual([{}]); expect(wrapper.vm.d_collapsedKeys).toEqual({}); diff --git a/components/lib/organizationchart/OrganizationChartNode.vue b/components/lib/organizationchart/OrganizationChartNode.vue index befc2dfac..0cc1b7fac 100755 --- a/components/lib/organizationchart/OrganizationChartNode.vue +++ b/components/lib/organizationchart/OrganizationChartNode.vue @@ -6,7 +6,7 @@
@@ -48,6 +48,8 @@