From 0ca6f36bc29d5ff444be323c33ee52c988eab5cf Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 9 Feb 2024 15:39:18 -0600 Subject: [PATCH] CE-798 more flexibility (+1 style) in getValuesString --- src/qqq/utils/qqq/FilterUtils.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/qqq/utils/qqq/FilterUtils.tsx b/src/qqq/utils/qqq/FilterUtils.tsx index 703e594..88ab5ea 100644 --- a/src/qqq/utils/qqq/FilterUtils.tsx +++ b/src/qqq/utils/qqq/FilterUtils.tsx @@ -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(", "));