register dictionary store

This commit is contained in:
Mads Rasmussen
2023-03-02 15:15:31 +01:00
parent 20126d16d5
commit bd3b96df87
5 changed files with 31 additions and 20 deletions

View File

@@ -15,8 +15,6 @@ import {
UmbBackofficeContext,
UMB_BACKOFFICE_CONTEXT_TOKEN,
} from './shared/components/backoffice-frame/backoffice.context';
import { UmbDictionaryDetailStore } from './translation/dictionary/repository/dictionary.detail.store';
import { UmbDictionaryTreeStore } from './translation/dictionary/repository/dictionary.tree.store';
import { UmbDocumentBlueprintDetailStore } from './documents/document-blueprints/document-blueprint.detail.store';
import { UmbDocumentBlueprintTreeStore } from './documents/document-blueprints/document-blueprint.tree.store';
import { UmbTemplateTreeStore } from './templating/templates/tree/data/template.tree.store';
@@ -74,8 +72,6 @@ export class UmbBackofficeElement extends UmbLitElement {
new UmbUserStore(this);
new UmbUserGroupStore(this);
new UmbDictionaryDetailStore(this);
new UmbDictionaryTreeStore(this);
new UmbDocumentBlueprintDetailStore(this);
new UmbDocumentBlueprintTreeStore(this);
new UmbTemplateTreeStore(this);

View File

@@ -1,7 +1,7 @@
import { DictionaryTreeServerDataSource } from './sources/dictionary.tree.server.data';
import { UmbDictionaryTreeStore, UMB_DICTIONARY_TREE_STORE_CONTEXT_TOKEN } from './dictionary.tree.store';
import { UmbDictionaryDetailServerDataSource } from './sources/dictionary.detail.server.data';
import { UmbDictionaryDetailStore, UMB_DICTIONARY_DETAIL_STORE_CONTEXT_TOKEN } from './dictionary.detail.store';
import { UmbDictionaryStore, UMB_DICTIONARY_STORE_CONTEXT_TOKEN } from './dictionary.store';
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
import { RepositoryTreeDataSource, UmbDetailRepository, UmbTreeRepository } from '@umbraco-cms/repository';
@@ -18,7 +18,7 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo
#treeStore?: UmbDictionaryTreeStore;
#detailSource: UmbDictionaryDetailServerDataSource;
#detailStore?: UmbDictionaryDetailStore;
#detailStore?: UmbDictionaryStore;
#notificationContext?: UmbNotificationContext;
@@ -30,7 +30,7 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo
this.#detailSource = new UmbDictionaryDetailServerDataSource(this.#host);
this.#init = Promise.all([
new UmbContextConsumerController(this.#host, UMB_DICTIONARY_DETAIL_STORE_CONTEXT_TOKEN, (instance) => {
new UmbContextConsumerController(this.#host, UMB_DICTIONARY_STORE_CONTEXT_TOKEN, (instance) => {
this.#detailStore = instance;
}),

View File

@@ -6,17 +6,15 @@ import type { DictionaryDetails } from '@umbraco-cms/models';
/**
* @export
* @class UmbDictionaryDetailStore
* @class UmbDictionaryStore
* @extends {UmbStoreBase}
* @description - Details Data Store for Dictionary
* @description - Data Store for Dictionary
*/
export class UmbDictionaryDetailStore
extends UmbStoreBase
{
export class UmbDictionaryStore extends UmbStoreBase {
#data = new ArrayState<DictionaryDetails>([], (x) => x.key);
constructor(host: UmbControllerHostInterface) {
super(host, UmbDictionaryDetailStore.name);
super(host, UmbDictionaryStore.name);
}
append(dictionary: DictionaryDetails) {
@@ -25,9 +23,7 @@ export class UmbDictionaryDetailStore
remove(uniques: string[]) {
this.#data.remove(uniques);
}
}
}
export const UMB_DICTIONARY_DETAIL_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDictionaryDetailStore>(
UmbDictionaryDetailStore.name
);
export const UMB_DICTIONARY_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDictionaryStore>(UmbDictionaryStore.name);

View File

@@ -9,7 +9,6 @@ import { UmbControllerHostInterface } from '@umbraco-cms/controller';
* @description - Tree Data Store for Dictionary
*/
export class UmbDictionaryTreeStore extends UmbTreeStoreBase {
/**
* Creates an instance of UmbDictionaryTreeStore.
* @param {UmbControllerHostInterface} host
@@ -22,4 +21,4 @@ export class UmbDictionaryTreeStore extends UmbTreeStoreBase {
export const UMB_DICTIONARY_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDictionaryTreeStore>(
UmbDictionaryTreeStore.name
);
);

View File

@@ -1,5 +1,8 @@
import { UmbDictionaryRepository } from '../repository/dictionary.repository';
import { UmbDictionaryTreeStore } from './dictionary.tree.store';
import { UmbDictionaryStore } from './dictionary.store';
import { ManifestRepository } from 'libs/extensions-registry/repository.models';
import { ManifestStore, ManifestTreeStore } from '@umbraco-cms/extensions-registry';
export const DICTIONARY_REPOSITORY_ALIAS = 'Umb.Repository.Dictionary';
@@ -10,4 +13,21 @@ const repository: ManifestRepository = {
class: UmbDictionaryRepository,
};
export const manifests = [repository];
export const DICTIONARY_STORE_ALIAS = 'Umb.Store.Dictionary';
export const DICTIONARY_TREE_STORE_ALIAS = 'Umb.Store.DictionaryTree';
const store: ManifestStore = {
type: 'store',
alias: DICTIONARY_STORE_ALIAS,
name: 'Dictionary Store',
class: UmbDictionaryStore,
};
const treeStore: ManifestTreeStore = {
type: 'treeStore',
alias: DICTIONARY_TREE_STORE_ALIAS,
name: 'Dictionary Tree Store',
class: UmbDictionaryTreeStore,
};
export const manifests = [repository, store, treeStore];