Skip to content

Commit

Permalink
Call the specific on_change when a scenario is created (#1671)
Browse files Browse the repository at this point in the history
* Call the specific on_change when a scenario is created in the scenario_selector
resolves #1616

* fix the test

---------

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide committed Aug 14, 2024
1 parent daa43df commit d6caa68
Show file tree
Hide file tree
Showing 7 changed files with 585 additions and 688 deletions.
805 changes: 399 additions & 406 deletions frontend/taipy-gui/package-lock.json

Large diffs are not rendered by default.

457 changes: 177 additions & 280 deletions frontend/taipy/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/taipy/src/ScenarioSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ const ScenarioSelector = (props: ScenarioSelectorProps) => {
{ action: props.onScenarioCrud, error_id: getUpdateVar(updateScVars, "error_id") },
props.onCreation,
props.updateVarName,
props.onChange,
...values
)
);
Expand Down
4 changes: 2 additions & 2 deletions taipy/gui_core/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def get_scenario_configs(self):
def crud_scenario(self, state: State, id: str, payload: t.Dict[str, str]): # noqa: C901
self.__lazy_start()
args = payload.get("args")
start_idx = 2
start_idx = 3
if (
args is None
or not isinstance(args, list)
Expand Down Expand Up @@ -507,7 +507,7 @@ def crud_scenario(self, state: State, id: str, payload: t.Dict[str, str]): # no
if (scenario or user_scenario) and (sel_scenario_var := args[1] if isinstance(args[1], str) else None):
try:
var_name, _ = gui._get_real_var_name(sel_scenario_var)
state.assign(var_name, scenario or user_scenario)
self.gui._update_var(var_name, scenario or user_scenario, on_change= args[2])
except Exception as e: # pragma: no cover
_warn("Can't find value variable name in context", e)
if scenario:
Expand Down
2 changes: 2 additions & 0 deletions tests/gui_core/test_context_is_deletable.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_crud_scenario(self):
"",
{
"args": [
"",
"",
"",
True,
Expand All @@ -78,6 +79,7 @@ def test_crud_scenario(self):
"",
{
"args": [
"",
"",
"",
True,
Expand Down
2 changes: 2 additions & 0 deletions tests/gui_core/test_context_is_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_crud_scenario(self):
"",
{
"args": [
"",
"",
"",
True,
Expand All @@ -75,6 +76,7 @@ def test_crud_scenario(self):
"",
{
"args": [
"",
"",
"",
True,
Expand Down
2 changes: 2 additions & 0 deletions tests/gui_core/test_context_is_readable.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def test_crud_scenario(self):
"",
{
"args": [
"",
"",
"",
True,
Expand All @@ -125,6 +126,7 @@ def test_crud_scenario(self):
"",
{
"args": [
"",
"",
"",
True,
Expand Down

0 comments on commit d6caa68

Please sign in to comment.