remove the workspace-context base class
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { UmbNotificationService } from '../../../../../core/notification';
|
||||
import { UmbNotificationDefaultData } from '../../../../../core/notification/layouts/default';
|
||||
import { UmbWorkspaceContext } from '../workspace-context/workspace.context';
|
||||
import { UmbNodeStoreBase } from '@umbraco-cms/stores/store';
|
||||
import { UmbControllerHostInterface } from 'src/core/controller/controller-host.mixin';
|
||||
import { UmbContextConsumerController } from 'src/core/context-api/consume/context-consumer.controller';
|
||||
@@ -14,7 +14,14 @@ import type { ContentDetails } from '@umbraco-cms/models';
|
||||
export class UmbWorkspaceContentContext<
|
||||
ContentTypeType extends ContentDetails = ContentDetails,
|
||||
StoreType extends UmbNodeStoreBase<ContentTypeType> = UmbNodeStoreBase<ContentTypeType>
|
||||
> extends UmbWorkspaceContext<ContentTypeType> {
|
||||
> {
|
||||
|
||||
protected _host: UmbControllerHostInterface;
|
||||
|
||||
// TODO: figure out how fine grained we want to make our observables.
|
||||
// TODO: add interface
|
||||
protected _data!:BehaviorSubject<ContentTypeType>;
|
||||
public readonly data: Observable<ContentTypeType>;
|
||||
|
||||
protected _notificationService?: UmbNotificationService;
|
||||
|
||||
@@ -32,8 +39,10 @@ export class UmbWorkspaceContentContext<
|
||||
storeAlias: string,
|
||||
entityType: string
|
||||
) {
|
||||
super(host, defaultData);
|
||||
|
||||
this._host = host;
|
||||
this._data = new BehaviorSubject<ContentTypeType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
this.entityType = entityType;
|
||||
|
||||
host.addEventListener('property-value-change', this._onPropertyValueChange);
|
||||
@@ -59,6 +68,14 @@ export class UmbWorkspaceContentContext<
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public getData() {
|
||||
return this._data.getValue();
|
||||
}
|
||||
public update(data: Partial<ContentTypeType>) {
|
||||
this._data.next({ ...this.getData(), ...data });
|
||||
}
|
||||
|
||||
load(entityKey: string) {
|
||||
this.#isNew = false;
|
||||
this.entityKey = entityKey;
|
||||
@@ -137,4 +154,12 @@ export class UmbWorkspaceContentContext<
|
||||
this._notificationService?.peek('danger', { data });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: how can we make sure to call this.
|
||||
public destroy(): void {
|
||||
this._host.removeEventListener('property-value-change', this._onPropertyValueChange);
|
||||
this._data.unsubscribe();
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
|
||||
CollectionContext {
|
||||
|
||||
// RxJS store..
|
||||
this._data = new BehaviorSubject<BlockType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
|
||||
getStore();
|
||||
|
||||
}
|
||||
|
||||
|
||||
DocumentCollectionContext extends CollectionContext {
|
||||
|
||||
// RxJS store..
|
||||
this._data = new BehaviorSubject<BlockType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
|
||||
getStore();
|
||||
publish();
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
|
||||
MediaCollectionContext extends CollectionContext {
|
||||
|
||||
// RxJS store..
|
||||
this._data = new BehaviorSubject<BlockType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
|
||||
getStore();
|
||||
update();
|
||||
save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
VendrCollectionContext extends CollectionContext {
|
||||
|
||||
// RxJS store..
|
||||
this._data = new BehaviorSubject<BlockType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
|
||||
getStore();
|
||||
update();
|
||||
save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DocumentContext {
|
||||
|
||||
// Validation?
|
||||
|
||||
// RxJS store..
|
||||
this._data = new BehaviorSubject<BlockType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
|
||||
getStore();
|
||||
|
||||
setPublishDate()
|
||||
|
||||
addVariant(name) {
|
||||
this.data.name = name;
|
||||
}
|
||||
|
||||
save() {
|
||||
this.backendStore.save()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
PropertyContext {
|
||||
|
||||
// Validation?
|
||||
|
||||
}
|
||||
|
||||
|
||||
BlockContext {
|
||||
|
||||
// Validation?
|
||||
|
||||
this._data = new BehaviorSubject<BlockType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
|
||||
this._liveEditing = true;
|
||||
|
||||
setName(name) {
|
||||
this.update({name: name})
|
||||
if(this._liveEditing) {
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
//
|
||||
this.parentData.block[123] = this.data.getData();
|
||||
this.parentDatarxJS.update(this.parentData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
var myBlockContext = new BlockContext(documentData.blocks[1]);
|
||||
|
||||
|
||||
// Property Editor Edit Element Name:
|
||||
|
||||
myBlockContext.data.subscribe((blockData) => {
|
||||
this.input.value = blockData.name;
|
||||
})
|
||||
this.input.addEventListener("change", () => {
|
||||
myBlockContext.setName(this.input.value);
|
||||
// RXJS update?? ^^
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
blockContext.setName('sdaafgdss');
|
||||
// Does does other update?
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { BehaviorSubject, Observable } from "rxjs";
|
||||
import { UmbControllerHostInterface } from "src/core/controller/controller-host.mixin";
|
||||
|
||||
|
||||
export abstract class UmbWorkspaceContext<DataType> {
|
||||
|
||||
protected _host: UmbControllerHostInterface;
|
||||
|
||||
// TODO: figure out how fine grained we want to make our observables.
|
||||
// TODO: add interface
|
||||
protected _data!:BehaviorSubject<DataType>;
|
||||
public readonly data: Observable<DataType>;
|
||||
|
||||
|
||||
constructor(host:UmbControllerHostInterface, defaultData: DataType) {
|
||||
this._host = host;
|
||||
|
||||
this._data = new BehaviorSubject<DataType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
}
|
||||
|
||||
|
||||
public getData() {
|
||||
return this._data.getValue();
|
||||
}
|
||||
|
||||
public update(data: Partial<DataType>) {
|
||||
this._data.next({ ...this.getData(), ...data });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: how can we make sure to call this.
|
||||
public destroy(): void {
|
||||
this._data.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user