Просмотр исходного кода

file_selector notify property (default True) (#946)

* file_selector notify property (default True)
support TimleDelta
resolves #573
resolves #455

* dependency

---------

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 1 год назад
Родитель
Сommit
1903c9b214

+ 5 - 3
frontend/taipy-gui/src/components/Taipy/FileSelector.tsx

@@ -30,6 +30,7 @@ interface FileSelectorProps extends TaipyActiveProps {
     multiple?: boolean;
     extensions?: string;
     dropMessage?: string;
+    notify?: boolean;
 }
 
 const handleDragOver = (evt: DragEvent) => {
@@ -50,6 +51,7 @@ const FileSelector = (props: FileSelectorProps) => {
         extensions = ".csv,.xlsx",
         dropMessage = "Drop here to Upload",
         label,
+        notify = true,
     } = props;
     const [dropLabel, setDropLabel] = useState("");
     const [dropSx, setDropSx] = useState(defaultSx);
@@ -74,20 +76,20 @@ const FileSelector = (props: FileSelectorProps) => {
                     (value) => {
                         setUpload(false);
                         onAction && dispatch(createSendActionNameAction(id, module, onAction));
-                        dispatch(
+                        notify && dispatch(
                             createAlertAction({ atype: "success", message: value, system: false, duration: 3000 })
                         );
                     },
                     (reason) => {
                         setUpload(false);
-                        dispatch(
+                        notify && dispatch(
                             createAlertAction({ atype: "error", message: reason, system: false, duration: 3000 })
                         );
                     }
                 );
             }
         },
-        [state.id, id, onAction, updateVarName, dispatch, module]
+        [state.id, id, onAction, notify, updateVarName, dispatch, module]
     );
 
     const handleChange = useCallback(

+ 1 - 0
taipy/gui/_renderers/factory.py

@@ -225,6 +225,7 @@ class _Factory:
                 ("extensions",),
                 ("drop_message",),
                 ("hover_text", PropertyType.dynamic_string),
+                ("notify", PropertyType.boolean, True),
             ]
         ),
         "image": lambda gui, control_type, attrs: _Builder(

+ 4 - 1
taipy/gui/_renderers/json.py

@@ -12,10 +12,11 @@ from __future__ import annotations
 
 import typing as t
 from abc import ABC, abstractmethod
-from datetime import date, datetime, time
+from datetime import date, datetime, time, timedelta
 from json import JSONEncoder
 from pathlib import Path
 
+import pandas
 from flask.json.provider import DefaultJSONProvider
 
 from .._warnings import _warn
@@ -45,6 +46,8 @@ class _DefaultJsonAdapter(JsonAdapter):
             return _date_to_string(o)
         if isinstance(o, Path):
             return str(o)
+        if isinstance(o, (timedelta, pandas.Timedelta)):
+            return str(o)
 
 
 class _TaipyJsonAdapter(object, metaclass=_Singleton):

+ 7 - 1
taipy/gui/viselements.json

@@ -667,6 +667,12 @@
             "type": "str",
             "default_value": "\"Drop here to Upload\"",
             "doc": "The message that is displayed when the user drags a file above the button."
+          },
+          {
+            "name": "notify",
+            "type": "bool",
+            "default_value": "True",
+            "doc": "If set to False, the user won't be notified of upload finish."
           }
         ]
       }
@@ -1128,7 +1134,7 @@
           {
             "name": "downloadable",
             "type": "boolean",
-            "doc": "The indicator that would show the icon to allow the user to download the data as a csv file if True."
+            "doc": "If True, a clickable icon is shown so the user can download the data as CSV."
           }
         ]
       }