@umbraco-cms/backoffice 14.0.0--preview007-6f3189e3 → 14.0.0--preview007-2ee36857

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist-cms/packages/core/collection/collection-view.manager.d.ts +1 -1
  2. package/dist-cms/packages/core/collection/collection-view.manager.js +1 -1
  3. package/dist-cms/packages/core/collection/default/collection-default.context.d.ts +1 -0
  4. package/dist-cms/packages/core/collection/default/collection-default.context.js +11 -3
  5. package/dist-cms/packages/core/collection/types.d.ts +3 -1
  6. package/dist-cms/packages/core/components/table/table.element.js +1 -1
  7. package/dist-cms/packages/core/property-editor/uis/collection-view/config/column-configuration/property-editor-ui-collection-view-column-configuration.element.d.ts +1 -1
  8. package/dist-cms/packages/core/property-editor/uis/collection-view/config/column-configuration/property-editor-ui-collection-view-column-configuration.element.js +2 -2
  9. package/dist-cms/packages/core/property-editor/uis/collection-view/property-editor-ui-collection-view.element.d.ts +2 -1
  10. package/dist-cms/packages/core/property-editor/uis/collection-view/property-editor-ui-collection-view.element.js +30 -4
  11. package/dist-cms/packages/documents/documents/collection/document-collection-toolbar.element.js +2 -7
  12. package/dist-cms/packages/documents/documents/collection/document-collection.context.d.ts +2 -3
  13. package/dist-cms/packages/documents/documents/collection/repository/document-collection.repository.d.ts +2 -2
  14. package/dist-cms/packages/documents/documents/collection/repository/document-collection.repository.js +2 -2
  15. package/dist-cms/packages/documents/documents/collection/repository/document-collection.server.data-source.d.ts +4 -5
  16. package/dist-cms/packages/documents/documents/collection/repository/document-collection.server.data-source.js +37 -37
  17. package/dist-cms/packages/documents/documents/collection/types.d.ts +26 -4
  18. package/dist-cms/packages/documents/documents/collection/views/grid/document-grid-collection-view.element.js +1 -1
  19. package/dist-cms/packages/documents/documents/collection/views/table/document-table-collection-view.element.d.ts +3 -1
  20. package/dist-cms/packages/documents/documents/collection/views/table/document-table-collection-view.element.js +85 -26
  21. package/dist-cms/packages/documents/documents/conditions/document-workspace-has-collection.condition.js +2 -2
  22. package/dist-cms/packages/documents/documents/repository/item/document-item.server.data-source.js +1 -1
  23. package/dist-cms/packages/documents/documents/repository/item/types.d.ts +1 -1
  24. package/dist-cms/packages/documents/documents/workspace/document-workspace-editor.element.d.ts +2 -2
  25. package/dist-cms/packages/documents/documents/workspace/document-workspace-editor.element.js +2 -2
  26. package/dist-cms/packages/documents/documents/workspace/document-workspace.element.d.ts +1 -1
  27. package/dist-cms/packages/documents/documents/workspace/document-workspace.element.js +3 -3
  28. package/dist-cms/packages/documents/documents/workspace/views/collection/document-workspace-view-collection.element.d.ts +1 -0
  29. package/dist-cms/packages/documents/documents/workspace/views/collection/document-workspace-view-collection.element.js +17 -5
  30. package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
  31. package/dist-cms/vscode-html-custom-data.json +4 -4
  32. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { UmbBaseController } from '../../../libs/class-api/index.js';
2
- import type { UmbControllerHost } from '../../../libs/controller-api/index.js';
3
2
  import type { ManifestCollectionView } from '../extension-registry/index.js';
3
+ import type { UmbControllerHost } from '../../../libs/controller-api/index.js';
4
4
  import type { UmbRoute } from '../../../shared/router/index.js';
5
5
  export interface UmbCollectionViewManagerConfig {
6
6
  defaultViewAlias?: string;
@@ -61,7 +61,7 @@ _UmbCollectionViewManager_views = new WeakMap(), _UmbCollectionViewManager_curre
61
61
  });
