darta type
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import type { DataTypeDetails } from '@umbraco-cms/models';
|
||||
|
||||
export class UmbDataTypeContext {
|
||||
// TODO: figure out how fine grained we want to make our observables.
|
||||
private _data = new BehaviorSubject<DataTypeDetails>({
|
||||
key: '',
|
||||
name: '',
|
||||
icon: '',
|
||||
type: 'dataType',
|
||||
hasChildren: false,
|
||||
parentKey: '',
|
||||
propertyEditorModelAlias: '',
|
||||
propertyEditorUIAlias: '',
|
||||
data: [],
|
||||
});
|
||||
public readonly data: Observable<DataTypeDetails> = this._data.asObservable();
|
||||
|
||||
constructor(dataType: DataTypeDetails) {
|
||||
if (!dataType) return;
|
||||
this._data.next(dataType);
|
||||
}
|
||||
|
||||
// TODO: figure out how we want to update data
|
||||
public update(data: Partial<DataTypeDetails>) {
|
||||
this._data.next({ ...this._data.getValue(), ...data });
|
||||
}
|
||||
|
||||
public getData() {
|
||||
return this._data.getValue();
|
||||
}
|
||||
|
||||
public setPropertyValue(propertyAlias: string, value: any) {
|
||||
const data = this._data.getValue();
|
||||
const property = data.data.find((p) => p.alias === propertyAlias);
|
||||
if (!property) return;
|
||||
|
||||
property.value = value;
|
||||
this._data.next({ ...data });
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { css, html, LitElement } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { distinctUntilChanged } from 'rxjs';
|
||||
import { UmbDataTypeStore } from '../../../core/stores/data-type/data-type.store';
|
||||
import { UmbDataTypeContext } from './data-type.context';
|
||||
import { UmbWorkspaceDataTypeContext } from './workspace-data-type.context';
|
||||
import type { DataTypeDetails } from '@umbraco-cms/models';
|
||||
import { UmbObserverMixin } from '@umbraco-cms/observable-api';
|
||||
@@ -36,13 +35,6 @@ export class UmbWorkspaceDataTypeElement extends UmbContextProviderMixin(
|
||||
`,
|
||||
];
|
||||
|
||||
@state()
|
||||
private _dataTypeName = '';
|
||||
|
||||
private _dataTypeContext?: UmbDataTypeContext;
|
||||
private _dataTypeStore?: UmbDataTypeStore;
|
||||
|
||||
|
||||
private _entityKey!: string;
|
||||
@property()
|
||||
public get entityKey(): string {
|
||||
@@ -55,6 +47,10 @@ export class UmbWorkspaceDataTypeElement extends UmbContextProviderMixin(
|
||||
|
||||
private _workspaceContext?:UmbWorkspaceDataTypeContext;
|
||||
|
||||
@state()
|
||||
private _dataTypeName = '';
|
||||
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user