diff --git a/packages/context/src/lib/context-manager/context-list/context-list.component.html b/packages/context/src/lib/context-manager/context-list/context-list.component.html index 0c5cedb465..6361732ea2 100644 --- a/packages/context/src/lib/context-manager/context-list/context-list.component.html +++ b/packages/context/src/lib/context-manager/context-list/context-list.component.html @@ -86,7 +86,7 @@ [checked]="getPermission(user).checked" [indeterminate]="getPermission(user).indeterminate" (click)="$event.stopPropagation()" - (change)="userSelection(user)" + (change)="handleToggleCategory(user)" > {{ user.title }} @@ -101,7 +101,7 @@ [checked]="getPermission(user).checked" [indeterminate]="getPermission(user).indeterminate" (click)="$event.stopPropagation()" - (change)="userSelection(user)" + (change)="handleToggleCategory(user)" > {{ user.title }} @@ -116,7 +116,7 @@ {{ child.title }} @@ -200,4 +200,8 @@ + +
+ {{ 'igo.context.contextManager.noResult' | translate }} +
diff --git a/packages/context/src/lib/context-manager/context-list/context-list.component.scss b/packages/context/src/lib/context-manager/context-list/context-list.component.scss index 91a6ca8ecc..ef17bd3b9d 100644 --- a/packages/context/src/lib/context-manager/context-list/context-list.component.scss +++ b/packages/context/src/lib/context-manager/context-list/context-list.component.scss @@ -37,3 +37,7 @@ .actions-container { margin-left: 4px; } + +.no-result { + padding: 16px; +} diff --git a/packages/context/src/lib/context-manager/context-list/context-list.component.ts b/packages/context/src/lib/context-manager/context-list/context-list.component.ts index 8c66f2302f..7b12d2a7f3 100644 --- a/packages/context/src/lib/context-manager/context-list/context-list.component.ts +++ b/packages/context/src/lib/context-manager/context-list/context-list.component.ts @@ -15,13 +15,7 @@ import { ActionStore, ActionbarMode } from '@igo2/common'; import { ConfigService, LanguageService, StorageService } from '@igo2/core'; import type { IgoMap } from '@igo2/geo'; -import { - BehaviorSubject, - EMPTY, - ReplaySubject, - Subscription, - timer -} from 'rxjs'; +import { BehaviorSubject, ReplaySubject, Subscription, timer } from 'rxjs'; import { take } from 'rxjs/operators'; import { debounce } from 'rxjs/operators'; @@ -58,7 +52,6 @@ export class ContextListComponent implements OnInit, OnDestroy { } set contexts(value: ContextsList) { this._contexts = value; - this.cdRef.detectChanges(); this.next(); } private _contexts: ContextsList = { ours: [] }; @@ -155,6 +148,14 @@ export class ContextListComponent implements OnInit, OnDestroy { public thresholdToFilter = 5; + get isEmpty(): boolean { + return ( + !this.contexts.ours.length && + !this.contexts.public?.length && + !this.contexts.shared?.length + ); + } + constructor( private cdRef: ChangeDetectorRef, public configService: ConfigService, @@ -168,15 +169,7 @@ export class ContextListComponent implements OnInit, OnDestroy { ngOnInit() { this.change$$ = this.change$ - .pipe( - debounce(() => { - return this.contexts.ours.length === 0 && - this.contexts.public?.length === 0 && - this.contexts.shared?.length === 0 - ? EMPTY - : timer(50); - }) - ) + .pipe(debounce(() => timer(50))) .subscribe(() => { this.contexts$.next(this.filterContextsList(this.contexts)); }); @@ -215,7 +208,7 @@ export class ContextListComponent implements OnInit, OnDestroy { this.change$.next(); } - private filterContextsList(contexts: ContextsList) { + private filterContextsList(contexts: ContextsList): ContextsList { if (this.term === '') { if (this.sortedAlpha) { contexts = this.sortContextsList(contexts); @@ -372,7 +365,7 @@ export class ContextListComponent implements OnInit, OnDestroy { } } - userSelection(user, parent?) { + handleToggleCategory(user, parent?) { const permission = this.getPermission(user); if (permission) { permission.checked = !permission.checked; diff --git a/packages/context/src/locale/en.context.json b/packages/context/src/locale/en.context.json index 50709602ae..bb79493dce 100644 --- a/packages/context/src/locale/en.context.json +++ b/packages/context/src/locale/en.context.json @@ -66,7 +66,8 @@ "contextMapTooltip": "Create a new context from map layers", "hide": "Hide this context", "show": "Show up this context", - "showHidden": "Show hidden contexts" + "showHidden": "Show hidden contexts", + "noResult": "No results for selected filters" }, "contextImportExport": { "export": { diff --git a/packages/context/src/locale/fr.context.json b/packages/context/src/locale/fr.context.json index 2b4e1f3df0..a631fa495c 100644 --- a/packages/context/src/locale/fr.context.json +++ b/packages/context/src/locale/fr.context.json @@ -66,7 +66,8 @@ "contextMapTooltip": "Créer un nouveau contexte à partir des couches la carte", "hide": "Masquer ce contexte", "show": "Montrer ce contexte", - "showHidden": "Montrer les contextes masqués" + "showHidden": "Montrer les contextes masqués", + "noResult": "Aucun résultat pour les filtres sélectionnés" }, "contextImportExport": { "export": {