Skip to content

Commit de9cbf9

Browse files
committed
Merge branch 'release/17.0' of https://github.com/umbraco/Umbraco-CMS into release/17.0
2 parents 04df265 + bd6ab83 commit de9cbf9

File tree

7 files changed

+89
-20
lines changed

7 files changed

+89
-20
lines changed
-37.6 KB
Loading

src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.context.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { UmbArrayState, UmbBasicState, UmbNumberState, UmbObjectState } from '@u
1515
import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';
1616
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
1717
import { UmbExtensionApiInitializer } from '@umbraco-cms/backoffice/extension-api';
18-
import { UmbSelectionManager, UmbPaginationManager, UmbDeprecation } from '@umbraco-cms/backoffice/utils';
18+
import { UmbSelectionManager, UmbPaginationManager, UmbDeprecation, debounce } from '@umbraco-cms/backoffice/utils';
1919
import type { ManifestRepository } from '@umbraco-cms/backoffice/extension-registry';
2020
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
2121
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
@@ -121,11 +121,11 @@ export class UmbDefaultCollectionContext<
121121
})
122122
.onReject(() => {
123123
// TODO: Maybe this can be removed?
124-
this.requestCollection();
124+
this._requestCollection();
125125
})
126126
.onSubmit(() => {
127127
// TODO: Maybe this can be removed?
128-
this.requestCollection();
128+
this._requestCollection();
129129
})
130130
.observeRouteBuilder((routeBuilder) => {
131131
this.#workspacePathBuilder.setValue(routeBuilder);
@@ -248,16 +248,30 @@ export class UmbDefaultCollectionContext<
248248
return this.manifest?.meta.noItemsLabel ?? this.#config?.noItemsLabel ?? '#collection_noItemsTitle';
249249
}
250250

251+
/* debouncing the load collection method because multiple filters can be set at the same time
252+
that will trigger multiple load calls with different filter arguments */
253+
public loadCollection = debounce(() => this._requestCollection(), 100);
254+
251255
/**
252256
* Requests the collection from the repository.
253-
* @returns {*}
257+
* @returns {Promise<void>}
258+
* @deprecated Deprecated since v.17.0.0. Use `loadCollection` instead.
254259
* @memberof UmbCollectionContext
255260
*/
256261
public async requestCollection() {
262+
new UmbDeprecation({
263+
removeInVersion: '19.0.0',
264+
deprecated: 'requestCollection',
265+
solution: 'Use .loadCollection method instead',
266+
}).warn();
267+
268+
return this._requestCollection();
269+
}
270+
271+
protected async _requestCollection() {
257272
await this._init;
258273

259274
if (!this._configured) this._configure();
260-
261275
if (!this._repository) throw new Error(`Missing repository for ${this._manifest}`);
262276

263277
this._loading.setValue(true);
@@ -281,7 +295,7 @@ export class UmbDefaultCollectionContext<
281295
*/
282296
public setFilter(filter: Partial<FilterModelType>) {
283297
this._filter.setValue({ ...this._filter.getValue(), ...filter });
284-
this.requestCollection();
298+
this.loadCollection();
285299
}
286300

287301
public updateFilter(filter: Partial<FilterModelType>) {
@@ -312,7 +326,7 @@ export class UmbDefaultCollectionContext<
312326
const items = this._items.getValue();
313327
const hasItem = items.some((item) => item.unique === event.getUnique());
314328
if (hasItem) {
315-
this.requestCollection();
329+
this._requestCollection();
316330
}
317331
};
318332

@@ -324,7 +338,7 @@ export class UmbDefaultCollectionContext<
324338
const entityType = entityContext.getEntityType();
325339

326340
if (unique === event.getUnique() && entityType === event.getEntityType()) {
327-
this.requestCollection();
341+
this._requestCollection();
328342
}
329343
};
330344

src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.element.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ umbExtensionsRegistry.register(manifest);
2323

2424
@customElement('umb-collection-default')
2525
export class UmbCollectionDefaultElement extends UmbLitElement {
26-
//
2726
#collectionContext?: UmbDefaultCollectionContext;
2827

2928
@state()
@@ -33,23 +32,43 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
3332
private _hasItems = false;
3433

3534
@state()
36-
private _isDoneLoading = false;
35+
private _emptyLabel?: string;
3736

3837
@state()
39-
private _emptyLabel?: string;
38+
private _initialLoadDone = false;
4039

4140
constructor() {
4241
super();
4342
this.consumeContext(UMB_COLLECTION_CONTEXT, async (context) => {
4443
this.#collectionContext = context;
44+
this.#observeIsLoading();
4545
this.#observeCollectionRoutes();
4646
this.#observeTotalItems();
4747
this.#getEmptyStateLabel();
48-
await this.#collectionContext?.requestCollection();
49-
this._isDoneLoading = true;
48+
this.#collectionContext?.loadCollection();
5049
});
5150
}
5251

52+
#observeIsLoading() {
53+
if (!this.#collectionContext) return;
54+
let hasBeenLoading = false;
55+
56+
this.observe(
57+
this.#collectionContext.loading,
58+
(isLoading) => {
59+
// We need to know when the initial loading has been done, to not show the empty state before that.
60+
// We can't just check if there are items, because there might be none.
61+
// So we check if it has been loading, and then when it stops loading we know the initial load is done.
62+
if (isLoading) {
63+
hasBeenLoading = true;
64+
} else if (hasBeenLoading) {
65+
this._initialLoadDone = true;
66+
}
67+
},
68+
'umbCollectionIsLoadingObserver',
69+
);
70+
}
71+
5372
#observeCollectionRoutes() {
5473
if (!this.#collectionContext) return;
5574

@@ -106,7 +125,7 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
106125
}
107126

108127
#renderEmptyState() {
109-
if (!this._isDoneLoading) return nothing;
128+
if (!this._initialLoadDone) return nothing;
110129

111130
return html`
112131
<div id="empty-state" class="uui-text">
@@ -138,12 +157,20 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
138157
height: 80%;
139158
align-content: center;
140159
text-align: center;
160+
opacity: 0;
161+
animation: fadeIn 200ms 200ms forwards;
141162
}
142163
143164
router-slot {
144165
width: 100%;
145166
height: 100%;
146167
}
168+
169+
@keyframes fadeIn {
170+
100% {
171+
opacity: 100%;
172+
}
173+
}
147174
`,
148175
];
149176
}

