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

Loading…
Cancel
Save