forked from Wavyzz/dolibarr
Enhance Custom Report Filter Editor (#32154)
* Enhance filter editor * add trans keys --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -1105,7 +1105,7 @@ function getParameterByName(name, valueifnotfound)
|
||||
/**
|
||||
* Get the list of operators for a given field type
|
||||
*/
|
||||
function getOperatorsForFieldType(type) {
|
||||
function getOperatorsForFieldType(type, maybenull = 0) {
|
||||
// Define the list of operators for each general field category
|
||||
const operatorList = {
|
||||
selectlink: {
|
||||
@@ -1147,8 +1147,8 @@ function getOperatorsForFieldType(type) {
|
||||
|
||||
console.log('Get list of operators for type='+type);
|
||||
|
||||
if (/^select$/i.test(type) || /^link$/i.test(type)) {
|
||||
generalType = "selectlink";
|
||||
if (/^select$/i.test(type) || /^link$/i.test(type)) {
|
||||
generalType = "selectlink";
|
||||
} else if (/^(varchar|char|text|blob|nchar|mediumtext|longtext)\(\d+\)$/i.test(type) || /^varchar$/i.test(type)) {
|
||||
generalType = "text";
|
||||
} else if (/^(int|integer|float|double|decimal|numeric)(\(\d+,\d+\))?$/i.test(type)) {
|
||||
@@ -1165,6 +1165,12 @@ function getOperatorsForFieldType(type) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// If maybenull is true, then append the "IsDefined" and "IsNotDefined" operators
|
||||
if (maybenull === 1) {
|
||||
operatorList[generalType]["IsDefined"] = '<?php print dol_escape_js($langs->trans('IsDefined')); ?>';
|
||||
operatorList[generalType]["IsNotDefined"] = '<?php print dol_escape_js($langs->trans('IsNotDefined')); ?>';
|
||||
}
|
||||
|
||||
// Return the operators for the general type, or an empty array if not found
|
||||
return operatorList[generalType] || [];
|
||||
}
|
||||
@@ -1194,6 +1200,12 @@ function generateFilterString(column, operator, context, fieldType) {
|
||||
case "EndsWith":
|
||||
filter = column + " like \'%" + context + "\'";
|
||||
break;
|
||||
case "IsDefined":
|
||||
filter = column + ":isnot:null";
|
||||
break;
|
||||
case "IsNotDefined":
|
||||
filter = column + ":is:null";
|
||||
break;
|
||||
case "=":
|
||||
filter = column + " = \'" + context + "\'";
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user