update dragging entities

This commit is contained in:
Dan Percic 2022-09-07 16:17:44 +03:00
parent 2d9abac1c8
commit c174a1985e
3 changed files with 19 additions and 16 deletions

View File

@ -24,7 +24,7 @@ export class CacheApiService {
for (const dynCache of this._dynamicCaches) {
for (const cacheUrl of dynCache.urls) {
if (url.indexOf(cacheUrl) >= 0) {
console.log('[CACHE-API] open cache: ', dynCache.name);
// console.log('[CACHE-API] open cache: ', dynCache.name);
return caches.open(dynCache.name).then(cache => this._handleFetchResponse(httpResponse, dynCache, cache, url));
}
}
@ -34,7 +34,7 @@ export class CacheApiService {
}
async wipeCaches(logoutDependant = false) {
console.log('[CACHE-API] delete app level cache ');
// console.log('[CACHE-API] delete app level cache ');
await caches.delete(APP_LEVEL_CACHE);
for (const cache of this._dynamicCaches) {
@ -51,7 +51,7 @@ export class CacheApiService {
getCachedRequest(request: HttpRequest<any>): Observable<HttpEvent<any>> {
const url = this._buildUrl(request);
console.log('[CACHE-API] get cached request: ', url);
// console.log('[CACHE-API] get cached request: ', url);
return from(caches.match(url)).pipe(
mergeMap(response => {
if (response) {
@ -78,7 +78,7 @@ export class CacheApiService {
return Promise.resolve();
}
console.log('[CACHE-API] cache value: ', name);
// console.log('[CACHE-API] cache value: ', name);
const cache = await caches.open(APP_LEVEL_CACHE);
const string = JSON.stringify(valueReference);
const expires = new Date().getTime() + ttl * 1000;
@ -97,7 +97,7 @@ export class CacheApiService {
return Promise.resolve(undefined);
}
console.log('[CACHE-API] get cached value: ', name);
// console.log('[CACHE-API] get cached value: ', name);
const cache = await caches.open(APP_LEVEL_CACHE);
const result = await cache.match(name);
if (!result) {
@ -233,7 +233,7 @@ export class CacheApiService {
}
private async _handleCacheExpiration(dynCache: DynamicCache, now: number) {
console.log('[CACHE-API] checking cache expiration');
// console.log('[CACHE-API] checking cache expiration');
const cache = await caches.open(dynCache.name);
let keys = await cache.keys();
// removed expired;

View File

@ -30,8 +30,8 @@ export class ListingService<Class extends IListable<PrimaryKey>, PrimaryKey exte
this.displayedLength$ = this.displayed$.pipe(getLength, shareDistinctLast());
this.selected$ = this._selected$.asObservable().pipe(shareDistinctLast());
this.selectedEntities$ = this._selected$.asObservable().pipe(
map(() => this.selected),
this.selectedEntities$ = combineLatest([this._selected$.asObservable(), this._entitiesService.all$]).pipe(
map(([selectedIds, all]) => all.filter(a => selectedIds.includes(a.id))),
shareLast(),
);
this.selectedLength$ = this._selected$.pipe(getLength, shareDistinctLast());

View File

@ -101,10 +101,18 @@ export class WorkflowComponent<T extends IListable, K extends string> extends Co
draggingEntities: this.draggingEntities$,
updateConfigItems: updateConfigItems$,
setupResizeObserver: setupResizeObserver$,
updateDragging: this.listingService.displayed$.pipe(
tap((entities: T[]) => {
const entitiesIds = entities.map(e => e.id);
const initialDraggingIds = this.draggingEntities$.value.map(entity => entity.id);
const updatedDraggingIds = initialDraggingIds.filter(id => entitiesIds.includes(id));
this.draggingEntities$.next(entities.filter(entity => updatedDraggingIds.includes(entity.id)));
}),
),
});
}
canMoveTo(column: WorkflowColumn<T, K>): () => boolean {
canMoveTo(column: WorkflowColumn<T, K>) {
return () => column.enterPredicate(this.draggingEntities$.value);
}
@ -163,15 +171,10 @@ export class WorkflowComponent<T extends IListable, K extends string> extends Co
}
private _updateConfigItems(entities: T[]) {
// Disable updating while dragging
if (this.dragging) {
return;
}
// Remove deleted entities
const updatedIds = entities.map(entity => entity.id);
const entitiesIds = entities.map(entity => entity.id);
for (const id of Object.keys(this.all)) {
if (!updatedIds.includes(id)) {
if (!entitiesIds.includes(id)) {
this._removeEntity(this.all[id].entity);
}
}