src/Umbraco.Web.UI.Client/src/packages/documents/documents/collection/document-collection.context.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection'
44
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
55
import { UMB_VARIANT_CONTEXT } from '@umbraco-cms/backoffice/variant';
66
import { UmbStringState } from '@umbraco-cms/backoffice/observable-api';
7+
import { UmbDeprecation } from '@umbraco-cms/backoffice/utils';
78

89
export class UmbDocumentCollectionContext extends UmbDefaultCollectionContext<
910
UmbDocumentCollectionItemModel,
@@ -35,9 +36,25 @@ export class UmbDocumentCollectionContext extends UmbDefaultCollectionContext<
3536
);
3637
}
3738

38-
public override async requestCollection() {
39+
/**
40+
* Requests the collection from the repository.
41+
* @returns {Promise<void>}
42+
* @deprecated Deprecated since v.17.0.0. Use `loadCollection` instead.
43+
* @memberof UmbDocumentCollectionContext
44+
*/
45+
public override async requestCollection(): Promise<void> {
46+
new UmbDeprecation({
47+
removeInVersion: '19.0.0',
48+
deprecated: 'requestCollection',
49+
solution: 'Use .loadCollection method instead',
50+
}).warn();
51+
52+
return this._requestCollection();
53+
}
54+
55+
protected override async _requestCollection() {
3956
await this.observe(this.#displayCultureObservable)?.asPromise();
40-
await super.requestCollection();
57+
await super._requestCollection();
4158
}
4259
}
4360

src/Umbraco.Web.UI.Client/src/packages/media/media/collection/media-collection.context.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { UmbFileDropzoneItemStatus } from '@umbraco-cms/backoffice/dropzone
55
import { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection';
66
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
77
import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';
8+
import { UmbDeprecation } from '@umbraco-cms/backoffice/utils';
89
export class UmbMediaCollectionContext extends UmbDefaultCollectionContext<
910
UmbMediaCollectionItemModel,
1011
UmbMediaCollectionFilterModel
@@ -51,9 +52,20 @@ export class UmbMediaCollectionContext extends UmbDefaultCollectionContext<
5152
/**
5253
* Requests the collection from the repository.
5354
* @returns {Promise<void>}
54-
* @memberof UmbCollectionContext
55+
* @deprecated Deprecated since v.17.0.0. Use `loadCollection` instead.
56+
* @memberof UmbMediaCollectionContext
5557
*/
56-
public override async requestCollection() {
58+
public override async requestCollection(): Promise<void> {
59+
new UmbDeprecation({
60+
removeInVersion: '19.0.0',
61+
deprecated: 'requestCollection',
62+
solution: 'Use .loadCollection method instead',
63+
}).warn();
64+
65+
return this._requestCollection();
66+
}
67+
68+
protected override async _requestCollection() {
5769
await this._init;
5870

5971
if (!this._configured) this._configure();

src/Umbraco.Web.UI.Client/src/packages/media/media/collection/media-collection.element.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class UmbMediaCollectionElement extends UmbCollectionDefaultElement {
6262
async #onComplete(event: Event) {
6363
event.preventDefault();
6464
this._progress = -1;
65-
this.#collectionContext?.requestCollection();
6665

6766
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
6867
if (!eventContext) {

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "17.0.0-beta2",
3+
"version": "17.0.0-rc",
44
"assemblyVersion": {
55
"precision": "build"
66
},

0 commit comments

Comments
 (0)