Skip to content

Commit 7b00033

Browse files
authored
Fix: 17764 (#18093)
* Add property value model type * make the element a Form Control
1 parent 776e731 commit 7b00033

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { UmbMediaItemRepository } from '../../repository/index.js';
22
import { UMB_IMAGE_CROPPER_EDITOR_MODAL, UMB_MEDIA_PICKER_MODAL } from '../../modals/index.js';
3-
import type { UmbMediaItemModel, UmbCropModel, UmbMediaPickerPropertyValue } from '../../types.js';
3+
import type { UmbMediaItemModel, UmbCropModel, UmbMediaPickerPropertyValueEntry } from '../../types.js';
44
import type { UmbUploadableItem } from '../../dropzone/types.js';
55
import { css, customElement, html, nothing, property, repeat, state } from '@umbraco-cms/backoffice/external/lit';
66
import { umbConfirmModal, UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
@@ -27,7 +27,7 @@ type UmbRichMediaCardModel = {
2727

2828
@customElement('umb-input-rich-media')
2929
export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement, '') {
30-
#sorter = new UmbSorterController<UmbMediaPickerPropertyValue>(this, {
30+
#sorter = new UmbSorterController<UmbMediaPickerPropertyValueEntry>(this, {
3131
getUniqueOfElement: (element) => {
3232
return element.id;
3333
},
@@ -46,7 +46,7 @@ export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement,
4646
},
4747
});
4848

49-
#sortCards(model: Array<UmbMediaPickerPropertyValue>) {
49+
#sortCards(model: Array<UmbMediaPickerPropertyValueEntry>) {
5050
const idToIndexMap: { [unique: string]: number } = {};
5151
model.forEach((item, index) => {
5252
idToIndexMap[item.key] = index;
@@ -93,15 +93,15 @@ export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement,
9393
maxMessage = 'This field exceeds the allowed amount of items';
9494

9595
@property({ type: Array })
96-
public set items(value: Array<UmbMediaPickerPropertyValue>) {
96+
public set items(value: Array<UmbMediaPickerPropertyValueEntry>) {
9797
this.#sorter.setModel(value);
9898
this.#items = value;
9999
this.#populateCards();
100100
}
101-
public get items(): Array<UmbMediaPickerPropertyValue> {
101+
public get items(): Array<UmbMediaPickerPropertyValueEntry> {
102102
return this.#items;
103103
}
104-
#items: Array<UmbMediaPickerPropertyValue> = [];
104+
#items: Array<UmbMediaPickerPropertyValueEntry> = [];
105105

106106
@property({ type: Array })
107107
allowedContentTypeIds?: string[] | undefined;
@@ -282,7 +282,7 @@ export class UmbInputRichMediaElement extends UUIFormControlMixin(UmbLitElement,
282282
#addItems(uniques: string[]) {
283283
if (!uniques.length) return;
284284

285-
const additions: Array<UmbMediaPickerPropertyValue> = uniques.map((unique) => ({
285+
const additions: Array<UmbMediaPickerPropertyValueEntry> = uniques.map((unique) => ({
286286
key: UmbId.new(),
287287
mediaKey: unique,
288288
mediaTypeAlias: '',

src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/media-picker/property-editor-ui-media-picker.element.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { UmbInputRichMediaElement } from '../../components/input-rich-media/input-rich-media.element.js';
2-
import type { UmbCropModel, UmbMediaPickerPropertyValue } from '../types.js';
2+
import type { UmbCropModel, UmbMediaPickerValueModel } from '../types.js';
33
import { customElement, html, property, state } from '@umbraco-cms/backoffice/external/lit';
44
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
55
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
@@ -11,17 +11,18 @@ import type {
1111
} from '@umbraco-cms/backoffice/property-editor';
1212

1313
import '../../components/input-rich-media/input-rich-media.element.js';
14+
import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
1415

1516
const elementName = 'umb-property-editor-ui-media-picker';
1617

1718
/**
1819
* @element umb-property-editor-ui-media-picker
1920
*/
2021
@customElement(elementName)
21-
export class UmbPropertyEditorUIMediaPickerElement extends UmbLitElement implements UmbPropertyEditorUiElement {
22-
@property({ attribute: false })
23-
value?: Array<UmbMediaPickerPropertyValue>;
24-
22+
export class UmbPropertyEditorUIMediaPickerElement
23+
extends UmbFormControlMixin<UmbMediaPickerValueModel | undefined, typeof UmbLitElement, undefined>(UmbLitElement)
24+
implements UmbPropertyEditorUiElement
25+
{
2526
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
2627
if (!config) return;
2728

src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
export type UmbMediaPickerPropertyValue = {
1+
export type UmbMediaPickerPropertyValueEntry = {
22
key: string;
33
mediaKey: string;
44
mediaTypeAlias: string;
55
focalPoint: UmbFocalPointModel | null;
66
crops: Array<UmbCropModel>;
77
};
88

9+
/**
10+
* @deprecated Use UmbMediaPickerPropertyValueEntry instead — Will be removed in v.17.
11+
* Also notice this is a modal for the entry type, use UmbMediaPickerPropertyValueModel for the type of the value.
12+
*/
13+
export type UmbMediaPickerPropertyValue = UmbMediaPickerPropertyValueEntry;
14+
15+
export type UmbMediaPickerValueModel = Array<UmbMediaPickerPropertyValueEntry>;
16+
917
export type UmbCropModel = {
1018
label?: string;
1119
alias: string;

0 commit comments

Comments
 (0)