recreate the tree
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { UmbTreeItemContextBase } from '../tree-item-base/tree-item-base.context.js';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { FileSystemTreeItemPresentationModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
// TODO get unique method from an entity repository static method
|
||||
export class UmbFileSystemTreeItemContext extends UmbTreeItemContextBase<FileSystemTreeItemPresentationModel> {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(host, (x: FileSystemTreeItemPresentationModel) => x.path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { UmbFileSystemTreeItemContext } from './file-system-tree-item.context.js';
|
||||
import { css, html, nothing, customElement, property } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
import { EntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
UmbBackofficeManifestKind,
|
||||
UmbTreeItemExtensionElement,
|
||||
umbExtensionsRegistry,
|
||||
} from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
// TODO: Move to separate file:
|
||||
const manifest: UmbBackofficeManifestKind = {
|
||||
type: 'kind',
|
||||
alias: 'Umb.Kind.FileSystemTreeItem',
|
||||
matchKind: 'fileSystem',
|
||||
matchType: 'treeItem',
|
||||
manifest: {
|
||||
type: 'treeItem',
|
||||
elementName: 'umb-file-system-tree-item',
|
||||
},
|
||||
};
|
||||
umbExtensionsRegistry.register(manifest);
|
||||
|
||||
@customElement('umb-file-system-tree-item')
|
||||
export class UmbFileSystemTreeItemElement extends UmbLitElement implements UmbTreeItemExtensionElement {
|
||||
private _item?: EntityTreeItemResponseModel;
|
||||
@property({ type: Object, attribute: false })
|
||||
public get item() {
|
||||
return this._item;
|
||||
}
|
||||
public set item(value: EntityTreeItemResponseModel | undefined) {
|
||||
this._item = value;
|
||||
this.#context.setTreeItem(value);
|
||||
}
|
||||
|
||||
#context = new UmbFileSystemTreeItemContext(this);
|
||||
|
||||
render() {
|
||||
if (!this.item) return nothing;
|
||||
return html`<umb-tree-item-base></umb-tree-item-base>`;
|
||||
}
|
||||
|
||||
static styles = [UUITextStyles, css``];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-file-system-tree-item': UmbFileSystemTreeItemElement;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './file-system-tree-item.context.js';
|
||||
export * from './file-system-tree-item.element.js';
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './entity-tree-item/index.js';
|
||||
export * from './file-system-tree-item/index.js';
|
||||
export * from './tree-item/index.js';
|
||||
export * from './tree-item-base/index.js';
|
||||
export * from './tree-menu-item/index.js';
|
||||
|
||||
@@ -57,10 +57,12 @@ export class UmbPartialViewsRepository
|
||||
// TREE:
|
||||
|
||||
async requestTreeRoot() {
|
||||
|
||||
await this.#init;
|
||||
|
||||
const data = {
|
||||
id: null,
|
||||
path: null,
|
||||
type: PARTIAL_VIEW_ROOT_ENTITY_TYPE,
|
||||
name: 'Partial Views',
|
||||
icon: 'umb:folder',
|
||||
@@ -82,8 +84,10 @@ export class UmbPartialViewsRepository
|
||||
}
|
||||
|
||||
async requestTreeItemsOf(path: string | null) {
|
||||
if (!path) throw new Error('Cannot request tree item with missing path');
|
||||
|
||||
if (path === null) {
|
||||
return this.requestRootTreeItems();
|
||||
}
|
||||
|
||||
await this.#init;
|
||||
|
||||
const { data, error } = await this.#treeDataSource.getChildrenOf({ path });
|
||||
|
||||
@@ -10,6 +10,7 @@ const tree: ManifestTree = {
|
||||
type: 'tree',
|
||||
alias: PARTIAL_VIEW_TREE_ALIAS,
|
||||
name: 'Partial Views Tree',
|
||||
weight: 30,
|
||||
meta: {
|
||||
repositoryAlias: PARTIAL_VIEW_REPOSITORY_ALIAS,
|
||||
},
|
||||
@@ -17,11 +18,11 @@ const tree: ManifestTree = {
|
||||
|
||||
const treeItem: ManifestTreeItem = {
|
||||
type: 'treeItem',
|
||||
kind: 'entity',
|
||||
kind: 'fileSystem',
|
||||
alias: 'Umb.TreeItem.PartialViews',
|
||||
name: 'Partial Views Tree Item',
|
||||
conditions: {
|
||||
entityTypes: [PARTIAL_VIEW_ENTITY_TYPE, PARTIAL_VIEW_ROOT_ENTITY_TYPE],
|
||||
entityTypes: [PARTIAL_VIEW_ROOT_ENTITY_TYPE, PARTIAL_VIEW_ENTITY_TYPE],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user