1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
import { isSome } from "@jet/environment/types/optional";
import * as models from "./base";
/** @public */
export class PageFacetOption extends models.Model {
constructor(title, value, metricsValue = null, systemImageName = undefined) {
super();
this.title = title;
this.value = value;
this.systemImageName = systemImageName;
this.metricsValue = metricsValue;
}
}
PageFacetOption.defaultValue = "pageFacetsDefaultValue";
PageFacetOption.trueValue = new PageFacetOption("true", "false");
PageFacetOption.falseValue = new PageFacetOption("false", "false");
/** @public */
export class PageFacetsFacet extends models.Model {
constructor(id, parameterName, title, displayType, options = [], defaultOptions = null, metricsParameterName = null, clickAction = null, displayOptionsInline = false, showsSelectedOptions = false, isHiddenFromMenu = false) {
super();
this.id = id;
this.parameterName = parameterName;
this.title = title;
this.displayType = displayType;
this.defaultOptions = defaultOptions;
this.options = options;
this.metricsParameterName = metricsParameterName;
this.clickAction = clickAction;
this.displayOptionsInline = displayOptionsInline;
this.showsSelectedOptions = showsSelectedOptions;
this.isHiddenFromMenu = isHiddenFromMenu;
}
}
/** @public */
export class PageFacetsGroup extends models.Model {
constructor(facets = [], title = null) {
super();
this.title = title;
this.facets = facets;
}
}
/** @public */
export class PageFacets extends models.Model {
constructor(facetGroups, allowsResetButton, resetButtonTitle) {
super();
this.facetGroups = facetGroups;
this.allowsResetButton = allowsResetButton;
this.resetButtonTitle = resetButtonTitle;
}
static isDefinedNonNullNonEmpty(object) {
return isSome(object) && Object.keys(object).length !== 0;
}
}
/**
* Facet out nil values / join all values together returning the string used for a query parameter value
* returns null if resulting string would be empty or selectedOptions is null
* @param selectedOptions
*/
PageFacets.requestValuesForSelectedFacetOptions = function (selectedOptions) {
if (PageFacets.isDefinedNonNullNonEmpty(selectedOptions)) {
const facetOptionValue = selectedOptions
.filter((option) => {
return PageFacets.isDefinedNonNullNonEmpty(option.value);
})
.map((option) => {
return option.value;
})
.join(",");
const allFacetOptionValues = facetOptionValue.split("&");
const primaryValue = allFacetOptionValues[0];
const additionalQueryValues = allFacetOptionValues.splice(1);
const additionalKeyValuePairs = {};
for (const additionalQueryValue of additionalQueryValues) {
const keyValue = additionalQueryValue.split("=");
if (keyValue.length !== 2) {
continue;
}
additionalKeyValuePairs[keyValue[0]] = keyValue[1];
}
return {
value: primaryValue,
additionalKeyValuePairs: additionalKeyValuePairs,
};
}
else {
return null;
}
};
//# sourceMappingURL=page-facets.js.map
|