Skip to content

Commit

Permalink
Merge branch 'develop' into metric-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 authored Jun 7, 2024
2 parents a19f531 + dc45806 commit 273c6fd
Show file tree
Hide file tree
Showing 10 changed files with 3,613 additions and 1,121 deletions.
3,259 changes: 2,541 additions & 718 deletions frontend/taipy-gui/package-lock.json

Large diffs are not rendered by default.

813 changes: 587 additions & 226 deletions frontend/taipy/package-lock.json

Large diffs are not rendered by default.

34 changes: 19 additions & 15 deletions frontend/taipy/src/CoreSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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 CoreItem = (props: {
item: Entity;
Expand Down Expand Up @@ -373,7 +374,7 @@ const CoreSelector = (props: CoreSelectorProps) => {
setSelectedItems(() => {
const lovVar = getUpdateVar(updateVars, lovPropertyName);
const val = multiple ? nodeId : isSelectable ? nodeId : "";
setTimeout(
setTimeout( // to avoid set state while render react errors
() => dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate, lovVar)),
1
);
Expand Down Expand Up @@ -524,15 +525,16 @@ const CoreSelector = (props: CoreSelectorProps) => {
if (old.length != filters.length || JSON.stringify(old) != jsonFilters) {
localStoreSet(jsonFilters, id, lovPropertyName, "filter");
const filterVar = getUpdateVar(updateCoreVars, "filter");
dispatch(
const lovVar = getUpdateVarNames(updateVars, lovPropertyName);
setTimeout(() => dispatch(
createRequestUpdateAction(
id,
module,
getUpdateVarNames(updateVars, lovPropertyName),
lovVar,
true,
filterVar ? { [filterVar]: filters } : undefined
)
);
), 1);
return filters;
}
return old;
Expand Down Expand Up @@ -623,6 +625,17 @@ const CoreSelector = (props: CoreSelectorProps) => {
<TableSort columns={colSorts} appliedSorts={sorts} onValidate={applySorts}></TableSort>
</Grid>
) : null}
{showSearch ? (
<Grid item>
<IconButton onClick={onRevealSearch} size="small" sx={iconInRowSx}>
{revealSearch ? (
<SearchOffOutlined fontSize="inherit" />
) : (
<SearchOutlined fontSize="inherit" />
)}
</IconButton>
</Grid>
) : null}
{showPins ? (
<Grid item>
<FormControlLabel
Expand All @@ -631,23 +644,14 @@ const CoreSelector = (props: CoreSelectorProps) => {
onChange={onShowPinsChange}
checked={hideNonPinned}
disabled={!hideNonPinned && !Object.keys(pins[0]).length}
size="small"
/>
}
label="Pinned only"
sx={labelInRowSx}
/>
</Grid>
) : null}
{showSearch ? (
<Grid item>
<IconButton onClick={onRevealSearch} size="small" sx={iconInRowSx}>
{revealSearch ? (
<SearchOffOutlined fontSize="inherit" />
) : (
<SearchOutlined fontSize="inherit" />
)}
</IconButton>
</Grid>
) : null}
{showSearch && revealSearch ? (
<Grid item xs={12}>
<TextField
Expand Down
16 changes: 10 additions & 6 deletions frontend/taipy/src/NodeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import CoreSelector from "./CoreSelector";
interface NodeSelectorProps {
id?: string;
updateVarName?: string;
datanodes?: Cycles | Scenarios | DataNodes;
innerDatanodes?: Cycles | Scenarios | DataNodes;
coreChanged?: Record<string, unknown>;
updateVars: string;
onChange?: string;
Expand All @@ -37,22 +37,26 @@ interface NodeSelectorProps {
dynamicClassName?: string;
showPins?: boolean;
multiple?: boolean;
updateDnVars?: string;
filter?: string;
sort?: string;
showSearch?: boolean;
}

const NodeSelector = (props: NodeSelectorProps) => {
const { showPins = true, multiple = false } = props;
const { showPins = true, multiple = false, updateDnVars = "", showSearch = true } = props;
const className = useClassNames(props.libClassName, props.dynamicClassName, props.className);
return (
<Box sx={MainTreeBoxSx} id={props.id} className={className}>
<CoreSelector
{...props}
entities={props.datanodes}
entities={props.innerDatanodes}
leafType={NodeType.NODE}
lovPropertyName="datanodes"
lovPropertyName="innerDatanodes"
showPins={showPins}
multiple={multiple}
showSearch={false}
updateCoreVars=""
showSearch={showSearch}
updateCoreVars={updateDnVars}
/>
<Box>{props.error}</Box>
</Box>
Expand Down
1 change: 1 addition & 0 deletions frontend/taipy/src/ScenarioSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ interface ScenarioSelectorProps {
showDialog?: boolean;
multiple?: boolean;
filter?: string;
sort?: string;
updateScVars?: string;
showSearch?: boolean;
}
Expand Down
24 changes: 22 additions & 2 deletions taipy/gui_core/_GuiCoreLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from ..version import _get_version
from ._adapters import (
_GuiCoreDatanodeAdapter,
_GuiCoreDatanodeFilter,
_GuiCoreDatanodeSort,
_GuiCoreDoNotUpdate,
_GuiCoreScenarioAdapter,
_GuiCoreScenarioDagAdapter,
Expand Down Expand Up @@ -57,6 +59,10 @@ class _GuiCore(ElementLibrary):
__DATANODE_VIZ_DATA_NODE_PROP = "data_node"
__DATANODE_SEL_SCENARIO_PROP = "scenario"
__SEL_SCENARIOS_PROP = "scenarios"
__SEL_DATANODES_PROP = "datanodes"
__DATANODE_SELECTOR_FILTER_VAR = "__tpgc_dn_filter"
__DATANODE_SELECTOR_SORT_VAR = "__tpgc_dn_sort"
__DATANODE_SELECTOR_ERROR_VAR = "__tpgc_dn_error"

__elts = {
"scenario_selector": Element(
Expand Down Expand Up @@ -165,15 +171,29 @@ class _GuiCore(ElementLibrary):
"class_name": ElementProperty(PropertyType.dynamic_string),
"show_pins": ElementProperty(PropertyType.boolean, True),
__DATANODE_SEL_SCENARIO_PROP: ElementProperty(PropertyType.dynamic_list),
__SEL_DATANODES_PROP: ElementProperty(PropertyType.dynamic_list),
"multiple": ElementProperty(PropertyType.boolean, False),
"filter": ElementProperty(_GuiCoreDatanodeFilter, "*"),
"sort": ElementProperty(_GuiCoreDatanodeSort, "*"),
"show_search": ElementProperty(PropertyType.boolean, True),
},
inner_properties={
"datanodes": ElementProperty(
"inner_datanodes": ElementProperty(
PropertyType.lov,
f"{{{__CTX_VAR_NAME}.get_datanodes_tree(<tp:prop:{__DATANODE_SEL_SCENARIO_PROP}>)}}",
f"{{{__CTX_VAR_NAME}.get_datanodes_tree(<tp:prop:{__DATANODE_SEL_SCENARIO_PROP}>, "
+ f"<tp:prop:{__SEL_DATANODES_PROP}>, "
+ f"{__DATANODE_SELECTOR_FILTER_VAR}<tp:uniq:dns>, "
+ f"{__DATANODE_SELECTOR_SORT_VAR}<tp:uniq:dns>)}}",
),
"core_changed": ElementProperty(PropertyType.broadcast, _GuiCoreContext._CORE_CHANGED_NAME),
"type": ElementProperty(PropertyType.inner, __DATANODE_ADAPTER),
"error": ElementProperty(PropertyType.react, f"{{{__DATANODE_SELECTOR_ERROR_VAR}<tp:uniq:dns>}}"),
"update_dn_vars": ElementProperty(
PropertyType.string,
f"filter={__DATANODE_SELECTOR_FILTER_VAR}<tp:uniq:dns>;"
+ f"sort={__DATANODE_SELECTOR_SORT_VAR}<tp:uniq:dns>;"
+ f"error_id={__DATANODE_SELECTOR_ERROR_VAR}<tp:uniq:dns>",
),
},
),
"data_node": Element(
Expand Down
Loading

0 comments on commit 273c6fd

Please sign in to comment.