diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/property-editor-ui-collection-view.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/property-editor-ui-collection-view.element.ts index dbe233044f..aae8535519 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/property-editor-ui-collection-view.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/property-editor-ui-collection-view.element.ts @@ -1,3 +1,7 @@ +import type { + UmbCollectionBulkActionPermissions, + UmbCollectionConfiguration, +} from '../../../../core/collection/types.js'; import type { UmbPropertyEditorConfigCollection } from '../../config/index.js'; import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry'; import { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit'; @@ -12,24 +16,27 @@ export class UmbPropertyEditorUICollectionViewElement extends UmbLitElement impl value?: string; @state() - pageSize = 0; - - @state() - orderDirection = 'asc'; - - @state() - useInfiniteEditor = false; + private _config?: UmbCollectionConfiguration; @property({ attribute: false }) public set config(config: UmbPropertyEditorConfigCollection | undefined) { - this.pageSize = Number(config?.getValueByAlias('pageSize')) || 0; - this.orderDirection = config?.getValueByAlias('orderDirection') ?? 'asc'; - this.useInfiniteEditor = config?.getValueByAlias('useInfiniteEditor') ?? false; + this._config = this.#mapDataTypeConfigToCollectionConfig(config); + } + + #mapDataTypeConfigToCollectionConfig( + config: UmbPropertyEditorConfigCollection | undefined, + ): UmbCollectionConfiguration { + return { + allowedEntityBulkActions: config?.getValueByAlias('bulkActionPermissions'), + orderBy: config?.getValueByAlias('orderBy') ?? 'updateDate', + orderDirection: config?.getValueByAlias('orderDirection') ?? 'asc', + pageSize: Number(config?.getValueByAlias('pageSize')) ?? 50, + useInfiniteEditor: config?.getValueByAlias('useInfiniteEditor') ?? false, + }; } render() { - // TODO: [LK] Figure out how to pass in the configuration to the collection view. - return html``; + return html``; } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/collection/document-workspace-view-collection.element.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/collection/document-workspace-view-collection.element.ts index eb5c301c2a..6d34977565 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/collection/document-workspace-view-collection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/views/collection/document-workspace-view-collection.element.ts @@ -1,28 +1,70 @@ -import { css, customElement, html } from '@umbraco-cms/backoffice/external/lit'; +import type { + UmbCollectionBulkActionPermissions, + UmbCollectionConfiguration, +} from '../../../../../core/collection/types.js'; +import { customElement, html, state } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; +import { UmbDataTypeDetailRepository } from '@umbraco-cms/backoffice/data-type'; +import { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor'; import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document'; import type { UmbWorkspaceViewElement } from '@umbraco-cms/backoffice/extension-registry'; @customElement('umb-document-workspace-view-collection') export class UmbDocumentWorkspaceViewCollectionElement extends UmbLitElement implements UmbWorkspaceViewElement { - #workspaceContext?: typeof UMB_DOCUMENT_WORKSPACE_CONTEXT.TYPE; + @state() + private _config?: UmbCollectionConfiguration; + + #dataTypeDetailRepository = new UmbDataTypeDetailRepository(this); constructor() { super(); + this.#observeConfig(); + } + async #observeConfig() { this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (workspaceContext) => { - this.#workspaceContext = workspaceContext; + this.observe( + workspaceContext.structure.ownerContentType(), + async (documentType) => { + if (!documentType) return; - // TODO: [LK] Get the `dataTypeId` and get the configuration for the collection view. + // TODO: [LK] Temp hard-coded. Once the API is ready, wire up the data-type ID from the content-type. + const dataTypeUnique = 'dt-collectionView'; + + if (dataTypeUnique) { + await this.#dataTypeDetailRepository.requestByUnique(dataTypeUnique); + this.observe( + await this.#dataTypeDetailRepository.byUnique(dataTypeUnique), + (dataType) => { + if (!dataType) return; + this._config = this.#mapDataTypeConfigToCollectionConfig( + new UmbPropertyEditorConfigCollection(dataType.values), + ); + }, + '#observeConfig.dataType', + ); + } + }, + '#observeConfig.documentType', + ); }); } - render() { - return html``; + #mapDataTypeConfigToCollectionConfig( + config: UmbPropertyEditorConfigCollection | undefined, + ): UmbCollectionConfiguration { + return { + allowedEntityBulkActions: config?.getValueByAlias('bulkActionPermissions'), + orderBy: config?.getValueByAlias('orderBy') ?? 'updateDate', + orderDirection: config?.getValueByAlias('orderDirection') ?? 'asc', + pageSize: Number(config?.getValueByAlias('pageSize')) ?? 50, + useInfiniteEditor: config?.getValueByAlias('useInfiniteEditor') ?? false, + }; } - static styles = [UmbTextStyles, css``]; + render() { + return html``; + } } export default UmbDocumentWorkspaceViewCollectionElement;