update create
This commit is contained in:
@@ -8,6 +8,7 @@ export interface UmbCreateDictionaryModalData {
|
||||
|
||||
export interface UmbCreateDictionaryModalResult {
|
||||
name?: string;
|
||||
parentId?: string;
|
||||
}
|
||||
|
||||
export const UMB_CREATE_DICTIONARY_MODAL = new UmbModalToken<
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user