@fluid-topics/ft-search-period-filter 1.1.112 → 1.1.114
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.
|
@@ -7,7 +7,7 @@ declare const FtSearchPeriodFilter_base: typeof FtSearchComponent & import("@flu
|
|
|
7
7
|
export declare class FtSearchPeriodFilter extends FtSearchPeriodFilter_base implements FtSearchPeriodFilterProperties {
|
|
8
8
|
static elementDefinitions: ElementDefinitionsMap;
|
|
9
9
|
static styles: import("lit").CSSResult;
|
|
10
|
-
key
|
|
10
|
+
key?: string;
|
|
11
11
|
lessThanAWeek?: boolean;
|
|
12
12
|
lessThanAMonth?: boolean;
|
|
13
13
|
lessThanAQuarter?: boolean;
|
|
@@ -16,6 +16,7 @@ export declare class FtSearchPeriodFilter extends FtSearchPeriodFilter_base impl
|
|
|
16
16
|
private metadataDescriptors;
|
|
17
17
|
private dateFilter?;
|
|
18
18
|
constructor();
|
|
19
|
+
get metadataKey(): string;
|
|
19
20
|
protected update(props: PropertyValues): void;
|
|
20
21
|
protected render(): import("lit").TemplateResult<1>;
|
|
21
22
|
private setPeriodFilter;
|
|
@@ -18,52 +18,67 @@ import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
|
18
18
|
class FtSearchPeriodFilter extends withI18n(FtSearchComponent) {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
|
-
this.key = "ft:lastEdition";
|
|
22
21
|
this.metadataDescriptors = [];
|
|
23
22
|
this.dateFilter = undefined;
|
|
24
23
|
this.addI18nContext(periodFilterContext, periodFilterDefaultMessages);
|
|
25
24
|
this.addStore(ftAppInfoStore);
|
|
26
25
|
}
|
|
26
|
+
get metadataKey() {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = this.key) !== null && _a !== void 0 ? _a : "ft:lastEdition";
|
|
29
|
+
}
|
|
27
30
|
update(props) {
|
|
28
31
|
var _a;
|
|
29
32
|
super.update(props);
|
|
30
33
|
if (props.has("filters") || props.has("key")) {
|
|
31
|
-
this.dateFilter = (_a = this.filters) === null || _a === void 0 ? void 0 : _a.filter(f => f.key === this.
|
|
34
|
+
this.dateFilter = (_a = this.filters) === null || _a === void 0 ? void 0 : _a.filter(f => f.key === this.metadataKey).filter(f => f.dateFilter).map(f => f.dateFilter).find(Boolean);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
render() {
|
|
35
38
|
var _a, _b, _c, _d;
|
|
36
|
-
return html
|
|
37
|
-
<div part="
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<ft-radio
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
return html `
|
|
40
|
+
<div part="container">
|
|
41
|
+
<div part="header">
|
|
42
|
+
<ft-typography variant="overline" part="label" id="label">
|
|
43
|
+
${this.header()}
|
|
44
|
+
</ft-typography>
|
|
45
|
+
</div>
|
|
46
|
+
<ft-radio-group @change=${(e) => this.setPeriodFilter(e)} aria-labelledby="label">
|
|
47
|
+
<ft-radio value="anyTime" ?checked=${this.dateFilter === undefined || this.dateFilter.type === undefined}>
|
|
48
|
+
${periodFilterContext.messages.anyTime()}
|
|
49
|
+
</ft-radio>
|
|
50
|
+
${this.lessThanAWeek ? html `
|
|
51
|
+
<ft-radio ?checked=${((_a = this.dateFilter) === null || _a === void 0 ? void 0 : _a.type) == "LAST_WEEK"} value="LAST_WEEK">${periodFilterContext.messages.LAST_WEEK()}
|
|
52
|
+
</ft-radio>` : nothing}
|
|
53
|
+
${this.lessThanAMonth ? html `
|
|
54
|
+
<ft-radio ?checked=${((_b = this.dateFilter) === null || _b === void 0 ? void 0 : _b.type) == "LAST_MONTH"} value="LAST_MONTH">${periodFilterContext.messages.LAST_MONTH()}
|
|
55
|
+
</ft-radio>` : nothing}
|
|
56
|
+
${this.lessThanAQuarter ? html `
|
|
57
|
+
<ft-radio ?checked=${((_c = this.dateFilter) === null || _c === void 0 ? void 0 : _c.type) == "LAST_QUARTER"} value="LAST_QUARTER">
|
|
58
|
+
${periodFilterContext.messages.LAST_QUARTER()}
|
|
59
|
+
</ft-radio>` : nothing}
|
|
60
|
+
${this.lessThanAYear ? html `
|
|
61
|
+
<ft-radio ?checked=${((_d = this.dateFilter) === null || _d === void 0 ? void 0 : _d.type) == "LAST_YEAR"} value="LAST_YEAR">${periodFilterContext.messages.LAST_YEAR()}
|
|
62
|
+
</ft-radio>` : nothing}
|
|
63
|
+
</ft-radio-group>
|
|
64
|
+
</div>`;
|
|
50
65
|
}
|
|
51
66
|
setPeriodFilter(e) {
|
|
52
67
|
var _a, _b;
|
|
53
68
|
const dateType = FtDateFilterType[e.detail];
|
|
54
69
|
if (dateType) {
|
|
55
|
-
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setDateFilter(this.
|
|
70
|
+
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setDateFilter(this.metadataKey, dateType);
|
|
56
71
|
}
|
|
57
72
|
else {
|
|
58
|
-
(_b = this.stateManager) === null || _b === void 0 ? void 0 : _b.removeDateFilter(this.
|
|
73
|
+
(_b = this.stateManager) === null || _b === void 0 ? void 0 : _b.removeDateFilter(this.metadataKey);
|
|
59
74
|
}
|
|
60
75
|
}
|
|
61
76
|
header() {
|
|
62
77
|
var _a, _b, _c;
|
|
63
|
-
if (this.
|
|
78
|
+
if (this.metadataKey === "ft:lastEdition") {
|
|
64
79
|
return periodFilterContext.messages.label();
|
|
65
80
|
}
|
|
66
|
-
return (_c = (_b = (_a = this.metadataDescriptors) === null || _a === void 0 ? void 0 : _a.find(d => d.key == this.
|
|
81
|
+
return (_c = (_b = (_a = this.metadataDescriptors) === null || _a === void 0 ? void 0 : _a.find(d => d.key == this.metadataKey)) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : this.metadataKey;
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
FtSearchPeriodFilter.elementDefinitions = {
|