diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/views/templates/document-type-workspace-view-templates.element.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/views/templates/document-type-workspace-view-templates.element.ts index 4292370aa8..76807025a8 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/views/templates/document-type-workspace-view-templates.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/views/templates/document-type-workspace-view-templates.element.ts @@ -1,5 +1,6 @@ import { UmbDocumentTypeWorkspaceContext } from '../../document-type-workspace.context.js'; import type { UmbInputTemplateElement } from '../../../../../templating/templates/components/input-template/input-template.element.js'; +import '../../../../../templating/templates/components/input-template/input-template.element.js'; import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui'; import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; @@ -52,7 +53,7 @@ export class UmbDocumentTypeWorkspaceViewTemplatesElement #templateInputChange(e: CustomEvent) { // save new allowed ids const input = e.target as UmbInputTemplateElement; - const idsWithoutRoot = input.selectedIds.filter((id) => id !== null) as Array; + const idsWithoutRoot = input.selectedIds?.filter((id) => id !== null) ?? []; this.#workspaceContext?.setAllowedTemplateIds(idsWithoutRoot); this.#workspaceContext?.setDefaultTemplateId(input.defaultId); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/info/document-info-workspace-view.element.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/info/document-info-workspace-view.element.ts index 1c844843b6..b6c91a7ff2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/info/document-info-workspace-view.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/info/document-info-workspace-view.element.ts @@ -102,6 +102,7 @@ export class UmbDocumentInfoWorkspaceViewElement extends UmbLitElement { super(); new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL) + .addAdditionalPath('document-type') .onSetup(() => { return { entityType: 'document-type', preset: {} }; }) diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/templates/components/input-template/input-template.element.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/templates/components/input-template/input-template.element.ts index cda5e0039d..7d75b9fa19 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/templates/components/input-template/input-template.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/templates/components/input-template/input-template.element.ts @@ -1,4 +1,6 @@ -import { UmbTemplateCardElement } from '../template-card/template-card.element.js'; +import type { UmbTemplateCardElement } from '../template-card/template-card.element.js'; +import '../template-card/template-card.element.js'; + import { UmbTemplateRepository } from '../../repository/template.repository.js'; import { css, html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit'; import { UUITextStyles, FormControlMixin } from '@umbraco-cms/backoffice/external/uui'; @@ -50,12 +52,12 @@ export class UmbInputTemplateElement extends FormControlMixin(UmbLitElement) { maxMessage = 'This field exceeds the allowed amount of items'; _selectedIds: Array = []; - @property({ type: Array }) + @property({ type: Array }) public get selectedIds() { return this._selectedIds; } - public set selectedIds(newKeys: Array) { - this._selectedIds = newKeys; + public set selectedIds(newKeys: Array | undefined) { + this._selectedIds = newKeys ?? []; this.#observePickedTemplates(); } @@ -111,7 +113,7 @@ export class UmbInputTemplateElement extends FormControlMixin(UmbLitElement) { // TODO: Change experience, so its not multi selectable. But instead already picked templates should be unpickable. (awaiting general picker features for such) const modalContext = this._modalContext?.open(UMB_TEMPLATE_PICKER_MODAL, { multiple: true, - selection: [...this.selectedIds], + selection: [...this._selectedIds], pickableFilter: (template: TemplateResponseModel) => template.id !== null, }); @@ -132,7 +134,7 @@ export class UmbInputTemplateElement extends FormControlMixin(UmbLitElement) { In current backoffice we just prevent deleting a default when there are other templates. But if its the only one its okay. This is a weird experience, so we should make something that makes more sense. BTW. its weird cause the damage of removing the default template is equally bad when there is one or more templates. */ - this.selectedIds = this.selectedIds.filter((x) => x !== id); + this.selectedIds = this._selectedIds.filter((x) => x !== id); } #openTemplate(e: CustomEvent) {