wip stylesheet workspace context
This commit is contained in:
@@ -32,7 +32,7 @@ export class UmbStylesheetServerDataSource implements UmbDataSource<StylesheetDe
|
||||
async get(path: string) {
|
||||
if (!path) throw new Error('Path is missing');
|
||||
console.log('GET STYLESHEET WITH PATH', path);
|
||||
return {};
|
||||
return { data: undefined, error: undefined };
|
||||
}
|
||||
|
||||
insert(data: StylesheetDetails): Promise<DataSourceResponse<StylesheetDetails>> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { UmbStylesheetTreeStore, UMB_STYLESHEET_TREE_STORE_CONTEXT_TOKEN } from './stylesheet.tree.store';
|
||||
import { UmbStylesheetTreeServerDataSource } from './sources/stylesheet.tree.server.data';
|
||||
import { UmbStylesheetServerDataSource } from './sources/stylesheet.server.data';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/notification';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api';
|
||||
@@ -12,8 +13,9 @@ import {
|
||||
export class UmbStylesheetRepository
|
||||
implements UmbTreeRepository<PagedFileSystemTreeItemPresentationModel, FileSystemTreeItemPresentationModel>
|
||||
{
|
||||
#host: UmbControllerHostInterface;
|
||||
#treeDataSource: UmbStylesheetTreeServerDataSource;
|
||||
#host;
|
||||
#dataSource;
|
||||
#treeDataSource;
|
||||
#treeStore?: UmbStylesheetTreeStore;
|
||||
#notificationContext?: UmbNotificationContext;
|
||||
#initResolver?: () => void;
|
||||
@@ -21,7 +23,9 @@ export class UmbStylesheetRepository
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
// TODO: figure out how spin up get the correct data source
|
||||
this.#dataSource = new UmbStylesheetServerDataSource(this.#host);
|
||||
this.#treeDataSource = new UmbStylesheetTreeServerDataSource(this.#host);
|
||||
|
||||
new UmbContextConsumerController(this.#host, UMB_STYLESHEET_TREE_STORE_CONTEXT_TOKEN, (instance) => {
|
||||
@@ -95,4 +99,12 @@ export class UmbStylesheetRepository
|
||||
await this.#init;
|
||||
return this.#treeStore!.items(paths);
|
||||
}
|
||||
|
||||
// DETAILS
|
||||
async requestByPath(path: string) {
|
||||
if (!path) throw new Error('Path is missing');
|
||||
await this.#init;
|
||||
const { data, error } = await this.#dataSource.get(path);
|
||||
return { data, error };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
import { UmbWorkspaceContext } from '../../../shared/components/workspace/workspace-context/workspace-context';
|
||||
import { UmbStylesheetRepository } from '../repository/stylesheet.repository';
|
||||
import { StylesheetDetails } from '..';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
|
||||
import { UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace';
|
||||
import { ObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
|
||||
export class UmbStylesheetWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbStylesheetRepository>
|
||||
implements UmbWorkspaceContextInterface
|
||||
{
|
||||
#data = new ObjectState<StylesheetDetails | undefined>(undefined);
|
||||
data = this.#data.asObservable();
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
super(host, new UmbStylesheetRepository(host));
|
||||
}
|
||||
|
||||
/*
|
||||
getEntityType(): string {
|
||||
return 'stylesheet';
|
||||
}
|
||||
|
||||
getEntityKey() {
|
||||
return '1234';
|
||||
}
|
||||
|
||||
getData() {
|
||||
return 'fake' as unknown as MemberDetails;
|
||||
return this.#data.getValue();
|
||||
}
|
||||
|
||||
async save() {
|
||||
console.log('save');
|
||||
getEntityKey() {
|
||||
return this.getData()?.path || '';
|
||||
}
|
||||
|
||||
async load(path: string) {
|
||||
console.log('load', path);
|
||||
const { data } = await this.repository.requestByPath(path);
|
||||
if (data) {
|
||||
this.setIsNew(false);
|
||||
this.#data.update(data);
|
||||
}
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
console.log('destroy');
|
||||
this.#data.complete();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user