@fluid-topics/ft-search-saved-searches 1.3.16 → 1.3.18

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.
@@ -1,7 +1,7 @@
1
1
  import { PropertyValues } from "lit";
2
2
  import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtSearchSavedSearchesProperties } from "./ft-search-saved-searches.properties";
4
- import { FtMetadataFilter, FtMySearch } from "@fluid-topics/public-api";
4
+ import { FtMetadataFilter, FtMySearch, FtSearchSortOption } from "@fluid-topics/public-api";
5
5
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
6
6
  declare const FtSearchSavedSearches_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
7
7
  export declare class FtSearchSavedSearches extends FtSearchSavedSearches_base implements FtSearchSavedSearchesProperties {
@@ -13,6 +13,7 @@ export declare class FtSearchSavedSearches extends FtSearchSavedSearches_base im
13
13
  savedSearches?: Array<FtMySearch>;
14
14
  private user?;
15
15
  private request?;
16
+ sortOptions?: FtSearchSortOption[];
16
17
  private requiredRole;
17
18
  static elementDefinitions: ElementDefinitionsMap;
18
19
  constructor();
@@ -26,7 +27,7 @@ export declare class FtSearchSavedSearches extends FtSearchSavedSearches_base im
26
27
  private renderValueFilter;
27
28
  private renderDateFilter;
28
29
  private renderRangeFilter;
29
- private mapSortKey;
30
+ private mapSortId;
30
31
  private mapDateFilterType;
31
32
  private get userHasRights();
32
33
  private get isEmpty();
@@ -21,6 +21,7 @@ import { FtIcon } from "@fluid-topics/ft-icon";
21
21
  import { FtCard } from "@fluid-topics/ft-card";
22
22
  import { FtChip } from "@fluid-topics/ft-chip";
23
23
  import { FtButton } from "@fluid-topics/ft-button";
24
+ import { i18nAttributeConverter } from "@fluid-topics/ft-i18n/build/decorators/I18nAttributeConverter";
24
25
  class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
25
26
  constructor() {
26
27
  super();
@@ -39,16 +40,16 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
39
40
  var _a;
40
41
  return html `
41
42
  <div part="container" role="group" aria-label="${savedSearches.messages.groupLabel()}">
42
- ${repeat((_a = this.savedSearches) !== null && _a !== void 0 ? _a : [], s => s.id, s => {
43
+ ${repeat((_a = this.savedSearches) !== null && _a !== void 0 ? _a : [], (s) => s.id, (s) => {
43
44
  const ftSearchRequest = this.toFtSearchRequest(s.searchRequest);
44
45
  if (ftSearchRequest === undefined) {
45
46
  return nothing;
46
47
  }
47
48
  return html `
48
49
  <a href="${searchPlaceConverter === null || searchPlaceConverter === void 0 ? void 0 : searchPlaceConverter.serialize(ftSearchRequest)}"
49
- @click="${(e) => this.onLinkClick(e, ftSearchRequest)}"
50
+ @click=${(e) => this.onLinkClick(e, ftSearchRequest)}
50
51
  aria-current="${this.isSelected(s.searchRequest)}">
51
- <ft-card clickable ?selected="${this.isSelected(s.searchRequest)}" part="card">
52
+ <ft-card clickable ?selected=${this.isSelected(s.searchRequest)} part="card">
52
53
  <div slot="header">
53
54
  <ft-typography variant="title">${s.title}</ft-typography>
54
55
  ${this.renderAlertStatus(s.alert)}
@@ -83,15 +84,15 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
83
84
  // See net.antidot.fluidtopics.client.application.mylibrary.shared.MyLibraryTagWidgetFactory.createMySearchTags
84
85
  renderSearchFilters(searchRequest) {
85
86
  return when(this.showSearchFilters, () => {
86
- var _a, _b, _c, _d, _e, _f, _g;
87
+ var _a, _b, _c, _d, _e;
87
88
  return html `
88
89
  <div part="search-filters" class="content">
89
90
  ${when((_a = searchRequest.query.length) !== null && _a !== void 0 ? _a : 0 > 0, () => this.renderMetadata(savedSearches.messages.keywords(), searchRequest.query))}
90
91
  ${when(searchRequest.virtualField == FtVirtualField.TITLE_ONLY, () => this.renderMetadata(savedSearches.messages.in(), savedSearches.messages.titles()))}
91
92
  ${when(searchRequest.scope == FtSearchScope.DOCUMENTS, () => this.renderMetadata(savedSearches.messages.resultsType(), savedSearches.messages.documentsOnly()))}
92
- ${(_c = (_b = searchRequest.metadataFilters) === null || _b === void 0 ? void 0 : _b.map(f => this.renderUnknownFilter(f))) !== null && _c !== void 0 ? _c : nothing}
93
+ ${(_c = (_b = searchRequest.metadataFilters) === null || _b === void 0 ? void 0 : _b.map((f) => this.renderUnknownFilter(f))) !== null && _c !== void 0 ? _c : nothing}
93
94
  ${when((_e = (_d = searchRequest.contentLocale) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0 > 0, () => this.renderMetadata(savedSearches.messages.language(), searchRequest.contentLocale))}
94
- ${when((_g = (_f = searchRequest.sort[0]) === null || _f === void 0 ? void 0 : _f.key.length) !== null && _g !== void 0 ? _g : 0 > 0, () => this.renderMetadata(savedSearches.messages.sort(), this.mapSortKey(searchRequest.sort[0].key)))}
95
+ ${when(searchRequest.sortId != undefined, () => this.renderMetadata(savedSearches.messages.sort(), this.mapSortId(searchRequest.sortId)))}
95
96
  </div>`;
96
97
  });
97
98
  }
@@ -123,15 +124,15 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
123
124
  renderRangeFilter() {
124
125
  return this.renderMetadata(savedSearches.messages.period(), savedSearches.messages.customPeriod());
125
126
  }
126
- mapSortKey(key) {
127
- switch (key) {
128
- case "afs:relevance":
129
- return savedSearches.messages.relevance();
130
- case "ft:lastEdition":
131
- return savedSearches.messages.lastUpdate();
132
- default:
133
- return key;
127
+ mapSortId(sortId) {
128
+ if (this.sortOptions == undefined) {
129
+ return undefined;
130
+ }
131
+ let sortOption = this.sortOptions.find((option) => option.id == sortId);
132
+ if (sortOption == undefined) {
133
+ sortOption = this.sortOptions.find((option) => option.id == "relevance");
134
134
  }
135
+ return this.i18n(i18nAttributeConverter.fromLocalizableLabel(sortOption.label));
135
136
  }
136
137
  mapDateFilterType(dateFilterType) {
137
138
  switch (dateFilterType) {
@@ -157,20 +158,20 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
157
158
  return this.request != undefined
158
159
  && deepEqual(this.request.query, mySearchRequest.query)
159
160
  && this.areFtMetadataFiltersEqual([...this.request.metadataFilters], [...(_a = mySearchRequest.metadataFilters) !== null && _a !== void 0 ? _a : []].map(this.toMetadataFilter))
160
- && deepEqual([...this.request.sort].map(this.mapFtSearchSortCriterion), [...mySearchRequest.sort].map(this.mapFtSearchSortCriterion))
161
+ && deepEqual(this.request.sortId, mySearchRequest.sortId)
161
162
  && deepEqual(this.request.contentLocale, mySearchRequest.contentLocale)
162
163
  && deepEqual((_b = this.request.virtualField) !== null && _b !== void 0 ? _b : "EVERYWHERE", (_c = mySearchRequest.virtualField) !== null && _c !== void 0 ? _c : "EVERYWHERE")
163
164
  && deepEqual((_d = this.request.scope) !== null && _d !== void 0 ? _d : "DEFAULT", (_e = mySearchRequest.scope) !== null && _e !== void 0 ? _e : "DEFAULT");
164
165
  }
165
166
  areFtMetadataFiltersEqual(arr1, arr2) {
166
- if (!deepEqual(arr1.map(i => i.key).sort(), arr2.map(i => i.key).sort())) {
167
+ if (!deepEqual(arr1.map((i) => i.key).sort(), arr2.map((i) => i.key).sort())) {
167
168
  return false;
168
169
  }
169
170
  const compareObjects = (obj1, obj2) => {
170
171
  return obj1.key === obj2.key && this.compareUnknownFilter(obj1, obj2);
171
172
  };
172
173
  for (const obj1 of arr1) {
173
- const matchingObject = arr2.find(obj2 => compareObjects(obj1, obj2));
174
+ const matchingObject = arr2.find((obj2) => compareObjects(obj1, obj2));
174
175
  if (!matchingObject) {
175
176
  return false;
176
177
  }
@@ -192,7 +193,7 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
192
193
  compareValueFilter(obj1, obj2) {
193
194
  return obj1.negative === obj2.negative
194
195
  && obj1.values.length === obj2.values.length
195
- && obj1.values.every(value => obj2.values.includes(value));
196
+ && obj1.values.every((value) => obj2.values.includes(value));
196
197
  }
197
198
  compareDateFilter(obj1, obj2) {
198
199
  return obj1.type === obj2.type;
@@ -210,10 +211,10 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
210
211
  ...this.request,
211
212
  query: mySearchRequest.query,
212
213
  metadataFilters: (_b = (_a = mySearchRequest.metadataFilters) === null || _a === void 0 ? void 0 : _a.map(this.toMetadataFilter)) !== null && _b !== void 0 ? _b : [],
213
- sort: mySearchRequest.sort,
214
+ sortId: mySearchRequest.sortId,
214
215
  contentLocale: mySearchRequest.contentLocale,
215
216
  virtualField: mySearchRequest.virtualField,
216
- scope: mySearchRequest.scope
217
+ scope: mySearchRequest.scope,
217
218
  };
218
219
  }
219
220
  toMetadataFilter(f) {
@@ -221,7 +222,7 @@ class FtSearchSavedSearches extends withI18n(FtSearchComponent) {
221
222
  key: f.key,
222
223
  valueFilter: f.valueFilter,
223
224
  dateFilter: f.dateFilter,
224
- rangeFilter: f.rangeFilter
225
+ rangeFilter: f.rangeFilter,
225
226
  };
226
227
  }
227
228
  connectedCallback() {
@@ -251,7 +252,7 @@ FtSearchSavedSearches.elementDefinitions = {
251
252
  "ft-icon": FtIcon,
252
253
  "ft-card": FtCard,
253
254
  "ft-chip": FtChip,
254
- "ft-button": FtButton
255
+ "ft-button": FtButton,
255
256
  };
256
257
  __decorate([
257
258
  property({ type: Boolean })
@@ -274,4 +275,7 @@ __decorate([
274
275
  __decorate([
275
276
  redux({ store: "search" })
276
277
  ], FtSearchSavedSearches.prototype, "request", void 0);
278
+ __decorate([
279
+ redux({ store: "search", selector: (state) => { var _a; return (_a = state.configuration) === null || _a === void 0 ? void 0 : _a.sortOptions; } })
280
+ ], FtSearchSavedSearches.prototype, "sortOptions", void 0);
277
281
  export { FtSearchSavedSearches };