-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
884 additions
and
33 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.defaultBannerTemplate = void 0; | ||
exports.defaultBannerTemplate = "\n <div class=\"banner\">\n {{#has_url}}<a href=\"{{url}}\">{{/has_url}}\n <picture>\n <source srcset=\"{{image_prefix}}{{desktop_img}}\" media=\"(min-width: {{breaking_point_size}}px)\" />\n <img src=\"{{image_prefix}}{{mobile_img}}\" />\n </picture>\n {{#has_url}}</a>{{/has_url}}\n </div>\n"; | ||
exports.defaultBannerTemplate = "\n <div class=\"banner\">\n {{#has_url}}<a href=\"{{url}}\">{{/has_url}}\n <picture>\n <source srcset=\"{{image_prefix}}{{desktop_img}}\" media=\"(min-width: {{breaking_point_size}}px)\" />\n <img src=\"{{image_prefix}}{{mobile_img}}\" loading=\"lazy\" class=\"soft-lazy\" onload=\"window.asImageShow(this)\" />\n </picture>\n {{#has_url}}</a>{{/has_url}}\n </div>\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.priorityFilterAction = exports.setupPriorityFilters = void 0; | ||
var Constants_1 = require("../../Constants"); | ||
var Container_1 = require("../../Container"); | ||
var Clone_1 = require("../Clone"); | ||
function setupPriorityFilters(environmentId, currentQuery, filters) { | ||
var clonedQuery = Clone_1["default"].object(currentQuery); | ||
clonedQuery.setMetadataValue("pf", filters); | ||
var dispatcher = Container_1["default"].get("".concat(Constants_1.APISEARCH_DISPATCHER, "__").concat(environmentId)); | ||
dispatcher.dispatch("UPDATE_APISEARCH_SETUP", { | ||
query: clonedQuery | ||
}); | ||
} | ||
exports.setupPriorityFilters = setupPriorityFilters; | ||
/** | ||
* @param environmentId | ||
* @param currentQuery | ||
* @param repository | ||
* @param filterName | ||
* @param filterField | ||
* @param filterValue | ||
* @param applicationType | ||
*/ | ||
function priorityFilterAction(environmentId, currentQuery, repository, filterName, filterField, filterValue, applicationType) { | ||
window.postMessage({ | ||
name: "apisearch_scroll_top" | ||
}, "*"); | ||
var clonedQuery = Clone_1["default"].object(currentQuery); | ||
clonedQuery.filterBy(filterName, filterField, [filterValue], applicationType, false); | ||
clonedQuery.page = 1; | ||
var dispatcher = Container_1["default"].get("".concat(Constants_1.APISEARCH_DISPATCHER, "__").concat(environmentId)); | ||
clonedQuery.setMetadataValue("af", [filterField, filterValue]); | ||
repository | ||
.query(clonedQuery) | ||
.then(function (result) { | ||
delete clonedQuery.metadata.af; | ||
dispatcher.dispatch("RENDER_FETCHED_DATA", { | ||
query: clonedQuery, | ||
result: result | ||
}); | ||
})["catch"](function (error) { | ||
// Do nothing | ||
}); | ||
} | ||
exports.priorityFilterAction = priorityFilterAction; |
117 changes: 117 additions & 0 deletions
117
lib/components/PriorityFilter/PriorityFilterComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
exports.__esModule = true; | ||
var preact_1 = require("preact"); | ||
var Template_1 = require("../Template"); | ||
var defaultTemplates_1 = require("./defaultTemplates"); | ||
var PriorityFilterActions_1 = require("./PriorityFilterActions"); | ||
/** | ||
* PriorityFilterComponent | ||
*/ | ||
var PriorityFilterComponent = /** @class */ (function (_super) { | ||
__extends(PriorityFilterComponent, _super); | ||
/** | ||
* Constructor | ||
*/ | ||
function PriorityFilterComponent() { | ||
var _this = _super.call(this) || this; | ||
_this.handleClick = function (filterValue) { | ||
var props = _this.props; | ||
var environmentId = props.environmentId; | ||
var repository = props.repository; | ||
var currentQuery = props.store.getCurrentQuery(); | ||
var priorityFilter = _this.props.store.getCurrentResult().getMetadataValue("priority_filter"); | ||
var priorityFilterName = priorityFilter.name; | ||
var priorityFilterObject = props.store.getCurrentQuery().getAggregation(priorityFilterName); | ||
(0, PriorityFilterActions_1.priorityFilterAction)(environmentId, currentQuery, repository, priorityFilterName, priorityFilterObject.getField().replace("indexed_metadata.", ""), filterValue, priorityFilterObject.getApplicationType()); | ||
}; | ||
_this.state = { | ||
filterName: "" | ||
}; | ||
return _this; | ||
} | ||
/** | ||
* Components will mount | ||
*/ | ||
PriorityFilterComponent.prototype.componentWillMount = function () { | ||
var props = this.props; | ||
/** | ||
* Dispatch action | ||
*/ | ||
(0, PriorityFilterActions_1.setupPriorityFilters)(props.environmentId, props.store.getCurrentQuery(), props.filters); | ||
}; | ||
/** | ||
* Component will receive props | ||
* | ||
* @param props | ||
*/ | ||
PriorityFilterComponent.prototype.componentWillReceiveProps = function (props) { | ||
this.setState(function (_) { | ||
return { | ||
filterName: props.store.getCurrentResult().getMetadataValue("priority_filter") | ||
}; | ||
}); | ||
}; | ||
/** | ||
* Render | ||
* | ||
* @return {any} | ||
*/ | ||
PriorityFilterComponent.prototype.render = function () { | ||
var _this = this; | ||
var priorityFilter = this.props.store.getCurrentResult().getMetadataValue("priority_filter"); | ||
if (!priorityFilter) { | ||
return null; | ||
} | ||
var priorityFilterName = priorityFilter.name; | ||
var that = this; | ||
return ((0, preact_1.h)("div", { className: "as-priorityFilter" }, | ||
(0, preact_1.h)(Template_1["default"], { template: this.props.template.top, className: "as-priorityFilter__top", dictionary: this.props.dictionary, data: { | ||
name: priorityFilterName | ||
} }), | ||
(0, preact_1.h)("div", { className: "as-priorityFilter__itemsList" }, | ||
(0, preact_1.h)("ul", null, Object.keys(priorityFilter.values).map(function (key) { | ||
var data = priorityFilter.values[key]; | ||
return ((0, preact_1.h)("li", { onClick: function (e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
that.handleClick(key); | ||
} }, | ||
(0, preact_1.h)(Template_1["default"], { template: _this.props.template.item, data: __assign(__assign({}, data), { value: key }), dictionary: _this.props.dictionary }))); | ||
}))))); | ||
}; | ||
return PriorityFilterComponent; | ||
}(preact_1.Component)); | ||
PriorityFilterComponent.defaultProps = { | ||
aggregationField: null, | ||
template: { | ||
item: defaultTemplates_1.defaultPriorityFilterItemTemplate, | ||
top: defaultTemplates_1.defaultPriorityFilterTopTemplate | ||
} | ||
}; | ||
exports["default"] = PriorityFilterComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
exports.__esModule = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
exports.__esModule = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.defaultPriorityFilterItemTemplate = exports.defaultPriorityFilterTopTemplate = void 0; | ||
exports.defaultPriorityFilterTopTemplate = "\n {{name}}\n"; | ||
exports.defaultPriorityFilterItemTemplate = "\n <div>{{value}}</div>\n <img src=\"{{image}}\" />\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
exports.__esModule = true; | ||
var preact_1 = require("preact"); | ||
var PriorityFilterComponent_1 = require("../components/PriorityFilter/PriorityFilterComponent"); | ||
var Widget_1 = require("./Widget"); | ||
/** | ||
* PriorityFilter | ||
*/ | ||
var PriorityFilter = /** @class */ (function (_super) { | ||
__extends(PriorityFilter, _super); | ||
/** | ||
* | ||
* @param target | ||
* @param filters | ||
* @param template | ||
*/ | ||
function PriorityFilter(_a) { | ||
var target = _a.target, filters = _a.filters, template = _a.template; | ||
var _this = _super.call(this) || this; | ||
_this.target = target; | ||
_this.component = (0, preact_1.h)(PriorityFilterComponent_1["default"], { target: target, filters: filters, template: __assign(__assign({}, PriorityFilterComponent_1["default"].defaultProps.template), template) }); | ||
return _this; | ||
} | ||
/** | ||
* @param environmentId | ||
* @param store | ||
* @param repository | ||
* @param dictionary | ||
*/ | ||
PriorityFilter.prototype.render = function (environmentId, store, repository, dictionary) { | ||
this.component.props = __assign(__assign({}, this.component.props), { dictionary: dictionary, environmentId: environmentId, repository: repository, store: store }); | ||
(0, preact_1.render)(this.component, document.querySelector(this.target)); | ||
}; | ||
return PriorityFilter; | ||
}(Widget_1["default"])); | ||
/** | ||
* Multiple filter widget | ||
* | ||
* @param settings | ||
*/ | ||
exports["default"] = (function (settings) { return new PriorityFilter(settings); }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.