Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primeng v17: fix treeselect issues #29706

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions core-web/apps/dotcms-ui/src/stories/primeng/data/Tree.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormsModule } from '@angular/forms';

import { Tree, TreeModule } from 'primeng/tree';

import { files } from '../../utils/tree-node-files';
import { generateFakeTree } from '../../utils/tree-node-files';

const meta: Meta<Tree> = {
title: 'PrimeNG/Data/Tree',
Expand All @@ -28,18 +28,15 @@ const meta: Meta<Tree> = {
layout: 'centered',
docs: {
description: {
component:
'Tree is used to display hierarchical data: https://www.primefaces.org/primeng-v15-lts/tree'
component: 'Tree is used to display hierarchical data: https://primeng.org/tree'
}
}
},
args: {
value: [...files]
value: [...generateFakeTree()]
},
render: (args) => ({
props: {
...args
},
props: args,
template: `<p-tree ${argsToTemplate(args)} />`
})
};
Expand All @@ -49,15 +46,22 @@ type Story = StoryObj<Tree>;

export const Default: Story = {};

export const Checkbox: Story = {
args: {
selectionMode: 'checkbox'
}
};

export const VirtualScroll: Story = {
args: {
value: [...generateFakeTree(1000)],
virtualScroll: true,
virtualScrollItemSize: 30,
virtualScrollOptions: {
autoSize: true,
style: {
width: '200px',
height: '200px'
height: '300px'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { TreeSelectModule, TreeSelect } from 'primeng/treeselect';

import { files } from '../../utils/tree-node-files';
import { generateFakeTree } from '../../utils/tree-node-files';

type ExtraArgs = {
invalid: boolean;
Expand All @@ -37,21 +37,19 @@ const meta: Meta<Args> = {
docs: {
description: {
component:
'TreeSelect is a form component to choose from hierarchical data.: https://www.primefaces.org/primeng-v15-lts/treeselect'
'TreeSelect is a form component to choose from hierarchical data.: https://primeng.org/treeselect'
}
}
},
args: {
placeholder: 'Select Item',
options: [...files],
options: [...generateFakeTree()],
showClear: true,
invalid: false,
selectionMode: 'single'
},
render: (args) => ({
props: {
...args
},
props: args,
template: `
<p-treeSelect
${argsToTemplate(args)}
Expand Down
99 changes: 19 additions & 80 deletions core-web/apps/dotcms-ui/src/stories/utils/tree-node-files.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,21 @@
import { faker } from '@faker-js/faker';

import { TreeNode } from 'primeng/api';

export const files: TreeNode[] = [
{
label: 'Documents',
data: 'Documents Folder',
expandedIcon: 'pi pi-folder-open',
collapsedIcon: 'pi pi-folder',
children: [
{
label: 'Work',
data: 'Work Folder',
expandedIcon: 'pi pi-folder-open',
collapsedIcon: 'pi pi-folder',
children: [
{
label: 'Expenses.doc',
icon: 'pi pi-file',
data: 'Expenses Document'
},
{ label: 'Resume.doc', icon: 'pi pi-file', data: 'Resume Document' }
]
},
{
label: 'Home',
data: 'Home Folder',
expandedIcon: 'pi pi-folder-open',
collapsedIcon: 'pi pi-folder',
children: [
{
label: 'Invoices.txt',
icon: 'pi pi-file',
data: 'Invoices for this month'
}
]
}
]
},
{
label: 'Pictures',
data: 'Pictures Folder',
expandedIcon: 'pi pi-folder-open',
collapsedIcon: 'pi pi-folder',
children: [
{ label: 'barcelona.jpg', icon: 'pi pi-image', data: 'Barcelona Photo' },
{ label: 'logo.jpg', icon: 'pi pi-image', data: 'PrimeFaces Logo' },
{ label: 'primeui.png', icon: 'pi pi-image', data: 'PrimeUI Logo' }
]
},
{
label: 'Movies',
data: 'Movies Folder',
expandedIcon: 'pi pi-folder-open',
collapsedIcon: 'pi pi-folder',
children: [
{
label: 'Al Pacino',
data: 'Pacino Movies',
children: [
{ label: 'Scarface', icon: 'pi pi-video', data: 'Scarface Movie' },
{ label: 'Serpico', icon: 'pi pi-video', data: 'Serpico Movie' }
]
},
{
label: 'Robert De Niro',
data: 'De Niro Movies',
children: [
{
label: 'Goodfellas',
icon: 'pi pi-video',
data: 'Goodfellas Movie'
},
{
label: 'Untouchables',
icon: 'pi pi-video',
data: 'Untouchables Movie'
}
]
}
]
}
];
export const generateFakeChildrenNode = (): TreeNode => ({
key: faker.string.uuid(),
label: faker.lorem.word(),
icon: 'pi pi-file'
});

export const generateFakeNode = (): TreeNode => ({
key: faker.string.uuid(),
label: faker.lorem.word(),
expandedIcon: 'pi pi-folder-open',
collapsedIcon: 'pi pi-folder',
children: faker.helpers.multiple(generateFakeChildrenNode, {
count: faker.number.int({ max: 5, min: 1 })
})
});

export const generateFakeTree = (count = 10) => faker.helpers.multiple(generateFakeNode, { count });
Loading