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 cd2823651e..62dd3f787c 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 @@ -8,6 +8,7 @@ export interface UmbCreateDictionaryModalData { export interface UmbCreateDictionaryModalResult { name?: string; + parentId?: string; } 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 0da96591f0..8f04a03911 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 @@ -10,6 +10,7 @@ import { UMB_CREATE_DICTIONARY_MODAL, } from '@umbraco-cms/backoffice/modal'; import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api'; +import { log } from '@openid/appauth'; @customElement('umb-dashboard-translation-dictionary') export class UmbDashboardTranslationDictionaryElement extends UmbLitElement { @@ -136,13 +137,16 @@ export class UmbDashboardTranslationDictionaryElement extends UmbLitElement { const modalContext = this.#modalContext?.open(UMB_CREATE_DICTIONARY_MODAL, { unique: null }); - // TODO: get type from modal result - const { name } = await modalContext.onSubmit(); + const { name, parentId } = await modalContext.onSubmit(); if (!name) return; - const { data } = await this.#repo.createScaffold(null); - console.log(data); - // TODO => get location header to route to new item + const { data: url } = await this.#repo.create({ name, parentId }); + if (!url) return; + + //TODO: Why do we need to extract the id like this? + const id = url.substring(url.lastIndexOf('/') + 1); + + history.pushState({}, '', `/section/translation/workspace/dictionary-item/edit/${id}`); } render() { 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-layout.element.ts index 7fb155aa05..9fdb3ab7ea 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-layout.element.ts @@ -36,9 +36,11 @@ export class UmbCreateDictionaryModalElement extends UmbModalBaseElement< if (!form || !form.checkValidity()) return; const formData = new FormData(form); + const name = formData.get('name') as string; this.modalContext?.submit({ - name: formData.get('name') as string, + name, + parentId: this.data?.unique ?? undefined, }); } 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 42b975382c..be7d31b0e5 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 @@ -44,13 +44,15 @@ export default class UmbCreateDictionaryEntityAction extends UmbEntityActionBase parentName: this.#sectionSidebarContext.headline, }); - // TODO: get type from modal result - const { name } = await modalContext.onSubmit(); + const { name, parentId } = await modalContext.onSubmit(); if (!name) return; - const { data } = await this.repository.createScaffold(this.unique, { name }); + const { data: url } = await this.repository.create({ name, parentId }); + if (!url) return; - // TODO => get location header to route to new item - console.log(data); + //TODO: Why do we need to extract the id like this? + const id = url.substring(url.lastIndexOf('/') + 1); + + history.pushState({}, '', `/section/translation/workspace/dictionary-item/edit/${id}`); } }