Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
a84f39cd
Commit
a84f39cd
authored
5 years ago
by
S.Listl
Browse files
Options
Downloads
Patches
Plain Diff
JditoFilter support for user-property selectionIgnoreCase
parent
2945588f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/JditoFilter_lib/process.js
+43
-28
43 additions, 28 deletions
process/JditoFilter_lib/process.js
with
43 additions
and
28 deletions
process/JditoFilter_lib/process.js
+
43
−
28
View file @
a84f39cd
import
(
"
system.tools
"
);
import
(
"
system.logging
"
);
import
(
"
Sql_lib
"
);
...
...
@@ -44,6 +45,8 @@ JditoFilterHelper.prototype.checkRecord = function (pRow)
if
(
this
.
filter
.
length
==
0
)
return
true
;
var
regexFlags
=
JditoFilterUtils
.
isUserIgnoreCase
()
?
"
i
"
:
undefined
;
return
_testRecord
.
call
(
this
,
this
.
filter
);
/**
...
...
@@ -74,17 +77,17 @@ JditoFilterHelper.prototype.checkRecord = function (pRow)
switch
(
pOperator
)
{
case
"
CONTAINS
"
:
return
(
new
RegExp
(
pFilterValue
)).
test
(
pRowValue
);
return
(
new
RegExp
(
pFilterValue
,
regexFlags
)).
test
(
pRowValue
);
case
"
CONTAINSNOT
"
:
return
!
(
new
RegExp
(
pFilterValue
)).
test
(
pRowValue
);
return
!
(
new
RegExp
(
pFilterValue
,
regexFlags
)).
test
(
pRowValue
);
case
"
STARTSWITH
"
:
return
(
new
RegExp
(
"
^
"
+
pFilterValue
)).
test
(
pRowValue
);
return
(
new
RegExp
(
"
^
"
+
pFilterValue
,
regexFlags
)).
test
(
pRowValue
);
case
"
ENDSWITH
"
:
return
(
new
RegExp
(
pFilterValue
+
"
$
"
)).
test
(
pRowValue
);
return
(
new
RegExp
(
pFilterValue
+
"
$
"
,
regexFlags
)).
test
(
pRowValue
);
case
"
EQUAL
"
:
return
(
new
RegExp
(
"
^
"
+
pFilterValue
+
"
$
"
)).
test
(
pRowValue
);
return
(
new
RegExp
(
"
^
"
+
pFilterValue
+
"
$
"
,
regexFlags
)).
test
(
pRowValue
);
case
"
NOT_EQUAL
"
:
return
!
(
new
RegExp
(
"
^
"
+
pFilterValue
+
"
$
"
)).
test
(
pRowValue
);
return
!
(
new
RegExp
(
"
^
"
+
pFilterValue
+
"
$
"
,
regexFlags
)).
test
(
pRowValue
);
case
"
LESS
"
:
return
pRowValue
<
pFilterValue
;
case
"
LESS_OR_EQUAL
"
:
...
...
@@ -192,7 +195,9 @@ JditoFilterUtils.filterRecords = function (pColumns, pRecords, pFilter, pCustomC
*/
JditoFilterUtils
.
getSqlCondition
=
function
(
pFilter
,
pTable
,
pTableAlias
,
pColumnOrFnMap
)
{
var
condition
=
newWhere
();
var
condition
=
newWhere
();
var
ignoreCase
=
JditoFilterUtils
.
isUserIgnoreCase
();
if
(
!
pFilter
)
return
condition
;
...
...
@@ -229,11 +234,15 @@ JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pTableAlias, pColu
}
else
{
condition
=
_getCondition
.
call
(
pFilter
,
pFilter
.
value
,
pFilter
.
operator
);
let
isStringType
,
filterValue
;
[
condition
,
filterValue
,
isStringType
]
=
_getCondition
(
pFilter
.
value
,
pFilter
.
operator
);
if
(
isStringType
&&
ignoreCase
)
condition
=
condition
.
replace
(
"
#
"
,
"
UPPER(#)
"
).
replace
(
"
?
"
,
"
UPPER(?)
"
);
if
(
pOperator
==
"
AND
"
)
this
.
andIfSet
(
pFilter
.
name
,
pF
ilter
.
v
alue
,
condition
);
this
.
andIfSet
(
pFilter
.
name
,
f
ilter
V
alue
,
condition
);
else
if
(
pOperator
==
"
OR
"
)
this
.
orIfSet
(
pFilter
.
name
,
pF
ilter
.
v
alue
,
condition
);
this
.
orIfSet
(
pFilter
.
name
,
f
ilter
V
alue
,
condition
);
}
}
else
if
(
pFilter
.
type
==
"
group
"
)
...
...
@@ -251,43 +260,49 @@ JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pTableAlias, pColu
}
}
//returns the condition depending on the operator and
//adds wildcards to the value if necessary
//returns [condition, value with wildcards, is a string type] depending on the operator
function
_getCondition
(
pValue
,
pOperator
)
{
switch
(
pOperator
)
{
case
"
CONTAINS
"
:
this
.
value
=
"
%
"
+
pValue
+
"
%
"
;
return
SqlBuilder
.
LIKE
();
return
[
SqlBuilder
.
LIKE
(),
"
%
"
+
pValue
+
"
%
"
,
true
];
case
"
CONTAINSNOT
"
:
this
.
value
=
"
%
"
+
pValue
+
"
%
"
;
return
SqlBuilder
.
NOT_LIKE
();
return
[
SqlBuilder
.
NOT_LIKE
(),
"
%
"
+
pValue
+
"
%
"
,
true
];
case
"
STARTSWITH
"
:
this
.
value
=
pValue
+
"
%
"
;
return
SqlBuilder
.
LIKE
();
return
[
SqlBuilder
.
LIKE
(),
pValue
+
"
%
"
,
true
];
case
"
ENDSWITH
"
:
this
.
value
=
"
%
"
+
pValue
;
return
SqlBuilder
.
LIKE
();
return
[
SqlBuilder
.
LIKE
(),
"
%
"
+
pValue
,
true
];
case
"
EQUAL
"
:
return
SqlBuilder
.
EQUAL
();
return
[
SqlBuilder
.
EQUAL
()
,
pValue
,
true
]
;
case
"
NOT_EQUAL
"
:
return
SqlBuilder
.
NOT_EQUAL
();
return
[
SqlBuilder
.
NOT_EQUAL
()
,
pValue
,
true
]
;
case
"
LESS
"
:
return
SqlBuilder
.
LESS
();
return
[
SqlBuilder
.
LESS
()
,
pValue
,
false
]
;
case
"
LESS_OR_EQUAL
"
:
return
SqlBuilder
.
LESS_OR_EQUAL
();
return
[
SqlBuilder
.
LESS_OR_EQUAL
()
,
pValue
,
false
]
;
case
"
GREATER
"
:
return
SqlBuilder
.
GREATER
();
return
[
SqlBuilder
.
GREATER
()
,
pValue
,
false
]
;
case
"
GREATER_OR_EQUAL
"
:
return
SqlBuilder
.
GREATER_OR_EQUAL
();
return
[
SqlBuilder
.
GREATER_OR_EQUAL
()
,
pValue
,
false
]
;
case
"
ISNULL
"
:
return
"
# is null
"
;
return
[
"
# is null
"
,
pValue
,
false
]
;
case
"
ISNOTNULL
"
:
return
"
# is not null
"
;
return
[
"
# is not null
"
,
pValue
,
false
]
;
}
}
}
/**
* @return {boolean} the selectionIgnoreCase property of the current user, defaults to true
*/
JditoFilterUtils
.
isUserIgnoreCase
=
function
()
{
var
user
=
tools
.
getCurrentUser
();
var
ignoreCase
=
user
?
user
[
tools
.
PARAMS
][
tools
.
SELECTION_IGNORECASE
]
:
""
;
return
ignoreCase
==
""
||
/true/i
.
test
(
ignoreCase
);
}
return
JditoFilterUtils
;
//return only functions that should be public
})();
This diff is collapsed.
Click to expand it.
Sebastian Listl
@s.listl
mentioned in commit
03f5dcc0
·
5 years ago
mentioned in commit
03f5dcc0
mentioned in commit 03f5dcc0140132786c291c2b6487c07ef6a7b625
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment