diff --git a/frontend/taipy/src/CoreSelector.tsx b/frontend/taipy/src/CoreSelector.tsx
index c42a767ac6..e7deb149e6 100644
--- a/frontend/taipy/src/CoreSelector.tsx
+++ b/frontend/taipy/src/CoreSelector.tsx
@@ -62,7 +62,6 @@ import {
BadgePos,
BadgeSx,
BaseTreeViewSx,
- EmptyArray,
FlagSx,
ParentItemSx,
getUpdateVarNames,
@@ -126,7 +125,7 @@ const tinyPinIconButtonSx = (theme: Theme) => ({
const switchBoxSx = { ml: 2, width: (theme: Theme) => `calc(100% - ${theme.spacing(2)})` };
const iconInRowSx = { fontSize: "body2.fontSize" };
-const labelInRowSx = {"& .MuiFormControlLabel-label": iconInRowSx};
+const labelInRowSx = { "& .MuiFormControlLabel-label": iconInRowSx };
const CoreItem = (props: {
item: Entity;
@@ -139,25 +138,27 @@ const CoreItem = (props: {
hideNonPinned: boolean;
active: boolean;
}) => {
- const [id, label, items = EmptyArray, nodeType, primary] = props.item;
+ const [id, label, items, nodeType, primary] = props.item;
const isPinned = props.pins[0][id];
const isShown = props.hideNonPinned ? props.pins[1][id] : true;
return !props.displayCycles && nodeType === NodeType.CYCLE ? (
<>
- {items.map((item) => (
-
- ))}
+ {items
+ ? items.map((item) => (
+
+ ))
+ : null}
>
) : isShown ? (
- {items.map((item) => (
-
- ))}
+ {items ?
+ items.map((item) => (
+
+ )) : null}
) : null;
};
@@ -374,7 +376,8 @@ const CoreSelector = (props: CoreSelectorProps) => {
setSelectedItems(() => {
const lovVar = getUpdateVar(updateVars, lovPropertyName);
const val = multiple ? nodeId : isSelectable ? nodeId : "";
- setTimeout( // to avoid set state while render react errors
+ setTimeout(
+ // to avoid set state while render react errors
() => dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate, lovVar)),
1
);
@@ -526,15 +529,19 @@ const CoreSelector = (props: CoreSelectorProps) => {
localStoreSet(jsonFilters, id, lovPropertyName, "filter");
const filterVar = getUpdateVar(updateCoreVars, "filter");
const lovVar = getUpdateVarNames(updateVars, lovPropertyName);
- setTimeout(() => dispatch(
- createRequestUpdateAction(
- id,
- module,
- lovVar,
- true,
- filterVar ? { [filterVar]: filters } : undefined
- )
- ), 1);
+ setTimeout(
+ () =>
+ dispatch(
+ createRequestUpdateAction(
+ id,
+ module,
+ lovVar,
+ true,
+ filterVar ? { [filterVar]: filters } : undefined
+ )
+ ),
+ 1
+ );
return filters;
}
return old;
@@ -674,20 +681,22 @@ const CoreSelector = (props: CoreSelectorProps) => {
onItemExpansionToggle={onItemExpand}
>
{foundEntities
- ? foundEntities.map((item) => (
-
- ))
+ ? foundEntities.map((item) =>
+ item ? (
+
+ ) : null
+ )
: null}
>
diff --git a/taipy/gui/utils/_adapter.py b/taipy/gui/utils/_adapter.py
index 8e7aafa5f6..eacb2489d3 100644
--- a/taipy/gui/utils/_adapter.py
+++ b/taipy/gui/utils/_adapter.py
@@ -185,9 +185,21 @@ def __get_label(self, value: t.Any, dig=True) -> t.Union[str, t.Dict, None]:
def __get_children(self, value: t.Any) -> t.Optional[t.List[t.Any]]:
if isinstance(value, (tuple, list)) and len(value) > 2:
- return value[2] if isinstance(value[2], list) else [value[2]]
+ return value[2] if isinstance(value[2], list) else None if value[2] is None else [value[2]]
elif hasattr(value, "children"):
- return value.children if isinstance(value.children, list) else [value.children]
+ return (
+ value.children
+ if isinstance(value.children, list)
+ else None
+ if value.children is None
+ else [value.children]
+ )
elif hasattr(value, "__getitem__") and "children" in value:
- return value["children"] if isinstance(value["children"], list) else [value["children"]]
+ return (
+ value["children"]
+ if isinstance(value["children"], list)
+ else None
+ if value["children"] is None
+ else [value["children"]]
+ )
return None
diff --git a/taipy/gui_core/_context.py b/taipy/gui_core/_context.py
index 76d598740d..b4cd662223 100644
--- a/taipy/gui_core/_context.py
+++ b/taipy/gui_core/_context.py
@@ -693,7 +693,7 @@ def data_node_adapter(
raise NotImplementedError
if isinstance(data, list):
if data[2] and isinstance(data[2][0], (Cycle, Scenario, Sequence, DataNode)):
- data[2] = self.get_sorted_datanode_list(data[2], sorts, adapt_dn)
+ data[2] = self.get_sorted_datanode_list(data[2], sorts, False)
return data
try:
if hasattr(data, "id") and is_readable(data.id) and core_get(data.id) is not None:
@@ -715,7 +715,7 @@ def data_node_adapter(
self.data_nodes_by_owner.get(data.id, [])
+ (self.scenario_by_cycle or {}).get(data, []),
sorts,
- adapt_dn,
+ False,
),
_EntityType.CYCLE.value,
False,
@@ -727,7 +727,7 @@ def data_node_adapter(
self.get_sorted_datanode_list(
self.data_nodes_by_owner.get(data.id, []) + list(data.sequences.values()),
sorts,
- adapt_dn,
+ False,
),
_EntityType.SCENARIO.value,
data.is_primary,
@@ -737,7 +737,7 @@ def data_node_adapter(
return [
data.id,
data.get_simple_label(),
- self.get_sorted_datanode_list(datanodes, sorts, adapt_dn),
+ self.get_sorted_datanode_list(datanodes, sorts, False),
_EntityType.SEQUENCE.value,
]
except Exception as e:
diff --git a/taipy/templates/scenario-management/{{cookiecutter.__root_folder_name}}/pages/scenario_page/data_node_management.py b/taipy/templates/scenario-management/{{cookiecutter.__root_folder_name}}/pages/scenario_page/data_node_management.py
index de24e51cbf..3c4954e5d4 100644
--- a/taipy/templates/scenario-management/{{cookiecutter.__root_folder_name}}/pages/scenario_page/data_node_management.py
+++ b/taipy/templates/scenario-management/{{cookiecutter.__root_folder_name}}/pages/scenario_page/data_node_management.py
@@ -9,37 +9,40 @@
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
+import taipy.gui.builder as tgb
+
+
# build partial content for a specific data node
def build_dn_partial(dn, dn_label):
- partial_content = "<|part|render={selected_scenario}|\n\n"
-
- # ##################################################################################################################
- # PLACEHOLDER: data node specific content before automatic content #
- # #
- # Example: #
- if dn_label == "replacement_type":
- partial_content += "All missing values will be replaced by the data node value."
- # Comment, remove or replace the previous lines with your own use case #
- # ##################################################################################################################
-
- # Automatic data node content
- partial_content += (
- "<|{selected_scenario.data_nodes['" + dn.config_id + "']}|data_node|scenario={" "selected_scenario}|>\n\n "
- )
-
- # ##################################################################################################################
- # PLACEHOLDER: data node specific content after automatic content #
- # #
- # Example: #
- if dn_label == "initial_dataset":
- partial_content += (
- "Select your CSV file: <|{selected_data_node.path}|file_selector|extensions=.csv|on_action"
- "={lambda s: s.refresh('selected_scenario')}|>\n\n "
- )
- # Comment, remove or replace the previous lines with your own use case #
- # ##################################################################################################################
-
- partial_content += "|>\n\n"
+ with tgb.Page() as partial_content:
+ with tgb.part(render="{selected_scenario}"):
+ # ##########################################################################################################
+ # PLACEHOLDER: data node specific content before automatic content #
+ # #
+ # Example: #
+ if dn_label == "replacement_type":
+ tgb.text("All missing values will be replaced by the data node value.")
+ # Comment, remove or replace the previous lines with your own use case #
+ # ##########################################################################################################
+
+ # Automatic data node content
+ tgb.data_node("{selected_scenario.data_nodes['" + dn.config_id + "']}", scenario="{selected_scenario}")
+
+ # ##########################################################################################################
+ # PLACEHOLDER: data node specific content after automatic content #
+ # #
+ # Example: #
+ if dn_label == "initial_dataset":
+ tgb.text("Select your CSV file:")
+ tgb.file_selector(
+ "{selected_data_node.path}",
+ extensions=".csv",
+ on_action="{lambda s: s.refresh('selected_scenario')}",
+ )
+
+ # Comment, remove or replace the previous lines with your own use case #
+ # ##########################################################################################################
+
return partial_content