From 4e576ac8f1b4e4f5f056e680ef29c22f3dc849c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 12 Jun 2023 10:16:39 +0200 Subject: [PATCH] refactor --- .../core/modal/token/create-dictionary-modal.token.ts | 6 +++--- .../dictionary/dashboard-translation-dictionary.element.ts | 3 ++- ...layout.element.ts => create-dictionary-modal.element.ts} | 2 +- .../dictionary/entity-actions/create/create.action.ts | 4 ++-- .../translation/dictionary/entity-actions/manifests.ts | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) rename src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/{create-dictionary-modal-layout.element.ts => create-dictionary-modal.element.ts} (98%) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/create-dictionary-modal.token.ts b/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/create-dictionary-modal.token.ts index 62dd3f787c..2f9641df86 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/create-dictionary-modal.token.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/create-dictionary-modal.token.ts @@ -2,13 +2,13 @@ import { Observable } from '@umbraco-cms/backoffice/external/rxjs'; import { UmbModalToken } from '@umbraco-cms/backoffice/modal'; export interface UmbCreateDictionaryModalData { - unique: string | null; + parentId: string | null; parentName?: Observable; } export interface UmbCreateDictionaryModalResult { - name?: string; - parentId?: string; + name: string; + parentId: string | null; } export const UMB_CREATE_DICTIONARY_MODAL = new UmbModalToken< diff --git a/src/Umbraco.Web.UI.Client/src/packages/translation/dashboards/dictionary/dashboard-translation-dictionary.element.ts b/src/Umbraco.Web.UI.Client/src/packages/translation/dashboards/dictionary/dashboard-translation-dictionary.element.ts index bf9ffd0430..029d884b38 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/translation/dashboards/dictionary/dashboard-translation-dictionary.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/translation/dashboards/dictionary/dashboard-translation-dictionary.element.ts @@ -134,7 +134,8 @@ export class UmbDashboardTranslationDictionaryElement extends UmbLitElement { if (!this.#modalContext) return; if (!this.#repo) return; - const modalContext = this.#modalContext?.open(UMB_CREATE_DICTIONARY_MODAL, { unique: null }); + console.log('open create:'); + const modalContext = this.#modalContext?.open(UMB_CREATE_DICTIONARY_MODAL, { parentId: null }); const { name, parentId } = await modalContext.onSubmit(); if (!name || parentId === undefined) return; diff --git a/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create-dictionary-modal-layout.element.ts b/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create-dictionary-modal.element.ts similarity index 98% rename from src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create-dictionary-modal-layout.element.ts rename to src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create-dictionary-modal.element.ts index 9fdb3ab7ea..d0e56f6016 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create-dictionary-modal-layout.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create-dictionary-modal.element.ts @@ -40,7 +40,7 @@ export class UmbCreateDictionaryModalElement extends UmbModalBaseElement< this.modalContext?.submit({ name, - parentId: this.data?.unique ?? undefined, + parentId: this.data?.parentId ?? null, }); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create.action.ts b/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create.action.ts index 846623acba..7b3c486288 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create.action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/create/create.action.ts @@ -11,7 +11,7 @@ import { } from '@umbraco-cms/backoffice/modal'; // TODO: temp import -import './create-dictionary-modal-layout.element.js'; +import './create-dictionary-modal.element.js'; export default class UmbCreateDictionaryEntityAction extends UmbEntityActionBase { static styles = [UUITextStyles]; @@ -40,7 +40,7 @@ export default class UmbCreateDictionaryEntityAction extends UmbEntityActionBase // TODO: how can we get the current entity detail in the modal? Passing the observable // feels a bit hacky. Works, but hacky. const modalContext = this.#modalContext?.open(UMB_CREATE_DICTIONARY_MODAL, { - unique: this.unique, + parentId: this.unique, parentName: this.#sectionSidebarContext.headline, }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/manifests.ts index d281819bbd..e1bfb8c2a8 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/translation/dictionary/entity-actions/manifests.ts @@ -107,7 +107,7 @@ const modals: Array = [ type: 'modal', alias: 'Umb.Modal.CreateDictionary', name: 'Create Dictionary Modal', - loader: () => import('./create/create-dictionary-modal-layout.element.js'), + loader: () => import('./create/create-dictionary-modal.element.js'), }, { type: 'modal',