Multi-URL Picker: Removing UDI support

Re-introduced the "Link Type" of "document, external or media".
This is to reduce the processing of UDI strings in the client UI.
This commit is contained in:
leekelleher
2024-02-01 12:26:12 +00:00
parent b8dc5ee333
commit 8b9003fa35
3 changed files with 17 additions and 16 deletions

View File

@@ -3,12 +3,8 @@ import { FormControlMixin } from '@umbraco-cms/backoffice/external/uui';
import type { UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';
import {
UMB_LINK_PICKER_MODAL,
UmbModalRouteRegistrationController,
} from '@umbraco-cms/backoffice/modal';
import type { UmbModalRouteBuilder ,
UmbLinkPickerLink} from '@umbraco-cms/backoffice/modal';
import { UMB_LINK_PICKER_MODAL, UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/modal';
import type { UmbModalRouteBuilder, UmbLinkPickerLink } from '@umbraco-cms/backoffice/modal';
/**
* @element umb-input-multi-url
@@ -109,6 +105,7 @@ export class UmbInputMultiUrlElement extends FormControlMixin(UmbLitElement) {
constructor() {
super();
this.addValidator(
'rangeUnderflow',
() => this.minMessage,
@@ -155,7 +152,8 @@ export class UmbInputMultiUrlElement extends FormControlMixin(UmbLitElement) {
queryString: data?.queryString,
target: data?.target,
trashed: data?.trashed,
udi: data?.udi,
type: data?.type,
unique: data?.unique,
url: data?.url,
},
},

View File

@@ -4,11 +4,11 @@ import type { UUIBooleanInputEvent, UUIInputElement } from '@umbraco-cms/backoff
import type {
UmbLinkPickerConfig,
UmbLinkPickerLink,
UmbLinkPickerLinkType,
UmbLinkPickerModalData,
UmbLinkPickerModalValue,
} from '@umbraco-cms/backoffice/modal';
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
import { buildUdi, getKeyFromUdi } from '@umbraco-cms/backoffice/utils';
import { UMB_DOCUMENT_TREE_ALIAS } from '@umbraco-cms/backoffice/document';
@customElement('umb-link-picker-modal')
@@ -57,7 +57,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
if (this.modalContext) {
this.observe(this.modalContext.value, (value) => {
(this._link as any) = value.link;
this._selectedKey = this._link?.udi ? getKeyFromUdi(this._link.udi) : undefined;
this._selectedKey = this._link?.unique ?? undefined;
this._selectionConfiguration.selection = this._selectedKey ? [this._selectedKey] : [];
});
}
@@ -88,18 +88,18 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
const selectedKey = selection[selection.length - 1];
if (!selectedKey) {
this.#partialUpdateLink({ udi: '', url: undefined });
this.#partialUpdateLink({ type: undefined, unique: '', url: undefined });
this._selectedKey = undefined;
this._selectionConfiguration.selection = [];
this.requestUpdate();
return;
}
const udi = buildUdi(entityType, selectedKey);
const linkType = (entityType as UmbLinkPickerLinkType) ?? 'external';
this._selectedKey = selectedKey;
this._selectionConfiguration.selection = [this._selectedKey];
this.#partialUpdateLink({ udi: udi, url: udi });
this.#partialUpdateLink({ type: linkType, unique: selectedKey, url: selectedKey });
this.requestUpdate();
}
@@ -154,9 +154,9 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
id="link-input"
placeholder=${this.localize.term('general_url')}
label=${this.localize.term('general_url')}
.value="${this._link.udi ?? this._link.url ?? ''}"
@input=${() => this.#partialUpdateLink({ url: this._linkInput.value as string })}
?disabled="${this._link.udi ? true : false}"></uui-input>
.value="${this._link.unique ?? this._link.url ?? ''}"
@input=${() => this.#partialUpdateLink({ type: 'external', url: this._linkInput.value as string })}
?disabled="${this._link.unique ? true : false}"></uui-input>
</span>`;
}

View File

@@ -15,10 +15,13 @@ export interface UmbLinkPickerLink {
queryString?: string | null;
target?: string | null;
trashed?: boolean | null;
udi?: string | null;
type?: UmbLinkPickerLinkType | null;
unique?: string | null;
url?: string | null;
}
export type UmbLinkPickerLinkType = 'document' | 'external' | 'media';
// TODO: investigate: this looks more like a property editor configuration. Is this used in the correct way?
export interface UmbLinkPickerConfig {
hideAnchor?: boolean;