Merge pull request #1625 from umbraco/bugfix/create-a-document-when-no-blueprint-error

Bugfix: Create a document when no blueprint available
This commit is contained in:
Lee Kelleher
2024-04-16 13:20:25 +01:00
committed by GitHub
2 changed files with 4 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ export class UmbDocumentCreateOptionsModalElement extends UmbModalBaseElement<
history.pushState(
null,
'',
`section/content/workspace/document/create/parent/${this.data?.parent.entityType}/${this.data?.parent.unique ?? 'null'}/${documentTypeUnique}/${blueprintUnique}`,
`section/content/workspace/document/create/parent/${this.data?.parent.entityType}/${this.data?.parent.unique ?? 'null'}/${documentTypeUnique}/blueprint/${blueprintUnique}`,
);
}
this._submitModal();
@@ -90,9 +90,8 @@ export class UmbDocumentCreateOptionsModalElement extends UmbModalBaseElement<
/** TODO: Fix this to use the correct endpoint when it becomes available */
const { data } = await this.#documentBlueprintItemRepository.requestItems([]);
if (!data?.length) return;
this._availableBlueprints = data.filter((blueprint) => blueprint.documentType.unique === documentTypeUnique);
this._availableBlueprints = data?.filter((blueprint) => blueprint.documentType.unique === documentTypeUnique) ?? [];
if (!this._availableBlueprints.length) {
this.#onNavigate(documentTypeUnique);

View File

@@ -161,7 +161,7 @@ export class UmbDocumentWorkspaceContext
this.routes.setRoutes([
{
path: 'create/parent/:entityType/:parentUnique/:documentTypeUnique/:blueprintUnique',
path: 'create/parent/:entityType/:parentUnique/:documentTypeUnique/blueprint/:blueprintUnique',
component: () => import('./document-workspace-editor.element.js'),
setup: async (_component, info) => {
const parentEntityType = info.match.params.entityType;
@@ -249,8 +249,7 @@ export class UmbDocumentWorkspaceContext
this.resetState();
this.#parent.setValue(parent);
/**TODO Explore bug: A way to make blueprintUnique undefined/null when no unique is given, rather than setting it to invariant */
if (blueprintUnique && blueprintUnique.toLowerCase() !== 'invariant') {
if (blueprintUnique) {
const { data } = await this.#blueprintRepository.requestByUnique(blueprintUnique);
this.#getDataPromise = this.repository.createScaffold({