@umbraco-cms/backoffice 14.0.0--preview004-2f33e9be → 14.0.0--preview004-24474e88
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.
- package/dist-cms/custom-elements.json +11 -0
- package/dist-cms/mocks/data/user.data.d.ts +7 -1
- package/dist-cms/mocks/data/user.data.js +27 -1
- package/dist-cms/mocks/data/utils.d.ts +3 -0
- package/dist-cms/mocks/data/utils.js +21 -0
- package/dist-cms/mocks/handlers/user/detail.handlers.js +4 -9
- package/dist-cms/mocks/handlers/user/filter.handlers.d.ts +1 -0
- package/dist-cms/mocks/handlers/user/filter.handlers.js +26 -0
- package/dist-cms/mocks/handlers/user/index.js +3 -1
- package/dist-cms/packages/core/collection/collection.context.d.ts +10 -7
- package/dist-cms/packages/core/collection/collection.context.js +42 -20
- package/dist-cms/packages/core/collection/collection.element.d.ts +1 -0
- package/dist-cms/packages/core/collection/collection.element.js +4 -0
- package/dist-cms/packages/core/collection/components/collection-selection-actions.element.d.ts +1 -1
- package/dist-cms/packages/core/collection/components/collection-selection-actions.element.js +6 -7
- package/dist-cms/packages/core/collection/components/index.d.ts +2 -0
- package/dist-cms/packages/core/collection/components/index.js +2 -0
- package/dist-cms/packages/core/collection/components/pagination/collection-pagination.element.d.ts +16 -0
- package/dist-cms/packages/core/collection/components/pagination/collection-pagination.element.js +59 -0
- package/dist-cms/packages/core/collection/types.d.ts +3 -0
- package/dist-cms/packages/core/collection/types.js +1 -0
- package/dist-cms/packages/core/event/change.event.d.ts +1 -0
- package/dist-cms/packages/core/event/change.event.js +2 -1
- package/dist-cms/packages/core/repository/data-source/collection-data-source.interface.d.ts +3 -4
- package/dist-cms/packages/core/repository/data-source/index.d.ts +1 -0
- package/dist-cms/packages/core/repository/data-source/index.js +1 -0
- package/dist-cms/packages/core/repository/data-source/tree-data-source.interface.d.ts +1 -1
- package/dist-cms/packages/core/repository/data-source/types.d.ts +4 -0
- package/dist-cms/packages/core/repository/data-source/types.js +1 -0
- package/dist-cms/packages/core/repository/tree-repository.interface.d.ts +2 -5
- package/dist-cms/packages/core/tree/tree-item-base/tree-item-base.context.d.ts +1 -1
- package/dist-cms/packages/user/user/collection/repository/user-collection.repository.js +1 -1
- package/dist-cms/packages/user/user/collection/repository/user-collection.server.data.d.ts +1 -22
- package/dist-cms/packages/user/user/collection/repository/user-collection.server.data.js +1 -12
- package/dist-cms/packages/user/user/collection/user-collection.context.js +1 -1
- package/dist-cms/packages/user/user-group/collection/repository/user-group-collection.repository.js +1 -1
- package/dist-cms/packages/user/user-group/collection/repository/user-group-collection.server.data.d.ts +1 -2
- package/dist-cms/packages/user/user-group/collection/repository/user-group-collection.server.data.js +1 -4
- package/dist-cms/shared/utils/index.d.ts +1 -0
- package/dist-cms/shared/utils/index.js +1 -0
- package/dist-cms/shared/utils/pagination-manager/pagination.manager.d.ts +56 -0
- package/dist-cms/shared/utils/pagination-manager/pagination.manager.js +113 -0
- package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
- package/dist-cms/vscode-html-custom-data.json +6 -1
- package/package.json +1 -1
|
@@ -498,6 +498,17 @@
|
|
|
498
498
|
}
|
|
499
499
|
]
|
|
500
500
|
},
|
|
501
|
+
{
|
|
502
|
+
"name": "umb-collection-pagination",
|
|
503
|
+
"path": "./../src/packages/core/collection/components/pagination/collection-pagination.element.ts",
|
|
504
|
+
"properties": [
|
|
505
|
+
{
|
|
506
|
+
"name": "styles",
|
|
507
|
+
"type": "array",
|
|
508
|
+
"default": "[\"UmbTextStyles\",null]"
|
|
509
|
+
}
|
|
510
|
+
]
|
|
511
|
+
},
|
|
501
512
|
{
|
|
502
513
|
"name": "umb-dashboard-collection",
|
|
503
514
|
"path": "./../src/packages/core/collection/dashboards/dashboard-collection.element.ts",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UmbEntityData } from './entity.data.js';
|
|
2
2
|
import { UmbLoggedInUser } from '../../shared/auth/index.js';
|
|
3
|
-
import { CreateUserRequestModel, CreateUserResponseModel, InviteUserRequestModel, UpdateUserGroupsOnUserRequestModel, UserItemResponseModel, UserResponseModel } from '../../external/backend-api/index.js';
|
|
3
|
+
import { CreateUserRequestModel, CreateUserResponseModel, InviteUserRequestModel, PagedUserResponseModel, UpdateUserGroupsOnUserRequestModel, UserItemResponseModel, UserResponseModel } from '../../external/backend-api/index.js';
|
|
4
4
|
declare class UmbUserData extends UmbEntityData<UserResponseModel> {
|
|
5
5
|
constructor(data: UserResponseModel[]);
|
|
6
6
|
/**
|
|
@@ -46,7 +46,13 @@ declare class UmbUserData extends UmbEntityData<UserResponseModel> {
|
|
|
46
46
|
* @memberof UmbUserData
|
|
47
47
|
*/
|
|
48
48
|
unlock(ids: Array<string>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Invites a user
|
|
51
|
+
* @param {InviteUserRequestModel} data
|
|
52
|
+
* @memberof UmbUserData
|
|
53
|
+
*/
|
|
49
54
|
invite(data: InviteUserRequestModel): void;
|
|
55
|
+
filter(options: any): PagedUserResponseModel;
|
|
50
56
|
}
|
|
51
57
|
export declare const data: Array<UserResponseModel & {
|
|
52
58
|
type: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { UmbId } from '../../packages/core/id/index.js';
|
|
2
1
|
import { UmbEntityData } from './entity.data.js';
|
|
3
2
|
import { umbUserGroupData } from './user-group.data.js';
|
|
3
|
+
import { arrayFilter, stringFilter, queryFilter } from './utils.js';
|
|
4
|
+
import { UmbId } from '../../packages/core/id/index.js';
|
|
4
5
|
import { UserStateModel, } from '../../external/backend-api/index.js';
|
|
5
6
|
const createUserItem = (item) => {
|
|
6
7
|
return {
|
|
@@ -8,6 +9,9 @@ const createUserItem = (item) => {
|
|
|
8
9
|
id: item.id,
|
|
9
10
|
};
|
|
10
11
|
};
|
|
12
|
+
const userGroupFilter = (filterOptions, item) => arrayFilter(filterOptions.userGroupIds, item.userGroupIds);
|
|
13
|
+
const userStateFilter = (filterOptions, item) => stringFilter(filterOptions.userStates, item.state);
|
|
14
|
+
const userQueryFilter = (filterOptions, item) => queryFilter(filterOptions.filter, item.name);
|
|
11
15
|
// Temp mocked database
|
|
12
16
|
class UmbUserData extends UmbEntityData {
|
|
13
17
|
constructor(data) {
|
|
@@ -116,6 +120,11 @@ class UmbUserData extends UmbEntityData {
|
|
|
116
120
|
user.state = UserStateModel.ACTIVE;
|
|
117
121
|
});
|
|
118
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Invites a user
|
|
125
|
+
* @param {InviteUserRequestModel} data
|
|
126
|
+
* @memberof UmbUserData
|
|
127
|
+
*/
|
|
119
128
|
invite(data) {
|
|
120
129
|
const invitedUser = {
|
|
121
130
|
status: UserStateModel.INVITED,
|
|
@@ -123,6 +132,23 @@ class UmbUserData extends UmbEntityData {
|
|
|
123
132
|
};
|
|
124
133
|
this.createUser(invitedUser);
|
|
125
134
|
}
|
|
135
|
+
filter(options) {
|
|
136
|
+
const { items: allItems } = this.getAll();
|
|
137
|
+
const filterOptions = {
|
|
138
|
+
skip: options.skip || 0,
|
|
139
|
+
take: options.take || 25,
|
|
140
|
+
orderBy: options.orderBy || 'name',
|
|
141
|
+
orderDirection: options.orderDirection || 'asc',
|
|
142
|
+
userGroupIds: options.userGroupIds,
|
|
143
|
+
userStates: options.userStates,
|
|
144
|
+
filter: options.filter,
|
|
145
|
+
};
|
|
146
|
+
const filteredItems = allItems.filter((item) => userGroupFilter(filterOptions, item) && userStateFilter(filterOptions, item) && userQueryFilter(filterOptions, item));
|
|
147
|
+
const totalItems = filteredItems.length;
|
|
148
|
+
const paginatedItems = filteredItems.slice(filterOptions.skip, filterOptions.skip + filterOptions.take);
|
|
149
|
+
return { total: totalItems, items: paginatedItems };
|
|
150
|
+
}
|
|
151
|
+
;
|
|
126
152
|
}
|
|
127
153
|
export const data = [
|
|
128
154
|
{
|
|
@@ -11,3 +11,6 @@ export declare const createDocumentTypeTreeItem: (item: DocumentTypeResponseMode
|
|
|
11
11
|
export declare const createFileSystemTreeItem: (item: any) => FileSystemTreeItemPresentationModel;
|
|
12
12
|
export declare const createTextFileItem: (item: any) => TextFileResponseModelBaseModel;
|
|
13
13
|
export declare const createFileItemResponseModelBaseModel: (item: any) => FileItemResponseModelBaseModel;
|
|
14
|
+
export declare const arrayFilter: (filterBy: Array<string>, value?: Array<string>) => boolean;
|
|
15
|
+
export declare const stringFilter: (filterBy: Array<string>, value?: string) => boolean;
|
|
16
|
+
export declare const queryFilter: (filterBy: string, value?: string) => boolean;
|
|
@@ -65,3 +65,24 @@ export const createFileItemResponseModelBaseModel = (item) => ({
|
|
|
65
65
|
name: item.name,
|
|
66
66
|
icon: item.icon,
|
|
67
67
|
});
|
|
68
|
+
export const arrayFilter = (filterBy, value) => {
|
|
69
|
+
// if a filter is not set, return all items
|
|
70
|
+
if (!filterBy) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return filterBy.some((filterValue) => value?.includes(filterValue));
|
|
74
|
+
};
|
|
75
|
+
export const stringFilter = (filterBy, value) => {
|
|
76
|
+
// if a filter is not set, return all items
|
|
77
|
+
if (!filterBy || !value) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return filterBy.includes(value);
|
|
81
|
+
};
|
|
82
|
+
export const queryFilter = (filterBy, value) => {
|
|
83
|
+
if (!filterBy || !value) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
const query = filterBy.toLowerCase();
|
|
87
|
+
return value.toLowerCase().includes(query);
|
|
88
|
+
};
|
|
@@ -3,6 +3,10 @@ import { umbUsersData } from '../../data/user.data.js';
|
|
|
3
3
|
import { slug } from './slug.js';
|
|
4
4
|
import { umbracoPath } from '../../../shared/utils/index.js';
|
|
5
5
|
export const handlers = [
|
|
6
|
+
rest.get(umbracoPath(`${slug}`), (req, res, ctx) => {
|
|
7
|
+
const response = umbUsersData.getAll();
|
|
8
|
+
return res(ctx.status(200), ctx.json(response));
|
|
9
|
+
}),
|
|
6
10
|
rest.post(umbracoPath(`${slug}`), async (req, res, ctx) => {
|
|
7
11
|
const data = await req.json();
|
|
8
12
|
if (!data)
|
|
@@ -10,15 +14,6 @@ export const handlers = [
|
|
|
10
14
|
const response = umbUsersData.createUser(data);
|
|
11
15
|
return res(ctx.status(200), ctx.json(response));
|
|
12
16
|
}),
|
|
13
|
-
rest.get(umbracoPath(`${slug}`), (req, res, ctx) => {
|
|
14
|
-
const response = umbUsersData.getAll();
|
|
15
|
-
return res(ctx.status(200), ctx.json(response));
|
|
16
|
-
}),
|
|
17
|
-
rest.get(umbracoPath(`${slug}/filter`), (req, res, ctx) => {
|
|
18
|
-
//TODO: Implementer filter
|
|
19
|
-
const response = umbUsersData.getAll();
|
|
20
|
-
return res(ctx.status(200), ctx.json(response));
|
|
21
|
-
}),
|
|
22
17
|
rest.get(umbracoPath(`${slug}/:id`), (req, res, ctx) => {
|
|
23
18
|
const id = req.params.id;
|
|
24
19
|
if (!id)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const handlers: import("msw").RestHandler<import("msw/lib/glossary-de6278a9.js").M<import("msw/lib/glossary-de6278a9.js").h>>[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { rest } = window.MockServiceWorker;
|
|
2
|
+
import { umbUsersData } from '../../data/user.data.js';
|
|
3
|
+
import { slug } from './slug.js';
|
|
4
|
+
import { umbracoPath } from '../../../shared/utils/index.js';
|
|
5
|
+
export const handlers = [
|
|
6
|
+
rest.get(umbracoPath(`${slug}/filter`), (req, res, ctx) => {
|
|
7
|
+
const skip = Number(req.url.searchParams.get('skip'));
|
|
8
|
+
const take = Number(req.url.searchParams.get('take'));
|
|
9
|
+
const orderBy = req.url.searchParams.get('orderBy');
|
|
10
|
+
const orderDirection = req.url.searchParams.get('orderDirection');
|
|
11
|
+
const userGroupIds = req.url.searchParams.getAll('userGroupIds');
|
|
12
|
+
const userStates = req.url.searchParams.getAll('userStates');
|
|
13
|
+
const filter = req.url.searchParams.get('filter');
|
|
14
|
+
const options = {
|
|
15
|
+
skip: skip || undefined,
|
|
16
|
+
take: take || undefined,
|
|
17
|
+
orderBy: orderBy || undefined,
|
|
18
|
+
orderDirection: orderDirection || undefined,
|
|
19
|
+
userGroupIds: userGroupIds.length > 0 ? userGroupIds : undefined,
|
|
20
|
+
userStates: userStates.length > 0 ? userStates : undefined,
|
|
21
|
+
filter: filter || undefined,
|
|
22
|
+
};
|
|
23
|
+
const response = umbUsersData.filter(options);
|
|
24
|
+
return res(ctx.status(200), ctx.json(response));
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
@@ -7,6 +7,7 @@ import { handlers as disableHandlers } from './disable.handlers.js';
|
|
|
7
7
|
import { handlers as changePasswordHandlers } from './change-password.handlers.js';
|
|
8
8
|
import { handlers as unlockHandlers } from './unlock.handlers.js';
|
|
9
9
|
import { handlers as inviteHandlers } from './invite.handlers.js';
|
|
10
|
+
import { handlers as filterHandlers } from './filter.handlers.js';
|
|
10
11
|
export const handlers = [
|
|
11
12
|
...itemHandlers,
|
|
12
13
|
...currentHandlers,
|
|
@@ -15,6 +16,7 @@ export const handlers = [
|
|
|
15
16
|
...setUserGroupsHandlers,
|
|
16
17
|
...changePasswordHandlers,
|
|
17
18
|
...unlockHandlers,
|
|
18
|
-
...
|
|
19
|
+
...filterHandlers,
|
|
19
20
|
...inviteHandlers,
|
|
21
|
+
...detailHandlers,
|
|
20
22
|
];
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { UmbCollectionConfiguration } from './types.js';
|
|
1
2
|
import { UmbCollectionRepository } from '../repository/index.js';
|
|
2
3
|
import { UmbBaseController, type UmbControllerHostElement } from '../../../libs/controller-api/index.js';
|
|
3
4
|
import { UmbContextToken } from '../../../libs/context-api/index.js';
|
|
4
5
|
import { ManifestCollectionView } from '../extension-registry/index.js';
|
|
5
6
|
import type { UmbCollectionFilterModel } from './index.js';
|
|
7
|
+
import { UmbPaginationManager } from '../../../shared/utils/index.js';
|
|
6
8
|
export declare class UmbCollectionContext<ItemType, FilterModelType extends UmbCollectionFilterModel> extends UmbBaseController {
|
|
7
9
|
#private;
|
|
8
10
|
protected entityType: string;
|
|
9
11
|
protected init: Promise<[import("../extension-registry/index.js").ManifestRepository, ManifestCollectionView[]]>;
|
|
10
|
-
readonly items: import("rxjs/internal/Observable").Observable<ItemType[]>;
|
|
11
|
-
readonly
|
|
12
|
-
readonly selection: import("rxjs/internal/Observable").Observable<(string | null)[]>;
|
|
13
|
-
readonly filter: import("rxjs/internal/Observable").Observable<object | FilterModelType>;
|
|
14
|
-
readonly views: import("rxjs/internal/Observable").Observable<ManifestCollectionView[]>;
|
|
15
|
-
readonly currentView: import("rxjs/internal/Observable").Observable<ManifestCollectionView | undefined>;
|
|
12
|
+
readonly items: import("rxjs/internal/Observable.js").Observable<ItemType[]>;
|
|
13
|
+
readonly totalItems: import("rxjs/internal/Observable.js").Observable<number>;
|
|
14
|
+
readonly selection: import("rxjs/internal/Observable.js").Observable<(string | null)[]>;
|
|
15
|
+
readonly filter: import("rxjs/internal/Observable.js").Observable<object | FilterModelType>;
|
|
16
|
+
readonly views: import("rxjs/internal/Observable.js").Observable<ManifestCollectionView[]>;
|
|
17
|
+
readonly currentView: import("rxjs/internal/Observable.js").Observable<ManifestCollectionView | undefined>;
|
|
16
18
|
repository?: UmbCollectionRepository;
|
|
17
19
|
collectionRootPathname: string;
|
|
18
|
-
|
|
20
|
+
readonly pagination: UmbPaginationManager;
|
|
21
|
+
constructor(host: UmbControllerHostElement, entityType: string, repositoryAlias: string, config?: UmbCollectionConfiguration);
|
|
19
22
|
/**
|
|
20
23
|
* Returns true if the given id is selected.
|
|
21
24
|
* @param {string} id
|
|
@@ -4,20 +4,21 @@ import { UmbArrayState, UmbNumberState, UmbObjectState, } from '../../../libs/ob
|
|
|
4
4
|
import { createExtensionApi } from '../../../libs/extension-api/index.js';
|
|
5
5
|
import { umbExtensionsRegistry } from '../extension-registry/index.js';
|
|
6
6
|
import { map } from '../../../external/rxjs/index.js';
|
|
7
|
-
import { UmbSelectionManager } from '../../../shared/utils/index.js';
|
|
7
|
+
import { UmbSelectionManager, UmbPaginationManager } from '../../../shared/utils/index.js';
|
|
8
|
+
import { UmbChangeEvent } from '../event/index.js';
|
|
8
9
|
export class UmbCollectionContext extends UmbBaseController {
|
|
9
10
|
#items;
|
|
10
|
-
#
|
|
11
|
+
#totalItems;
|
|
11
12
|
#selectionManager;
|
|
12
13
|
#filter;
|
|
13
14
|
#views;
|
|
14
15
|
#currentView;
|
|
15
|
-
constructor(host, entityType, repositoryAlias) {
|
|
16
|
+
constructor(host, entityType, repositoryAlias, config = { pageSize: 50 }) {
|
|
16
17
|
super(host);
|
|
17
18
|
this.#items = new UmbArrayState([]);
|
|
18
19
|
this.items = this.#items.asObservable();
|
|
19
|
-
this.#
|
|
20
|
-
this.
|
|
20
|
+
this.#totalItems = new UmbNumberState(0);
|
|
21
|
+
this.totalItems = this.#totalItems.asObservable();
|
|
21
22
|
this.#selectionManager = new UmbSelectionManager();
|
|
22
23
|
this.selection = this.#selectionManager.selection;
|
|
23
24
|
this.#filter = new UmbObjectState({});
|
|
@@ -26,25 +27,22 @@ export class UmbCollectionContext extends UmbBaseController {
|
|
|
26
27
|
this.views = this.#views.asObservable();
|
|
27
28
|
this.#currentView = new UmbObjectState(undefined);
|
|
28
29
|
this.currentView = this.#currentView.asObservable();
|
|
30
|
+
this.pagination = new UmbPaginationManager();
|
|
31
|
+
this.#onPageChange = (event) => {
|
|
32
|
+
const target = event.target;
|
|
33
|
+
const skipFilter = { skip: target.getSkip() };
|
|
34
|
+
this.setFilter(skipFilter);
|
|
35
|
+
};
|
|
29
36
|
this.entityType = entityType;
|
|
30
|
-
|
|
37
|
+
// listen for page changes on the pagination manager
|
|
38
|
+
this.pagination.addEventListener(UmbChangeEvent.TYPE, this.#onPageChange);
|
|
31
39
|
const currentUrl = new URL(window.location.href);
|
|
32
40
|
this.collectionRootPathname = currentUrl.pathname.substring(0, currentUrl.pathname.lastIndexOf('/'));
|
|
33
41
|
this.init = Promise.all([
|
|
34
|
-
this
|
|
35
|
-
|
|
36
|
-
const result = await createExtensionApi(repositoryManifest, [this._host]);
|
|
37
|
-
this.repository = result;
|
|
38
|
-
this.requestCollection();
|
|
39
|
-
}
|
|
40
|
-
}, 'umbCollectionRepositoryObserver').asPromise(),
|
|
41
|
-
this.observe(umbExtensionsRegistry.extensionsOfType('collectionView').pipe(map((extensions) => {
|
|
42
|
-
return extensions.filter((extension) => extension.conditions.entityType === this.getEntityType());
|
|
43
|
-
})), (views) => {
|
|
44
|
-
this.#views.next(views);
|
|
45
|
-
this.#setCurrentView();
|
|
46
|
-
}, 'umbCollectionViewsObserver').asPromise(),
|
|
42
|
+
this.#observeRepository(repositoryAlias).asPromise(),
|
|
43
|
+
this.#observeViews().asPromise(),
|
|
47
44
|
]);
|
|
45
|
+
this.#configure(config);
|
|
48
46
|
this.provideContext(UMB_COLLECTION_CONTEXT, this);
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
@@ -114,8 +112,9 @@ export class UmbCollectionContext extends UmbBaseController {
|
|
|
114
112
|
const filter = this.#filter.getValue();
|
|
115
113
|
const { data } = await this.repository.requestCollection(filter);
|
|
116
114
|
if (data) {
|
|
117
|
-
this.#total.next(data.total);
|
|
118
115
|
this.#items.next(data.items);
|
|
116
|
+
this.#totalItems.next(data.total);
|
|
117
|
+
this.pagination.setTotalItems(data.total);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
/**
|
|
@@ -144,6 +143,29 @@ export class UmbCollectionContext extends UmbBaseController {
|
|
|
144
143
|
getCurrentView() {
|
|
145
144
|
return this.#currentView.getValue();
|
|
146
145
|
}
|
|
146
|
+
#configure(configuration) {
|
|
147
|
+
this.#selectionManager.setMultiple(true);
|
|
148
|
+
this.pagination.setPageSize(configuration.pageSize);
|
|
149
|
+
this.#filter.next({ ...this.#filter.getValue(), skip: 0, take: configuration.pageSize });
|
|
150
|
+
}
|
|
151
|
+
#observeRepository(repositoryAlias) {
|
|
152
|
+
return this.observe(umbExtensionsRegistry.getByTypeAndAlias('repository', repositoryAlias), async (repositoryManifest) => {
|
|
153
|
+
if (repositoryManifest) {
|
|
154
|
+
const result = await createExtensionApi(repositoryManifest, [this._host]);
|
|
155
|
+
this.repository = result;
|
|
156
|
+
this.requestCollection();
|
|
157
|
+
}
|
|
158
|
+
}, 'umbCollectionRepositoryObserver');
|
|
159
|
+
}
|
|
160
|
+
#observeViews() {
|
|
161
|
+
return this.observe(umbExtensionsRegistry.extensionsOfType('collectionView').pipe(map((extensions) => {
|
|
162
|
+
return extensions.filter((extension) => extension.conditions.entityType === this.getEntityType());
|
|
163
|
+
})), (views) => {
|
|
164
|
+
this.#views.next(views);
|
|
165
|
+
this.#setCurrentView();
|
|
166
|
+
}, 'umbCollectionViewsObserver');
|
|
167
|
+
}
|
|
168
|
+
#onPageChange;
|
|
147
169
|
#setCurrentView() {
|
|
148
170
|
const currentUrl = new URL(window.location.href);
|
|
149
171
|
const lastPathSegment = currentUrl.pathname.split('/').pop();
|
|
@@ -11,6 +11,7 @@ export declare class UmbCollectionElement extends UmbLitElement {
|
|
|
11
11
|
private _createRoutes;
|
|
12
12
|
render(): import("lit-html").TemplateResult<1>;
|
|
13
13
|
protected renderToolbar(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
protected renderPagination(): import("lit-html").TemplateResult<1>;
|
|
14
15
|
protected renderSelectionActions(): import("lit-html").TemplateResult<1>;
|
|
15
16
|
static styles: import("@lit/reactive-element/css-tag.js").CSSResult[];
|
|
16
17
|
}
|
|
@@ -50,6 +50,7 @@ export let UmbCollectionElement = class UmbCollectionElement extends UmbLitEleme
|
|
|
50
50
|
<umb-body-layout header-transparent>
|
|
51
51
|
${this.renderToolbar()}
|
|
52
52
|
<umb-router-slot id="router-slot" .routes="${this._routes}"></umb-router-slot>
|
|
53
|
+
${this.renderPagination()}
|
|
53
54
|
${this.renderSelectionActions()}
|
|
54
55
|
</umb-body-layout>
|
|
55
56
|
`;
|
|
@@ -57,6 +58,9 @@ export let UmbCollectionElement = class UmbCollectionElement extends UmbLitEleme
|
|
|
57
58
|
renderToolbar() {
|
|
58
59
|
return html `<umb-collection-toolbar slot="header"></umb-collection-toolbar>`;
|
|
59
60
|
}
|
|
61
|
+
renderPagination() {
|
|
62
|
+
return html `<umb-collection-pagination></umb-collection-pagination>`;
|
|
63
|
+
}
|
|
60
64
|
renderSelectionActions() {
|
|
61
65
|
return html `<umb-collection-selection-actions slot="footer-info"></umb-collection-selection-actions>`;
|
|
62
66
|
}
|
package/dist-cms/packages/core/collection/components/collection-selection-actions.element.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { nothing } from '../../../../external/lit/index.js';
|
|
|
2
2
|
import { UmbLitElement } from '../../../../shared/lit-element/index.js';
|
|
3
3
|
export declare class UmbCollectionSelectionActionsElement extends UmbLitElement {
|
|
4
4
|
#private;
|
|
5
|
-
private
|
|
5
|
+
private _totalItems;
|
|
6
6
|
private _selectionLength;
|
|
7
7
|
private _extensionProps;
|
|
8
8
|
private _selection;
|
package/dist-cms/packages/core/collection/components/collection-selection-actions.element.js
CHANGED
|
@@ -11,7 +11,7 @@ import { UmbLitElement } from '../../../../shared/lit-element/index.js';
|
|
|
11
11
|
export let UmbCollectionSelectionActionsElement = class UmbCollectionSelectionActionsElement extends UmbLitElement {
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
|
-
this.
|
|
14
|
+
this._totalItems = 0;
|
|
15
15
|
this._selectionLength = 0;
|
|
16
16
|
this._extensionProps = {};
|
|
17
17
|
this._selection = [];
|
|
@@ -31,10 +31,9 @@ export let UmbCollectionSelectionActionsElement = class UmbCollectionSelectionAc
|
|
|
31
31
|
_observeCollectionContext() {
|
|
32
32
|
if (!this._collectionContext)
|
|
33
33
|
return;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, 'umbItemsLengthObserver');
|
|
34
|
+
this.observe(this._collectionContext.totalItems, (value) => {
|
|
35
|
+
this._totalItems = value;
|
|
36
|
+
}, 'umbTotalItemsObserver');
|
|
38
37
|
this.observe(this._collectionContext.selection, (selection) => {
|
|
39
38
|
this._selectionLength = selection.length;
|
|
40
39
|
this._selection = selection;
|
|
@@ -42,7 +41,7 @@ export let UmbCollectionSelectionActionsElement = class UmbCollectionSelectionAc
|
|
|
42
41
|
}, 'umbSelectionObserver');
|
|
43
42
|
}
|
|
44
43
|
_renderSelectionCount() {
|
|
45
|
-
return html `<div>${this._selectionLength} of ${this.
|
|
44
|
+
return html `<div>${this._selectionLength} of ${this._totalItems} selected</div>`;
|
|
46
45
|
}
|
|
47
46
|
#onActionExecuted(event) {
|
|
48
47
|
event.stopPropagation();
|
|
@@ -98,7 +97,7 @@ export let UmbCollectionSelectionActionsElement = class UmbCollectionSelectionAc
|
|
|
98
97
|
};
|
|
99
98
|
__decorate([
|
|
100
99
|
state()
|
|
101
|
-
], UmbCollectionSelectionActionsElement.prototype, "
|
|
100
|
+
], UmbCollectionSelectionActionsElement.prototype, "_totalItems", void 0);
|
|
102
101
|
__decorate([
|
|
103
102
|
state()
|
|
104
103
|
], UmbCollectionSelectionActionsElement.prototype, "_selectionLength", void 0);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import './pagination/collection-pagination.element.js';
|
|
1
2
|
import './collection-selection-actions.element.js';
|
|
2
3
|
import './collection-toolbar.element.js';
|
|
3
4
|
import './collection-view-bundle.element.js';
|
|
5
|
+
export * from './pagination/collection-pagination.element.js';
|
|
4
6
|
export * from './collection-selection-actions.element.js';
|
|
5
7
|
export * from './collection-toolbar.element.js';
|
|
6
8
|
export * from './collection-view-bundle.element.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import './pagination/collection-pagination.element.js';
|
|
1
2
|
import './collection-selection-actions.element.js';
|
|
2
3
|
import './collection-toolbar.element.js';
|
|
3
4
|
import './collection-view-bundle.element.js';
|
|
5
|
+
export * from './pagination/collection-pagination.element.js';
|
|
4
6
|
export * from './collection-selection-actions.element.js';
|
|
5
7
|
export * from './collection-toolbar.element.js';
|
|
6
8
|
export * from './collection-view-bundle.element.js';
|
package/dist-cms/packages/core/collection/components/pagination/collection-pagination.element.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { nothing } from '../../../../../external/lit/index.js';
|
|
2
|
+
import { UmbLitElement } from '../../../../../shared/lit-element/index.js';
|
|
3
|
+
export declare class UmbCollectionPaginationElement extends UmbLitElement {
|
|
4
|
+
#private;
|
|
5
|
+
_totalPages: number;
|
|
6
|
+
_currentPage: number;
|
|
7
|
+
private _collectionContext?;
|
|
8
|
+
constructor();
|
|
9
|
+
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
10
|
+
static styles: import("@lit/reactive-element/css-tag").CSSResult[];
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'umb-collection-pagination': UmbCollectionPaginationElement;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist-cms/packages/core/collection/components/pagination/collection-pagination.element.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { UmbTextStyles } from '../../../../../shared/style/index.js';
|
|
8
|
+
import { css, html, customElement, nothing, state } from '../../../../../external/lit/index.js';
|
|
9
|
+
import { UMB_COLLECTION_CONTEXT } from '../../index.js';
|
|
10
|
+
import { UmbLitElement } from '../../../../../shared/lit-element/index.js';
|
|
11
|
+
export let UmbCollectionPaginationElement = class UmbCollectionPaginationElement extends UmbLitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this._totalPages = 0;
|
|
15
|
+
this._currentPage = 1;
|
|
16
|
+
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
|
|
17
|
+
this._collectionContext = instance;
|
|
18
|
+
this.#observeCurrentPage();
|
|
19
|
+
this.#observerTotalPages();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
#observeCurrentPage() {
|
|
23
|
+
this.observe(this._collectionContext.pagination.currentPage, (currentPage) => {
|
|
24
|
+
this._currentPage = currentPage;
|
|
25
|
+
}, 'umbCurrentPageObserver');
|
|
26
|
+
}
|
|
27
|
+
#observerTotalPages() {
|
|
28
|
+
this.observe(this._collectionContext.pagination.totalPages, (totalPages) => {
|
|
29
|
+
this._totalPages = totalPages;
|
|
30
|
+
}, 'umbTotalPagesObserver');
|
|
31
|
+
}
|
|
32
|
+
#onChange(event) {
|
|
33
|
+
this._collectionContext?.pagination.setCurrentPageNumber(event.target.current);
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
if (this._totalPages <= 1) {
|
|
37
|
+
return nothing;
|
|
38
|
+
}
|
|
39
|
+
return html `<uui-pagination .current=${this._currentPage} .total=${this._totalPages} @change=${this.#onChange}></uui-pagination>`;
|
|
40
|
+
}
|
|
41
|
+
static { this.styles = [
|
|
42
|
+
UmbTextStyles,
|
|
43
|
+
css `
|
|
44
|
+
:host {
|
|
45
|
+
display: block;
|
|
46
|
+
margin-top: var(--uui-size-layout-1);
|
|
47
|
+
}
|
|
48
|
+
`
|
|
49
|
+
]; }
|
|
50
|
+
};
|
|
51
|
+
__decorate([
|
|
52
|
+
state()
|
|
53
|
+
], UmbCollectionPaginationElement.prototype, "_totalPages", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
state()
|
|
56
|
+
], UmbCollectionPaginationElement.prototype, "_currentPage", void 0);
|
|
57
|
+
UmbCollectionPaginationElement = __decorate([
|
|
58
|
+
customElement('umb-collection-pagination')
|
|
59
|
+
], UmbCollectionPaginationElement);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export class UmbChangeEvent extends Event {
|
|
2
|
+
static { this.TYPE = 'change'; }
|
|
2
3
|
constructor() {
|
|
3
4
|
// mimics the native change event
|
|
4
|
-
super(
|
|
5
|
+
super(UmbChangeEvent.TYPE, { bubbles: true, composed: false, cancelable: false });
|
|
5
6
|
}
|
|
6
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { UmbPagedData } from '../tree-repository.interface.js';
|
|
2
1
|
import type { DataSourceResponse } from '../index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { UmbPagedData } from './types.js';
|
|
3
|
+
export interface UmbCollectionDataSource<ItemType = any, FilterType = unknown> {
|
|
4
|
+
getCollection(filter: FilterType): Promise<DataSourceResponse<UmbPagedData<ItemType>>>;
|
|
6
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UmbPagedData } from '
|
|
1
|
+
import type { UmbPagedData } from './types.js';
|
|
2
2
|
import type { DataSourceResponse } from './data-source-response.interface.js';
|
|
3
3
|
export interface UmbTreeDataSource<ItemType = any, PagedItemType = UmbPagedData<ItemType>> {
|
|
4
4
|
getRootItems(): Promise<DataSourceResponse<PagedItemType>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type UmbPagedData } from './data-source/types.js';
|
|
2
|
+
import { type Observable } from '../../../external/rxjs/index.js';
|
|
2
3
|
import type { UmbTreeRootEntityModel, UmbTreeRootModel } from '../tree/index.js';
|
|
3
4
|
import { ProblemDetails, EntityTreeItemResponseModel } from '../../../external/backend-api/index.js';
|
|
4
|
-
export interface UmbPagedData<T> {
|
|
5
|
-
total: number;
|
|
6
|
-
items: Array<T>;
|
|
7
|
-
}
|
|
8
5
|
export interface UmbTreeRepository<TreeItemType extends EntityTreeItemResponseModel, TreeRootType extends UmbTreeRootModel = UmbTreeRootEntityModel> {
|
|
9
6
|
requestTreeRoot: () => Promise<{
|
|
10
7
|
data?: TreeRootType;
|
|
@@ -21,7 +21,7 @@ export declare class UmbTreeItemContextBase<TreeItemType extends TreeItemPresent
|
|
|
21
21
|
constructor(host: UmbControllerHost, getUniqueFunction: UmbTreeItemUniqueFunction<TreeItemType>);
|
|
22
22
|
setTreeItem(treeItem: TreeItemType | undefined): void;
|
|
23
23
|
requestChildren(): Promise<{
|
|
24
|
-
data?: import("../../repository/
|
|
24
|
+
data?: import("../../repository/index.js").UmbPagedData<TreeItemType> | undefined;
|
|
25
25
|
error?: import("../../../../external/backend-api/index.js").ProblemDetails | undefined;
|
|
26
26
|
asObservable?: (() => import("rxjs/internal/Observable.js").Observable<TreeItemType[]>) | undefined;
|
|
27
27
|
}>;
|
|
@@ -8,7 +8,7 @@ export class UmbUserCollectionRepository extends UmbUserRepositoryBase {
|
|
|
8
8
|
}
|
|
9
9
|
async requestCollection(filter = { skip: 0, take: 100 }) {
|
|
10
10
|
await this.init;
|
|
11
|
-
const { data, error } = await this.#collectionSource.
|
|
11
|
+
const { data, error } = await this.#collectionSource.getCollection(filter);
|
|
12
12
|
if (data) {
|
|
13
13
|
this.detailStore.appendItems(data.items);
|
|
14
14
|
}
|