Skip to content

Commit

Permalink
[SearchBar] Dates, Booleans, Numbers and Range Clauses (#485)
Browse files Browse the repository at this point in the history
Added date, boolean and number support to the Query language. With that, also added support for the following operations on field clauses:

- greater than (`gt`)
- greater than or equals (`gte`)
- less than (`lt`)
- less than or equals (`lte`)

When it comes to date values, we try to cover a large range of user friendly formats, including terms such as: `today`, `yesterday`, `last week`, `next week`, `this week`, `this month` and `last/next month/year`.

Date operation also respect the granularity of the date.. for example, `today` refers to the full day, therefore the value has a `DAY` granularity. Therefore, the expression `date:'today'` will match any value that falls in the full day.

With this change, the search bar also supports a "schema" - this enables defining a more granular set of rules of how the query should be interpreted. For example, the schema may state that field `count` is of type 'number' - if the user tries to assign a string to this field, a parsing error will be triggered. Aside from the data types, the schema enables defining finer validation logic for the assigned field values.

The `EuiInMemoryTable` was updated such that it is now possible to set `schema: true` on its search box. This will deduce a schema from the configured columns. (this can further be enhanced in the future, by supporting `searchable` and `validate` properties on the table columns).
  • Loading branch information
uboness authored Mar 30, 2018
1 parent 13ca884 commit 1309398
Show file tree
Hide file tree
Showing 33 changed files with 2,917 additions and 377 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- Relaxed query syntax of `EuiSearchBar` to allow usage of hyphens without escaping ([#581](https://github.com/elastic/eui/pull/581))
- Added support for range queries in `EuiSearchBar` (works for numeric and date values) ([#485](https://github.com/elastic/eui/pull/485))
- Add support for expandable rows to `EuiBasicTable` ([#585](https://github.com/elastic/eui/pull/585))

# [`0.0.35`](https://github.com/elastic/eui/tree/v0.0.35)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"html-webpack-plugin": "^2.30.1",
"jest": "^22.0.6",
"jest-cli": "^22.0.6",
"moment": "2.19.3",
"moment": "^2.20.1",
"node-sass": "^4.5.3",
"npm-run": "^4.1.2",
"pegjs": "^0.10.0",
Expand Down
54 changes: 54 additions & 0 deletions src-docs/src/views/search_bar/props_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,60 @@ export const propsInfo = {
required: false,
defaultValue: { value: 'false' },
type: { name: 'boolean' }
},
schema: {
description: 'A schema describing the supported fields and flags',
required: false,
type: { name: '#Schema' }
}
}
}
},

Schema: {
__docgenInfo: {
_euiObjectType: 'type',
props: {
strict: {
description: 'Indicates whether the query parsing should be strictly compliant with the schema',
required: false,
defaultValue: { value: 'false' },
type: { name: 'boolean' }
},
flags: {
description: 'A list of supported flags',
required: false,
type: { name: 'string[]' }
},
fields: {
description: 'A dictionary of supported fields',
required: false,
type: { name: '{ [fieldName]: #SchemaField }' }
}
}
}
},

SchemaField: {
__docgenInfo: {
_euiObjectType: 'type',
props: {
type: {
description: 'The data type of the field',
required: true,
type: { name: 'boolean | string | date | number' }
},
valueDescription: {
description: 'A description of the values accepted by this field',
required: false,
defaultValue: { value: 'the data type' },
type: { name: 'string' }
},
validate: {
description: 'A function to validate a possible value for the field. An error should be thrown when ' +
'validation fails (with appropriate error message of course)',
required: false,
type: { name: '(value) => void' }
}
}
}
Expand Down
Loading

0 comments on commit 1309398

Please sign in to comment.