Merge pull request #2222 from umbraco/v14/feature/readonly-dropdown
Feature: Readonly mode for Dropdown Property Editor UI
This commit is contained in:
@@ -16,6 +16,15 @@ export class UmbInputDropdownListElement extends UUIFormControlMixin(UmbLitEleme
|
||||
@property({ type: Boolean })
|
||||
public multiple?: boolean;
|
||||
|
||||
/**
|
||||
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
|
||||
* @type {boolean}
|
||||
* @attr
|
||||
* @default false
|
||||
*/
|
||||
@property({ type: Boolean, reflect: true })
|
||||
readonly = false;
|
||||
|
||||
@query('uui-select')
|
||||
private selectEle!: HTMLInputElement;
|
||||
|
||||
@@ -34,7 +43,8 @@ export class UmbInputDropdownListElement extends UUIFormControlMixin(UmbLitEleme
|
||||
label=${this.localize.term('formProviderFieldTypes_dropdownName')}
|
||||
.placeholder=${this.placeholder ?? ''}
|
||||
.options=${this.options ?? []}
|
||||
@change=${this.#onChange}></uui-select>`;
|
||||
@change=${this.#onChange}
|
||||
?readonly=${this.readonly}></uui-select>`;
|
||||
}
|
||||
|
||||
static override styles = [
|
||||
|
||||
@@ -12,6 +12,7 @@ export const manifests: Array<ManifestTypes> = [
|
||||
propertyEditorSchemaAlias: 'Umbraco.DropDown.Flexible',
|
||||
icon: 'icon-list',
|
||||
group: 'lists',
|
||||
supportsReadOnly: true,
|
||||
},
|
||||
},
|
||||
schemaManifest,
|
||||
|
||||
@@ -21,6 +21,15 @@ export class UmbPropertyEditorUIDropdownElement extends UmbLitElement implements
|
||||
return this.#selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
|
||||
* @type {boolean}
|
||||
* @attr
|
||||
* @default false
|
||||
*/
|
||||
@property({ type: Boolean, reflect: true })
|
||||
readonly = false;
|
||||
|
||||
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
|
||||
if (!config) return;
|
||||
|
||||
@@ -68,6 +77,10 @@ export class UmbPropertyEditorUIDropdownElement extends UmbLitElement implements
|
||||
}
|
||||
|
||||
#renderDropdownMultiple() {
|
||||
if (this.readonly) {
|
||||
return html`<div>${this.value?.join(', ')}</div>`;
|
||||
}
|
||||
|
||||
return html`
|
||||
<select id="native" multiple @change=${this.#onChangeMulitple}>
|
||||
${map(
|
||||
@@ -80,7 +93,10 @@ export class UmbPropertyEditorUIDropdownElement extends UmbLitElement implements
|
||||
|
||||
#renderDropdownSingle() {
|
||||
return html`
|
||||
<umb-input-dropdown-list .options=${this._options} @change=${this.#onChange}></umb-input-dropdown-list>
|
||||
<umb-input-dropdown-list
|
||||
.options=${this._options}
|
||||
@change=${this.#onChange}
|
||||
?readonly=${this.readonly}></umb-input-dropdown-list>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user