@fluid-topics/ft-search-context 2.1.18 → 2.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ft-search-context.d.ts +0 -1
- package/build/ft-search-context.js +7 -9
- package/build/ft-search-context.light.js +5 -5
- package/build/ft-search-context.min.js +17 -17
- package/build/store/FtAnalyticsSearchEventManager.js +4 -4
- package/build/store/FtSearchStateManager.d.ts +5 -2
- package/build/store/FtSearchStateManager.js +30 -10
- package/build/store/utils/analytics-utils.js +7 -7
- package/build/utils.js +3 -3
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { accessResult, watch } from "@fluid-topics/ft-wc-utils";
|
|
2
|
-
import { FtAnalyticsEventName, FtAnalyticsPublicationType, FtSearchResultType } from "@fluid-topics/public-api";
|
|
3
|
-
import { FtAnalyticsEventsService, ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
4
|
-
import { convertMetadataFilterToAnalyticsFacet, getAnalyticsLastUpdate } from "./utils/analytics-utils";
|
|
1
|
+
import { accessResult, watch, } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtAnalyticsEventName, FtAnalyticsPublicationType, FtSearchResultType, } from "@fluid-topics/public-api";
|
|
3
|
+
import { FtAnalyticsEventsService, ftAppInfoStore, } from "@fluid-topics/ft-app-context";
|
|
4
|
+
import { convertMetadataFilterToAnalyticsFacet, getAnalyticsLastUpdate, } from "./utils/analytics-utils";
|
|
5
5
|
export class FtAnalyticsSearchEventManager {
|
|
6
6
|
constructor(store, eventService) {
|
|
7
7
|
this.store = store;
|
|
@@ -18,8 +18,10 @@ export declare class FtSearchStateManager extends FtStateManager {
|
|
|
18
18
|
constructor(store: FtReduxStore<FtSearchPageState, FtSearchPageStateReducers>, service?: FtSearchService);
|
|
19
19
|
onNewNeededRequest: (neededRequest: string) => void;
|
|
20
20
|
initService(): Promise<boolean>;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
addListeners(): void;
|
|
22
|
+
removeListeners(): void;
|
|
23
|
+
private get recentQueriesStorageKey();
|
|
24
|
+
private get taruqaConfigStorageKey();
|
|
23
25
|
private onStorageEvent;
|
|
24
26
|
private updateSearchRequest;
|
|
25
27
|
setQuery(query: string): void;
|
|
@@ -56,6 +58,7 @@ export declare class FtSearchStateManager extends FtStateManager {
|
|
|
56
58
|
setIgnoreEmptyQuery(ignoreEmptyQuery: boolean): void;
|
|
57
59
|
setOpenExternalDocumentInNewTab(openExternalDocumentInNewTab: boolean): void;
|
|
58
60
|
setCanUpdateUiLocale(canUpdateUiLocale: boolean): void;
|
|
61
|
+
private loadTaruqaTemplate;
|
|
59
62
|
private loadRecentQueries;
|
|
60
63
|
addRecentQuery(query: string): void;
|
|
61
64
|
removeRecentQuery(query: string): void;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { FtSearchStateResourceRequest, } from "./model";
|
|
2
2
|
import { cancelable, CanceledPromiseError, Debouncer, deepCopy, FtStateManager, minmax, watch, } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { createSearchPageStore, } from "./redux";
|
|
4
|
-
import { FtSearchKeywordMatch, FtSearchScope, FtVirtualField, } from "@fluid-topics/public-api";
|
|
4
|
+
import { FtSearchKeywordMatch, FtSearchScope, FtUserRole, FtVirtualField, userHasRole, } from "@fluid-topics/public-api";
|
|
5
5
|
import { FtSearchService } from "./utils/FtSearchService";
|
|
6
6
|
import { ClearAllFiltersEvent } from "../utils";
|
|
7
|
-
import { ftAppStateManager } from "@fluid-topics/ft-app-context";
|
|
7
|
+
import { AuthenticationChangeEvent, ftAppInfoStore, ftAppStateManager, } from "@fluid-topics/ft-app-context";
|
|
8
8
|
export const searchInDocumentTitlesOnlySelector = (s) => s.request.virtualField === FtVirtualField.TITLE_ONLY
|
|
9
9
|
&& s.request.scope === FtSearchScope.DOCUMENTS;
|
|
10
10
|
export const keywordMatchSelector = (s) => s.request.keywordMatch == FtSearchKeywordMatch.MANDATORY;
|
|
11
|
-
const recentQueriesStorageKey = "ft-recent-queries";
|
|
12
11
|
const maxRecentQueries = 20;
|
|
13
12
|
export class FtSearchStateManager extends FtStateManager {
|
|
14
13
|
static build(id, service) {
|
|
@@ -27,9 +26,21 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
27
26
|
};
|
|
28
27
|
this.onStorageEvent = (e) => {
|
|
29
28
|
// detect changes from any context
|
|
30
|
-
if (e.key === recentQueriesStorageKey) {
|
|
29
|
+
if (e.key === this.recentQueriesStorageKey) {
|
|
31
30
|
this.loadRecentQueries();
|
|
32
31
|
}
|
|
32
|
+
else if (e.key === this.taruqaConfigStorageKey) {
|
|
33
|
+
this.loadTaruqaTemplate();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.loadTaruqaTemplate = () => {
|
|
37
|
+
var _a;
|
|
38
|
+
let taruqaTemplateOverride;
|
|
39
|
+
if (userHasRole(ftAppInfoStore.getState().session, FtUserRole.DEBUG_USER)) {
|
|
40
|
+
const config = JSON.parse((_a = window.localStorage.getItem(this.taruqaConfigStorageKey)) !== null && _a !== void 0 ? _a : "{}");
|
|
41
|
+
taruqaTemplateOverride = config.overrideEnabled ? config.template : undefined;
|
|
42
|
+
}
|
|
43
|
+
this.updateSearchRequest({ taruqaTemplateOverride, changedByConfiguration: true });
|
|
33
44
|
};
|
|
34
45
|
this.localesDebouncer = new Debouncer(10);
|
|
35
46
|
this.searchDebouncer = new Debouncer(100);
|
|
@@ -74,13 +85,22 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
74
85
|
this.setSortId(this.store.getState().request.sortId);
|
|
75
86
|
});
|
|
76
87
|
this.loadRecentQueries();
|
|
88
|
+
this.loadTaruqaTemplate();
|
|
77
89
|
return this.launchSearch();
|
|
78
90
|
}
|
|
79
|
-
|
|
91
|
+
addListeners() {
|
|
80
92
|
window.addEventListener("storage", this.onStorageEvent);
|
|
93
|
+
ftAppInfoStore.addEventListener(AuthenticationChangeEvent.eventName, this.loadTaruqaTemplate);
|
|
81
94
|
}
|
|
82
|
-
|
|
95
|
+
removeListeners() {
|
|
83
96
|
window.removeEventListener("storage", this.onStorageEvent);
|
|
97
|
+
ftAppInfoStore.removeEventListener(AuthenticationChangeEvent.eventName, this.loadTaruqaTemplate);
|
|
98
|
+
}
|
|
99
|
+
get recentQueriesStorageKey() {
|
|
100
|
+
return ftAppInfoStore.getState().tenantId + "-ft-recent-queries";
|
|
101
|
+
}
|
|
102
|
+
get taruqaConfigStorageKey() {
|
|
103
|
+
return ftAppInfoStore.getState().tenantId + "-taruqa-experiment-conf";
|
|
84
104
|
}
|
|
85
105
|
updateSearchRequest(partialRequest, resetPaging = false) {
|
|
86
106
|
const request = deepCopy(this.store.getState().request);
|
|
@@ -111,7 +131,7 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
111
131
|
}
|
|
112
132
|
this.updateSearchRequest({ contentLocale, metadataFilters: [] }, true);
|
|
113
133
|
if (this.canUpdateUiLocale && ((_b = ftAppStateManager.store.getState().localesConfiguration) === null || _b === void 0 ? void 0 : _b.searchLanguageSetsUiLanguage) && contentLocale) {
|
|
114
|
-
ftAppStateManager.requestUiLocaleUpdate(contentLocale);
|
|
134
|
+
ftAppStateManager.requestUiLocaleUpdate(contentLocale, contentLocale);
|
|
115
135
|
}
|
|
116
136
|
}
|
|
117
137
|
return contentLocale;
|
|
@@ -306,7 +326,7 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
306
326
|
}
|
|
307
327
|
loadRecentQueries() {
|
|
308
328
|
var _a;
|
|
309
|
-
this.store.actions.recentQueries(JSON.parse((_a = window.localStorage.getItem(recentQueriesStorageKey)) !== null && _a !== void 0 ? _a : "[]"));
|
|
329
|
+
this.store.actions.recentQueries(JSON.parse((_a = window.localStorage.getItem(this.recentQueriesStorageKey)) !== null && _a !== void 0 ? _a : "[]"));
|
|
310
330
|
}
|
|
311
331
|
addRecentQuery(query) {
|
|
312
332
|
query = query.trim();
|
|
@@ -328,10 +348,10 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
328
348
|
}
|
|
329
349
|
setRecentQueries(queries) {
|
|
330
350
|
const newValue = JSON.stringify(queries);
|
|
331
|
-
window.localStorage.setItem(recentQueriesStorageKey, newValue);
|
|
351
|
+
window.localStorage.setItem(this.recentQueriesStorageKey, newValue);
|
|
332
352
|
// notify all contexts
|
|
333
353
|
window.dispatchEvent(new StorageEvent("storage", {
|
|
334
|
-
key: recentQueriesStorageKey,
|
|
354
|
+
key: this.recentQueriesStorageKey,
|
|
335
355
|
newValue,
|
|
336
356
|
storageArea: window.localStorage,
|
|
337
357
|
url: window.location.href,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export function getAnalyticsLastUpdate(facets) {
|
|
2
2
|
return facets
|
|
3
|
-
.filter(f => f.key ===
|
|
4
|
-
.filter(f => !f.valueFilter)
|
|
5
|
-
.map(f => {
|
|
3
|
+
.filter((f) => f.key === "ft:lastEdition")
|
|
4
|
+
.filter((f) => !f.valueFilter)
|
|
5
|
+
.map((f) => {
|
|
6
6
|
if (f.dateFilter) {
|
|
7
7
|
return f.dateFilter.type;
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return "CUSTOM";
|
|
10
10
|
}).shift();
|
|
11
11
|
}
|
|
12
12
|
export function convertMetadataFilterToAnalyticsFacet(facet) {
|
|
@@ -15,7 +15,7 @@ export function convertMetadataFilterToAnalyticsFacet(facet) {
|
|
|
15
15
|
return {
|
|
16
16
|
key: facet.key,
|
|
17
17
|
type: "DATE",
|
|
18
|
-
dateValue: facet.dateFilter.type
|
|
18
|
+
dateValue: facet.dateFilter.type,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
else if (facet.rangeFilter) {
|
|
@@ -23,14 +23,14 @@ export function convertMetadataFilterToAnalyticsFacet(facet) {
|
|
|
23
23
|
key: facet.key,
|
|
24
24
|
type: "RANGE",
|
|
25
25
|
from: facet.rangeFilter.from,
|
|
26
|
-
to: facet.rangeFilter.to
|
|
26
|
+
to: facet.rangeFilter.to,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
return {
|
|
31
31
|
key: facet.key,
|
|
32
32
|
values: (_a = facet.valueFilter) === null || _a === void 0 ? void 0 : _a.values,
|
|
33
|
-
negative: (_b = facet.valueFilter) === null || _b === void 0 ? void 0 : _b.negative
|
|
33
|
+
negative: (_b = facet.valueFilter) === null || _b === void 0 ? void 0 : _b.negative,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
}
|
package/build/utils.js
CHANGED
|
@@ -10,17 +10,17 @@ export class SearchResultOpenContextMenuEvent extends CustomEvent {
|
|
|
10
10
|
}
|
|
11
11
|
export class LoadErrorEvent extends CustomEvent {
|
|
12
12
|
constructor(e) {
|
|
13
|
-
super("ft-search-load-error", { detail: e });
|
|
13
|
+
super("ft-search-load-error", { detail: e, composed: true, bubbles: true });
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
export class SearchRequestChangeEvent extends CustomEvent {
|
|
17
17
|
constructor(request) {
|
|
18
|
-
super("ft-search-request-change", { detail: request });
|
|
18
|
+
super("ft-search-request-change", { detail: request, composed: true, bubbles: true });
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
export class SearchResultsChangeEvent extends CustomEvent {
|
|
22
22
|
constructor(request, paging, spellcheck) {
|
|
23
|
-
super("ft-search-results-change", { detail: { request, paging, spellcheck } });
|
|
23
|
+
super("ft-search-results-change", { detail: { request, paging, spellcheck }, composed: true, bubbles: true });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
export class ClearAllFiltersEvent extends Event {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-context",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.20",
|
|
4
4
|
"description": "Context block for integrated search components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "2.1.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "2.1.
|
|
22
|
+
"@fluid-topics/ft-app-context": "2.1.20",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "2.1.20",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fluid-topics/public-api": "1.0.
|
|
27
|
+
"@fluid-topics/public-api": "1.0.136"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "77e9f03085f977dde887e175b964bf66b862253f"
|
|
30
30
|
}
|