Skip to content

Commit

Permalink
fix element removal
Browse files Browse the repository at this point in the history
  • Loading branch information
boal committed Nov 17, 2023
1 parent 75d6b3e commit f030ae1
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions frontend/src/store/modules/SearchStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,20 @@ export default {
state.searchResults = searchResults;
},
removeSearchResultById(state: SearchState, id: string): void {
_.remove(_.toArray(state.searchResults.searchResults), function (searchResult: SearchResultDto) {
return (
(_.isEqual(searchResult.type, SearchResultDtoTypeEnum.Abfrage) &&
_.isEqual(id, (searchResult as AbfrageSearchResultDto).id)) ||
(_.isEqual(searchResult.type, SearchResultDtoTypeEnum.Bauvorhaben) &&
_.isEqual(id, (searchResult as BauvorhabenSearchResultDto).id)) ||
(_.isEqual(searchResult.type, SearchResultDtoTypeEnum.Infrastruktureinrichtung) &&
_.isEqual(id, (searchResult as BauvorhabenSearchResultDto).id))
);
});
const searchResults = _.cloneDeep(state.searchResults);
searchResults.searchResults = _.toArray(state.searchResults.searchResults).filter(
(searchResult: SearchResultDto) => {
return !(
(_.isEqual(searchResult.type, SearchResultDtoTypeEnum.Abfrage) &&
_.isEqual(id, (searchResult as AbfrageSearchResultDto).id)) ||
(_.isEqual(searchResult.type, SearchResultDtoTypeEnum.Bauvorhaben) &&
_.isEqual(id, (searchResult as BauvorhabenSearchResultDto).id)) ||
(_.isEqual(searchResult.type, SearchResultDtoTypeEnum.Infrastruktureinrichtung) &&
_.isEqual(id, (searchResult as BauvorhabenSearchResultDto).id))
);
},
);
state.searchResults = searchResults;
},
requestSearchQueryAndSorting(state: SearchState, searchQueryAndSortingDto: SearchQueryAndSortingModel): void {
state.requestSearchQueryAndSorting = searchQueryAndSortingDto;
Expand Down

0 comments on commit f030ae1

Please sign in to comment.