@fluid-topics/ft-viewer 2.1.19 → 2.1.21
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/asset/ft-asset-viewer-context.js +1 -1
- package/build/common/model/FtViewerReduxStore.js +4 -0
- package/build/common/model/ft-viewer.models.d.ts +6 -1
- package/build/common/utils/MetadataValueLocalizer.d.ts +8 -0
- package/build/common/utils/MetadataValueLocalizer.js +20 -0
- package/build/definitions.d.ts +3 -1
- package/build/definitions.js +3 -1
- package/build/ft-viewer.light.js +1795 -217
- package/build/ft-viewer.min.js +1753 -182
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/ud/components/ft-ud-viewer-feedback.d.ts +53 -0
- package/build/ud/components/ft-ud-viewer-feedback.js +257 -0
- package/build/ud/components/ft-ud-viewer-feedback.styles.d.ts +2 -0
- package/build/ud/components/ft-ud-viewer-feedback.styles.js +13 -0
- package/build/ud/components/ft-ud-viewer-metadata.d.ts +37 -0
- package/build/ud/components/ft-ud-viewer-metadata.js +231 -0
- package/build/ud/components/ft-ud-viewer-metadata.properties.d.ts +10 -0
- package/build/ud/components/ft-ud-viewer-metadata.properties.js +1 -0
- package/build/ud/components/ft-ud-viewer-metadata.styles.d.ts +2 -0
- package/build/ud/components/ft-ud-viewer-metadata.styles.js +24 -0
- package/build/ud/components/ft-viewer-feedback.d.ts +4 -0
- package/build/ud/components/ft-viewer-feedback.js +6 -0
- package/build/ud/components/registration.d.ts +1 -0
- package/build/ud/components/registration.js +11 -0
- package/build/ud/ft-ud-viewer-context.d.ts +1 -0
- package/build/ud/ft-ud-viewer-context.js +18 -2
- package/build/ud/ft-ud-viewer.messages.d.ts +1 -0
- package/build/ud/ft-ud-viewer.messages.js +1 -0
- package/build/ud/index.d.ts +4 -0
- package/build/ud/index.js +4 -0
- package/build/ud/model/FtUdViewerService.d.ts +10 -3
- package/build/ud/model/FtUdViewerService.js +48 -2
- package/build/ud/model/FtUdViewerStateManager.d.ts +16 -1
- package/build/ud/model/FtUdViewerStateManager.js +79 -5
- package/build/ud/model/ft-ud-viewer.models.d.ts +11 -1
- package/build/ud/model/ft-ud-viewer.models.js +7 -0
- package/build/utils/events.d.ts +14 -0
- package/build/utils/events.js +17 -0
- package/package.json +10 -8
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FtBaseFeedback } from "@fluid-topics/ft-reader-feedback/build/ft-base-feedback";
|
|
2
|
+
import { generateFeedbackStyles } from "@fluid-topics/ft-reader-feedback/build/ft-base-feedback.styles";
|
|
3
|
+
import { FtViewerFeedbackCssVariables } from "./ft-ud-viewer-feedback.styles";
|
|
4
|
+
export class FtViewerFeedback extends FtBaseFeedback {
|
|
5
|
+
}
|
|
6
|
+
FtViewerFeedback.styles = generateFeedbackStyles(FtViewerFeedbackCssVariables);
|
|
@@ -11,6 +11,7 @@ export interface FtUdViewerComponentInterface extends FtViewerComponent {
|
|
|
11
11
|
viewerStateManager?: FtUdViewerStateManager;
|
|
12
12
|
neededUdvRequests: FtUdViewerResourceRequests[];
|
|
13
13
|
service?: FtUdViewerService;
|
|
14
|
+
setUdvStateManager(stateManager: FtUdViewerStateManager): void;
|
|
14
15
|
}
|
|
15
16
|
export type FtUdViewerComponentType<T extends Constructor<FtLitElementRedux>> = T & Constructor<FtUdViewerComponentInterface>;
|
|
16
17
|
export declare const toFtUdViewerComponent: <T extends Constructor<FtLitElementRedux>>(c: T) => FtUdViewerComponentType<T>;
|
|
@@ -30,6 +30,17 @@ export const toFtUdViewerComponent = applyMixinOnce(Symbol("toFtUdViewerComponen
|
|
|
30
30
|
(_c = this.viewerStateManager) === null || _c === void 0 ? void 0 : _c.registerComponent(this, this.neededUdvRequests);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
setUdvStateManager(stateManager) {
|
|
34
|
+
this.clearStateManager();
|
|
35
|
+
this.viewerStateManager = stateManager;
|
|
36
|
+
this.addStore(stateManager.store, "viewer");
|
|
37
|
+
}
|
|
38
|
+
clearStateManager() {
|
|
39
|
+
if (this.viewerStateManager) {
|
|
40
|
+
this.removeStore("viewer");
|
|
41
|
+
this.viewerStateManager = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
33
44
|
registerToUdvStateManager(stateManager) {
|
|
34
45
|
if (stateManager) {
|
|
35
46
|
stateManager.registerComponent(this, this.neededUdvRequests);
|
|
@@ -10,8 +10,8 @@ import { provide } from "@lit/context";
|
|
|
10
10
|
import { FtLitElementRedux, randomId, reduxEventListener, } from "@fluid-topics/ft-wc-utils";
|
|
11
11
|
import { FtUdViewerStateManager } from "./model/FtUdViewerStateManager";
|
|
12
12
|
import { udViewerStateManagerContext } from "./components/registration";
|
|
13
|
-
import { AuthenticationChangeEvent, ftAppInfoStore, } from "@fluid-topics/ft-app-context";
|
|
14
|
-
import { FtViewerLoadedEvent } from "../common";
|
|
13
|
+
import { AuthenticationChangeEvent, ftAppInfoStore, ftAppStateManager, UiLocaleChangedEvent, } from "@fluid-topics/ft-app-context";
|
|
14
|
+
import { FtViewerLoadedEvent, } from "../common";
|
|
15
15
|
export class FtUdViewerContext extends FtLitElementRedux {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(...arguments);
|
|
@@ -41,6 +41,19 @@ export class FtUdViewerContext extends FtLitElementRedux {
|
|
|
41
41
|
onAuthenticationChange() {
|
|
42
42
|
this.viewerStateManager.reload();
|
|
43
43
|
}
|
|
44
|
+
async reactToUiLocaleChanged(e) {
|
|
45
|
+
var _a;
|
|
46
|
+
if ((_a = ftAppInfoStore.getState().localesConfiguration) === null || _a === void 0 ? void 0 : _a.uiLanguageSetsReaderLanguage) {
|
|
47
|
+
ftAppStateManager === null || ftAppStateManager === void 0 ? void 0 : ftAppStateManager.stopReloadDebouncer();
|
|
48
|
+
const targetUrl = await this.viewerStateManager.getRelativeDocumentUrlForLocale(e.detail.uiLocale);
|
|
49
|
+
if (targetUrl) {
|
|
50
|
+
window.location.assign(targetUrl); // This call will also refresh the page
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
window.location.reload(); // Need to reload to affect UI locale
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
__decorate([
|
|
46
59
|
property()
|
|
@@ -51,3 +64,6 @@ __decorate([
|
|
|
51
64
|
__decorate([
|
|
52
65
|
reduxEventListener({ eventName: AuthenticationChangeEvent.eventName })
|
|
53
66
|
], FtUdViewerContext.prototype, "onAuthenticationChange", null);
|
|
67
|
+
__decorate([
|
|
68
|
+
reduxEventListener({ store: ftAppInfoStore.name, eventName: UiLocaleChangedEvent.eventName })
|
|
69
|
+
], FtUdViewerContext.prototype, "reactToUiLocaleChanged", null);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
|
|
2
2
|
export interface FtUdViewerMessages extends I18nMessages {
|
|
3
3
|
download(label: string): string;
|
|
4
|
+
itemWithNoValueForSwitchToRelatives(): string;
|
|
4
5
|
}
|
|
5
6
|
export declare const udViewerContext: I18nMessageContext<FtUdViewerMessages>;
|
|
6
7
|
export declare const defaultViewerMessages: DefaultI18nMessages<FtUdViewerMessages>;
|
package/build/ud/index.d.ts
CHANGED
|
@@ -8,3 +8,7 @@ export * from "./components/ft-ud-viewer-filename";
|
|
|
8
8
|
export * from "./components/ft-ud-viewer-title";
|
|
9
9
|
export * from "./components/ft-ud-viewer-mime-type-icon";
|
|
10
10
|
export * from "./components/ft-ud-viewer-attachments";
|
|
11
|
+
export * from "./components/ft-ud-viewer-feedback";
|
|
12
|
+
export * from "./components/ft-ud-viewer-feedback.styles";
|
|
13
|
+
export * from "./components/ft-ud-viewer-metadata.properties";
|
|
14
|
+
export * from "./components/ft-ud-viewer-metadata";
|
package/build/ud/index.js
CHANGED
|
@@ -8,3 +8,7 @@ export * from "./components/ft-ud-viewer-filename";
|
|
|
8
8
|
export * from "./components/ft-ud-viewer-title";
|
|
9
9
|
export * from "./components/ft-ud-viewer-mime-type-icon";
|
|
10
10
|
export * from "./components/ft-ud-viewer-attachments";
|
|
11
|
+
export * from "./components/ft-ud-viewer-feedback";
|
|
12
|
+
export * from "./components/ft-ud-viewer-feedback.styles";
|
|
13
|
+
export * from "./components/ft-ud-viewer-metadata.properties";
|
|
14
|
+
export * from "./components/ft-ud-viewer-metadata";
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
|
-
import { FtPublicationRatingSummary, FtRatingType } from "@fluid-topics/public-api";
|
|
2
|
+
import { FtPublicationRatingSummary, FtRatingType, FtRatingTypeKeys, FtViewerConfiguration, FtSearchResults } from "@fluid-topics/public-api";
|
|
3
|
+
import { FtViewerFeatureAccessData, FtViewerFeatures } from "./ft-ud-viewer.models";
|
|
3
4
|
export declare class FtUdViewerService extends FtServiceWithCache {
|
|
4
5
|
getDocument(documentId: string): Promise<import("@fluid-topics/public-api").FtUnstructuredDocument>;
|
|
5
6
|
getAttachments(documentId: string): Promise<import("@fluid-topics/public-api").FtDocumentAttachment[]>;
|
|
6
7
|
getAttachmentDownloadLink(documentId: string, id: string): string;
|
|
7
8
|
makeAbsolute(endpoint: string): string;
|
|
9
|
+
awaitMakeAbsolute(endpoint: string): Promise<string>;
|
|
8
10
|
getDocumentRating(documentId: string): Promise<FtPublicationRatingSummary | undefined>;
|
|
9
|
-
rateDocument(documentId: string, type: FtRatingType, value: number): Promise<void>;
|
|
11
|
+
rateDocument(documentId: string, type: FtRatingType | FtRatingTypeKeys, value: number): Promise<void>;
|
|
10
12
|
unrateDocument(documentId: string): Promise<void>;
|
|
11
|
-
sendDocumentFeedback(documentId: string, message: string): Promise<void>;
|
|
13
|
+
sendDocumentFeedback(documentId: string, message: string, from?: string): Promise<void>;
|
|
14
|
+
isFeatureAccessible(feature: FtViewerFeatures, { session }: FtViewerFeatureAccessData): boolean;
|
|
15
|
+
getConfiguration(): Promise<FtViewerConfiguration>;
|
|
16
|
+
clearConfiguration(): void;
|
|
17
|
+
private fetchRelativesForDocument;
|
|
18
|
+
getRelativesForDocument(metadataPivotKey: string, metadataPivotValues: string[]): Promise<FtSearchResults>;
|
|
12
19
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
|
+
import { FtUserRole, userHasRole, } from "@fluid-topics/public-api";
|
|
3
|
+
import { FtViewerFeatures, } from "./ft-ud-viewer.models";
|
|
2
4
|
export class FtUdViewerService extends FtServiceWithCache {
|
|
3
5
|
getDocument(documentId) {
|
|
4
6
|
return this.cache.get(documentId, () => this.api.getUnstructuredDocument(documentId));
|
|
@@ -12,13 +14,57 @@ export class FtUdViewerService extends FtServiceWithCache {
|
|
|
12
14
|
makeAbsolute(endpoint) {
|
|
13
15
|
return this.api.makeAbsolute(endpoint);
|
|
14
16
|
}
|
|
17
|
+
async awaitMakeAbsolute(endpoint) {
|
|
18
|
+
return (await this.awaitApi).makeAbsolute(endpoint);
|
|
19
|
+
}
|
|
15
20
|
async getDocumentRating(documentId) {
|
|
16
|
-
return
|
|
21
|
+
return (await this.api.getDocumentRating(documentId)).publication;
|
|
17
22
|
}
|
|
18
23
|
async rateDocument(documentId, type, value) {
|
|
24
|
+
return this.api.rateDocument(documentId, type, value);
|
|
19
25
|
}
|
|
20
26
|
async unrateDocument(documentId) {
|
|
27
|
+
return this.api.unrateDocument(documentId);
|
|
28
|
+
}
|
|
29
|
+
async sendDocumentFeedback(documentId, message, from) {
|
|
30
|
+
return this.api.sendDocumentFeedback(documentId, message, from);
|
|
31
|
+
}
|
|
32
|
+
isFeatureAccessible(feature, { session }) {
|
|
33
|
+
switch (feature) {
|
|
34
|
+
case FtViewerFeatures.FEEDBACK:
|
|
35
|
+
return userHasRole(session !== null && session !== void 0 ? session : [], FtUserRole.FEEDBACK_USER);
|
|
36
|
+
case FtViewerFeatures.RATING:
|
|
37
|
+
return userHasRole(session !== null && session !== void 0 ? session : [], FtUserRole.RATING_USER);
|
|
38
|
+
default:
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getConfiguration() {
|
|
43
|
+
return this.cache.get("configuration", () => this.api.getViewerConfiguration());
|
|
44
|
+
}
|
|
45
|
+
clearConfiguration() {
|
|
46
|
+
this.cache.clear("configuration");
|
|
47
|
+
}
|
|
48
|
+
fetchRelativesForDocument(metadataPivotKey, metadataPivotValues) {
|
|
49
|
+
const request = {
|
|
50
|
+
query: "",
|
|
51
|
+
paging: { page: 1, perPage: -1 },
|
|
52
|
+
scope: "DOCUMENTS",
|
|
53
|
+
metadataFilters: [
|
|
54
|
+
{
|
|
55
|
+
key: metadataPivotKey,
|
|
56
|
+
valueFilter: {
|
|
57
|
+
negative: false,
|
|
58
|
+
values: metadataPivotValues,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
sort: [],
|
|
63
|
+
facets: [],
|
|
64
|
+
};
|
|
65
|
+
return this.api.search(request);
|
|
21
66
|
}
|
|
22
|
-
|
|
67
|
+
getRelativesForDocument(metadataPivotKey, metadataPivotValues) {
|
|
68
|
+
return this.cache.get("document-relatives-" + metadataPivotKey + "-" + metadataPivotValues.join("-"), () => this.fetchRelativesForDocument(metadataPivotKey, metadataPivotValues));
|
|
23
69
|
}
|
|
24
70
|
}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { FtViewerReduxStore } from "../../common/model/FtViewerReduxStore";
|
|
2
2
|
import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
|
|
3
3
|
import { FtUdViewerService } from "./FtUdViewerService";
|
|
4
|
+
import { ClusteringHelper } from "@fluid-topics/ft-wc-utils";
|
|
4
5
|
export declare class FtUdViewerStateManager extends FtViewerStateManager {
|
|
5
6
|
store: FtViewerReduxStore;
|
|
6
7
|
service: FtUdViewerService;
|
|
8
|
+
private clusteringHelperProvider?;
|
|
7
9
|
static build(viewerId: string): FtUdViewerStateManager;
|
|
8
|
-
|
|
10
|
+
metadataForSwitchToRelatives: Set<string>;
|
|
11
|
+
clusteringHelper?: ClusteringHelper;
|
|
12
|
+
constructor(store: FtViewerReduxStore, service: FtUdViewerService, clusteringHelperProvider?: (() => ClusteringHelper) | undefined);
|
|
9
13
|
load(): Promise<import("../..").FtViewerState>;
|
|
14
|
+
fetchMapRating(): Promise<void>;
|
|
10
15
|
clear(): void;
|
|
11
16
|
reload(): Promise<import("../..").FtViewerState>;
|
|
12
17
|
setDocumentId(documentId: string | undefined): Promise<import("../..").FtViewerState>;
|
|
18
|
+
loadConfiguration(): Promise<{
|
|
19
|
+
payload: import("@fluid-topics/public-api").FtViewerConfiguration | undefined;
|
|
20
|
+
type: `${string}/configuration`;
|
|
21
|
+
}>;
|
|
22
|
+
private fetchRelatives;
|
|
23
|
+
private updateClusteringHelper;
|
|
24
|
+
private createClusteringHelper;
|
|
25
|
+
registerMetadataForSwitchToRelatives(id: string): void;
|
|
26
|
+
unregisterMetadataForSwitchToRelatives(id: string): void;
|
|
27
|
+
getRelativeDocumentUrlForLocale(uiLocale: string): Promise<string | undefined>;
|
|
13
28
|
}
|
|
@@ -3,22 +3,29 @@ import { createViewerStore, } from "../../common/model/FtViewerReduxStore";
|
|
|
3
3
|
import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
|
|
4
4
|
import { FtUdViewerService } from "./FtUdViewerService";
|
|
5
5
|
import { FtAssetHolderType } from "@fluid-topics/public-api";
|
|
6
|
-
import {
|
|
6
|
+
import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
7
|
+
import { accessResultId, accessResultUrl, ClusteringHelper } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { FtUdViewerStoreEvents } from "./ft-ud-viewer.models";
|
|
7
9
|
export class FtUdViewerStateManager extends FtViewerStateManager {
|
|
8
10
|
static build(viewerId) {
|
|
9
11
|
return new FtUdViewerStateManager(createViewerStore(viewerId), new FtUdViewerService());
|
|
10
12
|
}
|
|
11
|
-
constructor(store, service) {
|
|
13
|
+
constructor(store, service, clusteringHelperProvider) {
|
|
12
14
|
super(store);
|
|
13
15
|
this.store = store;
|
|
14
16
|
this.service = service;
|
|
17
|
+
this.clusteringHelperProvider = clusteringHelperProvider;
|
|
18
|
+
this.metadataForSwitchToRelatives = new Set();
|
|
15
19
|
store.actions.origin(FtViewerFileOrigin.UNSTRUCTURED_DOCUMENT);
|
|
16
20
|
}
|
|
17
21
|
async load() {
|
|
18
22
|
var _a, _b;
|
|
19
23
|
const { documentId } = this.store.getState();
|
|
20
24
|
if (documentId) {
|
|
21
|
-
const document = await
|
|
25
|
+
const [document] = await Promise.all([
|
|
26
|
+
this.service.getDocument(documentId),
|
|
27
|
+
this.loadConfiguration(),
|
|
28
|
+
]);
|
|
22
29
|
this.store.actions.unstructuredDocument(document);
|
|
23
30
|
this.store.actions.document({
|
|
24
31
|
type: FtAssetHolderType.UNSTRUCTURED_DOCUMENT,
|
|
@@ -28,7 +35,7 @@ export class FtUdViewerStateManager extends FtViewerStateManager {
|
|
|
28
35
|
metadata: document.metadata,
|
|
29
36
|
portalUrl: document.viewerUrl,
|
|
30
37
|
});
|
|
31
|
-
const
|
|
38
|
+
const contentUrl = await this.service.awaitMakeAbsolute(document.contentApiEndpoint);
|
|
32
39
|
this.store.actions.descriptor({
|
|
33
40
|
id: document.id,
|
|
34
41
|
portalUrl: document.viewerUrl,
|
|
@@ -39,21 +46,88 @@ export class FtUdViewerStateManager extends FtViewerStateManager {
|
|
|
39
46
|
mimeType: document.mimeType,
|
|
40
47
|
size: 0,
|
|
41
48
|
viewableInCurrentBrowser: document.viewableInCurrentBrowser,
|
|
42
|
-
contentUrl
|
|
49
|
+
contentUrl,
|
|
43
50
|
});
|
|
44
51
|
this.store.actions.watermark(document.watermark);
|
|
52
|
+
this.fetchMapRating();
|
|
53
|
+
if (this.metadataForSwitchToRelatives.size > 0) {
|
|
54
|
+
this.fetchRelatives();
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
return this.store.getState();
|
|
47
58
|
}
|
|
59
|
+
async fetchMapRating() {
|
|
60
|
+
var _a;
|
|
61
|
+
const { documentId } = this.store.getState();
|
|
62
|
+
if (documentId) {
|
|
63
|
+
this.store.actions.documentRating(await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getDocumentRating(documentId)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
48
66
|
clear() {
|
|
49
67
|
this.store.clearKeeping("documentId", "origin");
|
|
50
68
|
}
|
|
51
69
|
reload() {
|
|
70
|
+
var _a;
|
|
52
71
|
this.clear();
|
|
72
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.clearConfiguration();
|
|
53
73
|
return this.load();
|
|
54
74
|
}
|
|
55
75
|
setDocumentId(documentId) {
|
|
56
76
|
this.store.actions.documentId(documentId);
|
|
57
77
|
return this.reload();
|
|
58
78
|
}
|
|
79
|
+
async loadConfiguration() {
|
|
80
|
+
var _a;
|
|
81
|
+
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getConfiguration().then((conf) => this.store.actions.configuration(conf));
|
|
82
|
+
}
|
|
83
|
+
async fetchRelatives() {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const relativeMetadataValues = (_a = this.store.getState().document) === null || _a === void 0 ? void 0 : _a.metadata.filter((metadata) => { var _a; return metadata.key == ((_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.relativePivotMetadata); }).flatMap((metadata) => metadata.values);
|
|
86
|
+
if (relativeMetadataValues !== undefined && relativeMetadataValues.length > 0) {
|
|
87
|
+
const searchResults = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata, relativeMetadataValues));
|
|
88
|
+
const relatives = searchResults === null || searchResults === void 0 ? void 0 : searchResults.results.flatMap((result) => result.entries);
|
|
89
|
+
this.store.actions.relatives(relatives);
|
|
90
|
+
}
|
|
91
|
+
this.updateClusteringHelper();
|
|
92
|
+
}
|
|
93
|
+
updateClusteringHelper() {
|
|
94
|
+
this.clusteringHelper = this.createClusteringHelper();
|
|
95
|
+
if (this.clusteringHelper) {
|
|
96
|
+
this.store.dispatchEvent(new Event(FtUdViewerStoreEvents.clusteringHelperCreated));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
createClusteringHelper() {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
if (this.clusteringHelperProvider) {
|
|
102
|
+
return this.clusteringHelperProvider();
|
|
103
|
+
}
|
|
104
|
+
const relatives = this.store.getState().relatives;
|
|
105
|
+
if (relatives) {
|
|
106
|
+
const selectedResult = relatives.find((relative) => accessResultId(relative) == this.store.getState().documentId);
|
|
107
|
+
const metadataDescriptors = (_b = (_a = ftAppInfoStore.getState().metadataConfiguration) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : [];
|
|
108
|
+
return new ClusteringHelper(relatives, selectedResult, this.metadataForSwitchToRelatives, metadataDescriptors);
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
registerMetadataForSwitchToRelatives(id) {
|
|
113
|
+
this.metadataForSwitchToRelatives.add(id);
|
|
114
|
+
if (this.store.getState().relatives == undefined) {
|
|
115
|
+
this.fetchRelatives();
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.updateClusteringHelper();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
unregisterMetadataForSwitchToRelatives(id) {
|
|
122
|
+
this.metadataForSwitchToRelatives.delete(id);
|
|
123
|
+
this.updateClusteringHelper();
|
|
124
|
+
}
|
|
125
|
+
async getRelativeDocumentUrlForLocale(uiLocale) {
|
|
126
|
+
var _a;
|
|
127
|
+
if (this.store.getState().relatives == undefined) {
|
|
128
|
+
await this.fetchRelatives();
|
|
129
|
+
}
|
|
130
|
+
const maybeRelativeResult = ClusteringHelper.findResultWithMetadataValue((_a = this.store.getState().relatives) !== null && _a !== void 0 ? _a : [], "ft:locale", uiLocale);
|
|
131
|
+
return accessResultUrl(maybeRelativeResult);
|
|
132
|
+
}
|
|
59
133
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
import { FtSession } from "@fluid-topics/public-api";
|
|
1
2
|
export declare enum FtUdViewerResourceRequests {
|
|
2
3
|
RATING = "RATING"
|
|
3
4
|
}
|
|
4
5
|
export declare enum FtUdViewerStoreEvents {
|
|
5
|
-
udAttachmentsUpdate = "ud-attachments-update"
|
|
6
|
+
udAttachmentsUpdate = "ud-attachments-update",
|
|
7
|
+
udRatingUpdate = "ud-rating-update",
|
|
8
|
+
clusteringHelperCreated = "clustering-helper-created"
|
|
9
|
+
}
|
|
10
|
+
export declare enum FtViewerFeatures {
|
|
11
|
+
FEEDBACK = "FEEDBACK",
|
|
12
|
+
RATING = "RATING"
|
|
13
|
+
}
|
|
14
|
+
export interface FtViewerFeatureAccessData {
|
|
15
|
+
session?: FtSession;
|
|
6
16
|
}
|
|
@@ -5,4 +5,11 @@ export var FtUdViewerResourceRequests;
|
|
|
5
5
|
export var FtUdViewerStoreEvents;
|
|
6
6
|
(function (FtUdViewerStoreEvents) {
|
|
7
7
|
FtUdViewerStoreEvents["udAttachmentsUpdate"] = "ud-attachments-update";
|
|
8
|
+
FtUdViewerStoreEvents["udRatingUpdate"] = "ud-rating-update";
|
|
9
|
+
FtUdViewerStoreEvents["clusteringHelperCreated"] = "clustering-helper-created";
|
|
8
10
|
})(FtUdViewerStoreEvents || (FtUdViewerStoreEvents = {}));
|
|
11
|
+
export var FtViewerFeatures;
|
|
12
|
+
(function (FtViewerFeatures) {
|
|
13
|
+
FtViewerFeatures["FEEDBACK"] = "FEEDBACK";
|
|
14
|
+
FtViewerFeatures["RATING"] = "RATING";
|
|
15
|
+
})(FtViewerFeatures || (FtViewerFeatures = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FtPublicationRating, FtRatingTypeKeys } from "@fluid-topics/public-api";
|
|
2
|
+
interface OpenUdFeedbackDrawerEventDetail {
|
|
3
|
+
documentId: string;
|
|
4
|
+
documentTitle: string;
|
|
5
|
+
ratingType: FtRatingTypeKeys;
|
|
6
|
+
ratingValue: FtPublicationRating | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare class OpenUdFeedbackDrawerEvent extends CustomEvent<OpenUdFeedbackDrawerEventDetail> {
|
|
9
|
+
constructor(detail: OpenUdFeedbackDrawerEventDetail);
|
|
10
|
+
}
|
|
11
|
+
export declare class SendMailerUdFeedbackEvent extends CustomEvent<any> {
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class OpenUdFeedbackDrawerEvent extends CustomEvent {
|
|
2
|
+
constructor(detail) {
|
|
3
|
+
super("ft-ud-viewer-feedback", {
|
|
4
|
+
composed: true,
|
|
5
|
+
bubbles: true,
|
|
6
|
+
detail,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class SendMailerUdFeedbackEvent extends CustomEvent {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("ft-viewer-mailer-ud-feedback", {
|
|
13
|
+
composed: true,
|
|
14
|
+
bubbles: true,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-viewer",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.21",
|
|
4
4
|
"description": "File viewer components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,16 +19,18 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-content-watermark": "2.1.
|
|
23
|
-
"@fluid-topics/ft-i18n": "2.1.
|
|
24
|
-
"@fluid-topics/ft-reader-attachments": "2.1.
|
|
25
|
-
"@fluid-topics/ft-
|
|
26
|
-
"@fluid-topics/
|
|
22
|
+
"@fluid-topics/ft-content-watermark": "2.1.21",
|
|
23
|
+
"@fluid-topics/ft-i18n": "2.1.21",
|
|
24
|
+
"@fluid-topics/ft-reader-attachments": "2.1.21",
|
|
25
|
+
"@fluid-topics/ft-reader-feedback": "2.1.21",
|
|
26
|
+
"@fluid-topics/ft-search-result-context": "2.1.21",
|
|
27
|
+
"@fluid-topics/ft-wc-utils": "2.1.21",
|
|
28
|
+
"@fluid-topics/public-api": "1.0.136",
|
|
27
29
|
"@lit/context": "1.1.6",
|
|
28
30
|
"lit": "3.1.0"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@fluid-topics/ft-wc-test-utils": "2.1.
|
|
33
|
+
"@fluid-topics/ft-wc-test-utils": "2.1.21"
|
|
32
34
|
},
|
|
33
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "a0f619df74c0665183d73df09e75b1eddc2a2a1f"
|
|
34
36
|
}
|