Skip to content

Commit

Permalink
[NEP-12629] Fix filters default value.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Aksiutin committed Feb 20, 2022
1 parent df27902 commit 106b84b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 33 deletions.
21 changes: 14 additions & 7 deletions dist/react-filterbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18224,7 +18224,8 @@ var FilterGroup = /*#__PURE__*/function (_React$Component) {
style: {
marginTop: 'auto',
marginBottom: 'auto',
padding: '10px'
padding: '10px',
minWidth: '150px'
},
key: Math.random()
}, /*#__PURE__*/React.createElement(_FilterInput.FilterInput, {
Expand Down Expand Up @@ -22077,6 +22078,12 @@ var _SearchClient = require("../clients/SearchClient");

function _typeof(obj) { "@babel/helpers - typeof"; 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); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

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; }

function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
Expand Down Expand Up @@ -22105,7 +22112,7 @@ var FilterBarStore = /*#__PURE__*/function () {
this.exportResultsUrl = configuration.exportResultsUrl;
this.exportPageLimit = configuration.exportPageLimit;
this.exportPageLimitExceededMessage = configuration.exportPageLimitExceededMessage;
this.filters = configuration.filters;
this.filters = configuration.filters || {};
this.activeFilters = configuration.activeFilters || [];
this.quickFilters = configuration.quickFilters || {};

Expand Down Expand Up @@ -22480,13 +22487,13 @@ var FilterBarStore = /*#__PURE__*/function () {
}, {
key: "addGroupFilter",
value: function addGroupFilter(filterUid, groupKey, value) {
var filter = this.filters[filterUid];
var filterTemplate = this.filters[filterUid];

var filter = _objectSpread({}, filterTemplate);

filter.filterUid = filterUid;
filter.uid = filterUid;

if (value) {
filter.value = value;
}
filter.value = value;

if (groupKey == undefined) {
this.activeFilters.push([filter]);
Expand Down
8 changes: 4 additions & 4 deletions dist/react-filterbar.min.js

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions docs/react-components-structure.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
React Components Structure
--------------------------
### React Components Structure

FilterBar
-> FilterList
Expand All @@ -8,16 +7,22 @@ FilterBar
-> ClearFiltersButton
-> SaveFiltersButton
-> SavedSearchesList
-> ConfigurationButton *
-> ExportResultsButton *
-> ConfigurationButton
-> ExportResultsButton
-> BatchActionsList
-> FilterDisplay
-> FilterGroup
-> FilterItem
-> FilterButton
-> FilterButton
-> FilterInput
-> FilterButton ("OR" button)
-> FilterListOption
-> FilterButton ("ADD FILTER" or "ADD" button)
-> FilterListOption



### Filters Structure
Class _FilterBarStore_ has the following varables:
1. available filters
{} - available filters
[] - default filters
[
Expand Down
23 changes: 15 additions & 8 deletions example/public/js/react-filterbar.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class FilterGroup extends React.Component {
filters.push(
(
<div
style={ { marginTop: 'auto', marginBottom: 'auto', padding: '10px'} }
style={ { marginTop: 'auto', marginBottom: 'auto', padding: '10px', minWidth: '150px'} }
key={ Math.random() }
>
<FilterInput
Expand Down
11 changes: 5 additions & 6 deletions src/stores/FilterBarStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class FilterBarStore {
this.exportResultsUrl = configuration.exportResultsUrl;
this.exportPageLimit = configuration.exportPageLimit;
this.exportPageLimitExceededMessage = configuration.exportPageLimitExceededMessage;
this.filters = configuration.filters;
this.filters = configuration.filters || {};
this.activeFilters = configuration.activeFilters || [];
this.quickFilters = configuration.quickFilters || {};

Expand Down Expand Up @@ -212,13 +212,12 @@ export class FilterBarStore {
}

addGroupFilter(filterUid, groupKey, value) {
const filter = this.filters[filterUid];
const filterTemplate = this.filters[filterUid];
const filter = { ...filterTemplate };

filter.filterUid = filterUid;
filter.uid = filterUid;

if (value) {
filter.value = value
}
filter.value = value;

if (groupKey == undefined) {
this.activeFilters.push([filter])
Expand Down

0 comments on commit 106b84b

Please sign in to comment.