From 52c30b43427a73818f7ea9a2d861f161c8ff9f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 1 Mar 2024 11:41:41 +0100 Subject: [PATCH] append getters --- .../property/property/property.context.ts | 12 ++++++ .../property/property/property.element.ts | 40 +++++++++++++------ .../workspace-split-view.element.ts | 3 ++ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/packages/core/property/property/property.context.ts b/src/packages/core/property/property/property.context.ts index d177891bc1..fe39b0a587 100644 --- a/src/packages/core/property/property/property.context.ts +++ b/src/packages/core/property/property/property.context.ts @@ -110,12 +110,21 @@ export class UmbPropertyContext extends UmbControllerBase { public setAlias(alias: string | undefined): void { this.#alias.setValue(alias); } + public getAlias(): string | undefined { + return this.#alias.getValue(); + } public setLabel(label: string | undefined): void { this.#label.setValue(label); } + public getLabel(): string | undefined { + return this.#label.getValue(); + } public setDescription(description: string | undefined): void { this.#description.setValue(description); } + public getDescription(): string | undefined { + return this.#description.getValue(); + } /** * Set the value of this property. * @param value {ValueType} the whole value to be set @@ -136,6 +145,9 @@ export class UmbPropertyContext extends UmbControllerBase { public setConfig(config: Array | undefined): void { this.#configValues.setValue(config ?? []); } + public getConfig(): Array | undefined { + return this.#configValues.getValue(); + } public setVariantId(variantId: UmbVariantId | undefined): void { this.#variantId.setValue(variantId); } diff --git a/src/packages/core/property/property/property.element.ts b/src/packages/core/property/property/property.element.ts index 1219343b35..ca2364b4d8 100644 --- a/src/packages/core/property/property/property.element.ts +++ b/src/packages/core/property/property/property.element.ts @@ -27,9 +27,12 @@ export class UmbPropertyElement extends UmbLitElement { * @default '' */ @property({ type: String }) - public set label(label: string) { + public set label(label: string | undefined) { this.#propertyContext.setLabel(label); } + public get label() { + return this.#propertyContext.getLabel(); + } /** * Description: render a description underneath the label. @@ -38,9 +41,12 @@ export class UmbPropertyElement extends UmbLitElement { * @default '' */ @property({ type: String }) - public set description(description: string) { + public set description(description: string | undefined) { this.#propertyContext.setDescription(description); } + public get description() { + return this.#propertyContext.getDescription(); + } /** * Alias @@ -53,6 +59,9 @@ export class UmbPropertyElement extends UmbLitElement { public set alias(alias: string) { this.#propertyContext.setAlias(alias); } + public get alias() { + return this.#propertyContext.getAlias() ?? ''; + } /** * Property Editor UI Alias. Render the Property Editor UI registered for this alias. @@ -62,12 +71,14 @@ export class UmbPropertyElement extends UmbLitElement { * @default '' */ @property({ type: String, attribute: 'property-editor-ui-alias' }) - public set propertyEditorUiAlias(value: string) { - if (this._propertyEditorUiAlias === value) return; + public set propertyEditorUiAlias(value: string | undefined) { this._propertyEditorUiAlias = value; this._observePropertyEditorUI(); } - private _propertyEditorUiAlias = ''; + public get propertyEditorUiAlias(): string { + return this._propertyEditorUiAlias ?? ''; + } + private _propertyEditorUiAlias?: string; /** * Config. Configuration to pass to the Property Editor UI. This is also the configuration data stored on the Data Type. @@ -80,6 +91,9 @@ export class UmbPropertyElement extends UmbLitElement { public set config(value: UmbPropertyEditorConfig | undefined) { this.#propertyContext.setConfig(value); } + public get config(): UmbPropertyEditorConfig | undefined { + return this.#propertyContext.getConfig(); + } @state() private _variantDifference?: string; @@ -130,13 +144,15 @@ export class UmbPropertyElement extends UmbLitElement { }; private _observePropertyEditorUI(): void { - this.observe( - umbExtensionsRegistry.byTypeAndAlias('propertyEditorUi', this._propertyEditorUiAlias), - (manifest) => { - this._gotEditorUI(manifest); - }, - '_observePropertyEditorUI', - ); + if (this._propertyEditorUiAlias) { + this.observe( + umbExtensionsRegistry.byTypeAndAlias('propertyEditorUi', this._propertyEditorUiAlias), + (manifest) => { + this._gotEditorUI(manifest); + }, + '_observePropertyEditorUI', + ); + } } private async _gotEditorUI(manifest?: ManifestPropertyEditorUi | null): Promise { diff --git a/src/packages/core/workspace/components/workspace-split-view/workspace-split-view.element.ts b/src/packages/core/workspace/components/workspace-split-view/workspace-split-view.element.ts index 840765e937..88b284ede4 100644 --- a/src/packages/core/workspace/components/workspace-split-view/workspace-split-view.element.ts +++ b/src/packages/core/workspace/components/workspace-split-view/workspace-split-view.element.ts @@ -21,6 +21,9 @@ export class UmbWorkspaceSplitViewElement extends UmbLitElement { public set splitViewIndex(index: number) { this.splitViewContext.setSplitViewIndex(index); } + public get splitViewIndex(): number { + return this.splitViewContext.getSplitViewIndex()!; + } splitViewContext = new UmbWorkspaceSplitViewContext(this);