@fluid-topics/ft-search-result-metadata 1.1.54 → 1.1.55

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.
@@ -0,0 +1,7 @@
1
+ import { I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
2
+ export interface SearchResultMetadataAdminMessages extends I18nMessages {
3
+ noKeySelected(): string;
4
+ noValuePresent(key: string): string;
5
+ noValueInCluster(): string;
6
+ }
7
+ export declare const adminContext: I18nMessageContext<SearchResultMetadataAdminMessages>;
@@ -0,0 +1,2 @@
1
+ import { I18nMessageContext } from "@fluid-topics/ft-i18n";
2
+ export const adminContext = I18nMessageContext.build("designedSearchResultMetadataInAdmin");
@@ -1,7 +1,5 @@
1
1
  import { I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
2
2
  export interface SearchResultMetadataMessages extends I18nMessages {
3
- noKeySelected(): string;
4
- noValuePresent(key: string): string;
5
- noValueInCluster(): string;
3
+ itemWithNoValueForClusterSwitch(): string;
6
4
  }
7
- export declare const searchResultMetadataContext: I18nMessageContext<SearchResultMetadataMessages>;
5
+ export declare const context: I18nMessageContext<SearchResultMetadataMessages>;
@@ -1,2 +1,2 @@
1
1
  import { I18nMessageContext } from "@fluid-topics/ft-i18n";
2
- export const searchResultMetadataContext = I18nMessageContext.build("designedSearchResultMetadata");
2
+ export const context = I18nMessageContext.build("designedSearchResultMetadata");
@@ -11,12 +11,13 @@ import { styles } from "./ft-search-result-metadata.styles";
11
11
  import { FtSearchResultComponent } from "@fluid-topics/ft-search-result-context/build/registration";
12
12
  import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
13
13
  import { withI18n } from "@fluid-topics/ft-i18n";
14
- import { searchResultMetadataContext } from "./SearchResultMetadataMessages";
14
+ import { adminContext } from "./SearchResultMetadataAdminMessages";
15
15
  import { FtTooltip } from "@fluid-topics/ft-tooltip";
16
16
  import { FtChip } from "@fluid-topics/ft-chip";
17
17
  import { FtFloatingMenu, FtFloatingMenuItem, FtFloatingMenuLabel } from "@fluid-topics/ft-floating-menu";
18
18
  import { getResultUrl, SearchResultClickEvent } from "@fluid-topics/ft-search-result-context/build/utils";
19
19
  import { repeat } from "lit/directives/repeat.js";
20
+ import { context } from "./SearchResultMetadataMessages";
20
21
  class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
21
22
  constructor() {
22
23
  super();
@@ -27,7 +28,8 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
27
28
  this.metadataDescriptors = [];
28
29
  this.clustersByValue = {};
29
30
  this.addStore(ftAppInfoStore);
30
- this.addI18nContext(searchResultMetadataContext);
31
+ this.addI18nContext(context);
32
+ this.addI18nContext(adminContext);
31
33
  }
32
34
  setResultStateManager(resultStateManager) {
33
35
  super.setResultStateManager(resultStateManager);
@@ -70,9 +72,10 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
70
72
  var _a, _b;
71
73
  const clustersByValue = {};
72
74
  const clusteringHelper = new ClusteringHelper((_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries, this.result, this.resultStateManager.registeredMetadata, this.metadataDescriptors);
73
- this.clusterItems = clusteringHelper.computeClustersItemsForMetadata(this.key, ((_b = this.request) === null || _b === void 0 ? void 0 : _b.contentLocale) || "en");
75
+ this.clusterItems = clusteringHelper.computeClustersItemsForMetadata(this.key, ((_b = this.request) === null || _b === void 0 ? void 0 : _b.contentLocale) || "en", context.messages.itemWithNoValueForClusterSwitch());
74
76
  this.clusterItems.forEach(item => {
75
- clustersByValue[item.metadata.value] = item;
77
+ var _a;
78
+ clustersByValue[(_a = item.metadata.value) !== null && _a !== void 0 ? _a : "ft:no_value"] = item;
76
79
  });
77
80
  this.clustersByValue = clustersByValue;
78
81
  }
@@ -80,18 +83,19 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
80
83
  if (this.goToDocumentOnSwitch) {
81
84
  return html `
82
85
  <a href="${getResultUrl(result)}" @click=${() => this.onResultClick(result)}>
83
- <ft-floating-menu-item value="${metadata.value}">${this.renderClusterItemValue(metadata.value, metadata.displayValue)}
84
- </ft-floating-menu-item>
86
+ ${this.renderClusterItemValue(metadata.value, metadata.displayValue)}
85
87
  </a>
86
88
  `;
87
89
  }
88
- return html `
89
- <ft-floating-menu-item value="${metadata.value}">${this.renderClusterItemValue(metadata.value, metadata.displayValue)}</ft-floating-menu-item>
90
- `;
90
+ return this.renderClusterItemValue(metadata.value, metadata.displayValue);
91
91
  }
92
92
  renderClusterItemValue(value, displayValue) {
93
- return value === displayValue ? html `${value}` : html `
94
- <ft-tooltip text="${value}">${displayValue}</ft-tooltip>
93
+ return html `
94
+ <ft-floating-menu-item value="${value !== null && value !== void 0 ? value : "ft:no_value"}">
95
+ ${value == null || value === displayValue ? displayValue : html `
96
+ <ft-tooltip text="${value}">${displayValue}</ft-tooltip>
97
+ `}
98
+ </ft-floating-menu-item>
95
99
  `;
96
100
  }
97
101
  onResultClick(result) {
@@ -116,17 +120,17 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
116
120
  }
117
121
  renderContent() {
118
122
  if (this.resultMetadata) {
119
- return html `${this.getEllipsis(this.valueText)}`;
123
+ return this.getEllipsis(this.valueText);
120
124
  }
121
125
  if (this.useAsClusterSwitch && Object.keys(this.clustersByValue).length > 0) {
122
- return html `${searchResultMetadataContext.messages.noValueInCluster()}`;
126
+ return adminContext.messages.noValueInCluster();
123
127
  }
124
128
  if (this.editorMode) {
125
129
  if (this.key) {
126
- return html `${searchResultMetadataContext.messages.noValuePresent(this.key)}`;
130
+ return adminContext.messages.noValuePresent(this.key);
127
131
  }
128
132
  else {
129
- return html `${searchResultMetadataContext.messages.noKeySelected()}`;
133
+ return adminContext.messages.noKeySelected();
130
134
  }
131
135
  }
132
136
  return html `
@@ -194,7 +198,7 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
194
198
  return `${this.metadataLabel}: ${this.valueText}`;
195
199
  }
196
200
  if (this.useAsClusterSwitch) {
197
- return `${this.metadataLabel}: ${searchResultMetadataContext.messages.noValueInCluster()}`;
201
+ return `${this.metadataLabel}: ${adminContext.messages.noValueInCluster()}`;
198
202
  }
199
203
  return "";
200
204
  }