get selected type in create action
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { UMB_ALLOWED_DOCUMENT_TYPES_MODAL_TOKEN } from '../../../document-types/modals/allowed-document-types';
|
||||
import { UmbDocumentRepository } from '../../repository/document.repository';
|
||||
import type { UmbDocumentRepository } from '../../repository/document.repository';
|
||||
import { UmbEntityActionBase } from '@umbraco-cms/entity-action';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbModalContext, UMB_MODAL_CONTEXT_TOKEN } from '@umbraco-cms/modal';
|
||||
@@ -19,13 +19,18 @@ export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocume
|
||||
async execute() {
|
||||
// TODO: what to do if modal service is not available?
|
||||
if (!this.#modalContext) return;
|
||||
if (!this.repository) return;
|
||||
|
||||
const modalHandler = this.#modalContext?.open(UMB_ALLOWED_DOCUMENT_TYPES_MODAL_TOKEN, {
|
||||
key: this.unique,
|
||||
});
|
||||
const { data } = await this.repository.requestByKey(this.unique);
|
||||
|
||||
const { documentTypeKey } = await modalHandler.onSubmit();
|
||||
// TODO: how do we want to generate these urls?
|
||||
history.pushState(null, '', `/section/content/workspace/document/create/${this.unique}/type/${documentTypeKey}`);
|
||||
if (data && data.contentTypeKey) {
|
||||
const modalHandler = this.#modalContext?.open(UMB_ALLOWED_DOCUMENT_TYPES_MODAL_TOKEN, {
|
||||
key: data.contentTypeKey,
|
||||
});
|
||||
|
||||
const { documentTypeKey } = await modalHandler.onSubmit();
|
||||
// TODO: how do we want to generate these urls?
|
||||
history.pushState(null, '', `/section/content/workspace/document/create/${this.unique}/type/${documentTypeKey}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user