diff --git a/CHANGELOG.md b/CHANGELOG.md index a35cbcb6..9b66d1f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Sidebar: Collapse and expand attribute sections [#199](https://github.com/spraakbanken/korp-frontend/issues/199) - Error messages from backend show up in the GUI [#97](https://github.com/spraakbanken/korp-frontend/issues/97) - Catch unhandled errors and show in dialog [#419](https://github.com/spraakbanken/korp-frontend/issues/419) +- Save searches from extended mode [#118](https://github.com/spraakbanken/korp-frontend/issues/118) ### Changed diff --git a/app/scripts/components/search-history.ts b/app/scripts/components/search-history.ts index da0ab49f..57c4ecd7 100644 --- a/app/scripts/components/search-history.ts +++ b/app/scripts/components/search-history.ts @@ -30,6 +30,7 @@ const createSearchOption = (params: SearchParams): SearchOption => ({ const getLabel = (params: SearchParams): string => { if (!params.search) return "–" + if (params.search == "cqp") return params.cqp || "–" const [type, value] = splitFirst("|", params.search) return type === "lemgram" ? unregescape(value) : value } diff --git a/app/scripts/services/searches.ts b/app/scripts/services/searches.ts index 7d4ee1b1..a1c29dca 100644 --- a/app/scripts/services/searches.ts +++ b/app/scripts/services/searches.ts @@ -67,18 +67,19 @@ angular.module("korpApp").factory("searches", [ // The value is a string like | const [type, ...valueSplit] = searchExpr.split("|") let value = valueSplit.join("|") - - // Store new query in search history - // For Extended search, `value` is empty (then the CQP is instead in the `cqp` URL param) - if (value) { - searchHistory.addItem($location.search()) - } $q.all([searches.langDef.promise, $rootScope.globalFilterDef.promise]).then(function () { + // For Extended search, the CQP is instead in the `cqp` URL param if (type === "cqp") { if (!value) { value = $location.search().cqp || "" } } + + // Store new query in search history + if (value) { + searchHistory.addItem($location.search()) + } + // Update stored search query if (["cqp", "word", "lemgram"].includes(type)) { $rootScope.activeSearch = { type, val: value } diff --git a/app/scripts/urlparams.ts b/app/scripts/urlparams.ts index 316952b1..e033ab93 100644 --- a/app/scripts/urlparams.ts +++ b/app/scripts/urlparams.ts @@ -77,20 +77,23 @@ export type SortMethod = "" | "keyword" | "left" | "right" | "random" export type SearchParams = Pick -/** Parameters that define a search result set */ -export type SearchParamNames = +export type SearchParamNames = Extract< + keyof HashParams, | "corpus" | "cqp" | "global_filter" | "in_order" | "parallel_corpora" | "search" + | "search_tab" | "within" | "prefix" | "mid_comp" | "suffix" | "isCaseInsensitive" +> +/** Parameters that define a search result set */ export const getSearchParamNames = (): SearchParamNames[] => [ "corpus", "cqp", @@ -98,6 +101,7 @@ export const getSearchParamNames = (): SearchParamNames[] => [ "in_order", "parallel_corpora", "search", + "search_tab", "within", "prefix", "mid_comp",