-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add root node for relevant element trees (#875)
* Add root node for relevant element trees * Automatic frontend build --------- Co-authored-by: vin0401 <[email protected]>
- Loading branch information
Showing
37 changed files
with
1,922 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
assets/js/src/core/modules/asset/tree/utils/transform-api-data-to-node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - Pimcore Open Core License (POCL) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL | ||
*/ | ||
|
||
import { type TreeNodeProps } from '@Pimcore/components/element-tree/node/tree-node' | ||
import { type AssetGetTreeApiResponse, type AssetPermissions } from '../../asset-api-slice.gen' | ||
import { getElementIcon } from '@Pimcore/modules/element/element-helper' | ||
|
||
export interface DataTransformerReturnType { | ||
nodes: TreeNodeProps[] | ||
total: number | ||
} | ||
|
||
export const transformApiDataToNodes = (node: TreeNodeProps, data: AssetGetTreeApiResponse, maxItemsPerNode: number | undefined): DataTransformerReturnType => { | ||
const nodes: TreeNodeProps[] = [] | ||
|
||
const assetData = data.items | ||
assetData.forEach((assetNode) => { | ||
nodes.push({ | ||
id: assetNode.id.toString(), | ||
icon: getElementIcon(assetNode, { type: 'name', value: 'unknown' }), | ||
label: assetNode.filename!, | ||
type: assetNode.type, | ||
parentId: assetNode.parentId.toString(), | ||
children: [], | ||
hasChildren: assetNode.hasChildren, | ||
isLocked: assetNode.isLocked, | ||
metaData: { | ||
asset: assetNode | ||
}, | ||
permissions: assetNode.permissions ?? [] as AssetPermissions, | ||
level: node.level + 1, | ||
...(() => { | ||
if (node.level === -1) { | ||
return { internalKey: `${assetNode.id}` } | ||
} | ||
|
||
return { internalKey: `${node.internalKey}-${assetNode.id}` } | ||
})() | ||
}) | ||
}) | ||
|
||
const total = data.totalItems ?? maxItemsPerNode | ||
|
||
return { nodes, total } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.