Skip to content

Commit

Permalink
Highlights search fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Nov 6, 2023
1 parent 087f8c2 commit 6028fde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
15 changes: 0 additions & 15 deletions scripts/core/ArticlesListByQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,6 @@ class ArticlesListByQueryComponent extends SuperdeskReactComponent<IPropsInner,
shouldReloadTheList={(changedFields) => {
// TEMPORARY FIX FOR SDESK-6157
return false;

/** TODO: Have websockets transmit the diff.
* The component should not update when field value changes do not affect the query -
* for example, if the query is {desk: 'X'} and an update is about an item moved
* from desk Y to Z.
*/

const queryFields = getQueryFieldsRecursive(this.props.query.filter);

// add sorting fields
flatMap(this.props.query.sort, (option) => Object.keys(option)).forEach((sortField) => {
queryFields.add(sortField);
});

return Array.from(changedFields).some((changedField) => queryFields.has(changedField));
}}
onItemClick={this.props.onItemClick}
onItemDoubleClick={this.props.onItemDoubleClick}
Expand Down
15 changes: 11 additions & 4 deletions scripts/core/query-formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function toElasticQuery(q: ISuperdeskQuery): {q?: string; source: string}
query?: {
filtered: {
filter?: {};
query?: {};
};
};
sort: ISuperdeskQuery['sort'];
Expand All @@ -142,14 +143,20 @@ export function toElasticQuery(q: ISuperdeskQuery): {q?: string; source: string}
};
}

if (q.fullTextSearch) {
query.query.filtered.query = {
query_string: {
query: q.fullTextSearch,
lenient: true,
default_operator: 'AND',
},
};
}

const result: ReturnType<typeof toElasticQuery> = {
source: JSON.stringify(query),
};

if (q.fullTextSearch != null) {
result.q = q.fullTextSearch;
}

return result;
}

Expand Down

0 comments on commit 6028fde

Please sign in to comment.