diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/index.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/index.ts index 99bbb9c653..ee34d2f355 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/index.ts @@ -1 +1,2 @@ export { UmbDataTypeCollectionRepository } from './repository/index.js'; +export { UMB_DATA_TYPE_COLLECTION_ALIAS } from './constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/manifests.ts index 699cc91d01..9a3b80e549 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/manifests.ts @@ -1,4 +1,5 @@ -import { UMB_DATA_TYPE_COLLECTION_ALIAS, UMB_DATA_TYPE_COLLECTION_REPOSITORY_ALIAS } from './constants.js'; +import { UMB_DATA_TYPE_COLLECTION_REPOSITORY_ALIAS } from './repository/constants.js'; +import { UMB_DATA_TYPE_COLLECTION_ALIAS } from './constants.js'; import { manifests as collectionRepositoryManifests } from './repository/manifests.js'; export const manifests: Array = [ diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/repository/index.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/repository/index.ts index d633fd497e..f5e9356499 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/repository/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/collection/repository/index.ts @@ -1 +1,2 @@ +export { UMB_DATA_TYPE_COLLECTION_REPOSITORY_ALIAS } from './constants.js'; export { UmbDataTypeCollectionRepository } from './data-type-collection.repository.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/constants.ts index ce0921b3a1..6b39e48151 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/constants.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/constants.ts @@ -1,11 +1,12 @@ export * from './collection/constants.js'; -export * from './modals/constants.js'; +export * from './data-type-root/constants.js'; export * from './entity-actions/constants.js'; +export * from './modals/constants.js'; +export * from './paths.js'; export * from './reference/constants.js'; export * from './repository/constants.js'; export * from './tree/constants.js'; export * from './workspace/constants.js'; -export * from './paths.js'; export { UMB_DATA_TYPE_ENTITY_TYPE, UMB_DATA_TYPE_ROOT_ENTITY_TYPE, diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/constants.ts new file mode 100644 index 0000000000..3c186741bc --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/constants.ts @@ -0,0 +1 @@ +export const UMB_DATA_TYPE_ROOT_WORKSPACE_ALIAS = 'Umb.Workspace.DataType.Root'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/index.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/index.ts new file mode 100644 index 0000000000..4f07201dcf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/index.ts @@ -0,0 +1 @@ +export * from './constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/manifests.ts new file mode 100644 index 0000000000..86cdec1a3b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/data-type-root/manifests.ts @@ -0,0 +1,14 @@ +import { UMB_DATA_TYPE_ROOT_ENTITY_TYPE } from '../entity.js'; + +export const manifests: Array = [ + { + type: 'workspace', + kind: 'default', + alias: 'Umb.Workspace.DataType.Root', + name: 'Data Type Root Workspace', + meta: { + entityType: UMB_DATA_TYPE_ROOT_ENTITY_TYPE, + headline: '#treeHeaders_dataTypes', + }, + }, +]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/manifests.ts index e6d9723664..fcc8a78068 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/manifests.ts @@ -1,4 +1,5 @@ import { manifests as collectionManifests } from './collection/manifests.js'; +import { manifests as dataTypeRootManifest } from './data-type-root/manifests.js'; import { manifests as entityActions } from './entity-actions/manifests.js'; import { manifests as menuManifests } from './menu/manifests.js'; import { manifests as modalManifests } from './modals/manifests.js'; @@ -9,6 +10,7 @@ import { manifests as workspaceManifests } from './workspace/manifests.js'; export const manifests: Array = [ ...collectionManifests, + ...dataTypeRootManifest, ...entityActions, ...menuManifests, ...modalManifests, diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/paths.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/paths.ts index b227145ed0..95b20a31b3 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/paths.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/paths.ts @@ -18,3 +18,8 @@ export const UMB_CREATE_DATA_TYPE_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ parentEntityType: UmbEntityModel['entityType']; parentUnique: UmbEntityModel['unique']; }>('create/parent/:parentEntityType/:parentUnique', UMB_DATA_TYPE_WORKSPACE_PATH); + +export const UMB_EDIT_DATA_TYPE_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ unique: string }>( + 'edit/:unique', + UMB_DATA_TYPE_WORKSPACE_PATH, +); diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/constants.ts index 83415b9d5e..33e12f46bf 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/constants.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/constants.ts @@ -1,6 +1,7 @@ +export { UMB_DATA_TYPE_TREE_STORE_CONTEXT } from './data-type-tree.store.context-token.js'; +export * from './folder/constants.js'; +export * from './tree-item-children/constants.js'; + export const UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.DataType.Tree'; export const UMB_DATA_TYPE_TREE_STORE_ALIAS = 'Umb.Store.DataType.Tree'; export const UMB_DATA_TYPE_TREE_ALIAS = 'Umb.Tree.DataType'; -export { UMB_DATA_TYPE_TREE_STORE_CONTEXT } from './data-type-tree.store.context-token.js'; - -export * from './folder/constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/manifests.ts index c2df954881..767366a374 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/manifests.ts @@ -1,7 +1,9 @@ import { UMB_DATA_TYPE_FOLDER_ENTITY_TYPE } from '../../entity.js'; +import { UMB_DATA_TYPE_ROOT_WORKSPACE_ALIAS } from '../../data-type-root/index.js'; import { UMB_DATA_TYPE_FOLDER_REPOSITORY_ALIAS } from './repository/index.js'; import { manifests as workspaceManifests } from './workspace/manifests.js'; import { manifests as repositoryManifests } from './repository/manifests.js'; +import { UMB_DATA_TYPE_FOLDER_WORKSPACE_ALIAS } from './workspace/index.js'; export const manifests: Array = [ { @@ -24,6 +26,24 @@ export const manifests: Array = [ folderRepositoryAlias: UMB_DATA_TYPE_FOLDER_REPOSITORY_ALIAS, }, }, + { + type: 'workspaceView', + kind: 'collection', + alias: 'Umb.WorkspaceView.DataType.TreeItemChildrenCollection', + name: 'Data Type Tree Item Children Collection Workspace View', + meta: { + label: 'Folder', + pathname: 'folder', + icon: 'icon-folder', + collectionAlias: 'Umb.Collection.DataType.TreeItemChildren', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + oneOf: [UMB_DATA_TYPE_ROOT_WORKSPACE_ALIAS, UMB_DATA_TYPE_FOLDER_WORKSPACE_ALIAS], + }, + ], + }, ...repositoryManifests, ...workspaceManifests, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/constants.ts index f9db22ebb4..266f7848a0 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/constants.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/constants.ts @@ -1,2 +1,4 @@ -export const UMB_DATA_TYPE_FOLDER_WORKSPACE_ALIAS = 'Umb.Workspace.DataType.Folder'; export { UMB_DATA_TYPE_FOLDER_WORKSPACE_CONTEXT } from './data-type-folder.workspace.context-token.js'; +export * from './paths.js'; + +export const UMB_DATA_TYPE_FOLDER_WORKSPACE_ALIAS = 'Umb.Workspace.DataType.Folder'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/index.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/index.ts index b000fefb6a..5b900e0f4a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/index.ts @@ -1,2 +1,3 @@ export * from './constants.js'; export * from './data-type-folder.workspace.context-token.js'; +export * from './paths.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/paths.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/paths.ts new file mode 100644 index 0000000000..c73116be1a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/folder/workspace/paths.ts @@ -0,0 +1,14 @@ +import { UMB_DATA_TYPE_FOLDER_ENTITY_TYPE } from '../../../entity.js'; +import { UmbPathPattern } from '@umbraco-cms/backoffice/router'; +import { UMB_SETTINGS_SECTION_PATHNAME } from '@umbraco-cms/backoffice/settings'; +import { UMB_WORKSPACE_PATH_PATTERN } from '@umbraco-cms/backoffice/workspace'; + +export const UMB_DATA_TYPE_FOLDER_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({ + sectionName: UMB_SETTINGS_SECTION_PATHNAME, + entityType: UMB_DATA_TYPE_FOLDER_ENTITY_TYPE, +}); + +export const UMB_EDIT_DATA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ unique: string }>( + 'edit/:unique', + UMB_DATA_TYPE_FOLDER_WORKSPACE_PATH, +); diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/manifests.ts index 0a1adef5cd..4804b67c44 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/manifests.ts @@ -1,6 +1,5 @@ -import { UMB_DATA_TYPE_ROOT_ENTITY_TYPE } from '../entity.js'; import { manifests as folderManifests } from './folder/manifests.js'; -import { manifests as reloadManifests } from './reload-tree-item-children/manifests.js'; +import { manifests as treeItemChildren } from './tree-item-children/manifests.js'; import { UMB_DATA_TYPE_TREE_ALIAS, UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS, @@ -36,16 +35,6 @@ export const manifests: Array = [ name: 'Data Type Tree Item', forEntityTypes: ['data-type-root', 'data-type', 'data-type-folder'], }, - { - type: 'workspace', - kind: 'default', - alias: 'Umb.Workspace.DataType.Root', - name: 'Data Type Root Workspace', - meta: { - entityType: UMB_DATA_TYPE_ROOT_ENTITY_TYPE, - headline: '#treeHeaders_dataTypes', - }, - }, ...folderManifests, - ...reloadManifests, + ...treeItemChildren, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/constants.ts new file mode 100644 index 0000000000..19b6af02ac --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/constants.ts @@ -0,0 +1,2 @@ +export * from './repository/constants.js'; +export const UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS = 'Umb.Collection.DataType.TreeItemChildren'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/index.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/index.ts new file mode 100644 index 0000000000..6c11f6abbb --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/index.ts @@ -0,0 +1,2 @@ +export * from './constants.js'; +export * from './repository/index.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/manifests.ts new file mode 100644 index 0000000000..2013e6ee3b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/manifests.ts @@ -0,0 +1,18 @@ +import { manifests as viewManifests } from './views/manifests.js'; +import { manifests as repositoryManifests } from './repository/manifests.js'; +import { UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS } from './constants.js'; +import { UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS } from './repository/index.js'; + +export const manifests: Array = [ + { + type: 'collection', + kind: 'default', + alias: UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS, + name: 'Data Type Tree Item Children Collection', + meta: { + repositoryAlias: UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS, + }, + }, + ...viewManifests, + ...repositoryManifests, +]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/constants.ts new file mode 100644 index 0000000000..4b17784897 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/constants.ts @@ -0,0 +1,2 @@ +export const UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS = + 'Umb.Repository.DataType.TreeItemChildrenCollection'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/data-type-tree-item-children-collection.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/data-type-tree-item-children-collection.repository.ts new file mode 100644 index 0000000000..5aeb4da334 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/data-type-tree-item-children-collection.repository.ts @@ -0,0 +1,33 @@ +import { UmbDataTypeTreeRepository } from '../../../data-type-tree.repository.js'; +import type { UmbCollectionFilterModel, UmbCollectionRepository } from '@umbraco-cms/backoffice/collection'; +import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository'; +import { UMB_ENTITY_CONTEXT, type UmbEntityModel } from '@umbraco-cms/backoffice/entity'; + +export class UmbDataTypeTreeItemChildrenCollectionRepository + extends UmbRepositoryBase + implements UmbCollectionRepository +{ + #treeRepository = new UmbDataTypeTreeRepository(this); + + async requestCollection(filter: UmbCollectionFilterModel) { + // TODO: get parent from args + const entityContext = await this.getContext(UMB_ENTITY_CONTEXT); + if (!entityContext) throw new Error('Entity context not found'); + + const entityType = entityContext.getEntityType(); + const unique = entityContext.getUnique(); + + if (!entityType) throw new Error('Entity type not found'); + if (unique === undefined) throw new Error('Unique not found'); + + const parent: UmbEntityModel = { entityType, unique }; + + if (parent.unique === null) { + return this.#treeRepository.requestTreeRootItems({ skip: filter.skip, take: filter.take }); + } else { + return this.#treeRepository.requestTreeItemsOf({ parent, skip: filter.skip, take: filter.take }); + } + } +} + +export { UmbDataTypeTreeItemChildrenCollectionRepository as api }; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/index.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/index.ts new file mode 100644 index 0000000000..4f07201dcf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/index.ts @@ -0,0 +1 @@ +export * from './constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/manifests.ts new file mode 100644 index 0000000000..b0724d1fb6 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/repository/manifests.ts @@ -0,0 +1,10 @@ +import { UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS } from './constants.js'; + +export const manifests: Array = [ + { + type: 'repository', + alias: UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS, + name: 'Data Type Tree Item Children Collection Repository', + api: () => import('./data-type-tree-item-children-collection.repository.js'), + }, +]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/types.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/types.ts new file mode 100644 index 0000000000..caca1dd379 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/types.ts @@ -0,0 +1,6 @@ +import type { UmbCollectionFilterModel } from '@umbraco-cms/backoffice/collection'; +import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity'; + +export interface UmbDataTypeTreeItemChildrenCollectionFilterModel extends UmbCollectionFilterModel { + parent: UmbEntityModel; +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/views/data-type-tree-item-table-collection-view.element.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/views/data-type-tree-item-table-collection-view.element.ts new file mode 100644 index 0000000000..8a5e7d6041 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/views/data-type-tree-item-table-collection-view.element.ts @@ -0,0 +1,126 @@ +import type { UmbDataTypeTreeItemModel } from '../../../types.js'; +import { UMB_EDIT_DATA_TYPE_WORKSPACE_PATH_PATTERN } from '../../../../paths.js'; +import { UMB_EDIT_DATA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN } from '../../../folder/index.js'; +import type { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection'; +import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection'; +import type { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; +import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; +import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; +import { UmbModalRouteRegistrationController, type UmbModalRouteBuilder } from '@umbraco-cms/backoffice/router'; +import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/workspace'; + +@customElement('umb-data-type-tree-item-table-collection-view') +export class UmbDataTypeTreeItemTableCollectionViewElement extends UmbLitElement { + @state() + private _tableConfig: UmbTableConfig = { + allowSelection: false, + }; + + @state() + private _tableColumns: Array = [ + { + name: 'Name', + alias: 'name', + }, + { + name: '', + alias: 'entityActions', + }, + ]; + + @state() + private _tableItems: Array = []; + + #collectionContext?: UmbDefaultCollectionContext; + #routeBuilder?: UmbModalRouteBuilder; + + constructor() { + super(); + + this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => { + this.#collectionContext = instance; + }); + + this.#registerModalRoute(); + } + + #registerModalRoute() { + new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL) + .addAdditionalPath(':entityType') + .onSetup((params) => { + return { data: { entityType: params.entityType, preset: {} } }; + }) + .observeRouteBuilder((routeBuilder) => { + this.#routeBuilder = routeBuilder; + + // NOTE: Configuring the observations AFTER the route builder is ready, + // otherwise there is a race condition and `#collectionContext.items` tends to win. [LK] + this.#observeCollectionItems(); + }); + } + + #observeCollectionItems() { + if (!this.#collectionContext) return; + this.observe(this.#collectionContext.items, (items) => this.#createTableItems(items), 'umbCollectionItemsObserver'); + } + + #createTableItems(items: Array) { + const routeBuilder = this.#routeBuilder; + if (!routeBuilder) throw new Error('Route builder not ready'); + + this._tableItems = items.map((item) => { + const modalEditPath = + routeBuilder({ entityType: item.entityType }) + + UMB_EDIT_DATA_TYPE_WORKSPACE_PATH_PATTERN.generateLocal({ unique: item.unique }); + const inlineEditPath = UMB_EDIT_DATA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN.generateAbsolute({ + unique: item.unique, + }); + + return { + id: item.unique, + icon: item.isFolder && !item.icon ? 'icon-folder' : item.icon, + data: [ + { + columnAlias: 'name', + value: html``, + }, + { + columnAlias: 'entityActions', + value: html``, + }, + ], + }; + }); + } + + override render() { + return html` + + `; + } + + static override styles = [ + UmbTextStyles, + css` + :host { + display: flex; + flex-direction: column; + } + `, + ]; +} + +export { UmbDataTypeTreeItemTableCollectionViewElement as element }; + +declare global { + interface HTMLElementTagNameMap { + ['umb-data-type-tree-item-table-collection-view']: UmbDataTypeTreeItemTableCollectionViewElement; + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/views/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/views/manifests.ts new file mode 100644 index 0000000000..4e279b012e --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/collection/views/manifests.ts @@ -0,0 +1,23 @@ +import { UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS } from '../constants.js'; +import { UMB_COLLECTION_ALIAS_CONDITION } from '@umbraco-cms/backoffice/collection'; + +export const manifests: Array = [ + { + type: 'collectionView', + alias: 'Umb.CollectionView.DataType.TreeItem.Table', + name: 'Data Type Tree Item Table Collection View', + element: () => import('./data-type-tree-item-table-collection-view.element.js'), + weight: 300, + meta: { + label: 'Table', + icon: 'icon-list', + pathName: 'table', + }, + conditions: [ + { + alias: UMB_COLLECTION_ALIAS_CONDITION, + match: UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS, + }, + ], + }, +]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/constants.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/constants.ts new file mode 100644 index 0000000000..d7b529d49c --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/constants.ts @@ -0,0 +1 @@ +export * from './collection/constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/reload-tree-item-children/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/manifests.ts similarity index 80% rename from src/Umbraco.Web.UI.Client/src/packages/data-type/tree/reload-tree-item-children/manifests.ts rename to src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/manifests.ts index 295541cd05..51c3980b26 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/reload-tree-item-children/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/data-type/tree/tree-item-children/manifests.ts @@ -1,6 +1,8 @@ import { UMB_DATA_TYPE_FOLDER_ENTITY_TYPE, UMB_DATA_TYPE_ROOT_ENTITY_TYPE } from '../../entity.js'; +import { manifests as collectionManifests } from './collection/manifests.js'; export const manifests: Array = [ + ...collectionManifests, { type: 'entityAction', kind: 'reloadTreeItemChildren', diff --git a/src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts b/src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts index 42fa07d7f0..2388c5fe0f 100644 --- a/src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts +++ b/src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts @@ -116,7 +116,7 @@ export const foundConsts = [{ }, { path: '@umbraco-cms/backoffice/data-type', - consts: ["UMB_DATA_TYPE_COLLECTION_ALIAS","UMB_DATA_TYPE_COLLECTION_REPOSITORY_ALIAS","UMB_DATA_TYPE_CREATE_OPTIONS_MODAL","UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS","UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS","UMB_DATA_TYPE_ENTITY_TYPE","UMB_DATA_TYPE_ROOT_ENTITY_TYPE","UMB_DATA_TYPE_FOLDER_ENTITY_TYPE","UMB_DATA_TYPE_PICKER_FLOW_DATA_TYPE_PICKER_MODAL","UMB_DATA_TYPE_PICKER_FLOW_MODAL","UMB_DATA_TYPE_PICKER_MODAL","UMB_DATA_TYPE_WORKSPACE_PATH","UMB_DATA_TYPE_ROOT_WORKSPACE_PATH","UMB_CREATE_DATA_TYPE_WORKSPACE_PATH_PATTERN","UMB_DATA_TYPE_REFERENCE_REPOSITORY_ALIAS","UMB_DATA_TYPE_DETAIL_REPOSITORY_ALIAS","UMB_DATA_TYPE_DETAIL_STORE_ALIAS","UMB_DATA_TYPE_DETAIL_STORE_CONTEXT","UMB_DATA_TYPE_ITEM_REPOSITORY_ALIAS","UMB_DATA_TYPE_STORE_ALIAS","UMB_DATA_TYPE_ITEM_STORE_CONTEXT","UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS","UMB_DATA_TYPE_TREE_STORE_ALIAS","UMB_DATA_TYPE_TREE_ALIAS","UMB_DATA_TYPE_TREE_STORE_CONTEXT","UMB_DATA_TYPE_FOLDER_REPOSITORY_ALIAS","UMB_DATA_TYPE_FOLDER_STORE_ALIAS","UMB_DATA_TYPE_FOLDER_STORE_CONTEXT","UMB_DATA_TYPE_FOLDER_WORKSPACE_ALIAS","UMB_DATA_TYPE_FOLDER_WORKSPACE_CONTEXT","UMB_DATA_TYPE_WORKSPACE_ALIAS","UMB_DATA_TYPE_WORKSPACE_CONTEXT","UMB_DATATYPE_WORKSPACE_MODAL"] + consts: ["UMB_DATA_TYPE_COLLECTION_ALIAS","UMB_DATA_TYPE_COLLECTION_REPOSITORY_ALIAS","UMB_DATA_TYPE_ROOT_WORKSPACE_ALIAS","UMB_DATA_TYPE_CREATE_OPTIONS_MODAL","UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS","UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS","UMB_DATA_TYPE_ENTITY_TYPE","UMB_DATA_TYPE_ROOT_ENTITY_TYPE","UMB_DATA_TYPE_FOLDER_ENTITY_TYPE","UMB_DATA_TYPE_PICKER_FLOW_DATA_TYPE_PICKER_MODAL","UMB_DATA_TYPE_PICKER_FLOW_MODAL","UMB_DATA_TYPE_PICKER_MODAL","UMB_DATA_TYPE_WORKSPACE_PATH","UMB_DATA_TYPE_ROOT_WORKSPACE_PATH","UMB_CREATE_DATA_TYPE_WORKSPACE_PATH_PATTERN","UMB_EDIT_DATA_TYPE_WORKSPACE_PATH_PATTERN","UMB_DATA_TYPE_REFERENCE_REPOSITORY_ALIAS","UMB_DATA_TYPE_DETAIL_REPOSITORY_ALIAS","UMB_DATA_TYPE_DETAIL_STORE_ALIAS","UMB_DATA_TYPE_DETAIL_STORE_CONTEXT","UMB_DATA_TYPE_ITEM_REPOSITORY_ALIAS","UMB_DATA_TYPE_STORE_ALIAS","UMB_DATA_TYPE_ITEM_STORE_CONTEXT","UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS","UMB_DATA_TYPE_TREE_STORE_ALIAS","UMB_DATA_TYPE_TREE_ALIAS","UMB_DATA_TYPE_TREE_STORE_CONTEXT","UMB_DATA_TYPE_FOLDER_REPOSITORY_ALIAS","UMB_DATA_TYPE_FOLDER_STORE_ALIAS","UMB_DATA_TYPE_FOLDER_STORE_CONTEXT","UMB_DATA_TYPE_FOLDER_WORKSPACE_ALIAS","UMB_DATA_TYPE_FOLDER_WORKSPACE_CONTEXT","UMB_DATA_TYPE_FOLDER_WORKSPACE_PATH","UMB_EDIT_DATA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN","UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS","UMB_DATA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS","UMB_DATA_TYPE_WORKSPACE_ALIAS","UMB_DATA_TYPE_WORKSPACE_CONTEXT","UMB_DATATYPE_WORKSPACE_MODAL"] }, { path: '@umbraco-cms/backoffice/debug',