Fixed false visible items in the agenda

The fix has to be reworked with #4671 and can be eliminated with #4639
This commit is contained in:
FinnStutzenstein 2019-05-13 13:42:03 +02:00
parent ba9fcef5a1
commit c860f45041
3 changed files with 29 additions and 6 deletions

View File

@ -50,7 +50,7 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
/**
* stores the currently used raw data to be used for the filter
*/
private currentRawData: V[];
protected currentRawData: V[];
/**
* The currently used filters.
@ -110,7 +110,7 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
/**
* Constructor.
*/
public constructor(private store: StorageService, private repo: BaseRepository<V, BaseModel>) {}
public constructor(protected store: StorageService, protected repo: BaseRepository<V, BaseModel>) {}
/**
* Initializes the filterService. Returns the filtered data as Observable
@ -192,7 +192,7 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
* check their match with current definitions and set the current filter
* @param definitions: Currently defined Filter definitions
*/
private loadStorageDefinition(definitions: OsFilter[]): void {
protected loadStorageDefinition(definitions: OsFilter[]): void {
if (!definitions || !definitions.length) {
return;
}
@ -250,7 +250,7 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
/**
* Takes an array of data and applies current filters
*/
private filterData(data: V[]): V[] {
protected filterData(data: V[]): V[] {
const filteredData = [];
if (!data) {
return filteredData;

View File

@ -1,11 +1,14 @@
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { auditTime, map } from 'rxjs/operators';
import { BaseFilterListService, OsFilter, OsFilterOption } from 'app/core/ui-services/base-filter-list.service';
import { itemVisibilityChoices } from 'app/shared/models/agenda/item';
import { ViewItem } from '../models/view-item';
import { StorageService } from 'app/core/core-services/storage.service';
import { ItemRepositoryService } from 'app/core/repositories/agenda/item-repository.service';
import { TranslateService } from '@ngx-translate/core';
@Injectable({
providedIn: 'root'
@ -41,6 +44,26 @@ export class AgendaFilterListService extends BaseFilterListService<ViewItem> {
this.updateFilterDefinitions(this.filterOptions);
}
/**
* @override from base filter list service: Added custom filtering of items
* Initializes the filterService. Returns the filtered data as Observable
*/
public filter(): Observable<ViewItem[]> {
this.repo
.getViewModelListObservable()
.pipe(auditTime(10))
// Exclude items that are just there to provide a list of speakers. They have many
// restricted fields and must not be shown in the agenda!
.pipe(map(itemList => itemList.filter(item => item.type !== undefined)))
.subscribe(data => {
this.currentRawData = data;
this.filteredData = this.filterData(data);
this.filterDataOutput.next(this.filteredData);
});
this.loadStorageDefinition(this.filterDefinitions);
return this.filterDataOutput;
}
private createVisibilityFilterOptions(): OsFilterOption[] {
const options = [];
itemVisibilityChoices.forEach(choice => {

View File

@ -2,13 +2,13 @@ import { MatTableDataSource, MatTable, MatSort, MatPaginator, MatSnackBar, PageE
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { ViewChild, Type, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { BaseViewComponent } from './base-view';
import { BaseViewModel } from './base-view-model';
import { BaseSortListService } from 'app/core/ui-services/base-sort-list.service';
import { BaseFilterListService } from 'app/core/ui-services/base-filter-list.service';
import { BaseModel } from 'app/shared/models/base/base-model';
import { ActivatedRoute } from '@angular/router';
import { StorageService } from 'app/core/core-services/storage.service';
export abstract class ListViewBaseComponent<V extends BaseViewModel, M extends BaseModel> extends BaseViewComponent