refresh tree when adding a template

This commit is contained in:
Julia Gru
2023-06-01 09:54:31 +02:00
parent aa8781e99f
commit 9a3b2a62f0
2 changed files with 8 additions and 6 deletions

View File

@@ -78,7 +78,6 @@ export class UmbTemplateRepository
await this.#init;
const { data, error } = await this.#treeDataSource.getRootItems();
if (data) {
this.#treeStore?.appendItems(data.items);
}
@@ -161,9 +160,8 @@ export class UmbTemplateRepository
return { data, error };
}
async items(uniques: string[]) {
await this.#init;
return this.#store?.items(uniques);
async items(uniques: string[]): Promise<Observable<ItemResponseModelBaseModel[]>> {
throw new Error('items method is not implemented in UmbTemplateRepository');
}
async byId(id: string) {
@@ -190,7 +188,7 @@ export class UmbTemplateRepository
// TODO: we currently don't use the detail store for anything.
// Consider to look up the data before fetching from the server
//this.#store?.append(template);
//this.#store?.append({ ...template, $type: 'EntityTreeItemResponseModel' });
// TODO: Update tree store with the new item? or ask tree to request the new item?
return { error };
@@ -240,7 +238,6 @@ export class UmbTemplateRepository
// Consider notify a workspace if a template is deleted from the store while someone is editing it.
this.#store?.remove([id]);
this.#treeStore?.removeItem(id);
// TODO: would be nice to align the stores on methods/methodNames.
return { error };
}

View File

@@ -111,6 +111,11 @@ export class UmbTemplateWorkspaceContext extends UmbWorkspaceContext<UmbTemplate
content: template.content,
alias: template.alias,
});
if (this.#masterTemplate.value?.id) {
this.repository.requestTreeItemsOf(this.#masterTemplate.value?.id ?? '');
} else {
this.repository.requestRootTreeItems();
}
}
if (template?.id) {