SearchFilter.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _reactMaterialize = require("react-materialize");
  8. var _modularityFront = _interopRequireDefault(require("modularity-front"));
  9. var _searchbar = _interopRequireDefault(require("../searchbar"));
  10. require("./Filter.css");
  11. var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
  12. var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  16. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  17. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  19. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  21. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  22. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  23. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  24. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  25. var Module = _modularityFront.default.Module;
  26. var SearchFilter =
  27. /*#__PURE__*/
  28. function (_Modularity$Module) {
  29. _inherits(SearchFilter, _Modularity$Module);
  30. function SearchFilter(props) {
  31. var _this;
  32. _classCallCheck(this, SearchFilter);
  33. _this = _possibleConstructorReturn(this, _getPrototypeOf(SearchFilter).call(this, props));
  34. _this.state = _objectSpread({}, props.filter, {
  35. values: [props.filter.defaultValue || ""]
  36. });
  37. return _this;
  38. }
  39. _createClass(SearchFilter, [{
  40. key: "checkFilter",
  41. value: function checkFilter(value) {
  42. var values = value === undefined ? [this.props.filter.defaultValue] : [value];
  43. this.setState({
  44. values: values
  45. });
  46. this.Filters.set(_objectSpread({}, this.state, {
  47. values: values
  48. }));
  49. }
  50. }, {
  51. key: "render",
  52. value: function render() {
  53. var _this2 = this;
  54. return _react.default.createElement("div", {
  55. className: "flex-search"
  56. }, _react.default.createElement("div", null, this.filter.value.name), _react.default.createElement(_searchbar.default, {
  57. SearchBar: {
  58. defaultValue: this.filter.value.defaultValue,
  59. placeholder: this.filter.value.name
  60. },
  61. SearchData: function SearchData(data) {
  62. return _this2.checkFilter(data);
  63. }
  64. }));
  65. }
  66. }]);
  67. return SearchFilter;
  68. }(_modularityFront.default.Module);
  69. SearchFilter.Inputs = {
  70. filter: {
  71. type: Module.Types.Object
  72. }
  73. };
  74. SearchFilter.Outputs = {
  75. Filters: {}
  76. };
  77. SearchFilter.Category = 'sxoinas';
  78. var _default = SearchFilter;
  79. exports.default = _default;