use unique for template tree

This commit is contained in:
Mads Rasmussen
2024-01-31 19:53:20 +01:00
parent d8848d6480
commit a693f817b6
7 changed files with 19 additions and 19 deletions

View File

@@ -1,7 +1,5 @@
export const UMB_TEMPLATE_ROOT_ENTITY_TYPE = 'template-root';
export const UMB_TEMPLATE_ENTITY_TYPE = 'template';
export const UMB_TEMPLATE_FOLDER_ENTITY_TYPE = 'template-folder';
export type UmbTemplateEntityType = typeof UMB_TEMPLATE_ENTITY_TYPE;
export type UmbTemplateRootEntityType = typeof UMB_TEMPLATE_ROOT_ENTITY_TYPE;
export type UmbTemplateFolderEntityType = typeof UMB_TEMPLATE_FOLDER_ENTITY_TYPE;

View File

@@ -38,7 +38,7 @@ const tree: ManifestTree = {
const treeItem: ManifestTreeItem = {
type: 'treeItem',
kind: 'entity',
kind: 'unique',
alias: 'Umb.TreeItem.Template',
name: 'Template Tree Item',
meta: {

View File

@@ -1,8 +1,4 @@
import {
UMB_TEMPLATE_ROOT_ENTITY_TYPE,
UMB_TEMPLATE_ENTITY_TYPE,
UMB_TEMPLATE_FOLDER_ENTITY_TYPE,
} from '../../entity.js';
import { UMB_TEMPLATE_ROOT_ENTITY_TYPE, UMB_TEMPLATE_ENTITY_TYPE } from '../../entity.js';
import { UmbReloadTreeItemChildrenEntityAction } from '@umbraco-cms/backoffice/tree';
import type { ManifestEntityAction } from '@umbraco-cms/backoffice/extension-registry';
@@ -17,7 +13,7 @@ export const manifests: Array<ManifestEntityAction> = [
icon: 'icon-refresh',
label: 'Reload children...',
repositoryAlias: 'Umb.Repository.Template.Tree',
entityTypes: [UMB_TEMPLATE_ROOT_ENTITY_TYPE, UMB_TEMPLATE_ENTITY_TYPE, UMB_TEMPLATE_FOLDER_ENTITY_TYPE],
entityTypes: [UMB_TEMPLATE_ROOT_ENTITY_TYPE, UMB_TEMPLATE_ENTITY_TYPE],
},
},
];

View File

@@ -16,7 +16,7 @@ export class UmbTemplateTreeRepository
async requestTreeRoot() {
const data: UmbTemplateTreeRootModel = {
id: null,
unique: null,
entityType: UMB_TEMPLATE_ROOT_ENTITY_TYPE,
name: 'Templates',
hasChildren: true,

View File

@@ -1,3 +1,4 @@
import { UMB_TEMPLATE_ENTITY_TYPE } from '../entity.js';
import type { UmbTemplateTreeItemModel } from './types.js';
import { UmbTreeServerDataSourceBase } from '@umbraco-cms/backoffice/tree';
import type { NamedEntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
@@ -44,10 +45,10 @@ const getChildrenOf = (parentUnique: string | null) => {
const mapper = (item: NamedEntityTreeItemResponseModel): UmbTemplateTreeItemModel => {
return {
id: item.id,
parentId: item.parent ? item.parent.id : null,
unique: item.id,
parentUnique: item.parent ? item.parent.id : null,
name: item.name,
entityType: 'template',
entityType: UMB_TEMPLATE_ENTITY_TYPE,
hasChildren: item.hasChildren,
isFolder: false,
};

View File

@@ -1,6 +1,6 @@
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/tree';
import { UmbUniqueTreeStore } from '@umbraco-cms/backoffice/tree';
/**
* @export
@@ -8,7 +8,7 @@ import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/tree';
* @extends {UmbStoreBase}
* @description - Tree Data Store for Template Items
*/
export class UmbTemplateTreeStore extends UmbEntityTreeStore {
export class UmbTemplateTreeStore extends UmbUniqueTreeStore {
/**
* Creates an instance of UmbTemplateTreeStore.
* @param {UmbControllerHostElement} host

View File

@@ -1,5 +1,10 @@
import type { UmbEntityTreeItemModel, UmbEntityTreeRootModel } from '@umbraco-cms/backoffice/tree';
import type { UmbTemplateEntityType, UmbTemplateRootEntityType } from '../entity.js';
import type { UmbUniqueTreeItemModel, UmbUniqueTreeRootModel } from '@umbraco-cms/backoffice/tree';
export interface UmbTemplateTreeItemModel extends UmbEntityTreeItemModel {}
// TODO: TREE STORE TYPE PROBLEM:
export interface UmbTemplateTreeRootModel extends UmbEntityTreeRootModel {}
export interface UmbTemplateTreeItemModel extends UmbUniqueTreeItemModel {
entityType: UmbTemplateEntityType;
}
export interface UmbTemplateTreeRootModel extends UmbUniqueTreeRootModel {
entityType: UmbTemplateRootEntityType;
}