Browse Source

UI: Improved search in table, added eventEmits

pull/9021/head
Vladyslav_Prykhodko 3 years ago
parent
commit
bd50d1a9ef
  1. 2
      ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts
  2. 31
      ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/relation/relation-table.component.ts
  4. 2
      ui-ngx/src/app/modules/home/components/vc/entity-versions-table.component.ts

2
ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts

@ -298,7 +298,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
this.selectedWidgetsBundleAlias = null; this.selectedWidgetsBundleAlias = null;
this.attributeScope = this.defaultAttributeScope; this.attributeScope = this.defaultAttributeScope;
this.pageLink.textSearch = null; this.pageLink.textSearch = null;
this.textSearch.reset(); this.textSearch.reset('', {emitEvent: false});
if (this.viewsInited) { if (this.viewsInited) {
this.paginator.pageIndex = 0; this.paginator.pageIndex = 0;
const sortable = this.sort.sortables.get('key'); const sortable = this.sort.sortables.get('key');

31
ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts

@ -275,7 +275,7 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
const decodedTextSearch = decodeURI(textSearchParam); const decodedTextSearch = decodeURI(textSearchParam);
this.textSearchMode = true; this.textSearchMode = true;
this.pageLink.textSearch = decodedTextSearch.trim(); this.pageLink.textSearch = decodedTextSearch.trim();
this.textSearch.setValue(decodedTextSearch); this.textSearch.setValue(decodedTextSearch, {emitEvent: false});
} }
} }
this.dataSource = this.entitiesTableConfig.dataSource(this.dataLoaded.bind(this)); this.dataSource = this.entitiesTableConfig.dataSource(this.dataLoaded.bind(this));
@ -309,25 +309,24 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
} }
ngAfterViewInit() { ngAfterViewInit() {
this.textSearch.valueChanges.pipe( this.textSearch.valueChanges.pipe(
debounceTime(150), debounceTime(150),
distinctUntilChanged((prev, current) => (this.pageLink.textSearch ?? '') === current.trim()), distinctUntilChanged((prev, current) => (this.pageLink.textSearch ?? '') === current.trim()),
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe(value => { ).subscribe(value => {
const queryParams: PageQueryParam = {}; if (this.pageMode) {
if (isNotEmptyStr(value)) { const queryParams: PageQueryParam = {
queryParams.textSearch = encodeURI(value); textSearch: isNotEmptyStr(value) ? encodeURI(value) : null,
this.pageLink.textSearch = value.trim(); page: null
};
this.updatedRouterParamsAndData(queryParams);
} else { } else {
queryParams.textSearch = null; this.pageLink.textSearch = isNotEmptyStr(value) ? value.trim() : null;
this.pageLink.textSearch = null; if (this.displayPagination) {
} this.paginator.pageIndex = 0;
if (this.displayPagination) { }
this.paginator.pageIndex = 0; this.updateData();
queryParams.page = null;
} }
this.updatedRouterParamsAndData(queryParams);
}); });
if (this.pageMode) { if (this.pageMode) {
@ -346,9 +345,11 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
const decodedTextSearch = decodeURI(textSearchParam); const decodedTextSearch = decodeURI(textSearchParam);
this.textSearchMode = true; this.textSearchMode = true;
this.pageLink.textSearch = decodedTextSearch.trim(); this.pageLink.textSearch = decodedTextSearch.trim();
this.textSearch.setValue(decodedTextSearch); this.textSearch.setValue(decodedTextSearch, {emitEvent: false});
} else { } else {
this.textSearchMode = false;
this.pageLink.textSearch = null; this.pageLink.textSearch = null;
this.textSearch.reset('', {emitEvent: false});
} }
this.updateData(); this.updateData();
}); });
@ -596,7 +597,7 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
resetSortAndFilter(update: boolean = true, preserveTimewindow: boolean = false) { resetSortAndFilter(update: boolean = true, preserveTimewindow: boolean = false) {
this.textSearchMode = false; this.textSearchMode = false;
this.pageLink.textSearch = null; this.pageLink.textSearch = null;
this.textSearch.reset(); this.textSearch.reset('', {emitEvent: false});
if (this.entitiesTableConfig.useTimePageLink && !preserveTimewindow) { if (this.entitiesTableConfig.useTimePageLink && !preserveTimewindow) {
this.timewindow = this.entitiesTableConfig.defaultTimewindowInterval; this.timewindow = this.entitiesTableConfig.defaultTimewindowInterval;
} }

2
ui-ngx/src/app/modules/home/components/relation/relation-table.component.ts

@ -214,7 +214,7 @@ export class RelationTableComponent extends PageComponent implements AfterViewIn
this.direction = EntitySearchDirection.FROM; this.direction = EntitySearchDirection.FROM;
this.updateColumns(); this.updateColumns();
this.pageLink.textSearch = null; this.pageLink.textSearch = null;
this.textSearch.reset(); this.textSearch.reset('', {emitEvent: false});
this.paginator.pageIndex = 0; this.paginator.pageIndex = 0;
const sortable = this.sort.sortables.get('type'); const sortable = this.sort.sortables.get('type');
this.sort.active = sortable.id; this.sort.active = sortable.id;

2
ui-ngx/src/app/modules/home/components/vc/entity-versions-table.component.ts

@ -378,7 +378,7 @@ export class EntityVersionsTableComponent extends PageComponent implements OnIni
private resetSortAndFilter(update: boolean) { private resetSortAndFilter(update: boolean) {
this.textSearchMode = false; this.textSearchMode = false;
this.pageLink.textSearch = null; this.pageLink.textSearch = null;
this.textSearch.reset(); this.textSearch.reset('', {emitEvent: false});
if (this.viewsInited) { if (this.viewsInited) {
this.paginator.pageIndex = 0; this.paginator.pageIndex = 0;
const sortable = this.sort.sortables.get('timestamp'); const sortable = this.sort.sortables.get('timestamp');

Loading…
Cancel
Save