Adds loading state on the context
This commit is contained in:
@@ -31,6 +31,9 @@ export class UmbDefaultCollectionContext<
|
||||
#manifest?: ManifestCollection;
|
||||
#repository?: UmbCollectionRepository;
|
||||
|
||||
#loading = new UmbObjectState<boolean>(false);
|
||||
public readonly loading = this.#loading.asObservable();
|
||||
|
||||
#items = new UmbArrayState<CollectionItemType>([], (x) => x);
|
||||
public readonly items = this.#items.asObservable();
|
||||
|
||||
@@ -176,6 +179,8 @@ export class UmbDefaultCollectionContext<
|
||||
|
||||
if (!this.#repository) throw new Error(`Missing repository for ${this.#manifest}`);
|
||||
|
||||
this.#loading.setValue(true);
|
||||
|
||||
const filter = this.#filter.getValue();
|
||||
const { data } = await this.#repository.requestCollection(filter);
|
||||
|
||||
@@ -184,6 +189,8 @@ export class UmbDefaultCollectionContext<
|
||||
this.#totalItems.setValue(data.total);
|
||||
this.pagination.setTotalItems(data.total);
|
||||
}
|
||||
|
||||
this.#loading.setValue(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,8 @@ export class UmbDocumentGridCollectionViewElement extends UmbLitElement {
|
||||
#observeCollectionContext() {
|
||||
if (!this.#collectionContext) return;
|
||||
|
||||
this.observe(this.#collectionContext.loading, (loading) => (this._loading = loading), '_observeLoading');
|
||||
|
||||
this.observe(
|
||||
this.#collectionContext.userDefinedProperties,
|
||||
(userDefinedProperties) => {
|
||||
|
||||
@@ -75,6 +75,8 @@ export class UmbDocumentTableCollectionViewElement extends UmbLitElement {
|
||||
#observeCollectionContext() {
|
||||
if (!this.#collectionContext) return;
|
||||
|
||||
this.observe(this.#collectionContext.loading, (loading) => (this._loading = loading), '_observeLoading');
|
||||
|
||||
this.observe(
|
||||
this.#collectionContext.userDefinedProperties,
|
||||
(userDefinedProperties) => {
|
||||
|
||||
Reference in New Issue
Block a user