@umbraco-cms/backoffice 14.0.0--preview004-5857d7ce → 14.0.0--preview004-5d4a08ee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1759,22 +1759,7 @@
1759
1759
  {
1760
1760
  "name": "umb-property-editor-config",
1761
1761
  "path": "./../src/packages/core/components/property-editor-config/property-editor-config.element.ts",
1762
- "attributes": [
1763
- {
1764
- "name": "data",
1765
- "description": "Data. The element will render configuration editors with values from this data.\nIf a value is not found in this data, the element will use the default value from the configuration.",
1766
- "type": "Array<{ alias: string; value: unknown }>",
1767
- "default": "\"[]\""
1768
- }
1769
- ],
1770
1762
  "properties": [
1771
- {
1772
- "name": "data",
1773
- "attribute": "data",
1774
- "description": "Data. The element will render configuration editors with values from this data.\nIf a value is not found in this data, the element will use the default value from the configuration.",
1775
- "type": "Array<{ alias: string; value: unknown }>",
1776
- "default": "\"[]\""
1777
- },
1778
1763
  {
1779
1764
  "name": "styles",
1780
1765
  "type": "array",
@@ -6,20 +6,9 @@ import { UmbLitElement } from '../../../../shared/lit-element/index.js';
6
6
  */
7
7
  export declare class UmbPropertyEditorConfigElement extends UmbLitElement {
8
8
  #private;
9
- /**
10
- * Data. The element will render configuration editors with values from this data.
11
- * If a value is not found in this data, the element will use the default value from the configuration.
12
- * @type {Array<{ alias: string; value: unknown }>}
13
- * @attr
14
- * @default []
15
- */
16
- data: Array<{
17
- alias: string;
18
- value: unknown;
19
- }>;
20
9
  private _properties;
21
10
  constructor();
22
- render(): import("lit-html").TemplateResult<1>;
11
+ render(): unknown;
23
12
  static styles: import("@lit/reactive-element/css-tag").CSSResult[];
24
13
  }
25
14
  export default UmbPropertyEditorConfigElement;
@@ -4,8 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { html, customElement, property, state, ifDefined } from '../../../../external/lit/index.js';
8
- import { UmbTextStyles } from "../../../../shared/style/index.js";
7
+ import { html, customElement, state, ifDefined, repeat } from '../../../../external/lit/index.js';
8
+ import { UmbTextStyles } from '../../../../shared/style/index.js';
9
9
  import { UmbLitElement } from '../../../../shared/lit-element/index.js';
10
10
  import { UMB_DATA_TYPE_VARIANT_CONTEXT } from '../../../settings/data-types/index.js';
11
11
  /**
@@ -18,43 +18,31 @@ export let UmbPropertyEditorConfigElement = class UmbPropertyEditorConfigElement
18
18
  #variantContext;
19
19
  constructor() {
20
20
  super();
21
- /**
22
- * Data. The element will render configuration editors with values from this data.
23
- * If a value is not found in this data, the element will use the default value from the configuration.
24
- * @type {Array<{ alias: string; value: unknown }>}
25
- * @attr
26
- * @default []
27
- */
28
- this.data = [];
29
21
  this._properties = [];
30
22
  this.consumeContext(UMB_DATA_TYPE_VARIANT_CONTEXT, (instance) => {
31
23
  this.#variantContext = instance;
32
- this.observe(this.#variantContext.properties, (properties) => {
33
- this._properties = properties;
34
- }, 'observeProperties');
24
+ this.#observeProperties();
35
25
  });
36
26
  }
27
+ #observeProperties() {
28
+ if (!this.#variantContext)
29
+ return;
30
+ this.observe(this.#variantContext.properties, (properties) => {
31
+ this._properties = properties;
32
+ }, 'observeProperties');
33
+ }
37
34
  render() {
38
- return html `
39
- ${this._properties.length > 0
40
- ? html `
41
- ${this._properties?.map((property) => html `
42
- <umb-workspace-property
43
- label="${property.label}"
44
- description="${ifDefined(property.description)}"
45
- alias="${property.alias}"
46
- property-editor-ui-alias="${property.propertyEditorUiAlias}"
47
- .config=${property.config}></umb-workspace-property>
48
- `)}
49
- `
50
- : html `<div>No configuration</div>`}
51
- `;
35
+ return this._properties.length > 0
36
+ ? repeat(this._properties, (property) => property.alias, (property) => html `<umb-workspace-property
37
+ label="${property.label}"
38
+ description="${ifDefined(property.description)}"
39
+ alias="${property.alias}"
40
+ property-editor-ui-alias="${property.propertyEditorUiAlias}"
41
+ .config=${property.config}></umb-workspace-property>`)
42
+ : html `<div>No configuration</div>`;
52
43
  }
