From c2a41cd427f50eeb9cf423bb2fdec1a9c5d46081 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 8 Mar 2023 20:32:54 +0100 Subject: [PATCH] rename section picker --- .../input-list-base/input-list-base.ts | 17 +++++++---------- .../input-section/input-section.element.ts | 3 ++- .../section-picker/{indext.ts => index.ts} | 0 .../section-picker-modal.element.ts | 8 ++++---- 4 files changed, 13 insertions(+), 15 deletions(-) rename src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/{indext.ts => index.ts} (100%) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts index 5906a8cea0..e283e46cf6 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts @@ -2,7 +2,7 @@ import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { UUIModalSidebarSize } from '@umbraco-ui/uui-modal-sidebar'; import { UmbPickerModalData } from '../../../../../libs/modal/layouts/modal-layout-picker-base'; -import { UmbModalContext, UmbModalType, UMB_MODAL_CONTEXT_TOKEN } from '../../../../../libs/modal'; +import { UmbModalContext, UmbModalToken, UmbModalType, UMB_MODAL_CONTEXT_TOKEN } from '../../../../../libs/modal'; //TODO: These should probably be imported dynamically. import '../../modals/section-picker/section-picker-modal.element'; @@ -24,7 +24,7 @@ export class UmbInputListBase extends UmbLitElement { @property({ type: String }) public modalSize: UUIModalSidebarSize = 'small'; - protected pickerLayout?: string; + protected pickerToken?: UmbModalToken; private _modalContext?: UmbModalContext; constructor() { @@ -35,16 +35,13 @@ export class UmbInputListBase extends UmbLitElement { } private _openPicker() { - if (!this.pickerLayout) return; + if (!this.pickerToken) return; - const modalHandler = this._modalContext?.open(this.pickerLayout, { - type: this.modalType, - size: this.modalSize, - data: { - multiple: this.multiple, - selection: this.value, - }, + const modalHandler = this._modalContext?.open(this.pickerToken, { + multiple: this.multiple, + selection: this.value, }); + modalHandler?.onClose().then((data: UmbPickerModalData) => { if (data) { this.value = data.selection; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-section/input-section.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-section/input-section.element.ts index 70192a1689..a68fe5ee37 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-section/input-section.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-section/input-section.element.ts @@ -2,6 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UmbInputListBase } from '../input-list-base/input-list-base'; +import { UMB_SECTION_PICKER_MODAL_TOKEN } from '../../modals/section-picker'; import type { ManifestSection } from '@umbraco-cms/models'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-api'; @@ -41,7 +42,7 @@ export class UmbInputPickerSectionElement extends UmbInputListBase { connectedCallback(): void { super.connectedCallback(); - this.pickerLayout = 'umb-picker-layout-section'; + this.pickerToken = UMB_SECTION_PICKER_MODAL_TOKEN; this._observeSections(); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/indext.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/index.ts similarity index 100% rename from src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/indext.ts rename to src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/index.ts diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/section-picker-modal.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/section-picker-modal.element.ts index a65f8c2099..165e23d403 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/section-picker-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/modals/section-picker/section-picker-modal.element.ts @@ -5,8 +5,8 @@ import { UmbModalLayoutPickerBase } from '../../../../../libs/modal/layouts/moda import { umbExtensionsRegistry } from '@umbraco-cms/extensions-api'; import type { ManifestSection } from '@umbraco-cms/models'; -@customElement('umb-picker-layout-section') -export class UmbPickerLayoutSectionElement extends UmbModalLayoutPickerBase { +@customElement('umb-section-picker-modal') +export class UmbSectionPickerModalElement extends UmbModalLayoutPickerBase { static styles = [ UUITextStyles, css` @@ -91,10 +91,10 @@ export class UmbPickerLayoutSectionElement extends UmbModalLayoutPickerBase