@fluid-topics/ft-search-period-filter 1.1.107 → 1.1.109
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,8 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
1
2
|
import { FtSearchPeriodFilterProperties } from "./ft-search-period-filter.properties";
|
|
2
3
|
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
3
4
|
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
4
|
-
import {
|
|
5
|
+
import { FtMetadataFilter } from "@fluid-topics/public-api";
|
|
5
6
|
declare const FtSearchPeriodFilter_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
6
7
|
export declare class FtSearchPeriodFilter extends FtSearchPeriodFilter_base implements FtSearchPeriodFilterProperties {
|
|
7
8
|
static elementDefinitions: ElementDefinitionsMap;
|
|
@@ -11,9 +12,11 @@ export declare class FtSearchPeriodFilter extends FtSearchPeriodFilter_base impl
|
|
|
11
12
|
lessThanAMonth?: boolean;
|
|
12
13
|
lessThanAQuarter?: boolean;
|
|
13
14
|
lessThanAYear?: boolean;
|
|
14
|
-
|
|
15
|
+
filters?: FtMetadataFilter[];
|
|
15
16
|
private metadataDescriptors;
|
|
17
|
+
private dateFilter?;
|
|
16
18
|
constructor();
|
|
19
|
+
protected update(props: PropertyValues): void;
|
|
17
20
|
protected render(): import("lit").TemplateResult<1>;
|
|
18
21
|
private setPeriodFilter;
|
|
19
22
|
private header;
|
|
@@ -13,16 +13,24 @@ import { periodFilterContext, periodFilterDefaultMessages } from "./SearchPeriod
|
|
|
13
13
|
import { property } from "lit/decorators.js";
|
|
14
14
|
import { FtRadio, FtRadioGroup } from "@fluid-topics/ft-radio";
|
|
15
15
|
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
16
|
-
import {
|
|
16
|
+
import { FtDateFilterType } from "@fluid-topics/public-api";
|
|
17
17
|
import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
18
18
|
class FtSearchPeriodFilter extends withI18n(FtSearchComponent) {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
this.key = "ft:lastEdition";
|
|
22
22
|
this.metadataDescriptors = [];
|
|
23
|
+
this.dateFilter = undefined;
|
|
23
24
|
this.addI18nContext(periodFilterContext, periodFilterDefaultMessages);
|
|
24
25
|
this.addStore(ftAppInfoStore);
|
|
25
26
|
}
|
|
27
|
+
update(props) {
|
|
28
|
+
var _a;
|
|
29
|
+
super.update(props);
|
|
30
|
+
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.key).filter(f => f.dateFilter).map(f => f.dateFilter).find(Boolean);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
render() {
|
|
27
35
|
var _a, _b, _c, _d;
|
|
28
36
|
return html `<div part="container">
|
|
@@ -32,21 +40,23 @@ class FtSearchPeriodFilter extends withI18n(FtSearchComponent) {
|
|
|
32
40
|
</ft-typography>
|
|
33
41
|
</div>
|
|
34
42
|
<ft-radio-group @change=${(e) => this.setPeriodFilter(e)} aria-labelledby="label">
|
|
35
|
-
<ft-radio value="anyTime" ?checked=${this.
|
|
36
|
-
${this.lessThanAWeek ? html `<ft-radio ?checked=${((_a = this.
|
|
37
|
-
${this.lessThanAMonth ? html `<ft-radio ?checked=${((_b = this.
|
|
38
|
-
${this.lessThanAQuarter ? html `<ft-radio ?checked=${((_c = this.
|
|
39
|
-
${this.lessThanAYear ? html `<ft-radio ?checked=${((_d = this.
|
|
43
|
+
<ft-radio value="anyTime" ?checked=${this.dateFilter === undefined || this.dateFilter.type === undefined}>${periodFilterContext.messages.anyTime()}</ft-radio>
|
|
44
|
+
${this.lessThanAWeek ? html `<ft-radio ?checked=${((_a = this.dateFilter) === null || _a === void 0 ? void 0 : _a.type) == "LAST_WEEK"} value="LAST_WEEK">${periodFilterContext.messages.LAST_WEEK()}</ft-radio>` : nothing}
|
|
45
|
+
${this.lessThanAMonth ? html `<ft-radio ?checked=${((_b = this.dateFilter) === null || _b === void 0 ? void 0 : _b.type) == "LAST_MONTH"} value="LAST_MONTH">${periodFilterContext.messages.LAST_MONTH()}</ft-radio>` : nothing}
|
|
46
|
+
${this.lessThanAQuarter ? html `<ft-radio ?checked=${((_c = this.dateFilter) === null || _c === void 0 ? void 0 : _c.type) == "LAST_QUARTER"} value="LAST_QUARTER">${periodFilterContext.messages.LAST_QUARTER()}</ft-radio>` : nothing}
|
|
47
|
+
${this.lessThanAYear ? html `<ft-radio ?checked=${((_d = this.dateFilter) === null || _d === void 0 ? void 0 : _d.type) == "LAST_YEAR"} value="LAST_YEAR">${periodFilterContext.messages.LAST_YEAR()}</ft-radio>` : nothing}
|
|
40
48
|
</ft-radio-group>
|
|
41
49
|
</div>`;
|
|
42
50
|
}
|
|
43
51
|
setPeriodFilter(e) {
|
|
44
|
-
var _a;
|
|
45
|
-
const
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
var _a, _b;
|
|
53
|
+
const dateType = FtDateFilterType[e.detail];
|
|
54
|
+
if (dateType) {
|
|
55
|
+
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setDateFilter(this.key, dateType);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(_b = this.stateManager) === null || _b === void 0 ? void 0 : _b.removeDateFilter(this.key);
|
|
59
|
+
}
|
|
50
60
|
}
|
|
51
61
|
header() {
|
|
52
62
|
var _a, _b, _c;
|
|
@@ -78,9 +88,12 @@ __decorate([
|
|
|
78
88
|
property({ type: Boolean })
|
|
79
89
|
], FtSearchPeriodFilter.prototype, "lessThanAYear", void 0);
|
|
80
90
|
__decorate([
|
|
81
|
-
redux({ store: "search", selector: (state) => state.request.
|
|
82
|
-
], FtSearchPeriodFilter.prototype, "
|
|
91
|
+
redux({ store: "search", selector: (state) => state.request.metadataFilters })
|
|
92
|
+
], FtSearchPeriodFilter.prototype, "filters", void 0);
|
|
83
93
|
__decorate([
|
|
84
94
|
redux({ store: ftAppInfoStore.name, selector: (s) => { var _a, _b; return (_b = (_a = s.metadataConfiguration) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : []; } })
|
|
85
95
|
], FtSearchPeriodFilter.prototype, "metadataDescriptors", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ attribute: false })
|
|
98
|
+
], FtSearchPeriodFilter.prototype, "dateFilter", void 0);
|
|
86
99
|
export { FtSearchPeriodFilter };
|