CE-798 more flexibility (+1 style) in getValuesString

This commit is contained in:
2024-02-09 15:39:18 -06:00
parent 7a32d20acb
commit 0ca6f36bc2

View File

@ -319,7 +319,7 @@ class FilterUtils
** get the values associated with a criteria as a string, e.g., for showing
** in a tooltip.
*******************************************************************************/
public static getValuesString(fieldMetaData: QFieldMetaData, criteria: QFilterCriteria, maxValuesToShow: number = 3): string
public static getValuesString(fieldMetaData: QFieldMetaData, criteria: QFilterCriteria, maxValuesToShow: number = 3, andMoreFormat: "andNOther" | "+N" = "andNOther"): string
{
let valuesString = "";
@ -340,6 +340,10 @@ class FilterUtils
{
maxLoops = maxValuesToShow;
}
else if(maxValuesToShow == 1 && criteria.values.length > 1)
{
maxLoops = 1;
}
for (let i = 0; i < maxLoops; i++)
{
@ -383,7 +387,16 @@ class FilterUtils
if (maxLoops < criteria.values.length)
{
labels.push(" and " + (criteria.values.length - maxLoops) + " other values.");
const n = criteria.values.length - maxLoops;
switch (andMoreFormat)
{
case "andNOther":
labels.push(` and ${n} other value${n == 1 ? "" : "s"}.`);
break;
case "+N":
labels[labels.length-1] += ` +${n}`;
break;
}
}
valuesString = (labels.join(", "));