Browse Source

filter UI on boolean col (#1382)

* filter UI on boolean col
resolves #1366

* col with lov

---------

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 11 months ago
parent
commit
9aa2c7a52b

+ 10 - 7
frontend/taipy-gui/src/components/Taipy/TableFilter.tsx

@@ -101,7 +101,7 @@ const getActionsByType = (colType?: string) =>
 const getFilterDesc = (columns: Record<string, ColumnDesc>, colId?: string, act?: string, val?: string) => {
     if (colId && act && val !== undefined) {
         const colType = getTypeFromDf(columns[colId].type);
-        if (!val && (colType === "date" || colType === "number" || colType === "boolean")) {
+        if (val === "" && (colType === "date" || colType === "number" || colType === "boolean")) {
             return;
         }
         try {
@@ -109,12 +109,14 @@ const getFilterDesc = (columns: Record<string, ColumnDesc>, colId?: string, act?
                 col: columns[colId].dfid,
                 action: act,
                 value:
-                    colType === "number"
-                        ? parseFloat(val)
-                        : colType === "boolean"
-                        ? val === "1"
-                        : colType === "date"
-                        ? getDateTime(val)
+                    typeof val === "string"
+                        ? colType === "number"
+                            ? parseFloat(val)
+                            : colType === "boolean"
+                            ? val === "1"
+                            : colType === "date"
+                            ? getDateTime(val)
+                            : val
                         : val,
             } as FilterDesc;
         } catch (e) {
@@ -268,6 +270,7 @@ const FilterRow = (props: FilterRowProps) => {
                 ) : colLov ? (
                     <Autocomplete
                         freeSolo
+                        autoSelect
                         disableClearable
                         options={colLov}
                         value={val || ""}

+ 9 - 2
taipy/gui_core/_adapters.py

@@ -401,9 +401,16 @@ class _GuiCoreScenarioProperties(_GuiCoreProperties):
     def get_enums(self):
         if _GuiCoreScenarioProperties.__ENUMS is None:
             _GuiCoreScenarioProperties.__ENUMS = {
-                "Config id": [c for c in Config.scenarios.keys() if c != "default"],
-                "Tags": list({t for s in Config.scenarios.values() for t in s.properties.get("authorized_tags", [])}),
+                k: v
+                for k, v in {
+                    "Config id": [c for c in Config.scenarios.keys() if c != "default"],
+                    "Tags": list(
+                        {t for s in Config.scenarios.values() for t in s.properties.get("authorized_tags", [])}
+                    ),
+                }.items()
+                if len(v)
             }
+
         return _GuiCoreScenarioProperties.__ENUMS if self.full_desc() else {}
 
     @staticmethod