53
44
  static { this.styles = [UmbTextStyles]; }
54
45
  };
55
- __decorate([
56
- property({ type: Array })
57
- ], UmbPropertyEditorConfigElement.prototype, "data", void 0);
58
46
  __decorate([
59
47
  state()
60
48
  ], UmbPropertyEditorConfigElement.prototype, "_properties", void 0);
@@ -17,7 +17,7 @@ export let UmbCodeEditorModalElement = class UmbCodeEditorModalElement extends U
17
17
  this.#loadCodeEditor();
18
18
  }
19
19
  #handleConfirm() {
20
- this.modalContext?.submit({ content: this.data?.content ?? '' });
20
+ this.modalContext?.submit({ content: this._codeEditor?.editor?.monacoEditor?.getValue() ?? '' });
21
21
  }
22
22
  #handleCancel() {
23
23
  this.modalContext?.reject();
@@ -31,19 +31,10 @@ export let UmbCodeEditorModalElement = class UmbCodeEditorModalElement extends U
31
31
  console.error(error);
32
32
  }
33
33
  }
34
- // TODO => debounce?
35
- #onCodeEditorInput(e) {
36
- e.preventDefault();
37
- if (!this.data) {
38
- return;
39
- }
40
- this.data.content = this._codeEditor?.code ?? '';
41
- }
42
34
  #renderCodeEditor() {
43
35
  return html `<umb-code-editor
44
36
  language=${ifDefined(this.data?.language)}
45
- .code=${this.data?.content ?? ''}
46
- @input=${this.#onCodeEditorInput}></umb-code-editor>`;
37
+ .code=${this.data?.content ?? ''}></umb-code-editor>`;
47
38
  }
48
39
  #renderLoading() {
49
40
  return html `<div id="loader-container">
