Merge pull request #1932 from umbraco/feature/media-type-descriptions
Feature: Media Type Descriptions
This commit is contained in:
@@ -4,12 +4,16 @@ import { css, html, customElement, state, ifDefined } from '@umbraco-cms/backoff
|
||||
import { UmbLitElement, umbFocus } from '@umbraco-cms/backoffice/lit-element';
|
||||
import { UMB_ICON_PICKER_MODAL, UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbInputWithAliasElement } from '@umbraco-cms/backoffice/components';
|
||||
import type { UUITextareaElement } from '@umbraco-cms/backoffice/external/uui';
|
||||
|
||||
@customElement('umb-media-type-workspace-editor')
|
||||
export class UmbMediaTypeWorkspaceEditorElement extends UmbLitElement {
|
||||
@state()
|
||||
private _name?: string;
|
||||
|
||||
@state()
|
||||
private _description?: string;
|
||||
|
||||
@state()
|
||||
private _alias?: string;
|
||||
|
||||
@@ -36,6 +40,11 @@ export class UmbMediaTypeWorkspaceEditorElement extends UmbLitElement {
|
||||
#observeMediaType() {
|
||||
if (!this.#workspaceContext) return;
|
||||
this.observe(this.#workspaceContext.name, (name) => (this._name = name), '_observeName');
|
||||
this.observe(
|
||||
this.#workspaceContext.description,
|
||||
(description) => (this._description = description),
|
||||
'_observeDescription',
|
||||
);
|
||||
this.observe(this.#workspaceContext.alias, (alias) => (this._alias = alias), '_observeAlias');
|
||||
this.observe(this.#workspaceContext.icon, (icon) => (this._icon = icon), '_observeIcon');
|
||||
this.observe(this.#workspaceContext.isNew, (isNew) => (this._isNew = isNew), '_observeIsNew');
|
||||
@@ -66,6 +75,10 @@ export class UmbMediaTypeWorkspaceEditorElement extends UmbLitElement {
|
||||
this.#workspaceContext?.setAlias(event.target.alias ?? '');
|
||||
}
|
||||
|
||||
#onDescriptionChange(event: InputEvent & { target: UUITextareaElement }) {
|
||||
this.#workspaceContext?.setDescription(event.target.value.toString() ?? '');
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`<umb-workspace-editor alias="Umb.Workspace.MediaType">
|
||||
<div id="header" slot="header">
|
||||
@@ -73,15 +86,24 @@ export class UmbMediaTypeWorkspaceEditorElement extends UmbLitElement {
|
||||
<umb-icon name=${ifDefined(this._icon)}></umb-icon>
|
||||
</uui-button>
|
||||
|
||||
<umb-input-with-alias
|
||||
id="name"
|
||||
label="name"
|
||||
value=${this._name}
|
||||
alias=${this._alias}
|
||||
?auto-generate-alias=${this._isNew}
|
||||
@change="${this.#onNameAndAliasChange}"
|
||||
${umbFocus()}>
|
||||
</umb-input-with-alias>
|
||||
<div id="editors">
|
||||
<umb-input-with-alias
|
||||
id="name"
|
||||
label="name"
|
||||
value=${this._name}
|
||||
alias=${this._alias}
|
||||
?auto-generate-alias=${this._isNew}
|
||||
@change="${this.#onNameAndAliasChange}"
|
||||
${umbFocus()}>
|
||||
</umb-input-with-alias>
|
||||
|
||||
<uui-input
|
||||
id="description"
|
||||
.label=${this.localize.term('placeholders_enterDescription')}
|
||||
.value=${this._description}
|
||||
.placeholder=${this.localize.term('placeholders_enterDescription')}
|
||||
@input=${this.#onDescriptionChange}></uui-input>
|
||||
</div>
|
||||
</div>
|
||||
</umb-workspace-editor>`;
|
||||
}
|
||||
@@ -99,10 +121,27 @@ export class UmbMediaTypeWorkspaceEditorElement extends UmbLitElement {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
#editors {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
gap: var(--uui-size-space-1);
|
||||
}
|
||||
|
||||
#name {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#description {
|
||||
width: 100%;
|
||||
--uui-input-height: var(--uui-size-8);
|
||||
--uui-input-border-color: transparent;
|
||||
}
|
||||
|
||||
#description:hover {
|
||||
--uui-input-border-color: var(--uui-color-border);
|
||||
}
|
||||
|
||||
#icon {
|
||||
font-size: calc(var(--uui-size-layout-3) / 2);
|
||||
margin-right: var(--uui-size-space-2);
|
||||
|
||||
@@ -51,7 +51,11 @@ export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
|
||||
}
|
||||
|
||||
// close the modal when navigating to data type
|
||||
#onNavigate() {
|
||||
#onNavigate(mediaType: UmbAllowedMediaTypeModel) {
|
||||
const url = `section/media/workspace/media/create/parent/${this.data?.parent.entityType}/${
|
||||
this.data?.parent.unique ?? 'null'
|
||||
}/${mediaType.unique}`;
|
||||
history.pushState({}, '', url);
|
||||
this._submitModal();
|
||||
}
|
||||
|
||||
@@ -64,15 +68,15 @@ export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
|
||||
: nothing}
|
||||
${this._allowedMediaTypes.map(
|
||||
(mediaType) => html`
|
||||
<uui-menu-item
|
||||
<uui-ref-node-document-type
|
||||
data-id=${ifDefined(mediaType.unique)}
|
||||
href="${`section/media/workspace/media/create/parent/${this.data?.parent.entityType}/${
|
||||
this.data?.parent.unique ?? 'null'
|
||||
}/${mediaType.unique}`}"
|
||||
label="${mediaType.name}"
|
||||
@click=${this.#onNavigate}>
|
||||
> ${mediaType.icon ? html`<umb-icon slot="icon" name=${mediaType.icon}></umb-icon>` : nothing}
|
||||
</uui-menu-item>
|
||||
.name=${mediaType.name}
|
||||
.alias=${mediaType.description}
|
||||
select-only
|
||||
selectable
|
||||
@selected=${() => this.#onNavigate(mediaType)}>
|
||||
${mediaType.icon ? html`<umb-icon slot="icon" name=${mediaType.icon}></umb-icon>` : nothing}
|
||||
</uui-ref-node-document-type>
|
||||
`,
|
||||
)}
|
||||
</uui-box>
|
||||
|
||||
Reference in New Issue
Block a user