Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 158943c

Browse files
committed
input media
1 parent ece4b37 commit 158943c

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

src/packages/media/media/components/input-media/input-media.element.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
99
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
1010
import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';
1111
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/modal';
12-
import { UUIFormControlMixin } from '@umbraco-cms/backoffice/external/uui';
12+
import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
1313

1414
const elementName = 'umb-input-media';
1515

1616
@customElement(elementName)
17-
export class UmbInputMediaElement extends UUIFormControlMixin(UmbLitElement, '') {
17+
export class UmbInputMediaElement extends UmbFormControlMixin<string | undefined, typeof UmbLitElement>(UmbLitElement) {
1818
#sorter = new UmbSorterController<string>(this, {
1919
getUniqueOfElement: (element) => {
2020
return element.getAttribute('detail');
@@ -107,12 +107,12 @@ export class UmbInputMediaElement extends UUIFormControlMixin(UmbLitElement, '')
107107
@property({ type: String })
108108
startNode = '';
109109

110-
@property()
111-
public set value(idsString: string) {
112-
this.selection = splitStringToArray(idsString);
110+
@property({ type: String })
111+
public set value(selectionString: string | undefined) {
112+
this.selection = splitStringToArray(selectionString);
113113
}
114-
public get value() {
115-
return this.selection.join(',');
114+
public get value(): string | undefined {
115+
return this.selection.length > 0 ? this.selection.join(',') : undefined;
116116
}
117117

118118
@state()

src/packages/media/media/property-editors/media-entity-picker/property-editor-ui-media-entity-picker.element.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { html, customElement, property } from '@umbraco-cms/backoffice/external/lit';
2-
import { splitStringToArray } from '@umbraco-cms/backoffice/utils';
1+
import { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
32
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
43
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
54
import type { UmbNumberRangeValueType } from '@umbraco-cms/backoffice/models';
@@ -9,41 +8,34 @@ import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extensi
98

109
@customElement('umb-property-editor-ui-media-entity-picker')
1110
export class UmbPropertyEditorUIMediaEntityPickerElement extends UmbLitElement implements UmbPropertyEditorUiElement {
12-
#min: number = 0;
13-
#max: number = Infinity;
14-
15-
@property({ attribute: false })
16-
public set value(value: string | null | undefined) {
17-
this.#selection = value ? (Array.isArray(value) ? value : splitStringToArray(value)) : [];
18-
}
19-
public get value() {
20-
return this.#selection.length > 0 ? this.#selection.join(',') : null;
21-
}
22-
23-
#selection: Array<string> = [];
11+
@property({ type: String })
12+
public value: string | undefined;
2413

2514
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
2615
if (!config) return;
2716

2817
const minMax = config?.getValueByAlias<UmbNumberRangeValueType>('validationLimit');
29-
this.#min = minMax?.min ?? 0;
30-
this.#max = minMax?.max ?? Infinity;
31-
}
32-
public get config() {
33-
return undefined;
18+
this._min = minMax?.min ?? 0;
19+
this._max = minMax?.max ?? Infinity;
3420
}
3521

22+
@state()
23+
_min: number = 0;
24+
25+
@state()
26+
_max: number = Infinity;
27+
3628
#onChange(event: CustomEvent & { target: UmbInputMediaElement }) {
37-
this.value = event.target.selection?.join(',') ?? null;
29+
this.value = event.target.value;
3830
this.dispatchEvent(new UmbPropertyValueChangeEvent());
3931
}
4032

4133
render() {
4234
return html`
4335
<umb-input-media
44-
.min=${this.#min}
45-
.max=${this.#max}
46-
.selection=${this.#selection}
36+
.min=${this._min}
37+
.max=${this._max}
38+
.value=${this.value}
4739
@change=${this.#onChange}></umb-input-media>
4840
`;
4941
}

0 commit comments

Comments
 (0)