Skip to content

Commit

Permalink
category performance: add configuration to hide entries filter in ent…
Browse files Browse the repository at this point in the history
…ries table
  • Loading branch information
amirch1 committed Aug 6, 2020
1 parent 2ba98b6 commit dffd084
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<app-entry-engagement-filter *ngIf="!_isMultiAccount"
[totalCount]="entriesTableComponent.totalCount"
[dateFilter]="_dateFilter"
[viewConfig]="_viewConfig"
(filterChange)="_onRefineFilterChange($event)"></app-entry-engagement-filter>

<app-entries-table #entriesTableComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { map } from 'rxjs/operators';
@Component({
selector: 'app-engagement-entries-filter',
template: `
<kAutoComplete #searchEntries
<kAutoComplete #searchEntries *ngIf="_showEntryFilter"
appendTo="body"
suggestionItemField="item"
suggestionLabelField="name"
Expand All @@ -26,32 +26,33 @@ export class EntriesEngagementFilterComponent implements OnDestroy {
this._selectedEntries = value;
}
}

@Input() _showEntryFilter = true;

@Output() itemSelected = new EventEmitter();

@ViewChild('searchEntries') _autoComplete: AutoComplete = null;

private _selectedEntries: KalturaMediaEntry[] = [];
private _searchEntriesSubscription: Unsubscribable;

public _entriesProvider = new Subject<SuggestionsProviderData>();

constructor(private _kalturaServerClient: KalturaClient) {
}

ngOnDestroy() {

}

public _searchEntries(event, formControl?): void {
this._entriesProvider.next({ suggestions: [], isLoading: true });

if (this._searchEntriesSubscription) {
// abort previous request
this._searchEntriesSubscription.unsubscribe();
this._searchEntriesSubscription = null;
}

this._searchEntriesSubscription = this._searchEntriesRequest(event.query).subscribe(data => {
const suggestions = [];
(data || []).forEach((suggestedEntry: KalturaMediaEntry) => {
Expand All @@ -72,19 +73,19 @@ export class EntriesEngagementFilterComponent implements OnDestroy {
this._entriesProvider.next({ suggestions: [], isLoading: false, errorMessage: <any>(err.message || err) });
});
}

public _onSuggestionSelected(): void {

const selectedItem = this._autoComplete.getValue() as KalturaMediaEntry;
// clear entry text from component
this._autoComplete.clearValue();

if (selectedItem && !(this._selectedEntries || []).find(entry => entry.id === selectedItem.id)) {
this._selectedEntries.push(selectedItem);
this.itemSelected.emit(selectedItem);
}
}

private _searchEntriesRequest(text: string): Observable<KalturaMediaEntry[]> {
const request = new ESearchSearchEntryAction({
searchParams: new KalturaESearchEntryParams({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{'app.entry.totalEntriesCount' | translate: { '0': totalCount } }}
</span>
<div class="kSearch">
<app-engagement-entries-filter [selectedEntries]="_selectedValues['entries']"
<app-engagement-entries-filter [selectedEntries]="_selectedValues['entries']" [_showEntryFilter]="_showEntryFilter"
(itemSelected)="_onItemSelected($event, 'entries')"></app-engagement-entries-filter>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input } from '@angular/core';
import { KalturaLogger } from '@kaltura-ng/kaltura-logger';
import { FilterComponent } from 'shared/components/filter/filter.component';
import { ViewConfig } from "configuration/view-config";

@Component({
selector: 'app-entry-engagement-filter',
Expand All @@ -10,12 +11,17 @@ import { FilterComponent } from 'shared/components/filter/filter.component';
})
export class EntryEngagementFilterComponent extends FilterComponent {
@Input() totalCount = 0;
@Input() set viewConfig(config: ViewConfig) {
this._showEntryFilter = config.entryFilter !== null && config.entryFilter !== undefined;
}

public _showEntryFilter = true;

public _onItemSelected(item: any, type: string): void {
super._onItemSelected(item, type);
this._apply();
}

public _apply(forceApply = false): void {
super._apply(forceApply);
this._bottomPadding = '0';
Expand Down
1 change: 1 addition & 0 deletions src/configuration/view-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const viewsConfig = {
userFilter: {},
userLink: {},
entryDrilldown: {},
entryFilter: {},
entryLink: {}
},
topVideos: {},
Expand Down

0 comments on commit dffd084

Please sign in to comment.