@fluid-topics/ft-search-result-metadata 1.1.14 → 1.1.16
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.
|
@@ -16,9 +16,12 @@ export declare class FtSearchResultMetadata extends FtSearchResultMetadata_base
|
|
|
16
16
|
*/
|
|
17
17
|
maxLength?: number;
|
|
18
18
|
private editorMode;
|
|
19
|
+
private metadataDescriptors;
|
|
20
|
+
private request?;
|
|
19
21
|
private resultMetadata?;
|
|
20
22
|
private metadataLabel?;
|
|
21
|
-
private
|
|
23
|
+
private clustersByValue;
|
|
24
|
+
private clusters;
|
|
22
25
|
constructor();
|
|
23
26
|
setResultStateManager(resultStateManager: FtSearchResultStateManager): void;
|
|
24
27
|
protected render(): import("lit").TemplateResult<1>;
|
|
@@ -25,7 +25,9 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
|
|
|
25
25
|
this.useAsClusterSwitch = false;
|
|
26
26
|
this.goToDocumentOnSwitch = false;
|
|
27
27
|
this.editorMode = false;
|
|
28
|
-
this.
|
|
28
|
+
this.metadataDescriptors = [];
|
|
29
|
+
this.clustersByValue = {};
|
|
30
|
+
this.clusters = [];
|
|
29
31
|
this.addStore(ftAppInfoStore);
|
|
30
32
|
this.addI18nContext(searchResultMetadataContext);
|
|
31
33
|
}
|
|
@@ -46,23 +48,24 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
|
|
|
46
48
|
slot="button">
|
|
47
49
|
${this.renderChip("toggle")}
|
|
48
50
|
<ft-floating-menu-label>${this.metadataLabel}</ft-floating-menu-label>
|
|
49
|
-
${repeat(
|
|
51
|
+
${repeat(this.clusters, cluster => cluster.metadata.value, cluster => this.renderClusterItem(cluster.result, cluster.metadata))}
|
|
50
52
|
</ft-floating-menu>
|
|
51
53
|
</div>
|
|
52
54
|
`;
|
|
53
55
|
}
|
|
54
56
|
onClusterSelected(e) {
|
|
55
57
|
var _a;
|
|
56
|
-
(_a = this.resultStateManager) === null || _a === void 0 ? void 0 : _a.selectResult(this.
|
|
58
|
+
(_a = this.resultStateManager) === null || _a === void 0 ? void 0 : _a.selectResult(this.clustersByValue[e.detail].result);
|
|
57
59
|
}
|
|
58
60
|
computeClusters() {
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
clusteringHelper
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
var _a;
|
|
62
|
+
const clustersByValue = {};
|
|
63
|
+
const clusteringHelper = new ClusteringHelper(this.cluster, this.result, this.resultStateManager.registeredMetadata, this.metadataDescriptors);
|
|
64
|
+
this.clusters = clusteringHelper.computeClustersItemsForMetadata(this.key, ((_a = this.request) === null || _a === void 0 ? void 0 : _a.contentLocale) || "en");
|
|
65
|
+
this.clusters.forEach(item => {
|
|
66
|
+
clustersByValue[item.metadata.value] = item;
|
|
64
67
|
});
|
|
65
|
-
this.
|
|
68
|
+
this.clustersByValue = clustersByValue;
|
|
66
69
|
}
|
|
67
70
|
renderClusterItem(result, metadata) {
|
|
68
71
|
if (this.goToDocumentOnSwitch) {
|
|
@@ -101,7 +104,7 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
|
|
|
101
104
|
if (this.resultMetadata) {
|
|
102
105
|
return html `${this.getEllipsis(this.valueText)}`;
|
|
103
106
|
}
|
|
104
|
-
if (this.useAsClusterSwitch && Object.keys(this.
|
|
107
|
+
if (this.useAsClusterSwitch && Object.keys(this.clustersByValue).length > 0) {
|
|
105
108
|
return html `${searchResultMetadataContext.messages.noValueInCluster()}`;
|
|
106
109
|
}
|
|
107
110
|
if (this.editorMode) {
|
|
@@ -206,6 +209,12 @@ __decorate([
|
|
|
206
209
|
__decorate([
|
|
207
210
|
redux({ store: ftAppInfoStore.name })
|
|
208
211
|
], FtSearchResultMetadata.prototype, "editorMode", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
redux({ store: ftAppInfoStore.name })
|
|
214
|
+
], FtSearchResultMetadata.prototype, "metadataDescriptors", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
redux({ store: "search" })
|
|
217
|
+
], FtSearchResultMetadata.prototype, "request", void 0);
|
|
209
218
|
__decorate([
|
|
210
219
|
state()
|
|
211
220
|
], FtSearchResultMetadata.prototype, "resultMetadata", void 0);
|
|
@@ -214,5 +223,8 @@ __decorate([
|
|
|
214
223
|
], FtSearchResultMetadata.prototype, "metadataLabel", void 0);
|
|
215
224
|
__decorate([
|
|
216
225
|
state()
|
|
217
|
-
], FtSearchResultMetadata.prototype, "
|
|
226
|
+
], FtSearchResultMetadata.prototype, "clustersByValue", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
state()
|
|
229
|
+
], FtSearchResultMetadata.prototype, "clusters", void 0);
|
|
218
230
|
export { FtSearchResultMetadata };
|