@fluid-topics/ft-reader-context 2.2.17 → 2.2.19
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-reader-context.d.ts +7 -2
- package/build/ft-reader-context.js +52 -6
- package/build/ft-reader-context.light.js +17 -7
- package/build/ft-reader-context.min.js +34 -24
- package/build/store/FtReaderStateManager.d.ts +6 -1
- package/build/store/FtReaderStateManager.js +111 -41
- package/build/store/model.d.ts +9 -2
- package/build/store/model.js +6 -0
- package/build/store/redux.js +2 -0
- package/build/store/utils/FtOfficialReaderService.d.ts +2 -2
- package/build/store/utils/FtOfficialReaderService.js +4 -2
- package/build/store/utils/FtReaderConverter.d.ts +2 -1
- package/build/store/utils/FtReaderConverter.js +11 -8
- package/build/store/utils/FtReaderService.d.ts +9 -4
- package/build/store/utils/FtReaderService.js +40 -15
- package/package.json +5 -5
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { FtUserRole, userHasRole, } from "@fluid-topics/public-api";
|
|
2
2
|
import { FtReaderFeatures, } from "../model";
|
|
3
3
|
import { ftAppInfoStore, FtServiceWithCache, } from "@fluid-topics/ft-app-context";
|
|
4
|
+
import { SearchPlaceConverter, SearchPlaceQueryParams, } from "@fluid-topics/ft-wc-utils";
|
|
4
5
|
export class FtReaderService extends FtServiceWithCache {
|
|
6
|
+
get metadataFilters() {
|
|
7
|
+
return this._metadataFilters;
|
|
8
|
+
}
|
|
9
|
+
set metadataFilters(value) {
|
|
10
|
+
this._metadataFilters = value;
|
|
11
|
+
}
|
|
5
12
|
get mapId() {
|
|
6
13
|
return this._mapId;
|
|
7
14
|
}
|
|
@@ -11,10 +18,11 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
11
18
|
}
|
|
12
19
|
this._mapId = value;
|
|
13
20
|
}
|
|
14
|
-
constructor(converter, overrideApi, mapId) {
|
|
21
|
+
constructor(converter, overrideApi, mapId, metadataFilters) {
|
|
15
22
|
super(false, overrideApi);
|
|
16
23
|
this.converter = converter;
|
|
17
24
|
this._mapId = mapId;
|
|
25
|
+
this._metadataFilters = metadataFilters;
|
|
18
26
|
this.initCache();
|
|
19
27
|
}
|
|
20
28
|
async withMapId(provider) {
|
|
@@ -23,9 +31,10 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
23
31
|
initCache() {
|
|
24
32
|
this.cache.register("configuration", () => this.api.getReaderConfiguration());
|
|
25
33
|
this.cache.register("map", () => this.withMapId((mapId) => this.fetchMap(mapId)));
|
|
26
|
-
this.cache.register("enrichedToc", () => this.withMapId((mapId) => this.fetchPages(mapId).then((toc) => this.converter.convertPaginatedToc(mapId, toc))));
|
|
34
|
+
this.cache.register(this.makeCacheKey("enrichedToc", undefined, this.metadataFilters), () => this.withMapId((mapId) => this.fetchPages(mapId, this._metadataFilters).then((toc) => this.converter.convertPaginatedToc(mapId, toc))));
|
|
27
35
|
this.cache.register("ratingSummary", () => {
|
|
28
|
-
var _a
|
|
36
|
+
var _a;
|
|
37
|
+
var _b;
|
|
29
38
|
const userHaveRatingRole = userHasRole((_b = (_a = ftAppInfoStore.getState().session) === null || _a === void 0 ? void 0 : _a.profile.roles) !== null && _b !== void 0 ? _b : [], "RATING_USER");
|
|
30
39
|
return userHaveRatingRole ? this.withMapId((mapId) => this.fetchMapRating(mapId)) : Promise.resolve();
|
|
31
40
|
});
|
|
@@ -33,8 +42,10 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
33
42
|
clear() {
|
|
34
43
|
this.cache.clearMatching((key) => key !== "configuration");
|
|
35
44
|
}
|
|
36
|
-
makeCacheKey(base, translationSettings) {
|
|
37
|
-
return base
|
|
45
|
+
makeCacheKey(base, translationSettings, metadataFilters) {
|
|
46
|
+
return base
|
|
47
|
+
+ (translationSettings ? "-destinationLanguage-" + (translationSettings === null || translationSettings === void 0 ? void 0 : translationSettings.destinationLanguage) : "")
|
|
48
|
+
+ (!metadataFilters || metadataFilters.length == 0 ? "" : "-metadataFilters-" + this.hash(metadataFilters));
|
|
38
49
|
}
|
|
39
50
|
getMap(translationSettings) {
|
|
40
51
|
return this.cache.get(this.makeCacheKey("map", translationSettings), () => this.fetchMap(this.mapId, translationSettings));
|
|
@@ -49,10 +60,10 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
49
60
|
this.cache.clear("configuration");
|
|
50
61
|
}
|
|
51
62
|
getEnrichedToc(translationSettings) {
|
|
52
|
-
return this.cache.get(this.makeCacheKey("enrichedToc", translationSettings), () => this.fetchPages(this.mapId, translationSettings).then((toc) => this.converter.convertPaginatedToc(this.mapId, toc)));
|
|
63
|
+
return this.cache.get(this.makeCacheKey("enrichedToc", translationSettings, this.metadataFilters), () => this.fetchPages(this.mapId, this.metadataFilters, translationSettings).then((toc) => this.converter.convertPaginatedToc(this.mapId, toc)));
|
|
53
64
|
}
|
|
54
65
|
getEnrichedTocNow(translationSettings) {
|
|
55
|
-
return this.cache.getNow(this.makeCacheKey("enrichedToc", translationSettings));
|
|
66
|
+
return this.cache.getNow(this.makeCacheKey("enrichedToc", translationSettings, this.metadataFilters));
|
|
56
67
|
}
|
|
57
68
|
async getPaginationConfiguration() {
|
|
58
69
|
const enrichedToc = await this.getEnrichedToc();
|
|
@@ -70,6 +81,10 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
70
81
|
const enrichedToc = await this.getEnrichedToc(translationSettings);
|
|
71
82
|
return enrichedToc.translationError;
|
|
72
83
|
}
|
|
84
|
+
async getFilteredTocNodes(translationSettings) {
|
|
85
|
+
const enrichedToc = await this.getEnrichedToc(translationSettings);
|
|
86
|
+
return enrichedToc.filteredTocNodes;
|
|
87
|
+
}
|
|
73
88
|
async getTocNode(tocId, translationSettings) {
|
|
74
89
|
const enrichedToc = await this.getEnrichedToc(translationSettings);
|
|
75
90
|
return enrichedToc.nodeByTocId[tocId];
|
|
@@ -126,7 +141,7 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
126
141
|
getAttachmentDownloadLink(id) {
|
|
127
142
|
return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(id).content}?download=true&locationValue=reader`);
|
|
128
143
|
}
|
|
129
|
-
getLink(tocId, pageNumber, section) {
|
|
144
|
+
getLink(tocId, pageNumber, section, withMetadataFilter) {
|
|
130
145
|
const navigationData = this.getNavigationData(tocId, pageNumber, section);
|
|
131
146
|
const path = this.getReaderLinkPrefix() + (navigationData.prettyUrl ? navigationData.prettyUrl : `${navigationData.mapId}/${navigationData.tocId}`);
|
|
132
147
|
const url = new URL(path, this.api.tenantBaseUrl);
|
|
@@ -139,8 +154,17 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
139
154
|
if (navigationData.section != null) {
|
|
140
155
|
url.searchParams.set("section", navigationData.section);
|
|
141
156
|
}
|
|
157
|
+
if (withMetadataFilter && navigationData.metadataFilters) {
|
|
158
|
+
const serializeFilters = SearchPlaceConverter.serializeValueFilters(navigationData.metadataFilters);
|
|
159
|
+
if (serializeFilters) {
|
|
160
|
+
url.searchParams.set(SearchPlaceQueryParams.VALUE_FILTERS, serializeFilters);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
142
163
|
return url.href;
|
|
143
164
|
}
|
|
165
|
+
getLinkWithFilter(tocId, pageNumber, section) {
|
|
166
|
+
return this.getLink(tocId, pageNumber, section, true);
|
|
167
|
+
}
|
|
144
168
|
getNavigationData(tocId, pageNumber, section, translationInput) {
|
|
145
169
|
var _a, _b;
|
|
146
170
|
tocId = tocId || "root";
|
|
@@ -157,6 +181,7 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
157
181
|
prettyUrl: prettyUrl != null ? prettyUrl.replace(/^r\//, "") : undefined,
|
|
158
182
|
prettyUrlDuplicated: (_b = enrichedToc === null || enrichedToc === void 0 ? void 0 : enrichedToc.duplicatedPrettyUrls.has(prettyUrl !== null && prettyUrl !== void 0 ? prettyUrl : "")) !== null && _b !== void 0 ? _b : false,
|
|
159
183
|
section: section,
|
|
184
|
+
metadataFilters: this.metadataFilters,
|
|
160
185
|
};
|
|
161
186
|
}
|
|
162
187
|
async getAccurateNavigationData(tocId, pageNumber, section, translationInput) {
|
|
@@ -174,13 +199,10 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
174
199
|
return this.getRatingSummary().then((rm) => rm === null || rm === void 0 ? void 0 : rm.publication);
|
|
175
200
|
}
|
|
176
201
|
getTopicRating(tocId) {
|
|
177
|
-
return this.getRatingSummary().then((rm) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find((t) => t.tocId === tocId),
|
|
182
|
-
} : undefined;
|
|
183
|
-
});
|
|
202
|
+
return this.getRatingSummary().then((rm) => { var _a; return rm ? {
|
|
203
|
+
type: rm.topics.type,
|
|
204
|
+
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find((t) => t.tocId === tocId),
|
|
205
|
+
} : undefined; });
|
|
184
206
|
}
|
|
185
207
|
rateMap(type, value) {
|
|
186
208
|
return this.makeRateMapRequest(type, value).then(() => this.clearRatingIfNecessary());
|
|
@@ -214,6 +236,9 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
214
236
|
}
|
|
215
237
|
buildBreadcrumb(tocId, translationInput) {
|
|
216
238
|
const target = this.getTocNodeNow(tocId, translationInput);
|
|
239
|
+
if (!target) {
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
217
242
|
const breadcrumb = [{ tocId: target.tocId, title: target.title, untranslatedTitle: target.untranslatedTitle }];
|
|
218
243
|
let parent = this.getTocNodeNow(target.parentTocId, translationInput);
|
|
219
244
|
while (parent) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-context",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.19",
|
|
4
4
|
"description": "Context block for integrated reader 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.2.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "2.2.
|
|
22
|
+
"@fluid-topics/ft-app-context": "2.2.19",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "2.2.19",
|
|
24
24
|
"lit": "3.3.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fluid-topics/public-api": "1.0.
|
|
27
|
+
"@fluid-topics/public-api": "1.0.143"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1ae520afe5e3697dee3c95ba254b53a8f7850594"
|
|
30
30
|
}
|