Merge pull request #1775 from umbraco/bugfix/collection-context-loading
Bugfix/collection context loading
This commit is contained in:
@@ -1,29 +1,10 @@
|
||||
import type { UmbDefaultCollectionContext } from '../default/collection-default.context.js';
|
||||
import { UMB_COLLECTION_CONTEXT } from '../default/collection-default.context.js';
|
||||
import { html, customElement, state, nothing } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { html, customElement } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
|
||||
@customElement('umb-collection-action-bundle')
|
||||
export class UmbCollectionActionBundleElement extends UmbLitElement {
|
||||
#collectionContext?: UmbDefaultCollectionContext<any, any>;
|
||||
|
||||
@state()
|
||||
_collectionAlias? = '';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.consumeContext(UMB_COLLECTION_CONTEXT, (context) => {
|
||||
this.#collectionContext = context;
|
||||
if (!this.#collectionContext) return;
|
||||
this._collectionAlias = this.#collectionContext.getManifest()?.alias;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
${this._collectionAlias ? html`<umb-extension-slot type="collectionAction"></umb-extension-slot>` : nothing}
|
||||
`;
|
||||
return html`<umb-extension-slot type="collectionAction"></umb-extension-slot>`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,15 +32,11 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
|
||||
super();
|
||||
this.consumeContext(UMB_COLLECTION_CONTEXT, (context) => {
|
||||
this.#collectionContext = context;
|
||||
this.#collectionContext?.requestCollection();
|
||||
this.#observeCollectionRoutes();
|
||||
});
|
||||
}
|
||||
|
||||
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
|
||||
super.firstUpdated(_changedProperties);
|
||||
this.#collectionContext?.requestCollection();
|
||||
}
|
||||
|
||||
#observeCollectionRoutes() {
|
||||
if (!this.#collectionContext) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user