diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/templates/tree/template-tree.store.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/templates/tree/template-tree.store.ts index ca16f4e581..1e27c06d6a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/templates/tree/template-tree.store.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/templates/tree/template-tree.store.ts @@ -1,5 +1,10 @@ +import { UMB_TEMPLATE_DETAIL_STORE_CONTEXT } from '../repository/detail/template-detail.store.js'; +import type { UmbTemplateDetailModel } from '../types.js'; +import { UMB_TEMPLATE_ENTITY_TYPE } from '../entity.js'; +import type { UmbTemplateTreeItemModel } from './types.js'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { UmbStoreConnector } from '@umbraco-cms/backoffice/store'; import { UmbUniqueTreeStore } from '@umbraco-cms/backoffice/tree'; /** @@ -16,7 +21,36 @@ export class UmbTemplateTreeStore extends UmbUniqueTreeStore { */ constructor(host: UmbControllerHostElement) { super(host, UMB_TEMPLATE_TREE_STORE_CONTEXT.toString()); + + new UmbStoreConnector( + host, + this, + UMB_TEMPLATE_DETAIL_STORE_CONTEXT, + (item) => this.#createTreeItemMapper(item), + (item) => this.#updateTreeItemMapper(item), + ); } + + // TODO: revisit this when we have decided on detail model sizes + #createTreeItemMapper = (item: UmbTemplateDetailModel) => { + const treeItem: UmbTemplateTreeItemModel = { + unique: item.unique, + parentUnique: item.parentUnique, + entityType: UMB_TEMPLATE_ENTITY_TYPE, + name: item.name, + hasChildren: false, + isFolder: false, + }; + + return treeItem; + }; + + // TODO: revisit this when we have decided on detail model sizes + #updateTreeItemMapper = (item: UmbTemplateDetailModel) => { + return { + name: item.name, + }; + }; } export const UMB_TEMPLATE_TREE_STORE_CONTEXT = new UmbContextToken('UmbTemplateTreeStore');