don't request items if it is the tree root

This commit is contained in:
Mads Rasmussen
2024-01-29 19:37:11 +01:00
parent cd9dbe5436
commit f952102e2b

View File

@@ -23,11 +23,16 @@ export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocume
async execute() {
if (!this.repository) return;
// get document item to get the doc type id
const { data, error } = await this.#itemRepository.requestItems([this.unique]);
if (error || !data) throw new Error(`Failed to load document item`);
const documentItem = data[0];
// default to root
let documentItem = null;
if (this.unique) {
// get document item to get the doc type id
const { data, error } = await this.#itemRepository.requestItems([this.unique]);
if (error || !data) throw new Error(`Failed to load document item`);
documentItem = data[0];
}
this._openModal({
document: documentItem ? { unique: documentItem.unique } : null,