{"version":3,"file":"workspace-view-collection.element-DKbDr8ae.js","sources":["../../../src/packages/core/workspace/components/workspace-collection/workspace-view-collection.element.ts"],"sourcesContent":["import type { UmbCollectionBulkActionPermissions, UmbCollectionConfiguration } from '../../../collection/types.js';\nimport { customElement, html, nothing, state } from '@umbraco-cms/backoffice/external/lit';\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\nimport { UmbDataTypeDetailRepository } from '@umbraco-cms/backoffice/data-type';\nimport { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';\nimport { UMB_COLLECTION_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';\nimport type { UmbDataTypeDetailModel } from '@umbraco-cms/backoffice/data-type';\nimport type { UmbWorkspaceViewElement } from '@umbraco-cms/backoffice/extension-registry';\n\n@customElement('umb-workspace-view-collection')\nexport class UmbWorkspaceViewCollectionElement extends UmbLitElement implements UmbWorkspaceViewElement {\n\t@state()\n\tprivate _loading = true;\n\n\t@state()\n\tprivate _config?: UmbCollectionConfiguration;\n\n\t@state()\n\tprivate _collectionAlias?: string;\n\n\t@state()\n\tprivate _documentUnique?: string;\n\n\t#dataTypeDetailRepository = new UmbDataTypeDetailRepository(this);\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.#observeConfig();\n\t}\n\n\tasync #observeConfig() {\n\t\tthis.consumeContext(UMB_COLLECTION_WORKSPACE_CONTEXT, (workspaceContext) => {\n\t\t\tthis._collectionAlias = workspaceContext.getCollectionAlias();\n\t\t\tthis._documentUnique = workspaceContext.getUnique() ?? '';\n\n\t\t\tthis.observe(\n\t\t\t\tworkspaceContext.structure.ownerContentType,\n\t\t\t\tasync (contentType) => {\n\t\t\t\t\tif (!contentType || !contentType.collection) return;\n\n\t\t\t\t\tconst dataTypeUnique = contentType.collection.unique;\n\n\t\t\t\t\tif (dataTypeUnique) {\n\t\t\t\t\t\tawait this.#dataTypeDetailRepository.requestByUnique(dataTypeUnique);\n\t\t\t\t\t\tthis.observe(\n\t\t\t\t\t\t\tawait this.#dataTypeDetailRepository.byUnique(dataTypeUnique),\n\t\t\t\t\t\t\t(dataType) => {\n\t\t\t\t\t\t\t\tif (!dataType) return;\n\t\t\t\t\t\t\t\tthis._config = this.#mapDataTypeConfigToCollectionConfig(dataType);\n\t\t\t\t\t\t\t\tthis._loading = false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'_observeConfigDataType',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t'_observeConfigContentType',\n\t\t\t);\n\t\t});\n\t}\n\n\t#mapDataTypeConfigToCollectionConfig(dataType: UmbDataTypeDetailModel): UmbCollectionConfiguration {\n\t\tconst config = new UmbPropertyEditorConfigCollection(dataType.values);\n\t\tconst pageSize = Number(config.getValueByAlias('pageSize'));\n\t\treturn {\n\t\t\tunique: this._documentUnique,\n\t\t\tallowedEntityBulkActions: config?.getValueByAlias('bulkActionPermissions'),\n\t\t\tlayouts: config?.getValueByAlias('layouts'),\n\t\t\torderBy: config?.getValueByAlias('orderBy') ?? 'updateDate',\n\t\t\torderDirection: config?.getValueByAlias('orderDirection') ?? 'asc',\n\t\t\tpageSize: isNaN(pageSize) ? 50 : pageSize,\n\t\t\tuserDefinedProperties: config?.getValueByAlias('includeProperties'),\n\t\t};\n\t}\n\n\toverride render() {\n\t\tif (this._loading) return nothing;\n\t\treturn html``;\n\t}\n}\n\nexport default UmbWorkspaceViewCollectionElement;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-workspace-view-collection': UmbWorkspaceViewCollectionElement;\n\t}\n}\n"],"names":["_dataTypeDetailRepository","_UmbWorkspaceViewCollectionElement_instances","observeConfig_fn","mapDataTypeConfigToCollectionConfig_fn","UmbWorkspaceViewCollectionElement","UmbLitElement","__privateAdd","UmbDataTypeDetailRepository","__privateMethod","nothing","html","UMB_COLLECTION_WORKSPACE_CONTEXT","workspaceContext","contentType","dataTypeUnique","__privateGet","dataType","config","UmbPropertyEditorConfigCollection","pageSize","__decorateClass","state","customElement","UmbWorkspaceViewCollectionElement$1"],"mappings":";;;;;;;;;;;+TAAAA,GAAAC,GAAAC,GAAAC;AAUa,IAAAC,IAAN,cAAgDC,EAAiD;AAAA,EAevG,cAAc;AACP,aAhBDC,EAAA,MAAAL,CAAA,GAEN,KAAQ,WAAW,IAWSK,EAAA,MAAAN,GAAA,IAAIO,EAA4B,IAAI,CAAA,GAI/DC,EAAA,MAAKP,GAALC,CAAA,EAAA,KAAA,IAAA;AAAA,EACD;AAAA,EA8CS,SAAS;AACb,WAAA,KAAK,WAAiBO,IACnBC,2BAA8B,KAAK,gBAAgB,YAAY,KAAK,OAAO;AAAA,EACnF;AACD;AAvDCV,IAAA,oBAAA,QAAA;AAbMC,IAAA,oBAAA,QAAA;AAoBAC,IAAc,iBAAG;AACjB,OAAA,eAAeS,GAAkC,CAACC,MAAqB;AACtE,SAAA,mBAAmBA,EAAiB,sBACpC,KAAA,kBAAkBA,EAAiB,UAAA,KAAe,IAElD,KAAA;AAAA,MACJA,EAAiB,UAAU;AAAA,MAC3B,OAAOC,MAAgB;AACtB,YAAI,CAACA,KAAe,CAACA,EAAY,WAAY;AAEvC,cAAAC,IAAiBD,EAAY,WAAW;AAE9C,QAAIC,MACG,MAAAC,EAAA,MAAKf,CAA0B,EAAA,gBAAgBc,CAAc,GAC9D,KAAA;AAAA,UACJ,MAAMC,EAAA,MAAKf,CAA0B,EAAA,SAASc,CAAc;AAAA,UAC5D,CAACE,MAAa;AACb,YAAKA,MACA,KAAA,UAAUR,EAAK,MAAAP,GAAAE,CAAA,EAAL,KAA0C,MAAAa,CAAA,GACzD,KAAK,WAAW;AAAA,UACjB;AAAA,UACA;AAAA,QAAA;AAAA,MAGH;AAAA,MACA;AAAA,IAAA;AAAA,EACD,CACA;AACF;AAEAb,IAAoC,SAACa,GAA8D;AAClG,QAAMC,IAAS,IAAIC,EAAkCF,EAAS,MAAM,GAC9DG,IAAW,OAAOF,EAAO,gBAA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