further implementation
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
PagedEntityTreeItem,
|
PagedEntityTreeItem,
|
||||||
ProblemDetails,
|
ProblemDetails,
|
||||||
} from '@umbraco-cms/backend-api';
|
} from '@umbraco-cms/backend-api';
|
||||||
import { UmbTreeRepository } from 'libs/repositories/tree-repository.interface';
|
import { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
// Extension Manifests
|
// Extension Manifests
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ export interface UmbDetailRepository<DetailType> {
|
|||||||
error?: ProblemDetails;
|
error?: ProblemDetails;
|
||||||
}>
|
}>
|
||||||
|
|
||||||
create(data: DetailType): Promise<{
|
createDetail(data: DetailType): Promise<{
|
||||||
error?: ProblemDetails;
|
error?: ProblemDetails;
|
||||||
}>
|
}>
|
||||||
|
|
||||||
save(data: DetailType): Promise<{
|
saveDetail(data: DetailType): Promise<{
|
||||||
error?: ProblemDetails;
|
error?: ProblemDetails;
|
||||||
}>
|
}>
|
||||||
|
|
||||||
2
src/Umbraco.Web.UI.Client/libs/repository/index.ts
Normal file
2
src/Umbraco.Web.UI.Client/libs/repository/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './detail-repository.interface';
|
||||||
|
export * from './tree-repository.interface';
|
||||||
@@ -2,19 +2,21 @@ import type { Observable } from "rxjs";
|
|||||||
import { EntityTreeItem, PagedEntityTreeItem, ProblemDetails } from "@umbraco-cms/backend-api";
|
import { EntityTreeItem, PagedEntityTreeItem, ProblemDetails } from "@umbraco-cms/backend-api";
|
||||||
|
|
||||||
export interface UmbTreeRepository {
|
export interface UmbTreeRepository {
|
||||||
requestRootItems: () => Promise<{
|
|
||||||
|
requestRootTreeItems: () => Promise<{
|
||||||
data: PagedEntityTreeItem | undefined;
|
data: PagedEntityTreeItem | undefined;
|
||||||
error: ProblemDetails | undefined;
|
error: ProblemDetails | undefined;
|
||||||
}>;
|
}>;
|
||||||
requestChildrenOf: (parentKey: string | null) => Promise<{
|
requestTreeItemsOf: (parentKey: string | null) => Promise<{
|
||||||
data: PagedEntityTreeItem | undefined;
|
data: PagedEntityTreeItem | undefined;
|
||||||
error: ProblemDetails | undefined;
|
error: ProblemDetails | undefined;
|
||||||
}>;
|
}>;
|
||||||
requestItems: (keys: string[]) => Promise<{
|
requestTreeItems: (keys: string[]) => Promise<{
|
||||||
data: Array<EntityTreeItem> | undefined;
|
data: Array<EntityTreeItem> | undefined;
|
||||||
error: ProblemDetails | undefined;
|
error: ProblemDetails | undefined;
|
||||||
}>;
|
}>;
|
||||||
rootItems: () => Promise<Observable<EntityTreeItem[]>>;
|
|
||||||
childrenOf: (parentKey: string | null) => Promise<Observable<EntityTreeItem[]>>;
|
rootTreeItems: () => Promise<Observable<EntityTreeItem[]>>;
|
||||||
items: (keys: string[]) => Promise<Observable<EntityTreeItem[]>>;
|
treeItemsOf: (parentKey: string | null) => Promise<Observable<EntityTreeItem[]>>;
|
||||||
|
treeItems: (keys: string[]) => Promise<Observable<EntityTreeItem[]>>;
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import type { DocumentTreeDataSource } from '../tree/data/sources/document.tree.
|
|||||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||||
import { ProblemDetails } from '@umbraco-cms/backend-api';
|
import { ProblemDetails } from '@umbraco-cms/backend-api';
|
||||||
import type { UmbTreeRepository } from 'libs/repositories/tree-repository.interface';
|
import type { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||||
|
|
||||||
// Move to documentation / JSdoc
|
// Move to documentation / JSdoc
|
||||||
/* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */
|
/* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */
|
||||||
@@ -39,7 +39,7 @@ export class UmbDocumentRepository implements UmbTreeRepository {
|
|||||||
// TODO: Move
|
// TODO: Move
|
||||||
|
|
||||||
|
|
||||||
async requestRootItems() {
|
async requestRootTreeItems() {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
const { data, error } = await this.#source.getRootItems();
|
const { data, error } = await this.#source.getRootItems();
|
||||||
@@ -51,7 +51,7 @@ export class UmbDocumentRepository implements UmbTreeRepository {
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestChildrenOf(parentKey: string | null) {
|
async requestTreeItemsOf(parentKey: string | null) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
if (!parentKey) {
|
if (!parentKey) {
|
||||||
@@ -68,7 +68,7 @@ export class UmbDocumentRepository implements UmbTreeRepository {
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestItems(keys: Array<string>) {
|
async requestTreeItems(keys: Array<string>) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
if (!keys) {
|
if (!keys) {
|
||||||
@@ -81,17 +81,17 @@ export class UmbDocumentRepository implements UmbTreeRepository {
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async rootItems() {
|
async rootTreeItems() {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
return this.#store!.rootItems;
|
return this.#store!.rootItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
async childrenOf(parentKey: string | null) {
|
async treeItemsOf(parentKey: string | null) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
return this.#store!.childrenOf(parentKey);
|
return this.#store!.childrenOf(parentKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
async items(keys: Array<string>) {
|
async treeItems(keys: Array<string>) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
return this.#store!.items(keys);
|
return this.#store!.items(keys);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Observable } from 'rxjs';
|
import type { Observable } from 'rxjs';
|
||||||
import type { ManifestTree, UmbTreeRepository } from '@umbraco-cms/models';
|
import { UmbTreeRepository } from '@umbraco-cms/repository';
|
||||||
|
import type { ManifestTree } from '@umbraco-cms/models';
|
||||||
import { DeepState } from '@umbraco-cms/observable-api';
|
import { DeepState } from '@umbraco-cms/observable-api';
|
||||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||||
|
|
||||||
@@ -56,18 +57,18 @@ export class UmbTreeContextBase implements UmbTreeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async requestRootItems() {
|
public async requestRootItems() {
|
||||||
return this.repository.requestRootItems();
|
return this.repository.requestRootTreeItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async requestChildrenOf(parentKey: string | null) {
|
public async requestChildrenOf(parentKey: string | null) {
|
||||||
return this.repository.requestChildrenOf(parentKey);
|
return this.repository.requestTreeItemsOf(parentKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async rootItems() {
|
public async rootItems() {
|
||||||
return this.repository.rootItems();
|
return this.repository.rootTreeItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async childrenOf(parentKey: string | null) {
|
public async childrenOf(parentKey: string | null) {
|
||||||
return this.repository.childrenOf(parentKey);
|
return this.repository.treeItemsOf(parentKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { UmbTemplateDetailServerDataSource } from '../workspace/data/sources/template.detail.server.data';
|
import { UmbTemplateDetailServerDataSource } from '../workspace/data/sources/template.detail.server.data';
|
||||||
import { TemplateTreeServerDataSource } from '../tree/data/sources/template.tree.server.data';
|
import { TemplateTreeServerDataSource } from '../tree/data/sources/template.tree.server.data';
|
||||||
import { UmbTemplateDetailStore, UMB_TEMPLATE_DETAIL_STORE_CONTEXT_TOKEN } from '../workspace/data/template.detail.store';
|
import { UmbTemplateDetailStore, UMB_TEMPLATE_DETAIL_STORE_CONTEXT_TOKEN } from '../workspace/data/template.detail.store';
|
||||||
import { UmbTemplateTreeStore, UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN } from './template.tree.store';
|
import { UmbTemplateTreeStore, UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN } from '../tree/data/template.tree.store';
|
||||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||||
import { ProblemDetails, Template } from '@umbraco-cms/backend-api';
|
import { ProblemDetails, Template } from '@umbraco-cms/backend-api';
|
||||||
import { UmbDetailRepository } from 'libs/repositories/detail-repository.interface';
|
import { UmbDetailRepository } from 'libs/repository/detail-repository.interface';
|
||||||
import { UmbTreeRepository } from 'libs/repositories/tree-repository.interface';
|
import { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||||
|
|
||||||
// Move to documentation / JSdoc
|
// Move to documentation / JSdoc
|
||||||
/* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */
|
/* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */
|
||||||
@@ -55,7 +55,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
// TREE:
|
// TREE:
|
||||||
|
|
||||||
|
|
||||||
async requestRootItems() {
|
async requestRootTreeItems() {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
const { data, error } = await this.#treeDataSource.getRootItems();
|
const { data, error } = await this.#treeDataSource.getRootItems();
|
||||||
@@ -67,7 +67,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestChildrenOf(parentKey: string | null) {
|
async requestTreeItemsOf(parentKey: string | null) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
if (!parentKey) {
|
if (!parentKey) {
|
||||||
@@ -83,7 +83,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestItems(keys: Array<string>) {
|
async requestTreeItems(keys: Array<string>) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
if (!keys) {
|
if (!keys) {
|
||||||
@@ -95,17 +95,17 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async rootItems() {
|
async rootTreeItems() {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
return this.#treeStore!.rootItems();
|
return this.#treeStore!.rootItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
async childrenOf(parentKey: string | null) {
|
async treeItemsOf(parentKey: string | null) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
return this.#treeStore!.childrenOf(parentKey);
|
return this.#treeStore!.childrenOf(parentKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
async items(keys: Array<string>) {
|
async treeItems(keys: Array<string>) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
return this.#treeStore!.items(keys);
|
return this.#treeStore!.items(keys);
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,12 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
return { data, error };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(template: Template) {
|
|
||||||
|
|
||||||
|
// Could potentially be general methods:
|
||||||
|
|
||||||
|
|
||||||
|
async createDetail(template: Template) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
if (!template || !template.key) {
|
if (!template || !template.key) {
|
||||||
@@ -169,7 +174,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
return { error };
|
return { error };
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(template: Template) {
|
async saveDetail(template: Template) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
if (!template || !template.key) {
|
if (!template || !template.key) {
|
||||||
@@ -193,6 +198,11 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
|||||||
return { error };
|
return { error };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// General:
|
||||||
|
|
||||||
async delete(key: string) {
|
async delete(key: string) {
|
||||||
await this.#init;
|
await this.#init;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { UmbTemplateTreeRepository } from './data/template.tree.repository';
|
import { UmbTemplateRepository } from '../repository/template.repository';
|
||||||
import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models';
|
import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models';
|
||||||
|
|
||||||
const tree: ManifestTree = {
|
const tree: ManifestTree = {
|
||||||
@@ -6,7 +6,7 @@ const tree: ManifestTree = {
|
|||||||
alias: 'Umb.Tree.Templates',
|
alias: 'Umb.Tree.Templates',
|
||||||
name: 'Templates Tree',
|
name: 'Templates Tree',
|
||||||
meta: {
|
meta: {
|
||||||
repository: UmbTemplateTreeRepository,
|
repository: UmbTemplateRepository,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"@umbraco-cms/utils": ["libs/utils"],
|
"@umbraco-cms/utils": ["libs/utils"],
|
||||||
"@umbraco-cms/router": ["libs/router"],
|
"@umbraco-cms/router": ["libs/router"],
|
||||||
"@umbraco-cms/test-utils": ["libs/test-utils"],
|
"@umbraco-cms/test-utils": ["libs/test-utils"],
|
||||||
|
"@umbraco-cms/repository": ["libs/repository"],
|
||||||
"@umbraco-cms/resources": ["libs/resources"],
|
"@umbraco-cms/resources": ["libs/resources"],
|
||||||
"@umbraco-cms/store": ["libs/store"],
|
"@umbraco-cms/store": ["libs/store"],
|
||||||
"@umbraco-cms/components/*": ["src/backoffice/components/*"],
|
"@umbraco-cms/components/*": ["src/backoffice/components/*"],
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export default {
|
|||||||
'@umbraco-cms/utils': './libs/utils/index.ts',
|
'@umbraco-cms/utils': './libs/utils/index.ts',
|
||||||
'@umbraco-cms/test-utils': './libs/test-utils/index.ts',
|
'@umbraco-cms/test-utils': './libs/test-utils/index.ts',
|
||||||
'@umbraco-cms/resources': './libs/resources/index.ts',
|
'@umbraco-cms/resources': './libs/resources/index.ts',
|
||||||
|
"@umbraco-cms/repository": './libs/repository',
|
||||||
'@umbraco-cms/router': './libs/router/index.ts'
|
'@umbraco-cms/router': './libs/router/index.ts'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user