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

Commit 91355e1

Browse files
committed
media-type + collection input
1 parent 158943c commit 91355e1

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

src/packages/core/components/input-collection-configuration/input-collection-configuration.element.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou
1010
import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
1111

1212
@customElement('umb-input-collection-configuration')
13-
export class UmbInputCollectionConfigurationElement extends UmbFormControlMixin(UmbLitElement) {
13+
export class UmbInputCollectionConfigurationElement extends UmbFormControlMixin<string, typeof UmbLitElement>(
14+
UmbLitElement,
15+
) {
1416
protected getFormElement() {
1517
return undefined;
1618
}
@@ -25,7 +27,7 @@ export class UmbInputCollectionConfigurationElement extends UmbFormControlMixin(
2527
@property({ attribute: 'default-value' })
2628
defaultValue?: string;
2729

28-
#setValue(value: string) {
30+
#setValue(value: string | undefined) {
2931
this.value = value;
3032
this.dispatchEvent(new UmbChangeEvent());
3133
}
@@ -65,7 +67,7 @@ export class UmbInputCollectionConfigurationElement extends UmbFormControlMixin(
6567
}
6668

6769
#clearDataType() {
68-
this.#setValue('');
70+
this.#setValue(undefined);
6971
}
7072

7173
#createDataType() {
@@ -99,7 +101,7 @@ export class UmbInputCollectionConfigurationElement extends UmbFormControlMixin(
99101
if (!this.value || !this._dataTypePickerModalPath) return nothing;
100102
return html`
101103
<uui-ref-list>
102-
<umb-ref-data-type standalone data-type-id=${this.value as string} @open=${this.#editDataType}>
104+
<umb-ref-data-type standalone data-type-id=${this.value} @open=${this.#editDataType}>
103105
<uui-action-bar slot="actions">
104106
<uui-button
105107
label=${this.localize.term('general_choose')}

src/packages/data-type/components/ref-data-type/ref-data-type.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { UmbDataTypeDetailRepository } from '../../repository/detail/data-type-detail.repository.js';
21
import { UUIIconRequestEvent, UUIRefNodeElement } from '@umbraco-cms/backoffice/external/uui';
32
import { html, customElement, property, state, css } from '@umbraco-cms/backoffice/external/lit';
43
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
54
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
5+
import { UmbDataTypeDetailRepository } from '../../repository/detail/data-type-detail.repository.js';
66

77
/**
88
* @element umb-ref-data-type

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

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

1212
@customElement('umb-input-media-type')
13-
export class UmbInputMediaTypeElement extends UUIFormControlMixin(UmbLitElement, '') {
13+
export class UmbInputMediaTypeElement extends UmbFormControlMixin<string | undefined, typeof UmbLitElement>(
14+
UmbLitElement,
15+
) {
1416
#sorter = new UmbSorterController<string>(this, {
1517
getUniqueOfElement: (element) => {
1618
return element.id;
@@ -82,12 +84,12 @@ export class UmbInputMediaTypeElement extends UUIFormControlMixin(UmbLitElement,
8284
return this.#pickerContext.getSelection();
8385
}
8486

85-
@property()
86-
public set value(uniques: string) {
87-
this.selection = splitStringToArray(uniques);
87+
@property({ type: String })
88+
public set value(selectionString: string | undefined) {
89+
this.selection = splitStringToArray(selectionString);
8890
}
89-
public get value(): string {
90-
return this.selection.join(',');
91+
public get value(): string | undefined {
92+
return this.selection.length > 0 ? this.selection.join(',') : undefined;
9193
}
9294

9395
@state()

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ export class UmbPropertyEditorUIMediaTypePickerElement extends UmbLitElement imp
1515
if (!config) return;
1616

1717
const minMax = config?.getValueByAlias<UmbNumberRangeValueType>('validationLimit');
18-
this.min = minMax?.min ?? 0;
19-
this.max = minMax?.max ?? Infinity;
18+
this._min = minMax?.min ?? 0;
19+
this._max = minMax?.max ?? Infinity;
2020
}
2121

2222
@state()
23-
min = 0;
23+
_min = 0;
2424

2525
@state()
26-
max = Infinity;
26+
_max = Infinity;
2727

2828
#onChange(event: CustomEvent & { target: UmbInputMediaTypeElement }) {
29-
this.value = event.target.selection.join(',');
29+
this.value = event.target.value;
3030
this.dispatchEvent(new UmbPropertyValueChangeEvent());
3131
}
3232

3333
render() {
3434
return html`
35-
<umb-input-media-type .min=${this.min} .max=${this.max} .value=${this.value ?? ''} @change=${this.#onChange}>
35+
<umb-input-media-type .min=${this._min} .max=${this._max} .value=${this.value} @change=${this.#onChange}>
3636
</umb-input-media-type>
3737
`;
3838
}

src/packages/media/media-types/workspace/views/structure/media-type-workspace-view-structure.element.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class UmbMediaTypeWorkspaceViewStructureElement extends UmbLitElement imp
2020
private _allowedContentTypeIDs?: Array<string>;
2121

2222
@state()
23-
private _collection?: string | null;
23+
private _collection?: string;
2424

2525
constructor() {
2626
super();
@@ -82,10 +82,8 @@ export class UmbMediaTypeWorkspaceViewStructureElement extends UmbLitElement imp
8282
<!-- TODO: maybe we want to somehow display the hierarchy, but not necessary in the same way as old backoffice? -->
8383
<umb-input-media-type
8484
.selection=${this._allowedContentTypeIDs ?? []}
85-
@change="${(e: CustomEvent) => {
86-
const sortedContentTypesList: Array<UmbContentTypeSortModel> = (
87-
e.target as UmbInputMediaTypeElement
88-
).selection.map((id, index) => ({
85+
@change="${(e: CustomEvent & { target: UmbInputMediaTypeElement }) => {
86+
const sortedContentTypesList: Array<UmbContentTypeSortModel> = e.target.selection.map((id, index) => ({
8987
contentType: { unique: id },
9088
sortOrder: index,
9189
}));
@@ -101,7 +99,7 @@ export class UmbMediaTypeWorkspaceViewStructureElement extends UmbLitElement imp
10199
<div slot="editor">
102100
<umb-input-collection-configuration
103101
default-value="3a0156c4-3b8c-4803-bdc1-6871faa83fff"
104-
.value=${this._collection ?? ''}
102+
.value=${this._collection}
105103
@change=${(e: CustomEvent) => {
106104
const unique = (e.target as UmbInputCollectionConfigurationElement).value as string;
107105
this.#workspaceContext?.setCollection({ unique });

0 commit comments

Comments
 (0)