Skip to content

Commit

Permalink
fix(search): allow filtering for date values
Browse files Browse the repository at this point in the history
related to CAM-11808
  • Loading branch information
marstamm authored Oct 21, 2021
1 parent b95120f commit a9275a0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions webapps/ui/common/scripts/util/search-widget-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,12 @@ function getSearchValue(search) {
return sanitizeValue(
search.value.key,
search.value.value,
search.operator.value.key,
search
search.operator.value.key
);
}

var simpleDateExp = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(|\.[0-9]{0,4})$/;
function sanitizeValue(key, value, operator, search) {
function sanitizeValue(key, value, operator) {
// Regex for '\_' and '\%' epxressions
var specialWildCardCharExp = /(\\%)|(\\_)/g;
// Regex for '_' and '%' special characters
Expand All @@ -284,7 +283,7 @@ function sanitizeValue(key, value, operator, search) {
!wildCardExp.test(value.replace(specialWildCardCharExp, ''))
) {
return '%' + value + '%';
} else if (search.allowDates && simpleDateExp.test(value)) {
} else if (simpleDateExp.test(value)) {
return moment(value, moment.ISO_8601).format('YYYY-MM-DDTHH:mm:ss.SSSZZ');
}
return key ? key : value;
Expand Down

0 comments on commit a9275a0

Please sign in to comment.