@@ -1,7 +1,7 @@
1
1
  export const manifest = {
2
2
  type: 'propertyEditorSchema',
3
3
  name: 'Checkbox List',
4
- alias: 'Umbraco.CheckboxList',
4
+ alias: 'Umbraco.CheckBoxList',
5
5
  meta: {
6
6
  defaultPropertyEditorUiAlias: 'Umb.PropertyEditorUi.CheckboxList',
7
7
  },
@@ -42,27 +42,25 @@ export default class UmbTinyMceLinkPickerPlugin extends UmbTinyMcePluginBase {
42
42
  data.text = ' ';
43
43
  }
44
44
  if (!this.#anchorElement) {
45
- this.#openLinkPicker();
45
+ this.#openLinkPicker({ name: this.editor.selection.getContent() });
46
46
  return;
47
47
  }
48
48
  //if we already have a link selected, we want to pass that data over to the dialog
49
49
  const currentTarget = {
50
- name: this.#anchorElement.title,
51
- url: this.#anchorElement.getAttribute('href') ?? '',
50
+ name: this.#anchorElement.title || this.#anchorElement.textContent,
52
51
  target: this.#anchorElement.target,
52
+ queryString: `${this.#anchorElement.search}${this.#anchorElement.hash}`,
53
53
  };
54
- // drop the lead char from the anchor text, if it has a value
55
- const anchorVal = this.#anchorElement.dataset.anchor;
56
- if (anchorVal) {
57
- currentTarget.queryString = anchorVal.substring(1);
54
+ if (this.#anchorElement.href.includes('localLink:')) {
55
+ const href = this.#anchorElement.getAttribute('href');
56
+ currentTarget.udi = href.split('localLink:')[1].slice(0, -1);
58
57
  }
59
- if (currentTarget.url?.includes('localLink:')) {
60
- currentTarget.udi =
61
- currentTarget.url?.substring(currentTarget.url.indexOf(':') + 1, currentTarget.url.lastIndexOf('}')) ?? '';
58
+ else if (this.#anchorElement.host.length) {
59
+ currentTarget.url = this.#anchorElement.protocol ? this.#anchorElement.protocol + '//' : undefined;
60
+ currentTarget.url += this.#anchorElement.host + this.#anchorElement.pathname;
62
61
  }
63
62
  this.#openLinkPicker(currentTarget);
64
63
  }
65
- // TODO => get anchors to provide to link picker?
66
64
  async #openLinkPicker(currentTarget) {
67
65
  const modalHandler = this.#modalContext?.open(UMB_LINK_PICKER_MODAL, {
68
66
  config: {
@@ -73,7 +71,7 @@ export default class UmbTinyMceLinkPickerPlugin extends UmbTinyMcePluginBase {
73
71
  });
74
72
  if (!modalHandler)
75
73
  return;
76
- const linkPickerData = await modalHandler.onSubmit();
74
+ const linkPickerData = await modalHandler.onSubmit().catch(() => undefined);
77
75
  if (!linkPickerData)
78
76
  return;
79
77
  this.#linkPickerData = linkPickerData;
@@ -82,12 +80,17 @@ export default class UmbTinyMceLinkPickerPlugin extends UmbTinyMcePluginBase {
82
80
  //Create a json obj used to create the attributes for the tag
83
81
  // TODO => where has rel gone?
84
82
  #createElemAttributes() {
85
- const a = Object.assign({}, this.#linkPickerData?.link, { 'data-anchor': null });
83
+ // Attribute 'name' because of linkPickerData. It should be 'title' .
84
+ const { name, ...linkPickerData } = this.#linkPickerData.link;
85
+ const a = Object.assign({}, linkPickerData);
86
86
  // always need to map back to href for tinymce to render correctly
87
87
  // do this first as checking querystring below may modify the href property
88
88
  if (this.#linkPickerData?.link.url) {
89
89
  a.href = this.#linkPickerData.link.url;
90
90
  }
91
+ if (this.#linkPickerData?.link.name) {
92
+ a.title = name;
93
+ }
91
94
  if (this.#linkPickerData?.link.queryString?.startsWith('#')) {
92
95
  a['data-anchor'] = this.#linkPickerData?.link.queryString;
93
96
  a.href += this.#linkPickerData?.link.queryString;
@@ -136,7 +139,7 @@ export default class UmbTinyMceLinkPickerPlugin extends UmbTinyMcePluginBase {
136
139
  this.#linkPickerData.link.queryString = urlParts[1] + urlParts[2];
137
140
  }
138
141
  }
139
- if (!this.#linkPickerData?.link.url && !this.#linkPickerData?.link.queryString) {
142
+ if (!this.#linkPickerData?.link.url && !this.#linkPickerData?.link.queryString && !this.#linkPickerData?.link.udi) {
140
143
  this.editor.execCommand('unlink');
141
144
  return;
142
145
  }
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { UmbTextStyles } from "../../../../../shared/style/index.js";
7
+ import { UmbTextStyles } from '../../../../../shared/style/index.js';
8
8
  import { html, customElement, property } from '../../../../../external/lit/index.js';
9
9
  import { UmbLitElement } from '../../../../../shared/lit-element/index.js';
10
10
  /**
@@ -16,12 +16,15 @@ export declare class UmbDataTypeWorkspaceContext extends UmbWorkspaceContext<Umb
16
16
  properties: Observable<Array<PropertyEditorConfigProperty> | undefined>;
17
17
  private _propertyEditorSchemaConfigDefaultData;
18
18
  private _propertyEditorUISettingsDefaultData;
19
- private _propertyEditorSchemaConfigProperties?;
20
- private _propertyEditorUISettingsProperties?;
19
+ private _propertyEditorSchemaConfigProperties;
20
+ private _propertyEditorUISettingsProperties;
21
+ private _propertyEditorSchemaConfigDefaultUIAlias;
21
22
  private _configDefaultData?;
23
+ private _propertyEditorUISettingsSchemaAlias?;
22
24
  defaults: Observable<PropertyEditorConfigDefaultData[]>;
25
+ propertyEditorUiIcon: Observable<string | null>;
26
+ propertyEditorUiName: Observable<string | null>;
23
27
  constructor(host: UmbControllerHostElement);
24
- private _observePropertyEditorSchemaConfig;
25
28
  private _mergeConfigProperties;
26
29
  private _mergeConfigDefaultData;
27
30
  getPropertyDefaultValue(alias: string): unknown;
@@ -1,10 +1,10 @@
1
1
  import { UmbDataTypeRepository } from '../repository/data-type.repository.js';
2
2
  import { UmbDataTypeVariantContext } from '../variant-context/data-type-variant-context.js';
3
- import { UmbWorkspaceContext } from '../../../core/workspace/index.js';
4
- import { appendToFrozenArray, UmbArrayState, UmbObjectState } from '../../../../libs/observable-api/index.js';
3
+ import { UmbWorkspaceContext, } from '../../../core/workspace/index.js';
4
+ import { appendToFrozenArray, UmbArrayState, UmbObjectState, UmbStringState, } from '../../../../libs/observable-api/index.js';
5
5
  import { UmbContextToken } from '../../../../libs/context-api/index.js';
6
6
  import { combineLatest, map } from '../../../../external/rxjs/index.js';
7
- import { umbExtensionsRegistry } from '../../../core/extension-registry/index.js';
7
+ import { umbExtensionsRegistry, } from '../../../core/extension-registry/index.js';
8
8
  import { UMB_PROPERTY_EDITOR_SCHEMA_ALIAS_DEFAULT } from '../../../core/property-editor/index.js';
9
9
  export class UmbDataTypeWorkspaceContext extends UmbWorkspaceContext {
10
10
  // TODO: revisit. temp solution because the create and response models are different.
@@ -12,6 +12,8 @@ export class UmbDataTypeWorkspaceContext extends UmbWorkspaceContext {
12
12
  #getDataPromise;
13
13
  #properties;
14
14
  #defaults;
15
+ #propertyEditorUiIcon;
16
+ #propertyEditorUiName;
15
17
  constructor(host) {
16
18
  super(host, 'Umb.Workspace.DataType', new UmbDataTypeRepository(host));
17
19
  // TODO: revisit. temp solution because the create and response models are different.
@@ -25,38 +27,69 @@ export class UmbDataTypeWorkspaceContext extends UmbWorkspaceContext {
25
27
  this.properties = this.#properties.asObservable();
26
28
  this._propertyEditorSchemaConfigDefaultData = [];
27
29
  this._propertyEditorUISettingsDefaultData = [];
30
+ this._propertyEditorSchemaConfigProperties = [];
31
+ this._propertyEditorUISettingsProperties = [];
32
+ this._propertyEditorSchemaConfigDefaultUIAlias = null;
28
33
  this.#defaults = new UmbArrayState([], (entry) => entry.alias);
29
34
  this.defaults = this.#defaults.asObservable();
30
- this.observe(this.propertyEditorUiAlias, (propertyEditorUiAlias) => {
31
- if (!propertyEditorUiAlias) {
32
- // No property editor ui alias, so we clean up and reset the properties.
33
- this.removeControllerByAlias('propertyEditorUiAlias');
34
- this._propertyEditorUISettingsProperties = [];
35
- this._propertyEditorUISettingsDefaultData = [];
36
- this._mergeConfigProperties();
37
- this._mergeConfigDefaultData();
35
+ this.#propertyEditorUiIcon = new UmbStringState(null);
36
+ this.propertyEditorUiIcon = this.#propertyEditorUiIcon.asObservable();
37
+ this.#propertyEditorUiName = new UmbStringState(null);
38
+ this.propertyEditorUiName = this.#propertyEditorUiName.asObservable();
39
+ this.#observePropertyEditorUIAlias();
40
+ }
41
+ #observePropertyEditorUIAlias() {
42
+ this.observe(this.propertyEditorUiAlias, async (propertyEditorUiAlias) => {
43
+ // we only want to react on the change if the alias is set or null. When it is undefined something is still loading
44
+ if (propertyEditorUiAlias === undefined)
38
45
  return;
46
+ // if the property editor ui alias is not set, we use the default alias from the schema
47
+ if (propertyEditorUiAlias === null) {
48
+ await this.#observePropertyEditorSchemaAlias();
49
+ this.setPropertyEditorUiAlias(this._propertyEditorSchemaConfigDefaultUIAlias);
39
50
  }
40
- this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorUi', propertyEditorUiAlias), (manifest) => {
41
- this._observePropertyEditorSchemaConfig(manifest?.meta.propertyEditorSchemaAlias || UMB_PROPERTY_EDITOR_SCHEMA_ALIAS_DEFAULT);
42
- this._propertyEditorUISettingsProperties = manifest?.meta.settings?.properties || [];
43
- this._propertyEditorUISettingsDefaultData = manifest?.meta.settings?.defaultData || [];
44
- this._mergeConfigProperties();
45
- this._mergeConfigDefaultData();
46
- }, 'observePropertyEditorUiAlias');
51
+ else {
52
+ await this.#setPropertyEditorUIConfig(propertyEditorUiAlias);
53
+ this.setPropertyEditorSchemaAlias(this._propertyEditorUISettingsSchemaAlias);
54
+ await this.#observePropertyEditorSchemaAlias();
55
+ }
56
+ this._mergeConfigProperties();
57
+ this._mergeConfigDefaultData();
47
58
  });
48
59
  }
49
- _observePropertyEditorSchemaConfig(propertyEditorSchemaAlias) {
50
- this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorSchema', propertyEditorSchemaAlias), (manifest) => {
60
+ #observePropertyEditorSchemaAlias() {
61
+ return this.observe(this.propertyEditorSchemaAlias, async (propertyEditorSchemaAlias) => {
62
+ if (!propertyEditorSchemaAlias) {
63
+ this.setPropertyEditorSchemaAlias(UMB_PROPERTY_EDITOR_SCHEMA_ALIAS_DEFAULT);
64
+ return;
65
+ }
66
+ await this.#setPropertyEditorSchemaConfig(propertyEditorSchemaAlias);
67
+ }).asPromise();
68
+ }
69
+ #setPropertyEditorSchemaConfig(propertyEditorSchemaAlias) {
70
+ return this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorSchema', propertyEditorSchemaAlias), (manifest) => {
51
71
  this._propertyEditorSchemaConfigProperties = manifest?.meta.settings?.properties || [];
52
72
  this._propertyEditorSchemaConfigDefaultData = manifest?.meta.settings?.defaultData || [];
53
- this._mergeConfigProperties();
54
- this._mergeConfigDefaultData();
55
- });
73
+ this._propertyEditorSchemaConfigDefaultUIAlias = manifest?.meta.defaultPropertyEditorUiAlias || null;
74
+ }).asPromise();
75
+ }
76
+ #setPropertyEditorUIConfig(propertyEditorUIAlias) {
77
+ return this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorUi', propertyEditorUIAlias), (manifest) => {
78
+ this.#propertyEditorUiIcon.next(manifest?.meta.icon || null);
79
+ this.#propertyEditorUiName.next(manifest?.name || null);
80
+ this._propertyEditorUISettingsSchemaAlias = manifest?.meta.propertyEditorSchemaAlias;
81
+ this._propertyEditorUISettingsProperties = manifest?.meta.settings?.properties || [];
82
+ this._propertyEditorUISettingsDefaultData = manifest?.meta.settings?.defaultData || [];
83
+ }).asPromise();
56
84
  }
57
85
  _mergeConfigProperties() {
86
+ console.log('schema properties', this._propertyEditorSchemaConfigProperties);
87
+ console.log('ui properties', this._propertyEditorUISettingsProperties);
58
88
  if (this._propertyEditorSchemaConfigProperties && this._propertyEditorUISettingsProperties) {
59
- this.#properties.next([...this._propertyEditorSchemaConfigProperties, ...this._propertyEditorUISettingsProperties]);
89
+ this.#properties.next([
90
+ ...this._propertyEditorSchemaConfigProperties,
91
+ ...this._propertyEditorUISettingsProperties,
92
+ ]);
60
93
  }
61
94
  }
62
95
  _mergeConfigDefaultData() {
@@ -122,12 +155,13 @@ export class UmbDataTypeWorkspaceContext extends UmbWorkspaceContext {
122
155
  this.#data.asObservablePart((data) => data?.values?.find((x) => x.alias === propertyAlias)?.value),
123
156
  this.#defaults.asObservablePart((defaults) => defaults?.find((x) => x.alias === propertyAlias)?.value),
124
157
  ]).pipe(map(([value, defaultValue]) => {
125
- return (value ?? defaultValue);
158
+ return value ?? defaultValue;
126
159
  }));
127
160
  //return this.#data.asObservablePart((data) => data?.values?.find((x) => x.alias === propertyAlias)?.value ?? this.getPropertyDefaultValue(propertyAlias) as ReturnType);
128
161
  }
129
162
  getPropertyValue(propertyAlias) {
130
- return this.#data.getValue()?.values?.find((x) => x.alias === propertyAlias)?.value ?? this.getPropertyDefaultValue(propertyAlias);
163
+ return (this.#data.getValue()?.values?.find((x) => x.alias === propertyAlias)?.value ??
164
+ this.getPropertyDefaultValue(propertyAlias));
131
165
  }
132
166
  // TODO: its not called a property in the model, but we do consider this way in our front-end
133
167
  async setPropertyValue(alias, value) {
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { UmbDataTypeWorkspaceContext } from './data-type-workspace.context.js';
8
- import { UmbTextStyles } from "../../../../shared/style/index.js";
8
+ import { UmbTextStyles } from '../../../../shared/style/index.js';
9
9
  import { html, customElement } from '../../../../external/lit/index.js';
10
10
  import { UmbLitElement } from '../../../../shared/lit-element/index.js';
11
11
  import './data-type-workspace-editor.element.js';
@@ -2,23 +2,18 @@ import { UmbLitElement } from '../../../../../../shared/lit-element/index.js';
2
2
  import type { DataTypeResponseModel } from '../../../../../../external/backend-api/index.js';
3
3
  import { UmbWorkspaceEditorViewExtensionElement } from '../../../../../core/extension-registry/index.js';
4
4
  export declare class UmbDataTypeDetailsWorkspaceViewEditElement extends UmbLitElement implements UmbWorkspaceEditorViewExtensionElement {
5
+ #private;
5
6
  _dataType?: DataTypeResponseModel;
6
7
  private _propertyEditorUiIcon?;
7
8
  private _propertyEditorUiName?;
8
9
  private _propertyEditorUiAlias?;
9
10
  private _propertyEditorSchemaAlias?;
10
- private _data;
11
11
  private _workspaceContext?;
12
12
  private _modalContext?;
13
13
  constructor();
14
14
  private _observeDataType;
15
- private _setPropertyEditorUiAlias;
16
- private _observePropertyEditorUI;
17
15
  private _openPropertyEditorUIPicker;
18
- private _selectPropertyEditorUI;
19
16
  render(): import("lit-html").TemplateResult<1>;
20
- private _renderPropertyEditorUI;
21
- private _renderConfig;
22
17
  static styles: import("@lit/reactive-element/css-tag.js").CSSResult[];
23
18
  }
24
19
  export default UmbDataTypeDetailsWorkspaceViewEditElement;
@@ -5,15 +5,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { UMB_DATA_TYPE_WORKSPACE_CONTEXT } from '../../data-type-workspace.context.js';
8
- import { UmbTextStyles } from "../../../../../../shared/style/index.js";
9
- import { css, html, nothing, customElement, state } from '../../../../../../external/lit/index.js';
8
+ import { UmbTextStyles } from '../../../../../../shared/style/index.js';
9
+ import { css, html, customElement, state } from '../../../../../../external/lit/index.js';
10
10
  import { UMB_MODAL_MANAGER_CONTEXT_TOKEN, UMB_PROPERTY_EDITOR_UI_PICKER_MODAL, } from '../../../../../core/modal/index.js';
11
11
  import { UmbLitElement } from '../../../../../../shared/lit-element/index.js';
12
- import { umbExtensionsRegistry, } from '../../../../../core/extension-registry/index.js';
13
12
  export let UmbDataTypeDetailsWorkspaceViewEditElement = class UmbDataTypeDetailsWorkspaceViewEditElement extends UmbLitElement {
14
13
  constructor() {
15
14
  super();
16
- this._data = [];
15
+ this._propertyEditorUiIcon = null;
16
+ this._propertyEditorUiName = null;
17
+ this._propertyEditorUiAlias = null;
18
+ this._propertyEditorSchemaAlias = null;
17
19
  this.consumeContext(UMB_MODAL_MANAGER_CONTEXT_TOKEN, (instance) => {
18
20
  this._modalContext = instance;
19
21
  });
@@ -27,78 +29,37 @@ export let UmbDataTypeDetailsWorkspaceViewEditElement = class UmbDataTypeDetails
27
29
  return;
28
30
  }
29
31
  this.observe(this._workspaceContext.data, (dataType) => {
30
- if (!dataType)
31
- return;
32
- // TODO: handle if model is not of the type wanted.
33
32
  this._dataType = dataType;
34
- if (!this._dataType.propertyEditorUiAlias) {
35
- if (this._dataType.propertyEditorAlias) {
36
- // Get the property editor UI alias from the property editor alias:
37
- this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorSchema', this._dataType.propertyEditorAlias), (propertyEditorSchema) => {
38
- // TODO: show error. We have stored a propertyEditorSchemaAlias and can't find the PropertyEditorSchema in the registry.
39
- if (!propertyEditorSchema)
40
- return;
41
- this._setPropertyEditorUiAlias(propertyEditorSchema.meta.defaultPropertyEditorUiAlias ?? undefined);
42
- }, '_observePropertyEditorSchemaForDefaultUI');
43
- }
44
- else {
45
- this._setPropertyEditorUiAlias(undefined);
46
- }
47
- }
48
- else {
49
- this._setPropertyEditorUiAlias(this._dataType.propertyEditorUiAlias);
50
- }
51
- if (this._dataType.values && this._dataType.values !== this._data) {
52
- this._data = this._dataType.values;
53
- }
54
33
  });
55
- }
56
- _setPropertyEditorUiAlias(value) {
57
- const oldValue = this._propertyEditorUiAlias;
58
- if (oldValue !== value) {
34
+ this.observe(this._workspaceContext.propertyEditorUiAlias, (value) => {
59
35
  this._propertyEditorUiAlias = value;
60
- this._observePropertyEditorUI(value || undefined);
61
- }
62
- }
63
- _observePropertyEditorUI(propertyEditorUiAlias) {
64
- if (!propertyEditorUiAlias) {
65
- this._propertyEditorUiName = this._propertyEditorUiIcon = this._propertyEditorUiAlias = undefined;
66
- this.removeControllerByAlias('_observePropertyEditorUI');
67
- return;
68
- }
69
- // remove the '_observePropertyEditorSchemaForDefaultUI' controller, as we do not want to observe for default value anymore:
70
- this.removeControllerByAlias('_observePropertyEditorSchemaForDefaultUI');
71
- this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorUi', propertyEditorUiAlias), (propertyEditorUI) => {
72
- // TODO: show error. We have stored a PropertyEditorUIAlias and can't find the PropertyEditorUI in the registry.
73
- if (!propertyEditorUI)
74
- return;
75
- this._propertyEditorUiName = propertyEditorUI?.meta.label ?? propertyEditorUI?.name ?? '';
76
- this._propertyEditorUiAlias = propertyEditorUI?.alias ?? '';
77
- this._propertyEditorUiIcon = propertyEditorUI?.meta.icon ?? '';
78
- this._propertyEditorSchemaAlias = propertyEditorUI?.meta.propertyEditorSchemaAlias ?? '';
79
- this._workspaceContext?.setPropertyEditorSchemaAlias(this._propertyEditorSchemaAlias);
80
- }, '_observePropertyEditorUI');
36
+ });
37
+ this.observe(this._workspaceContext.propertyEditorSchemaAlias, (value) => {
38
+ this._propertyEditorSchemaAlias = value;
39
+ });
40
+ this.observe(this._workspaceContext.propertyEditorUiName, (value) => {
41
+ this._propertyEditorUiName = value;
42
+ });
43
+ this.observe(this._workspaceContext.propertyEditorUiIcon, (value) => {
44
+ this._propertyEditorUiIcon = value;
45
+ });
81
46
  }
82
47
  _openPropertyEditorUIPicker() {
83
- if (!this._dataType)
84
- return;
85
48
  const modalContext = this._modalContext?.open(UMB_PROPERTY_EDITOR_UI_PICKER_MODAL, {
86
49
  selection: this._propertyEditorUiAlias ? [this._propertyEditorUiAlias] : [],
87
50
  });
88
51
  modalContext?.onSubmit().then(({ selection }) => {
89
- this._selectPropertyEditorUI(selection[0]);
52
+ this._workspaceContext?.setPropertyEditorUiAlias(selection[0]);
90
53
  });
91
54
  }
92
- _selectPropertyEditorUI(propertyEditorUiAlias) {
93
- this._workspaceContext?.setPropertyEditorUiAlias(propertyEditorUiAlias);
94
- }
95
55
  render() {
96
56
  return html `
97
- <uui-box> ${this._renderPropertyEditorUI()} </uui-box>
98
- ${this._renderConfig()} </uui-box>
57
+ <uui-box> ${this.#renderPropertyEditorReference()} </uui-box>
58
+ ${this.#renderPropertyEditorConfig()} </uui-box>
99
59
  `;
100
60
  }
101
- _renderPropertyEditorUI() {
61
+ #renderPropertyEditorReference() {
62
+ console.log(this._dataType);
102
63
  return html `
103
64
  <umb-workspace-property-layout label="Property Editor" description="Select a property editor">
104
65
  ${this._propertyEditorUiAlias && this._propertyEditorSchemaAlias
@@ -129,18 +90,10 @@ export let UmbDataTypeDetailsWorkspaceViewEditElement = class UmbDataTypeDetails
129
90
  </umb-workspace-property-layout>
130
91
  `;
131
92
  }
132
- _renderConfig() {
133
- return html `
134
- ${this._propertyEditorSchemaAlias && this._propertyEditorUiAlias
135
- ? html `
136
- <uui-box headline="Settings">
137
- <umb-property-editor-config
138
- property-editor-ui-alias="${this._propertyEditorUiAlias}"
139
- .data="${this._data}"></umb-property-editor-config>
140
- </uui-box>
141
- `
142
- : nothing}
143
- `;
93
+ #renderPropertyEditorConfig() {
94
+ return html `<uui-box headline="Settings">
95
+ <umb-property-editor-config></umb-property-editor-config>
96
+ </uui-box> `;
144
97
  }
145
98
  static { this.styles = [
146
99
  UmbTextStyles,
@@ -172,9 +125,6 @@ __decorate([
172
125
  __decorate([
173
126
  state()
174
127
  ], UmbDataTypeDetailsWorkspaceViewEditElement.prototype, "_propertyEditorSchemaAlias", void 0);
175
- __decorate([
176
- state()
177
- ], UmbDataTypeDetailsWorkspaceViewEditElement.prototype, "_data", void 0);
178
128
  UmbDataTypeDetailsWorkspaceViewEditElement = __decorate([
179
129
  customElement('umb-data-type-details-workspace-view')
180
130
  ], UmbDataTypeDetailsWorkspaceViewEditElement);