Skip to content

Commit

Permalink
implemented #893 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitzarkar committed Nov 7, 2024
1 parent 532bf13 commit 4ab2b49
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/components/layer-table/layer-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,11 @@ export class LayerTable {
*/
protected _searchExpression: string;

/**
* number[]: selected features from table
*/
protected _tempSelectedIds: number[];

//--------------------------------------------------------------------------
//
// Watch handlers
Expand Down Expand Up @@ -946,18 +951,36 @@ export class LayerTable {
*
*/
protected async _searchFullText(): Promise<void> {
let selectedIds = [];
let showSelected = false;
if (this._showOnlySelected) {
selectedIds = this._tempSelectedIds;
showSelected = true;
} else {
this._clearSelection();
this._tempSelectedIds = [];
}
//always clear previous search definition
if (this._searchExpression) {
this._clearSearchDefinitionExpression();
}
let searchedIds = [];
if (this._fullTextSearchInfo.length) {
if (this._fullTextSearchInfo[0].searchTerm) {
const searchQueryParams = this._layer.createQuery();
(searchQueryParams as any).fullText = this._fullTextSearchInfo;
const searchedIds = await this._layer.queryObjectIds(searchQueryParams);
searchedIds = await this._layer.queryObjectIds(searchQueryParams);
if (showSelected && selectedIds?.length) {
searchedIds = searchedIds.filter((id) => selectedIds.includes(id));
}
await this._updateSearchDefinitionExpression(searchedIds?.length ? searchedIds : [-1]);
}
}
// highlight the feature only when selected feature is present in applied filter
if (showSelected && searchedIds?.length) {
this._showOnlySelected = true;
this._table.highlightIds.addMany(searchedIds.reverse());
}
//Added timeout and table.refresh() to avoid the issue in which we see empty table records after searching in combination to filter/reset filter
await new Promise(resolve => setTimeout(resolve, 800));
await this._updateAllIds();
Expand Down Expand Up @@ -1887,6 +1910,7 @@ export class LayerTable {
// only readd in specific case where we have multiple selected and then click one of the currently selected
const reAdd = this.selectedIds.length > 1 && evt.removed.length === 1;
const newIds = reAdd ? evt.removed : ids.filter(id => this.selectedIds.indexOf(id) < 0);
this._tempSelectedIds = newIds.length ? [...newIds] : [...this.selectedIds];
this._clearSelection();
this.selectedIds = [...newIds];
if (newIds.length > 0) {
Expand All @@ -1897,9 +1921,11 @@ export class LayerTable {
} else {
// https://github.com/Esri/solutions-components/issues/365
this.selectedIds = ids.reverse();
this._tempSelectedIds = [...this.selectedIds];
}
} else if (this._ctrlIsPressed) {
this.selectedIds = ids.reverse();
this._tempSelectedIds = [...this.selectedIds];
} else if (this._shiftIsPressed && ids?.length > 0) {
this._skipOnChange = true;
this._previousCurrentId = this._currentId;
Expand Down Expand Up @@ -1938,8 +1964,8 @@ export class LayerTable {
}, []);

const selectedIds = _start < _end ? idsInRange.reverse() : idsInRange;
this.selectedIds = [...new Set([...selectedIds, ...this.selectedIds])]

this.selectedIds = [...new Set([...selectedIds, ...this.selectedIds])];
this._tempSelectedIds = [...this.selectedIds];
this._table.highlightIds.addMany(this.selectedIds.filter(i => ids.indexOf(i) < 0));
}
}
Expand Down

0 comments on commit 4ab2b49

Please sign in to comment.