From d4a675e952aee5b96ab8c0fb49717f9fbbc0566f Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Fri, 6 Jun 2025 19:17:10 -0500 Subject: [PATCH] updated to include the unique count of valid values --- .../components/query/FilterCriteriaPaster.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qqq/components/query/FilterCriteriaPaster.tsx b/src/qqq/components/query/FilterCriteriaPaster.tsx index fbd3c25..0107953 100644 --- a/src/qqq/components/query/FilterCriteriaPaster.tsx +++ b/src/qqq/components/query/FilterCriteriaPaster.tsx @@ -91,6 +91,7 @@ function FilterCriteriaPaster({table, field, type, onSave}: Props): JSX.Element const [delimiterCharacter, setDelimiterCharacter] = useState(""); const [customDelimiterValue, setCustomDelimiterValue] = useState(""); const [chipData, setChipData] = useState(undefined); + const [uniqueCount, setUniqueCount] = useState(undefined); const [chipValidity, setChipValidity] = useState([] as boolean[]); const [chipPVSIds, setChipPVSIds] = useState([] as any[]); const [detectedText, setDetectedText] = useState(""); @@ -297,6 +298,7 @@ function FilterCriteriaPaster({table, field, type, onSave}: Props): JSX.Element let regex = new RegExp(currentDelimiterCharacter); let parts = inputText.split(regex); let chipData = [] as string[]; + const uniqueValuesMap: { [key: string]: number } = {}; /////////////////////////////////////////////////////// // if delimiter is empty string, dont split anything // @@ -312,9 +314,9 @@ function FilterCriteriaPaster({table, field, type, onSave}: Props): JSX.Element { chipData.push(part); - ////////////////////////////////////////////////////////////////////// - // if numeric or pvs, check validity first before pushing as a chip // - ////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////// + // if numeric or pvs, check validity and add to invalid count // + //////////////////////////////////////////////////////////////// if (chipValidity[i] != null && chipValidity[i] !== true) { if ((type === "number" && Number.isNaN(Number(part))) || type === "pvs") @@ -322,6 +324,11 @@ function FilterCriteriaPaster({table, field, type, onSave}: Props): JSX.Element invalidCount++; } } + else + { + let count = uniqueValuesMap[part] == null ? 0 : uniqueValuesMap[part]; + uniqueValuesMap[part] = count + 1; + } } } } @@ -340,6 +347,7 @@ function FilterCriteriaPaster({table, field, type, onSave}: Props): JSX.Element } } + setUniqueCount(Object.keys(uniqueValuesMap).length); setChipData(chipData); }, [inputText, delimiterCharacter, customDelimiterValue, detectedText, chipValidity]); @@ -490,7 +498,7 @@ function FilterCriteriaPaster({table, field, type, onSave}: Props): JSX.Element { chipData && chipData.length > 0 && ( - {chipData.length.toLocaleString()} {chipData.length === 1 ? "value" : "values"} + {chipData.length.toLocaleString()} {chipData.length === 1 ? "value" : "values"} {uniqueCount && `(${uniqueCount} unique)`} ) }