rename TreeStoreBase to EntityTreeStore
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { ManifestClass } from './models';
|
||||
import { UmbStoreBase, UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbStoreBase, UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
|
||||
export interface ManifestStore extends ManifestClass<UmbStoreBase> {
|
||||
type: 'store';
|
||||
}
|
||||
|
||||
export interface ManifestTreeStore extends ManifestClass<UmbTreeStoreBase> {
|
||||
export interface ManifestTreeStore extends ManifestClass<UmbEntityTreeStore> {
|
||||
type: 'treeStore';
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import { UmbStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbTreeStoreBase
|
||||
* @class UmbEntityTreeStore
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - General Tree Data Store
|
||||
*/
|
||||
// TODO: consider if tree store could be turned into a general EntityTreeStore class?
|
||||
export class UmbTreeStoreBase<
|
||||
export class UmbEntityTreeStore<
|
||||
T extends EntityTreeItemResponseModel = EntityTreeItemResponseModel
|
||||
> extends UmbStoreBase {
|
||||
#data = new ArrayState<T>([], (x) => x.key);
|
||||
@@ -17,7 +17,7 @@ export class UmbTreeStoreBase<
|
||||
/**
|
||||
* Appends items to the store
|
||||
* @param {Array<EntityTreeItemResponseModel>} items
|
||||
* @memberof UmbTreeStoreBase
|
||||
* @memberof UmbEntityTreeStore
|
||||
*/
|
||||
appendItems(items: Array<T>) {
|
||||
this.#data.append(items);
|
||||
@@ -27,7 +27,7 @@ export class UmbTreeStoreBase<
|
||||
* Updates an item in the store
|
||||
* @param {string} key
|
||||
* @param {Partial<EntityTreeItemResponseModel>} data
|
||||
* @memberof UmbTreeStoreBase
|
||||
* @memberof UmbEntityTreeStore
|
||||
*/
|
||||
updateItem(key: string, data: Partial<T>) {
|
||||
this.#data.next(partialUpdateFrozenArray(this.#data.getValue(), data, (entry) => entry.key === key));
|
||||
@@ -36,7 +36,7 @@ export class UmbTreeStoreBase<
|
||||
/**
|
||||
* Removes an item from the store
|
||||
* @param {string} key
|
||||
* @memberof UmbTreeStoreBase
|
||||
* @memberof UmbEntityTreeStore
|
||||
*/
|
||||
removeItem(key: string) {
|
||||
this.#data.removeOne(key);
|
||||
@@ -44,7 +44,7 @@ export class UmbTreeStoreBase<
|
||||
|
||||
/**
|
||||
* An observable to observe the root items
|
||||
* @memberof UmbTreeStoreBase
|
||||
* @memberof UmbEntityTreeStore
|
||||
*/
|
||||
rootItems = this.#data.getObservablePart((items) => items.filter((item) => item.parentKey === null));
|
||||
|
||||
@@ -52,7 +52,7 @@ export class UmbTreeStoreBase<
|
||||
* Returns an observable to observe the children of a given parent
|
||||
* @param {(string | null)} parentKey
|
||||
* @return {*}
|
||||
* @memberof UmbTreeStoreBase
|
||||
* @memberof UmbEntityTreeStore
|
||||
*/
|
||||
childrenOf(parentKey: string | null) {
|
||||
return this.#data.getObservablePart((items) => items.filter((item) => item.parentKey === parentKey));
|
||||
@@ -62,7 +62,7 @@ export class UmbTreeStoreBase<
|
||||
* Returns an observable to observe the items with the given keys
|
||||
* @param {Array<string>} keys
|
||||
* @return {*}
|
||||
* @memberof UmbTreeStoreBase
|
||||
* @memberof UmbEntityTreeStore
|
||||
*/
|
||||
items(keys: Array<string>) {
|
||||
return this.#data.getObservablePart((items) => items.filter((item) => keys.includes(item.key ?? '')));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
export const UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDocumentBlueprintTreeStore>(
|
||||
@@ -12,7 +12,7 @@ export const UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT_TOKEN = new UmbContextTok
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Tree Data Store for Document Blueprints
|
||||
*/
|
||||
export class UmbDocumentBlueprintTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbDocumentBlueprintTreeStore extends UmbEntityTreeStore {
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
super(host, UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT_TOKEN.toString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
/**
|
||||
@@ -9,7 +9,7 @@ import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
* @description - Tree Data Store for Document-Types
|
||||
*/
|
||||
// TODO: consider if tree store could be turned into a general EntityTreeStore class?
|
||||
export class UmbDocumentTypeTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbDocumentTypeTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbDocumentTypeTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbDocumentTreeStore
|
||||
* @extends {UmbTreeStoreBase}
|
||||
* @extends {UmbEntityTreeStore}
|
||||
* @description - Tree Data Store for Templates
|
||||
*/
|
||||
export class UmbDocumentTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbDocumentTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbDocumentTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
@@ -19,6 +19,4 @@ export class UmbDocumentTreeStore extends UmbTreeStoreBase {
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_DOCUMENT_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDocumentTreeStore>(
|
||||
'UmbDocumentTreeStore'
|
||||
);
|
||||
export const UMB_DOCUMENT_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDocumentTreeStore>('UmbDocumentTreeStore');
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbMediaTypeTreeStore
|
||||
* @extends {UmbTreeStoreBase}
|
||||
* @extends {UmbEntityTreeStore}
|
||||
* @description - Tree Data Store for Media Types
|
||||
*/
|
||||
export class UmbMediaTypeTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbMediaTypeTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbMediaTypeTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { ArrayState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
export const UMB_MEDIA_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbMediaTreeStore>('UmbMediaTreeStore');
|
||||
@@ -9,10 +9,10 @@ export const UMB_MEDIA_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbMediaTr
|
||||
/**
|
||||
* @export
|
||||
* @class UmbMediaTreeStore
|
||||
* @extends {UmbTreeStoreBase}
|
||||
* @extends {UmbEntityTreeStore}
|
||||
* @description - Tree Data Store for Media
|
||||
*/
|
||||
export class UmbMediaTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbMediaTreeStore extends UmbEntityTreeStore {
|
||||
#data = new ArrayState<EntityTreeItemResponseModel>([], (x) => x.key);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbMemberGroupTreeStore
|
||||
* @extends {UmbTreeStoreBase}
|
||||
* @extends {UmbEntityTreeStore}
|
||||
* @description - Tree Data Store for Member Groups
|
||||
*/
|
||||
export class UmbMemberGroupTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbMemberGroupTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbMemberGroupTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
/**
|
||||
@@ -8,7 +8,7 @@ import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/control
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Tree Data Store for Member Types
|
||||
*/
|
||||
export class UmbMemberTypeTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbMemberTypeTreeStore extends UmbEntityTreeStore {
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
super(host, UMB_MEMBER_TYPE_TREE_STORE_CONTEXT_TOKEN.toString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
export const UMB_MEMBER_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbMemberTreeStore>('UmbMemberTreeStore');
|
||||
@@ -7,10 +7,10 @@ export const UMB_MEMBER_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbMember
|
||||
/**
|
||||
* @export
|
||||
* @class UmbMemberTreeStore
|
||||
* @extends {UmbTreeStoreBase}
|
||||
* @extends {UmbEntityTreeStore}
|
||||
* @description - Tree Data Store for Members
|
||||
*/
|
||||
export class UmbMemberTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbMemberTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbTemplateTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
|
||||
/**
|
||||
* @export
|
||||
@@ -9,7 +9,7 @@ import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
* @description - Tree Data Store for Data-Types
|
||||
*/
|
||||
// TODO: consider if tree store could be turned into a general EntityTreeStore class?
|
||||
export class UmbDataTypeTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbDataTypeTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbDataTypeTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
@@ -20,6 +20,4 @@ export class UmbDataTypeTreeStore extends UmbTreeStoreBase {
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_DATA_TYPE_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDataTypeTreeStore>(
|
||||
'UmbDataTypeTreeStore'
|
||||
);
|
||||
export const UMB_DATA_TYPE_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDataTypeTreeStore>('UmbDataTypeTreeStore');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
|
||||
/**
|
||||
* @export
|
||||
@@ -9,7 +9,7 @@ import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
* @description - Tree Data Store for relation-types
|
||||
*/
|
||||
// TODO: consider if tree store could be turned into a general EntityTreeStore class?
|
||||
export class UmbRelationTypeTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbRelationTypeTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbRelationTypeTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
export const UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbTemplateTreeStore>(
|
||||
'UmbTemplateTreeStore'
|
||||
);
|
||||
export const UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbTemplateTreeStore>('UmbTemplateTreeStore');
|
||||
|
||||
/**
|
||||
* @export
|
||||
@@ -12,7 +10,7 @@ export const UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbTemp
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Tree Data Store for Templates
|
||||
*/
|
||||
export class UmbTemplateTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbTemplateTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbTemplateTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbTreeStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbDictionaryTreeStore
|
||||
* @extends {UmbTreeStoreBase}
|
||||
* @extends {UmbEntityTreeStore}
|
||||
* @description - Tree Data Store for Dictionary
|
||||
*/
|
||||
export class UmbDictionaryTreeStore extends UmbTreeStoreBase {
|
||||
export class UmbDictionaryTreeStore extends UmbEntityTreeStore {
|
||||
/**
|
||||
* Creates an instance of UmbDictionaryTreeStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
|
||||
Reference in New Issue
Block a user