62
62
  }, _UmbCollectionViewManager_createRoutes = function _UmbCollectionViewManager_createRoutes(views) {
63
63
  let routes = [];
64
- if (views) {
64
+ if (views?.length) {
65
65
  // find the default view from the config. If it doesn't exist, use the first view
66
66
  const defaultView = views.find((view) => view.alias === __classPrivateFieldGet(this, _UmbCollectionViewManager_defaultViewAlias, "f"));
67
67
  const fallbackView = defaultView?.meta.pathName || views[0].meta.pathName;
@@ -13,6 +13,7 @@ export declare class UmbDefaultCollectionContext<CollectionItemType = any, Filte
13
13
  readonly items: import("rxjs").Observable<CollectionItemType[]>;
14
14
  readonly totalItems: import("rxjs").Observable<number>;
15
15
  readonly filter: import("rxjs").Observable<object | FilterModelType>;
16
+ readonly userDefinedProperties: import("rxjs").Observable<any[]>;
16
17
  repository?: UmbCollectionRepository;
17
18
  readonly pagination: UmbPaginationManager;
18
19
  readonly selection: UmbSelectionManager;
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _UmbDefaultCollectionContext_instances, _UmbDefaultCollectionContext_manifest, _UmbDefaultCollectionContext_items, _UmbDefaultCollectionContext_totalItems, _UmbDefaultCollectionContext_filter, _UmbDefaultCollectionContext_initResolver, _UmbDefaultCollectionContext_initialized, _UmbDefaultCollectionContext_init, _UmbDefaultCollectionContext_checkIfInitialized, _UmbDefaultCollectionContext_config, _UmbDefaultCollectionContext_configure, _UmbDefaultCollectionContext_onPageChange, _UmbDefaultCollectionContext_observeRepository;
12
+ var _UmbDefaultCollectionContext_instances, _UmbDefaultCollectionContext_manifest, _UmbDefaultCollectionContext_items, _UmbDefaultCollectionContext_totalItems, _UmbDefaultCollectionContext_filter, _UmbDefaultCollectionContext_userDefinedProperties, _UmbDefaultCollectionContext_initResolver, _UmbDefaultCollectionContext_initialized, _UmbDefaultCollectionContext_init, _UmbDefaultCollectionContext_checkIfInitialized, _UmbDefaultCollectionContext_config, _UmbDefaultCollectionContext_configure, _UmbDefaultCollectionContext_onPageChange, _UmbDefaultCollectionContext_observeRepository;
13
13
  import { UmbCollectionViewManager } from '../collection-view.manager.js';
14
14
  import { UmbContextBase } from '../../../../libs/class-api/index.js';
15
15
  import { UmbContextToken } from '../../../../libs/context-api/index.js';
@@ -29,6 +29,8 @@ export class UmbDefaultCollectionContext extends UmbContextBase {
29
29
  this.totalItems = __classPrivateFieldGet(this, _UmbDefaultCollectionContext_totalItems, "f").asObservable();
30
30
  _UmbDefaultCollectionContext_filter.set(this, new UmbObjectState({}));
31
31
  this.filter = __classPrivateFieldGet(this, _UmbDefaultCollectionContext_filter, "f").asObservable();
32
+ _UmbDefaultCollectionContext_userDefinedProperties.set(this, new UmbArrayState([], (x) => x));
33
+ this.userDefinedProperties = __classPrivateFieldGet(this, _UmbDefaultCollectionContext_userDefinedProperties, "f").asObservable();
32
34
  _UmbDefaultCollectionContext_initResolver.set(this, void 0);
33
35
  _UmbDefaultCollectionContext_initialized.set(this, false);
34
36
  _UmbDefaultCollectionContext_init.set(this, new Promise((resolve) => {
@@ -106,7 +108,7 @@ export class UmbDefaultCollectionContext extends UmbContextBase {
106
108
  this.requestCollection();
107
109
  }
108
110
  }
109
- _UmbDefaultCollectionContext_manifest = new WeakMap(), _UmbDefaultCollectionContext_items = new WeakMap(), _UmbDefaultCollectionContext_totalItems = new WeakMap(), _UmbDefaultCollectionContext_filter = new WeakMap(), _UmbDefaultCollectionContext_initResolver = new WeakMap(), _UmbDefaultCollectionContext_initialized = new WeakMap(), _UmbDefaultCollectionContext_init = new WeakMap(), _UmbDefaultCollectionContext_config = new WeakMap(), _UmbDefaultCollectionContext_onPageChange = new WeakMap(), _UmbDefaultCollectionContext_instances = new WeakSet(), _UmbDefaultCollectionContext_checkIfInitialized = function _UmbDefaultCollectionContext_checkIfInitialized() {
111
+ _UmbDefaultCollectionContext_manifest = new WeakMap(), _UmbDefaultCollectionContext_items = new WeakMap(), _UmbDefaultCollectionContext_totalItems = new WeakMap(), _UmbDefaultCollectionContext_filter = new WeakMap(), _UmbDefaultCollectionContext_userDefinedProperties = new WeakMap(), _UmbDefaultCollectionContext_initResolver = new WeakMap(), _UmbDefaultCollectionContext_initialized = new WeakMap(), _UmbDefaultCollectionContext_init = new WeakMap(), _UmbDefaultCollectionContext_config = new WeakMap(), _UmbDefaultCollectionContext_onPageChange = new WeakMap(), _UmbDefaultCollectionContext_instances = new WeakSet(), _UmbDefaultCollectionContext_checkIfInitialized = function _UmbDefaultCollectionContext_checkIfInitialized() {
110
112
  if (this.repository) {
111
113
  __classPrivateFieldSet(this, _UmbDefaultCollectionContext_initialized, true, "f");
112
114
  __classPrivateFieldGet(this, _UmbDefaultCollectionContext_initResolver, "f")?.call(this);
@@ -114,7 +116,13 @@ _UmbDefaultCollectionContext_manifest = new WeakMap(), _UmbDefaultCollectionCont
114
116
  }, _UmbDefaultCollectionContext_configure = function _UmbDefaultCollectionContext_configure() {
115
117
  this.selection.setMultiple(true);
116
118
  this.pagination.setPageSize(__classPrivateFieldGet(this, _UmbDefaultCollectionContext_config, "f").pageSize);
117
- __classPrivateFieldGet(this, _UmbDefaultCollectionContext_filter, "f").setValue({ ...__classPrivateFieldGet(this, _UmbDefaultCollectionContext_filter, "f").getValue(), skip: 0, take: __classPrivateFieldGet(this, _UmbDefaultCollectionContext_config, "f").pageSize });
119
+ __classPrivateFieldGet(this, _UmbDefaultCollectionContext_filter, "f").setValue({
120
+ ...__classPrivateFieldGet(this, _UmbDefaultCollectionContext_config, "f"),
121
+ ...__classPrivateFieldGet(this, _UmbDefaultCollectionContext_filter, "f").getValue(),
122
+ skip: 0,
123
+ take: __classPrivateFieldGet(this, _UmbDefaultCollectionContext_config, "f").pageSize,
124
+ });
125
+ __classPrivateFieldGet(this, _UmbDefaultCollectionContext_userDefinedProperties, "f").setValue(__classPrivateFieldGet(this, _UmbDefaultCollectionContext_config, "f").userDefinedProperties ?? []);
118
126
  }, _UmbDefaultCollectionContext_observeRepository = function _UmbDefaultCollectionContext_observeRepository(repositoryAlias) {
119
127
  new UmbExtensionApiInitializer(this, umbExtensionsRegistry, repositoryAlias, [this._host], (permitted, ctrl) => {
120
128
  this.repository = permitted ? ctrl.api : undefined;
@@ -9,12 +9,14 @@ export interface UmbCollectionBulkActionPermissions {
9
9
  allowBulkUnpublish: boolean;
10
10
  }
11
11
  export interface UmbCollectionConfiguration {
12
+ unique?: string;
13
+ dataTypeId?: string;
12
14
  allowedEntityBulkActions?: UmbCollectionBulkActionPermissions;
13
- includeProperties?: Array<any>;
14
15
  orderBy?: string;
15
16
  orderDirection?: string;
16
17
  pageSize?: number;
17
18
  useInfiniteEditor?: boolean;
19
+ userDefinedProperties?: Array<any>;
18
20
  }
19
21
  export interface UmbCollectionContext {
20
22
  setConfig(config: UmbCollectionConfiguration): void;
@@ -255,7 +255,7 @@ __decorate([
255
255
  property({ type: String, attribute: false })
256
256
  ], UmbTableElement.prototype, "orderingColumn", void 0);
257
257
  __decorate([
258
- property({ type: String, attribute: false })
258
+ property({ type: Boolean, attribute: false })
259
259
  ], UmbTableElement.prototype, "orderingDesc", void 0);
260
260
  __decorate([
261
261
  state()
@@ -4,7 +4,7 @@ import { UmbLitElement } from '../../../../../lit-element/index.js';
4
4
  interface ColumnConfig {
5
5
  alias: string;
6
6
  header: string;
7
- isSystem: boolean;
7
+ isSystem: 1 | 0;
8
8
  nameTemplate?: string;
9
9
  }
10
10
  /**
@@ -77,7 +77,7 @@ _UmbPropertyEditorUICollectionViewColumnConfigurationElement_onAdd = function _U
77
77
  const config = {
78
78
  alias: selected.value,
79
79
  header: selected.name,
80
- isSystem: selected?.group === 'System Fields',
80
+ isSystem: selected?.group === 'System Fields' ? 1 : 0,
81
81
  };
82
82
  this.value = [...this.value, config];
83
83
  this.dispatchEvent(new UmbPropertyValueChangeEvent());
@@ -112,7 +112,7 @@ _UmbPropertyEditorUICollectionViewColumnConfigurationElement_renderTable = funct
112
112
  </uui-table-row>
113
113
  ${repeat(this.value, (configuration) => configuration.alias, (configuration) => html `<uui-table-row>
114
114
  <uui-table-cell><uui-icon name="icon-navigation"></uui-icon></uui-table-cell>
115
- ${configuration.isSystem
115
+ ${configuration.isSystem === 1
116
116
  ? __classPrivateFieldGet(this, _UmbPropertyEditorUICollectionViewColumnConfigurationElement_instances, "m", _UmbPropertyEditorUICollectionViewColumnConfigurationElement_renderSystemFieldRow).call(this, configuration)
117
117
  : __classPrivateFieldGet(this, _UmbPropertyEditorUICollectionViewColumnConfigurationElement_instances, "m", _UmbPropertyEditorUICollectionViewColumnConfigurationElement_renderCustomFieldRow).call(this, configuration)}
118
118
  <uui-table-cell>
@@ -1,6 +1,6 @@
1
1
  import type { UmbPropertyEditorConfigCollection } from '../../config/index.js';
2
- import type { UmbPropertyEditorUiElement } from '../../../extension-registry/index.js';
3
2
  import { UmbLitElement } from '../../../lit-element/index.js';
3
+ import type { UmbPropertyEditorUiElement } from '../../../extension-registry/index.js';
4
4
  /**
5
5
  * @element umb-property-editor-ui-collection-view
6
6
  */
@@ -9,6 +9,7 @@ export declare class UmbPropertyEditorUICollectionViewElement extends UmbLitElem
9
9
  value?: string;
10
10
  private _config?;
11
11
  set config(config: UmbPropertyEditorConfigCollection | undefined);
12
+ constructor();
12
13
  render(): import("lit-html").TemplateResult<1>;
13
14
  }
14
15
  export default UmbPropertyEditorUICollectionViewElement;
@@ -12,18 +12,43 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _UmbPropertyEditorUICollectionViewElement_instances, _UmbPropertyEditorUICollectionViewElement_mapDataTypeConfigToCollectionConfig;
13
13
  import { html, customElement, property, state } from '../../../../../external/lit/index.js';
14
14
  import { UmbLitElement } from '../../../lit-element/index.js';
15
+ import { UMB_PROPERTY_CONTEXT } from '../../../property/index.js';
16
+ import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '../../../../documents/documents/index.js';
15
17
  /**
16
18
  * @element umb-property-editor-ui-collection-view
17
19
  */
18
20
  let UmbPropertyEditorUICollectionViewElement = class UmbPropertyEditorUICollectionViewElement extends UmbLitElement {
19
- constructor() {
20
- super(...arguments);
21
- _UmbPropertyEditorUICollectionViewElement_instances.add(this);
22
- }
23
21
  set config(config) {
24
22
  this._config = __classPrivateFieldGet(this, _UmbPropertyEditorUICollectionViewElement_instances, "m", _UmbPropertyEditorUICollectionViewElement_mapDataTypeConfigToCollectionConfig).call(this, config);
25
23
  }
24
+ constructor() {
25
+ super();
26
+ _UmbPropertyEditorUICollectionViewElement_instances.add(this);
27
+ // Gets the Data Type ID for the current property.
28
+ this.consumeContext(UMB_PROPERTY_CONTEXT, (propertyContext) => {
29
+ // TODO: [LK:2024-02-01] Replace `UMB_DOCUMENT_WORKSPACE_CONTEXT`
30
+ // with an abstracted context that supports both document and media workspaces.
31
+ this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (workspaceContext) => {
32
+ this.observe(workspaceContext.unique, (unique) => {
33
+ if (this._config) {
34
+ this._config.unique = unique;
35
+ }
36
+ });
37
+ this.observe(propertyContext.alias, async (propertyAlias) => {
38
+ if (propertyAlias) {
39
+ const property = await workspaceContext.structure.getPropertyStructureByAlias(propertyAlias);
40
+ if (property && this._config) {
41
+ this._config.dataTypeId = property.dataType.unique;
42
+ this.requestUpdate('_config');
43
+ }
44
+ }
45
+ });
46
+ });
47
+ });
48
+ }
26
49
  render() {
50
+ if (!this._config?.unique || !this._config?.dataTypeId)
51
+ return html `<uui-loader></uui-loader>`;
27
52
  return html `<umb-collection alias="Umb.Collection.Document" .config=${this._config}></umb-collection>`;
28
53
  }
29
54
  };
@@ -35,6 +60,7 @@ _UmbPropertyEditorUICollectionViewElement_mapDataTypeConfigToCollectionConfig =
35
60
  orderDirection: config?.getValueByAlias('orderDirection') ?? 'asc',
36
61
  pageSize: Number(config?.getValueByAlias('pageSize')) ?? 50,
37
62
  useInfiniteEditor: config?.getValueByAlias('useInfiniteEditor') ?? false,
63
+ userDefinedProperties: config?.getValueByAlias('includeProperties'),
38
64
  };
39
65
  };
40
66
  __decorate([
@@ -15,7 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
16
16
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
17
17
  };
18
- var _UmbDocumentCollectionToolbarElement_instances, _UmbDocumentCollectionToolbarElement_collectionContext, _UmbDocumentCollectionToolbarElement_inputTimer, _UmbDocumentCollectionToolbarElement_inputTimerAmount, _UmbDocumentCollectionToolbarElement_updateSearch, _UmbDocumentCollectionToolbarElement_renderSearch;
18
+ var _UmbDocumentCollectionToolbarElement_instances, _UmbDocumentCollectionToolbarElement_collectionContext, _UmbDocumentCollectionToolbarElement_inputTimer, _UmbDocumentCollectionToolbarElement_inputTimerAmount, _UmbDocumentCollectionToolbarElement_updateSearch;
19
19
  import { css, html, customElement } from '../../../../external/lit/index.js';
20
20
  import { UmbLitElement } from '../../../core/lit-element/index.js';
21
21
  import { UMB_DEFAULT_COLLECTION_CONTEXT } from '../../../core/collection/index.js';
@@ -33,7 +33,7 @@ let UmbDocumentCollectionToolbarElement = class UmbDocumentCollectionToolbarElem
33
33
  render() {
34
34
  return html `
35
35
  <umb-collection-action-bundle></umb-collection-action-bundle>
36
- ${__classPrivateFieldGet(this, _UmbDocumentCollectionToolbarElement_instances, "m", _UmbDocumentCollectionToolbarElement_renderSearch).call(this)}
36
+ <uui-input @input=${__classPrivateFieldGet(this, _UmbDocumentCollectionToolbarElement_instances, "m", _UmbDocumentCollectionToolbarElement_updateSearch)} label="Search" placeholder="Search..." id="input-search"></uui-input>
37
37
  <umb-collection-view-bundle></umb-collection-view-bundle>
38
38
  `;
39
39
  }
@@ -48,11 +48,6 @@ _UmbDocumentCollectionToolbarElement_updateSearch = function _UmbDocumentCollect
48
48
  clearTimeout(__classPrivateFieldGet(this, _UmbDocumentCollectionToolbarElement_inputTimer, "f"));
49
49
  __classPrivateFieldSet(this, _UmbDocumentCollectionToolbarElement_inputTimer, setTimeout(() => __classPrivateFieldGet(this, _UmbDocumentCollectionToolbarElement_collectionContext, "f")?.setFilter({ filter }), __classPrivateFieldGet(this, _UmbDocumentCollectionToolbarElement_inputTimerAmount, "f")), "f");
50
50
  };
51
- _UmbDocumentCollectionToolbarElement_renderSearch = function _UmbDocumentCollectionToolbarElement_renderSearch() {
52
- return html `
53
- <uui-input @input=${__classPrivateFieldGet(this, _UmbDocumentCollectionToolbarElement_instances, "m", _UmbDocumentCollectionToolbarElement_updateSearch)} label="Search" placeholder="Search..." id="input-search"></uui-input>
54
- `;
55
- };
56
51
  UmbDocumentCollectionToolbarElement.styles = [
57
52
  css `
58
53
  :host {
@@ -1,7 +1,6 @@
1
- import type { UmbDocumentDetailModel } from '../types.js';
2
- import type { UmbDocumentCollectionFilterModel } from './types.js';
1
+ import type { UmbDocumentCollectionFilterModel, UmbDocumentCollectionItemModel } from './types.js';
3
2
  import { UmbDefaultCollectionContext } from '../../../core/collection/index.js';
4
3
  import type { UmbControllerHost } from '../../../../libs/controller-api/index.js';
5
- export declare class UmbDocumentCollectionContext extends UmbDefaultCollectionContext<UmbDocumentDetailModel, UmbDocumentCollectionFilterModel> {
4
+ export declare class UmbDocumentCollectionContext extends UmbDefaultCollectionContext<UmbDocumentCollectionItemModel, UmbDocumentCollectionFilterModel> {
6
5
  constructor(host: UmbControllerHost);
7
6
  }
@@ -4,9 +4,9 @@ import type { UmbControllerHost } from '../../../../../libs/controller-api/index
4
4
  export declare class UmbDocumentCollectionRepository implements UmbCollectionRepository {
5
5
  #private;
6
6
  constructor(host: UmbControllerHost);
7
- requestCollection(filter: UmbDocumentCollectionFilterModel): Promise<{
7
+ requestCollection(query: UmbDocumentCollectionFilterModel): Promise<{
8
8
  data: {
9
- items: import("../../tree/types.js").UmbDocumentTreeItemModel[];
9
+ items: import("../types.js").UmbDocumentCollectionItemModel[];
10
10
  total: number;
11
11
  };
12
12
  error?: undefined;
@@ -16,8 +16,8 @@ export class UmbDocumentCollectionRepository {
16
16
  _UmbDocumentCollectionRepository_collectionSource.set(this, void 0);
17
17
  __classPrivateFieldSet(this, _UmbDocumentCollectionRepository_collectionSource, new UmbDocumentCollectionServerDataSource(host), "f");
18
18
  }
19
- async requestCollection(filter) {
20
- return __classPrivateFieldGet(this, _UmbDocumentCollectionRepository_collectionSource, "f").getCollection(filter);
19
+ async requestCollection(query) {
20
+ return __classPrivateFieldGet(this, _UmbDocumentCollectionRepository_collectionSource, "f").getCollection(query);
21
21
  }
22
22
  destroy() { }
23
23
  }
@@ -1,13 +1,12 @@
1
- import type { UmbDocumentCollectionFilterModel } from '../types.js';
2
- import type { UmbDocumentTreeItemModel } from '../../tree/types.js';
1
+ import type { UmbDocumentCollectionFilterModel, UmbDocumentCollectionItemModel } from '../types.js';
3
2
  import type { UmbCollectionDataSource } from '../../../../core/repository/index.js';
4
3
  import type { UmbControllerHost } from '../../../../../libs/controller-api/index.js';
5
- export declare class UmbDocumentCollectionServerDataSource implements UmbCollectionDataSource<UmbDocumentTreeItemModel> {
4
+ export declare class UmbDocumentCollectionServerDataSource implements UmbCollectionDataSource<UmbDocumentCollectionItemModel> {
6
5
  #private;
7
6
  constructor(host: UmbControllerHost);
8
- getCollection(filter: UmbDocumentCollectionFilterModel): Promise<{
7
+ getCollection(query: UmbDocumentCollectionFilterModel): Promise<{
9
8
  data: {
10
- items: UmbDocumentTreeItemModel[];
9
+ items: UmbDocumentCollectionItemModel[];
11
10
  total: number;
12
11
  };
13
12
  error?: undefined;
@@ -9,52 +9,52 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _UmbDocumentCollectionServerDataSource_host, _UmbDocumentCollectionServerDataSource_mapper;
13
- import { UMB_DOCUMENT_ENTITY_TYPE } from '../../entity.js';
14
- import { DocumentResource } from '../../../../../external/backend-api/index.js';
12
+ var _UmbDocumentCollectionServerDataSource_host;
13
+ import { DirectionModel, DocumentResource } from '../../../../../external/backend-api/index.js';
15
14
  import { tryExecuteAndNotify } from '../../../../../shared/resources/index.js';
16
15
  export class UmbDocumentCollectionServerDataSource {
17
16
  constructor(host) {
18
17
  _UmbDocumentCollectionServerDataSource_host.set(this, void 0);
19
- // TODO: [LK] Temp solution. Copied from "src/packages/documents/documents/tree/document-tree.server.data-source.ts"
20
- _UmbDocumentCollectionServerDataSource_mapper.set(this, (item) => {
21
- return {
22
- unique: item.id,
23
- parentUnique: item.parent ? item.parent.id : null,
24
- entityType: UMB_DOCUMENT_ENTITY_TYPE,
25
- noAccess: item.noAccess,
26
- isTrashed: item.isTrashed,
27
- hasChildren: item.hasChildren,
28
- isProtected: item.isProtected,
29
- documentType: {
30
- unique: item.documentType.id,
31
- icon: item.documentType.icon,
32
- hasCollection: item.documentType.hasListView,
33
- },
34
- variants: item.variants.map((variant) => {
35
- return {
36
- name: variant.name,
37
- culture: variant.culture || null,
38
- state: variant.state,
39
- };
40
- }),
41
- name: item.variants[0]?.name, // TODO: this is not correct. We need to get it from the variants. This is a temp solution.
42
- isFolder: false,
43
- };
44
- });
45
18
  __classPrivateFieldSet(this, _UmbDocumentCollectionServerDataSource_host, host, "f");
46
19
  }
47
- async getCollection(filter) {
48
- // TODO: [LK] Replace the Management API call with the correct endpoint once it is available.
49
- const { data, error } = await tryExecuteAndNotify(__classPrivateFieldGet(this, _UmbDocumentCollectionServerDataSource_host, "f"), DocumentResource.getTreeDocumentRoot(filter));
20
+ async getCollection(query) {
21
+ if (!query.unique) {
22
+ throw new Error('Unique ID is required to fetch a collection.');
23
+ }
24
+ if (!query.dataTypeId) {
25
+ throw new Error('Data type ID is required to fetch a collection.');
26
+ }
27
+ const params = {
28
+ id: query.unique,
29
+ dataTypeId: query.dataTypeId,
30
+ orderBy: query.orderBy ?? 'updateDate',
31
+ orderCulture: query.orderCulture ?? 'en-US',
32
+ orderDirection: query.orderDirection === 'asc' ? DirectionModel.ASCENDING : DirectionModel.DESCENDING,
33
+ filter: query.filter,
34
+ skip: query.skip ?? 0,
35
+ take: query.take ?? 100,
36
+ };
37
+ const { data, error } = await tryExecuteAndNotify(__classPrivateFieldGet(this, _UmbDocumentCollectionServerDataSource_host, "f"), DocumentResource.getCollectionDocumentById(params));
50
38
  if (data) {
51
- const skip = Number(filter.skip) ?? 0;
52
- const take = Number(filter.take) ?? 100;
53
- const items = data.items.slice(skip, skip + take).map((item) => __classPrivateFieldGet(this, _UmbDocumentCollectionServerDataSource_mapper, "f").call(this, item));
54
- //console.log('UmbDocumentCollectionServerDataSource.getCollection', [data, items]);
39
+ const items = data.items.map((item) => {
40
+ // TODO: [LK] Temp solution, review how to get the name from the corresponding variant.
41
+ const variant = item.variants[0];
42
+ const model = {
43
+ unique: item.id,
44
+ createDate: new Date(variant.createDate),
45
+ creator: item.creator,
46
+ icon: item.documentType.icon,
47
+ name: variant.name,
48
+ state: variant.state,
49
+ updateDate: new Date(variant.updateDate),
50
+ updater: item.updater,
51
+ values: item.values.map((item) => { return { alias: item.alias, value: item.value }; }),
52
+ };
53
+ return model;
54
+ });
55
55
  return { data: { items, total: data.total } };
56
56
  }
57
57
  return { error };
58
58
  }
59
59
  }
60
- _UmbDocumentCollectionServerDataSource_host = new WeakMap(), _UmbDocumentCollectionServerDataSource_mapper = new WeakMap();
60
+ _UmbDocumentCollectionServerDataSource_host = new WeakMap();
@@ -1,5 +1,27 @@
1
- export interface UmbDocumentCollectionFilterModel {
2
- skip?: number;
3
- take?: number;
4
- filter?: string;
1
+ import type { UmbCollectionFilterModel } from '../../../core/collection/index.js';
2
+ export interface UmbDocumentCollectionFilterModel extends UmbCollectionFilterModel {
3
+ unique: string;
4
+ dataTypeId?: string;
5
+ orderBy?: string;
6
+ orderCulture?: string;
7
+ orderDirection?: 'asc' | 'desc';
8
+ userDefinedProperties: Array<{
9
+ alias: string;
10
+ header: string;
11
+ isSystem: boolean;
12
+ }>;
13
+ }
14
+ export interface UmbDocumentCollectionItemModel {
15
+ unique: string;
16
+ createDate: Date;
17
+ creator?: string | null;
18
+ icon: string;
19
+ name: string;
20
+ state: string;
21
+ updateDate: Date;
22
+ updater?: string | null;
23
+ values: Array<{
24
+ alias: string;
25
+ value: string;
26
+ }>;
5
27
  }
@@ -67,7 +67,7 @@ _UmbDocumentGridCollectionViewElement_renderCard = function _UmbDocumentGridColl
67
67
  @open=${() => this._handleOpenCard(item.unique ?? '')}
68
68
  @selected=${() => __classPrivateFieldGet(this, _UmbDocumentGridCollectionViewElement_instances, "m", _UmbDocumentGridCollectionViewElement_onSelect).call(this, item)}
69
69
  @deselected=${() => __classPrivateFieldGet(this, _UmbDocumentGridCollectionViewElement_instances, "m", _UmbDocumentGridCollectionViewElement_onDeselect).call(this, item)}>
70
- <uui-icon slot="icon" name=${item.documentType.icon}></uui-icon>
70
+ <uui-icon slot="icon" name=${item.icon}></uui-icon>
71
71
  </uui-card-content-node>
72
72
  `;
73
73
  };
@@ -1,5 +1,8 @@
1
1
  import { UmbLitElement } from '../../../../../core/lit-element/index.js';
2
2
  export declare class UmbDocumentTableCollectionViewElement extends UmbLitElement {
3
+ #private;
4
+ private _busy;
5
+ private _userDefinedProperties?;
3
6
  private _items?;
4
7
  private _tableConfig;
5
8
  private _tableColumns;
@@ -8,7 +11,6 @@ export declare class UmbDocumentTableCollectionViewElement extends UmbLitElement
8
11
  private _collectionContext?;
9
12
  constructor();
10
13
  private _observeCollectionContext;
11
- private _createTableItems;
12
14
  private _handleSelect;
13
15
  private _handleDeselect;
14
16
  private _handleOrdering;
@@ -4,6 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _UmbDocumentTableCollectionViewElement_instances, _UmbDocumentTableCollectionViewElement_systemColumns, _UmbDocumentTableCollectionViewElement_createTableHeadings, _UmbDocumentTableCollectionViewElement_createTableItems;
7
13
  import { css, html, customElement, state } from '../../../../../../external/lit/index.js';
8
14
  import { UmbLitElement } from '../../../../../core/lit-element/index.js';
9
15
  import { UmbTextStyles } from '../../../../../../shared/style/index.js';
@@ -11,16 +17,19 @@ import { UMB_DEFAULT_COLLECTION_CONTEXT } from '../../../../../core/collection/i
11
17
  let UmbDocumentTableCollectionViewElement = class UmbDocumentTableCollectionViewElement extends UmbLitElement {
12
18
  constructor() {
13
19
  super();
20
+ _UmbDocumentTableCollectionViewElement_instances.add(this);
21
+ this._busy = false;
14
22
  this._tableConfig = {
15
23
  allowSelection: true,
16
24
  };
17
- this._tableColumns = [
25
+ this._tableColumns = [];
26
+ _UmbDocumentTableCollectionViewElement_systemColumns.set(this, [
18
27
  {
19
28
  name: 'Name',
20
29
  alias: 'entityName',
21
30
  allowSorting: true,
22
31
  },
23
- ];
32
+ ]);
24
33
  this._tableItems = [];
25
34
  this._selection = [];
26
35
  this.consumeContext(UMB_DEFAULT_COLLECTION_CONTEXT, (instance) => {
@@ -31,36 +40,18 @@ let UmbDocumentTableCollectionViewElement = class UmbDocumentTableCollectionView
31
40
  _observeCollectionContext() {
32
41
  if (!this._collectionContext)
33
42
  return;
43
+ this.observe(this._collectionContext.userDefinedProperties, (userDefinedProperties) => {
44
+ this._userDefinedProperties = userDefinedProperties;
45
+ __classPrivateFieldGet(this, _UmbDocumentTableCollectionViewElement_instances, "m", _UmbDocumentTableCollectionViewElement_createTableHeadings).call(this);
46
+ });
34
47
  this.observe(this._collectionContext.items, (items) => {
35
48
  this._items = items;
36
- this._createTableItems(this._items);
49
+ __classPrivateFieldGet(this, _UmbDocumentTableCollectionViewElement_instances, "m", _UmbDocumentTableCollectionViewElement_createTableItems).call(this, this._items);
37
50
  });
38
51
  this.observe(this._collectionContext.selection.selection, (selection) => {
39
52
  this._selection = selection;
40
53
  });
41
54
  }
42
- _createTableItems(items) {
43
- this._tableItems = items.map((item) => {
44
- if (!item.unique)
45
- throw new Error('Item id is missing.');
46
- return {
47
- id: item.unique,
48
- icon: item.documentType.icon,
49
- data: [
50
- {
51
- columnAlias: 'entityName',
52
- value: item.name || 'Unnamed Document',
53
- },
54
- // {
55
- // columnAlias: 'entityActions',
56
- // value: {
57
- // entityType: item.entityType,
58
- // },
59
- // },
60
- ],
61
- };
62
- });
63
- }
64
55
  _handleSelect(event) {
65
56
  event.stopPropagation();
66
57
  const table = event.target;
@@ -77,9 +68,16 @@ let UmbDocumentTableCollectionViewElement = class UmbDocumentTableCollectionView
77
68
  const table = event.target;
78
69
  const orderingColumn = table.orderingColumn;
79
70
  const orderingDesc = table.orderingDesc;
80
- console.log(`fetch media items, order column: ${orderingColumn}, desc: ${orderingDesc}`);
71
+ this._collectionContext?.setFilter({
72
+ orderBy: orderingColumn,
73
+ orderDirection: orderingDesc ? 'desc' : 'asc',
74
+ });
81
75
  }
82
76
  render() {
77
+ if (this._busy)
78
+ return html `<div class="container"><uui-loader></uui-loader></div>`;
79
+ if (this._tableItems.length === 0)
80
+ return html `<div class="container"><p>${this.localize.term('content_listViewNoItems')}</p></div>`;
83
81
  return html `
84
82
  <umb-table
85
83
  .config=${this._tableConfig}
@@ -92,6 +90,55 @@ let UmbDocumentTableCollectionViewElement = class UmbDocumentTableCollectionView
92
90
  `;
93
91
  }
94
92
  };
93
+ _UmbDocumentTableCollectionViewElement_systemColumns = new WeakMap();
94
+ _UmbDocumentTableCollectionViewElement_instances = new WeakSet();
95
+ _UmbDocumentTableCollectionViewElement_createTableHeadings = function _UmbDocumentTableCollectionViewElement_createTableHeadings() {
96
+ if (this._userDefinedProperties && this._userDefinedProperties.length > 0) {
97
+ const userColumns = this._userDefinedProperties.map((item) => {
98
+ return {
99
+ name: item.header,
100
+ alias: item.alias,
101
+ elementName: item.elementName,
102
+ allowSorting: true,
103
+ };
104
+ });
105
+ this._tableColumns = [...__classPrivateFieldGet(this, _UmbDocumentTableCollectionViewElement_systemColumns, "f"), ...userColumns];
106
+ }
107
+ };
108
+ _UmbDocumentTableCollectionViewElement_createTableItems = function _UmbDocumentTableCollectionViewElement_createTableItems(items) {
109
+ // TODO: [LK] This is a temporary solution. Let's explore a nicer way to display the values.
110
+ const getValue = (item, alias) => {
111
+ switch (alias) {
112
+ case 'createDate':
113
+ return item.createDate.toLocaleString();
114
+ case 'owner':
115
+ return item.creator;
116
+ case 'published':
117
+ return item.state !== 'Draft' ? 'True' : 'False';
118
+ case 'updateDate':
119
+ return item.updateDate.toLocaleString();
120
+ case 'updater':
121
+ return item.updater;
122
+ default:
123
+ return item.values.find((value) => value.alias === alias)?.value ?? '';
124
+ }
125
+ };
126
+ this._tableItems = items.map((item) => {
127
+ if (!item.unique)
128
+ throw new Error('Item id is missing.');
129
+ const data = this._tableColumns?.map((column) => {
130
+ return {
131
+ columnAlias: column.alias,
132
+ value: column.elementName ? item : getValue(item, column.alias),
133
+ };
134
+ }) ?? [];
135
+ return {
136
+ id: item.unique,
137
+ icon: item.icon,
138
+ data: data,
139
+ };
140
+ });
141
+ };
95
142
  UmbDocumentTableCollectionViewElement.styles = [
96
143
  UmbTextStyles,
97
144
  css `
@@ -107,8 +154,20 @@ UmbDocumentTableCollectionViewElement.styles = [
107
154
  umb-table {
108
155
  padding: 0; /* To fix the embedded padding in the table component. */
109
156
  }
157
+
158
+ .container {
159
+ display: flex;
160
+ justify-content: center;
161
+ align-items: center;
162
+ }
110
163
  `,
111
164
  ];
165
+ __decorate([
166
+ state()
167
+ ], UmbDocumentTableCollectionViewElement.prototype, "_busy", void 0);
168
+ __decorate([
169
+ state()
170
+ ], UmbDocumentTableCollectionViewElement.prototype, "_userDefinedProperties", void 0);
112
171
  __decorate([
113
172
  state()
114
173
  ], UmbDocumentTableCollectionViewElement.prototype, "_items", void 0);
@@ -21,9 +21,9 @@ export class UmbDocumentWorkspaceHasCollectionCondition extends UmbBaseControlle
21
21
  __classPrivateFieldSet(this, _UmbDocumentWorkspaceHasCollectionCondition_onChange, args.onChange, "f");
22
22
  this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (context) => {
23
23
  this.observe(context.contentTypeHasCollection, (hasCollection) => {
24
- this.permitted = hasCollection === true;
24
+ this.permitted = hasCollection ?? false;
25
25
  __classPrivateFieldGet(this, _UmbDocumentWorkspaceHasCollectionCondition_onChange, "f").call(this);
26
- });
26
+ }, 'observeCollection');
27
27
  });
28
28
  }
29
29
  }
@@ -29,7 +29,7 @@ const mapper = (item) => {
29
29
  documentType: {
30
30
  unique: item.documentType.id,
31
31
  icon: item.documentType.icon,
32
- hasListView: item.documentType.hasListView,
32
+ hasCollection: item.documentType.hasListView,
33
33
  },
34
34
  variants: item.variants.map((variant) => {
35
35
  return {