Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ export class UmbDefaultCollectionContext<
return this._manifest;
}

public getEmptyLabel(): string {
return this.manifest?.meta.noItemsLabel ?? this.#config?.noItemsLabel ?? '#collection_noItemsTitle';
}

/**
* Requests the collection from the repository.
* @returns {*}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ umbExtensionsRegistry.register(manifest);

@customElement('umb-collection-default')
export class UmbCollectionDefaultElement extends UmbLitElement {
//
#collectionContext?: UmbDefaultCollectionContext;

@state()
private _routes: Array<UmbRoute> = [];

Expand All @@ -32,14 +35,16 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
@state()
private _isDoneLoading = false;

#collectionContext?: UmbDefaultCollectionContext<any, any>;
@state()
private _emptyLabel?: string;

constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT, async (context) => {
this.#collectionContext = context;
this.#observeCollectionRoutes();
this.#observeTotalItems();
this.#getEmptyStateLabel();
await this.#collectionContext?.requestCollection();
this._isDoneLoading = true;
});
Expand Down Expand Up @@ -69,6 +74,10 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
);
}

#getEmptyStateLabel() {
this._emptyLabel = this.#collectionContext?.getEmptyLabel();
}

override render() {
return this._routes
? html`
Expand Down Expand Up @@ -98,9 +107,10 @@ export class UmbCollectionDefaultElement extends UmbLitElement {

#renderEmptyState() {
if (!this._isDoneLoading) return nothing;

return html`
<div id="empty-state" class="uui-text">
<h4><umb-localize key="collection_noItemsTitle"></umb-localize></h4>
<h4>${this.localize.string(this._emptyLabel)}</h4>
</div>
`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ManifestCollection

export interface MetaCollection {
repositoryAlias: string;
noItemsLabel?: string;
}

declare global {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface UmbCollectionConfiguration {
orderBy?: string;
orderDirection?: string;
pageSize?: number;
noItemsLabel?: string;
userDefinedProperties?: Array<UmbCollectionColumnConfiguration>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class UmbMediaCollectionElement extends UmbCollectionDefaultElement {
super();

this.consumeContext(UMB_MEDIA_COLLECTION_CONTEXT, (context) => {
// TODO: stop consuming the context both in the default element and here. Instead make the default able to inform when the context is consumed. Or come up with a better system for the controllers to talk together. [NL]
this.#collectionContext = context;
});

Expand Down
Loading