clean up
This commit is contained in:
@@ -9,8 +9,9 @@ import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
import { UMB_DATA_TYPE_DATASET_CONTEXT } from '@umbraco-cms/backoffice/data-type';
|
||||
|
||||
/**
|
||||
* @element umb-property-editor-config
|
||||
* @description - Element for displaying the configuration for a Property Editor based on a Property Editor UI Alias and a Property Editor Model alias.
|
||||
* @element umb-property-editor-config
|
||||
* @description - Element for displaying the configuration for a Property Editor based on a Property Editor UI Alias and a Property Editor Model alias.
|
||||
* This element requires a UMB_DATA_TYPE_WORKSPACE_CONTEXT to be present.
|
||||
*/
|
||||
@customElement('umb-property-editor-config')
|
||||
export class UmbPropertyEditorConfigElement extends UmbLitElement {
|
||||
@@ -35,7 +36,6 @@ export class UmbPropertyEditorConfigElement extends UmbLitElement {
|
||||
super();
|
||||
|
||||
this.consumeContext(UMB_DATA_TYPE_WORKSPACE_CONTEXT, (instance) => {
|
||||
console.log("config got context, but has already?...", this.#datasetContext)
|
||||
this.#datasetContext = instance.createDatasetContext(this);
|
||||
this.observe(this.#datasetContext.properties, (properties) => {
|
||||
this._properties = properties as Array<PropertyEditorConfigProperty>;
|
||||
@@ -44,15 +44,6 @@ export class UmbPropertyEditorConfigElement extends UmbLitElement {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stored value for a property. It will render the default value from the configuration if no value is stored in the database.
|
||||
*/
|
||||
// TODO: Refactor: setup a dataset for this, otherwise we cannot ensure features, neither the right reactivity.
|
||||
// TODO: Refactor: move the default data and getting the property config etc. to the workspace.
|
||||
/**
|
||||
Create a dataset context for this one. Feed if with fallback/default values.
|
||||
*/
|
||||
|
||||
render() {
|
||||
return html`
|
||||
${this._properties.length > 0
|
||||
|
||||
@@ -31,25 +31,6 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
|
||||
private _dataTypeRepository: UmbDataTypeRepository = new UmbDataTypeRepository(this);
|
||||
private _dataTypeObserver?: UmbObserverController<DataTypeResponseModel | undefined>;
|
||||
|
||||
/**
|
||||
* propertyVariantId. A VariantID to identify which the variant of this properties value.
|
||||
* @public
|
||||
* @type {UmbVariantId}
|
||||
* @attr
|
||||
* @default undefined
|
||||
*/
|
||||
// TODO: Refactor: this can be simplified..
|
||||
@property({ type: Object, attribute: false })
|
||||
public get propertyVariantId(): UmbVariantId | undefined {
|
||||
return this._propertyVariantId;
|
||||
}
|
||||
public set propertyVariantId(value: UmbVariantId | undefined) {
|
||||
const oldValue = this._propertyVariantId;
|
||||
if (value && oldValue?.equal(value)) return;
|
||||
this._propertyVariantId = value;
|
||||
this.requestUpdate('propertyVariantId', oldValue);
|
||||
}
|
||||
private _propertyVariantId?: UmbVariantId | undefined;
|
||||
|
||||
|
||||
private async _observeDataType(dataTypeId?: string) {
|
||||
@@ -87,7 +68,6 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
|
||||
label=${ifDefined(this._property?.name)}
|
||||
description=${ifDefined(this._property?.description || undefined)}
|
||||
property-editor-ui-alias=${ifDefined(this._propertyEditorUiAlias)}
|
||||
.propertyVariantId=${this.propertyVariantId}
|
||||
.config=${this._dataTypeData}></umb-workspace-property>`;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
UMB_WORKSPACE_SPLIT_VIEW_CONTEXT,
|
||||
UMB_VARIANT_DATASET_CONTEXT,
|
||||
ActiveVariant,
|
||||
IsNameableDatasetContext,
|
||||
} from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
import { DocumentVariantResponseModel, ContentStateModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
@@ -122,10 +123,8 @@ export class UmbVariantSelectorElement extends UmbLitElement {
|
||||
if (event instanceof UUIInputEvent) {
|
||||
const target = event.composedPath()[0] as UUIInputElement;
|
||||
|
||||
if (typeof target?.value === 'string') {
|
||||
// TODO: Refactor: find a good way to mix these features... maybe we should request the context multiple times? or find a way to mix the discriminators? or a way to investigate the context for features?
|
||||
alert("cannot set name currently.")
|
||||
//this.#datasetContext?.setName(target.value);
|
||||
if (typeof target?.value === 'string' && this.#datasetContext && IsNameableDatasetContext(this.#datasetContext)) {
|
||||
this.#datasetContext.setName(target.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,6 @@ export * from './dataset-context.interface.js';
|
||||
export * from './dataset-context.token.js';
|
||||
export * from './variant-dataset-context.interface.js';
|
||||
export * from './variant-dataset-context.token.js';
|
||||
export * from './nameable-dataset-context.interface.js';
|
||||
export * from './nameable-dataset-context.token.js';
|
||||
export * from './invariant-dataset-context.js';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { UmbDatasetContext } from "./dataset-context.interface.js";
|
||||
|
||||
/**
|
||||
* A dataset with ability to set the name of it.
|
||||
*/
|
||||
export interface UmbNameableDatasetContext extends UmbDatasetContext {
|
||||
setName(name:string): void
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { type UmbDatasetContext } from "./dataset-context.interface.js";
|
||||
import { UmbNameableDatasetContext } from "./nameable-dataset-context.interface.js";
|
||||
import { UmbContextToken } from "@umbraco-cms/backoffice/context-api";
|
||||
|
||||
export const IsNameableDatasetContext = (context: UmbDatasetContext): context is UmbNameableDatasetContext => 'setName' in context;
|
||||
|
||||
export const UMB_NAMEABLE_DATASET_CONTEXT = new UmbContextToken<UmbDatasetContext, UmbNameableDatasetContext>(
|
||||
"UmbEntityContext",
|
||||
IsNameableDatasetContext);
|
||||
@@ -2,6 +2,8 @@ import { type UmbDatasetContext } from "./dataset-context.interface.js";
|
||||
import { UmbVariantDatasetContext } from "./variant-dataset-context.interface.js";
|
||||
import { UmbContextToken } from "@umbraco-cms/backoffice/context-api";
|
||||
|
||||
export const IsVariantDatasetContext = (context: UmbDatasetContext): context is UmbVariantDatasetContext => 'getVariantId' in context;
|
||||
|
||||
export const UMB_VARIANT_DATASET_CONTEXT = new UmbContextToken<UmbDatasetContext, UmbVariantDatasetContext>(
|
||||
"UmbEntityContext",
|
||||
(context): context is UmbVariantDatasetContext => 'getVariantId' in context);
|
||||
IsVariantDatasetContext);
|
||||
|
||||
@@ -2,7 +2,6 @@ import { type UmbDataTypeConfig } from '../../property-editor/index.js';
|
||||
import { UmbWorkspacePropertyContext } from './workspace-property.context.js';
|
||||
import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import { createExtensionElement } from '@umbraco-cms/backoffice/extension-api';
|
||||
import { ManifestPropertyEditorUi, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
|
||||
import { UmbObserverController } from '@umbraco-cms/backoffice/observable-api';
|
||||
|
||||
Reference in New Issue
Block a user