add document type tree repo, store etc.
This commit is contained in:
@@ -14,6 +14,6 @@ export const UMB_DOCUMENT_TYPE_PICKER_MODAL = new UmbModalToken<
|
||||
size: 'small',
|
||||
},
|
||||
{
|
||||
treeAlias: 'Umb.Tree.DocumentTypes',
|
||||
treeAlias: 'Umb.Tree.DocumentType',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DOCUMENT_TYPE_TREE_ALIAS } from '../tree/manifests.js';
|
||||
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
const menuItem: ManifestTypes = {
|
||||
@@ -7,7 +8,7 @@ const menuItem: ManifestTypes = {
|
||||
name: 'Document Types Menu Item',
|
||||
weight: 900,
|
||||
meta: {
|
||||
treeAlias: 'Umb.Tree.DocumentTypes',
|
||||
treeAlias: DOCUMENT_TYPE_TREE_ALIAS,
|
||||
label: 'Document Types',
|
||||
icon: 'icon-folder',
|
||||
menus: ['Umb.Menu.Settings'],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UmbDocumentTypeTreeServerDataSource } from './sources/document-type.tree.server.data.js';
|
||||
import { UmbDocumentTypeTreeServerDataSource } from '../tree/document-type.tree.server.data-source.js';
|
||||
import { UmbDocumentTypeServerDataSource } from './sources/document-type.server.data.js';
|
||||
import { UmbDocumentTypeTreeStore, UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT_TOKEN } from './document-type.tree.store.js';
|
||||
import { UmbDocumentTypeStore, UMB_DOCUMENT_TYPE_STORE_CONTEXT_TOKEN } from './document-type.store.js';
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { DOCUMENT_TYPE_ROOT_ENTITY_TYPE } from '../index.js';
|
||||
import { UmbDocumentTypeTreeServerDataSource } from './document-type.tree.server.data-source.js';
|
||||
import { UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT } from './document-type.tree.store.js';
|
||||
import { UmbDocumentTypeTreeItemModel, UmbDocumentTypeTreeRootModel } from './types.js';
|
||||
import { UmbEntityTreeRepositoryBase } from '@umbraco-cms/backoffice/tree';
|
||||
import { type UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbApi } from '@umbraco-cms/backoffice/extension-api';
|
||||
|
||||
export class UmbDocumentTypeTreeRepository
|
||||
extends UmbEntityTreeRepositoryBase<UmbDocumentTypeTreeItemModel, UmbDocumentTypeTreeRootModel>
|
||||
implements UmbApi
|
||||
{
|
||||
constructor(host: UmbControllerHost) {
|
||||
super(host, UmbDocumentTypeTreeServerDataSource, UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT);
|
||||
}
|
||||
|
||||
async requestTreeRoot() {
|
||||
const data = {
|
||||
id: null,
|
||||
type: DOCUMENT_TYPE_ROOT_ENTITY_TYPE,
|
||||
name: 'BLa Bla',
|
||||
icon: 'icon-folder',
|
||||
hasChildren: true,
|
||||
};
|
||||
|
||||
return { data };
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
/**
|
||||
* A data source for the Document tree that fetches data from the server
|
||||
* A data source for the Document Type tree that fetches data from the server
|
||||
* @export
|
||||
* @class UmbDocumentTypeTreeServerDataSource
|
||||
* @implements {UmbTreeDataSource}
|
||||
@@ -12,35 +12,6 @@ import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
export class UmbDocumentTypeTreeServerDataSource implements UmbTreeDataSource {
|
||||
#host: UmbControllerHost;
|
||||
|
||||
// TODO: how do we handle trashed items?
|
||||
async trashItems(ids: Array<string>) {
|
||||
// TODO: use backend cli when available.
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
fetch('/umbraco/management/api/v1/document-type/trash', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(ids),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async moveItems(ids: Array<string>, destination: string) {
|
||||
// TODO: use backend cli when available.
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
fetch('/umbraco/management/api/v1/document-type/move', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ids: ids, destination }),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbDocumentTypeTreeServerDataSource.
|
||||
* @param {UmbControllerHost} host
|
||||
@@ -0,0 +1,24 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/tree';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbDocumentTypeTreeStore
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Tree Data Store for Document Types
|
||||
*/
|
||||
export class UmbDocumentTypeTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbDocumentTypeTreeStore.
|
||||
* @param {UmbControllerHostElement} host
|
||||
* @memberof UmbDocumentTypeTreeStore
|
||||
*/
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(host, UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT.toString());
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT = new UmbContextToken<UmbDocumentTypeTreeStore>(
|
||||
'UmbDocumentTypeTreeStore',
|
||||
);
|
||||
@@ -1,14 +1,36 @@
|
||||
import { DOCUMENT_TYPE_REPOSITORY_ALIAS } from '../repository/manifests.js';
|
||||
import type { ManifestTree, ManifestTreeItem } from '@umbraco-cms/backoffice/extension-registry';
|
||||
import { UmbDocumentTypeTreeRepository } from './document-type-tree.repository.js';
|
||||
import { UmbDocumentTypeTreeStore } from './document-type.tree.store.js';
|
||||
import type {
|
||||
ManifestRepository,
|
||||
ManifestTree,
|
||||
ManifestTreeItem,
|
||||
ManifestTreeStore,
|
||||
} from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const DOCUMENT_TYPE_TREE_ALIAS = 'Umb.Tree.DocumentTypes';
|
||||
export const DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.DocumentType.Tree';
|
||||
export const DOCUMENT_TYPE_TREE_STORE_ALIAS = 'Umb.Store.DocumentType.Tree';
|
||||
export const DOCUMENT_TYPE_TREE_ALIAS = 'Umb.Tree.DocumentType';
|
||||
|
||||
const treeRepository: ManifestRepository = {
|
||||
type: 'repository',
|
||||
alias: DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
name: 'Document Type Tree Repository',
|
||||
api: UmbDocumentTypeTreeRepository,
|
||||
};
|
||||
|
||||
const treeStore: ManifestTreeStore = {
|
||||
type: 'treeStore',
|
||||
alias: DOCUMENT_TYPE_TREE_STORE_ALIAS,
|
||||
name: 'Document Type Tree Store',
|
||||
api: UmbDocumentTypeTreeStore,
|
||||
};
|
||||
|
||||
const tree: ManifestTree = {
|
||||
type: 'tree',
|
||||
alias: DOCUMENT_TYPE_TREE_ALIAS,
|
||||
name: 'Document Types Tree',
|
||||
name: 'Document Type Tree',
|
||||
meta: {
|
||||
repositoryAlias: DOCUMENT_TYPE_REPOSITORY_ALIAS,
|
||||
repositoryAlias: DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -22,4 +44,4 @@ const treeItem: ManifestTreeItem = {
|
||||
},
|
||||
};
|
||||
|
||||
export const manifests = [tree, treeItem];
|
||||
export const manifests = [treeRepository, treeStore, tree, treeItem];
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { DocumentTypeTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbEntityTreeItemModel, UmbEntityTreeRootModel } from '@umbraco-cms/backoffice/tree';
|
||||
|
||||
export type UmbDocumentTypeTreeItemModel = DocumentTypeTreeItemResponseModel & UmbEntityTreeItemModel;
|
||||
export type UmbDocumentTypeTreeRootModel = DocumentTypeTreeItemResponseModel & UmbEntityTreeRootModel;
|
||||
Reference in New Issue
Block a user