ability to configure prevalue editor

This commit is contained in:
Niels Lyngsø
2023-05-31 13:49:12 +02:00
parent 0fe46ffa71
commit 0f11bc2b0a
6 changed files with 21 additions and 15 deletions

View File

@@ -110,7 +110,8 @@ export class UmbPropertyEditorConfigElement extends UmbLitElement {
description="${ifDefined(property.description)}"
alias="${property.alias}"
property-editor-ui-alias="${property.propertyEditorUI}"
.value=${this._getValue(property)}></umb-workspace-property>
.value=${this._getValue(property)}
.config=${property.config}></umb-workspace-property>
`
)}
`

View File

@@ -1,4 +1,5 @@
import type { UmbPropertyEditorExtensionElement } from '../interfaces/index.js';
import { DataTypePropertyPresentationModel } from '@umbraco-cms/backoffice/backend-api';
import type { ManifestElement, ManifestBase } from '@umbraco-cms/backoffice/extension-api';
export interface ManifestPropertyEditorUI extends ManifestElement<UmbPropertyEditorExtensionElement> {
@@ -37,6 +38,7 @@ export interface PropertyEditorConfigProperty {
description?: string;
alias: string;
propertyEditorUI: string;
config?: Array<DataTypePropertyPresentationModel>;
}
export interface PropertyEditorConfigDefaultData {

View File

@@ -15,6 +15,20 @@ export const manifest: ManifestPropertyEditorModel = {
description:
'When enabled the time displayed will be offset with the servers timezone, this is useful for scenarios like scheduled publishing when an editor is in a different timezone than the hosted server',
propertyEditorUI: 'Umb.PropertyEditorUI.Toggle',
config: [
{
alias: 'labelOff',
value: 'Adjust to local time',
},
{
alias: 'labelOn',
value: 'Adjust to local time',
},
{
alias: 'showLabels',
value: true,
},
],
},
],
},

View File

@@ -18,23 +18,12 @@ export const manifest: ManifestPropertyEditorUI = {
description: 'If left empty then the format is YYYY-MM-DD',
propertyEditorUI: 'Umb.PropertyEditorUI.TextBox',
},
{
alias: 'offsetTime',
label: 'Offset time',
description:
'When enabled the time displayed will be offset with the servers timezone, this is useful for scenarios like scheduled publishing when an editor is in a different timezone than the hosted server',
propertyEditorUI: 'Umb.PropertyEditorUI.Toggle',
},
],
defaultData: [
{
alias: 'format',
value: 'YYYY-MM-DD HH:mm:ss',
},
{
alias: 'offsetTime',
value: false,
},
],
},
},

View File

@@ -103,7 +103,7 @@ export class UmbWorkspacePropertyContext<ValueType = any> {
this._workspaceContext?.setPropertyValue(alias, value, this.#variantId.getValue());
}
}
public setConfig(config: WorkspacePropertyData<ValueType>['config']) {
public setConfig(config: WorkspacePropertyData<ValueType>['config'] | undefined) {
this._data.update({ config });
}
public setVariantId(variantId: UmbVariantId | undefined) {

View File

@@ -1,6 +1,6 @@
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 { 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';
@@ -86,7 +86,7 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
* @default ''
*/
@property({ type: Object, attribute: false })
public set config(value: DataTypePropertyPresentationModel[]) {
public set config(value: DataTypePropertyPresentationModel[] | undefined) {
this._propertyContext.setConfig(value);
}