fix variuous interface errors
This commit is contained in:
@@ -2,8 +2,7 @@ import { UmbTemplateRepository } from '../repository/partial-views.repository';
|
||||
import { PARTIAL_VIEW_REPOSITORY_ALIAS } from '../config';
|
||||
import { UmbPartialViewsTreeStore } from './partial-views.tree.store';
|
||||
import { UmbPartialViewsStore } from './partial-views.store';
|
||||
import { ManifestRepository } from 'libs/extensions-registry/repository.models';
|
||||
import { ManifestStore, ManifestTreeStore } from '@umbraco-cms/backoffice/extensions-registry';
|
||||
import { ManifestRepository, ManifestStore, ManifestTreeStore } from '@umbraco-cms/backoffice/extensions-registry';
|
||||
|
||||
|
||||
const repository: ManifestRepository = {
|
||||
|
||||
@@ -81,7 +81,7 @@ export class UmbTemplateRepository implements UmbTreeRepository<any>, UmbDetailR
|
||||
return { data: undefined, error };
|
||||
}
|
||||
|
||||
const { data, error } = await this.#treeDataSource.getItems(keys);
|
||||
const { data, error } = await this.#treeDataSource.getItem(keys);
|
||||
|
||||
return { data, error, asObservable: () => this.#treeStore!.items(keys) };
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { ArrayState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import type { TemplateResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
import { UMB_PARTIAL_VIEW_STORE_CONTEXT_TOKEN_ALIAS } from '../config';
|
||||
|
||||
/**
|
||||
@@ -12,15 +12,17 @@ import { UMB_PARTIAL_VIEW_STORE_CONTEXT_TOKEN_ALIAS } from '../config';
|
||||
* @description - Data Store for partial views
|
||||
*/
|
||||
export class UmbPartialViewsStore extends UmbStoreBase {
|
||||
#data = new ArrayState<TemplateResponseModel>([], (x) => x.key);
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbPartialViewsStore.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
* @memberof UmbPartialViewsStore
|
||||
*/
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
super(host, UMB_PARTIAL_VIEWS_STORE_CONTEXT_TOKEN.toString());
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(
|
||||
host,
|
||||
UMB_PARTIAL_VIEWS_STORE_CONTEXT_TOKEN.toString(),
|
||||
new UmbArrayState<TemplateResponseModel>([], (x) => x.id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +31,7 @@ export class UmbPartialViewsStore extends UmbStoreBase {
|
||||
* @memberof UmbPartialViewsStore
|
||||
*/
|
||||
append(template: TemplateResponseModel) {
|
||||
this.#data.append([template]);
|
||||
this._data.append([template]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ export class UmbPartialViewsStore extends UmbStoreBase {
|
||||
* @memberof UmbPartialViewsStore
|
||||
*/
|
||||
remove(uniques: string[]) {
|
||||
this.#data.remove(uniques);
|
||||
this._data.remove(uniques);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UMB_PARTIAL_VIEW_TREE_STORE_CONTEXT_TOKEN_ALIAS } from '../config';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbFileSystemTreeStore } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
export const UMB_PARTIAL_VIEW_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbPartialViewsTreeStore>(
|
||||
UMB_PARTIAL_VIEW_TREE_STORE_CONTEXT_TOKEN_ALIAS
|
||||
@@ -20,7 +20,7 @@ export class UmbPartialViewsTreeStore extends UmbFileSystemTreeStore {
|
||||
* @param {UmbControllerHostInterface} host
|
||||
* @memberof UmbPartialViewsTreeStore
|
||||
*/
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(host, UMB_PARTIAL_VIEW_TREE_STORE_CONTEXT_TOKEN.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ export interface PartialViewsTreeDataSource {
|
||||
skip?: number | undefined;
|
||||
take?: number | undefined;
|
||||
}): Promise<DataSourceResponse<PagedFileSystemTreeItemPresentationModel>>;
|
||||
getItems(paths: Array<string>): Promise<DataSourceResponse<FileSystemTreeItemPresentationModel[]>>;
|
||||
getItem(ids: Array<string>): Promise<DataSourceResponse<FileSystemTreeItemPresentationModel[]>>;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import { PartialViewDetails } from '../../config';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
import { DataSourceResponse, UmbDataSource } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
export class UmbPartialViewDetailServerDataSource implements UmbDataSource<PartialViewDetails> {
|
||||
#host: UmbControllerHostInterface;
|
||||
//TODO Pass proper models
|
||||
export class UmbPartialViewDetailServerDataSource
|
||||
implements UmbDataSource<PartialViewDetails, PartialViewDetails, PartialViewDetails>
|
||||
{
|
||||
#host: UmbControllerHostElement;
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbPartialViewDetailServerDataSource.
|
||||
* @param {UmbControllerHostInterface} host
|
||||
* @memberof UmbPartialViewDetailServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
@@ -33,10 +36,10 @@ export class UmbPartialViewDetailServerDataSource implements UmbDataSource<Parti
|
||||
insert(data: any): Promise<DataSourceResponse<PartialViewDetails>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
update(data: PartialViewDetails): Promise<DataSourceResponse<PartialViewDetails>> {
|
||||
update(unique: string, data: PartialViewDetails): Promise<DataSourceResponse<PartialViewDetails>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
delete(key: string): Promise<DataSourceResponse<PartialViewDetails>> {
|
||||
delete(unique: string): Promise<DataSourceResponse> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { PartialViewsTreeDataSource } from '.';
|
||||
import { PartialViewResource, ProblemDetailsModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
export class UmbPartialViewsTreeServerDataSource implements PartialViewsTreeDataSource {
|
||||
#host: UmbControllerHostInterface;
|
||||
#host: UmbControllerHostElement;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
@@ -38,16 +38,16 @@ export class UmbPartialViewsTreeServerDataSource implements PartialViewsTreeData
|
||||
);
|
||||
}
|
||||
|
||||
async getItems(paths: Array<string>) {
|
||||
if (!paths) {
|
||||
async getItem(id: Array<string>) {
|
||||
if (!id) {
|
||||
const error: ProblemDetailsModel = { title: 'Paths are missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
PartialViewResource.getTreePartialViewItem({
|
||||
path: paths,
|
||||
PartialViewResource.getPartialViewItem({
|
||||
id,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,27 @@ import { UmbTemplateRepository } from '../repository/partial-views.repository';
|
||||
import { UmbWorkspaceContext } from '../../../shared/components/workspace/workspace-context/workspace-context';
|
||||
import { createObservablePart, UmbDeepState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { TemplateResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
|
||||
export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbTemplateRepository> {
|
||||
export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbTemplateRepository, TemplateResponseModel> {
|
||||
getEntityId(): string | undefined {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
getEntityType(): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
save(): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
destroy(): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
#data = new UmbDeepState<TemplateResponseModel | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
name = createObservablePart(this.#data, (data) => data?.name);
|
||||
content = createObservablePart(this.#data, (data) => data?.content);
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(host, new UmbTemplateRepository(host));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { TEMPLATE_REPOSITORY_ALIAS } from '../repository/manifests';
|
||||
import { UmbSaveWorkspaceAction } from '@umbraco-cms/backoffice/workspace';
|
||||
import type {
|
||||
ManifestWorkspace,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { UUITextStyles } from '@umbraco-ui/uui-css';
|
||||
import { css, html } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { UmbRouterSlotInitEvent, IRoute, IRoutingInfo } from '@umbraco-cms/internal/router';
|
||||
import { UmbRouterSlotInitEvent } from '@umbraco-cms/internal/router';
|
||||
import type { IRoute, IRoutingInfo, PageComponent } from '@umbraco-cms/backoffice/router';
|
||||
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
|
||||
import './template-workspace-edit.element';
|
||||
@@ -23,7 +25,7 @@ export class UmbTemplateWorkspaceElement extends UmbLitElement {
|
||||
{
|
||||
path: 'create/:parentKey',
|
||||
component: () => this.#element,
|
||||
setup: async (component: HTMLElement, info: IRoutingInfo) => {
|
||||
setup: (component: PageComponent, info: IRoutingInfo) => {
|
||||
const parentKey = info.match.params.parentKey;
|
||||
this.#templateWorkspaceContext.createScaffold(parentKey);
|
||||
},
|
||||
@@ -31,7 +33,7 @@ export class UmbTemplateWorkspaceElement extends UmbLitElement {
|
||||
{
|
||||
path: 'edit/:key',
|
||||
component: () => this.#element,
|
||||
setup: (component: HTMLElement, info: IRoutingInfo) => {
|
||||
setup: (component: PageComponent, info: IRoutingInfo): void => {
|
||||
const key = info.match.params.key;
|
||||
this.#templateWorkspaceContext.load(key);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user