Skip to content

Commit 78fd55f

Browse files
committed
Improve search form
1 parent fb3aee2 commit 78fd55f

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/power_grid_model_ds/_core/visualizer/callbacks/search_form.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
Output("cytoscape-graph", "stylesheet"),
99
Input("search-form-group-input", "value"),
1010
Input("search-form-column-input", "value"),
11+
Input("search-form-operator-input", "value"),
1112
Input("search-form-value-input", "value"),
1213
)
13-
def search_element(group, column, value):
14+
def search_element(group, column, operator, value):
1415
"""Color the specified element red based on the input values."""
1516
if not group or not column or not value:
1617
return DEFAULT_STYLESHEET
@@ -22,11 +23,15 @@ def search_element(group, column, value):
2223
"text-background-color": CYTO_COLORS["highlighted"],
2324
}
2425
else:
25-
style = {"line-color": CYTO_COLORS["highlighted"]}
26+
style = {"line-color": CYTO_COLORS["highlighted"], "target-arrow-color": CYTO_COLORS["highlighted"]}
27+
28+
if column == "id":
29+
selector = f'[{column} {operator} "{value}"]'
30+
else:
31+
selector = f'[{column} {operator} {value}]'
2632

27-
# Create selectors that match both the group type and the specific value
2833
new_style = {
29-
"selector": f'[{column} = {str(value)}], [{column} = "{value}"]',
34+
"selector": selector,
3035
"style": style,
3136
}
3237
return DEFAULT_STYLESHEET + [new_style]

src/power_grid_model_ds/_core/visualizer/layout/search_form.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,27 @@
2929
style={"width": "150px", "display": "inline-block"}
3030
)
3131

32+
operator_input = dbc.Select(
33+
id="search-form-operator-input",
34+
options=[
35+
{"label": "=", "value": "="},
36+
{"label": "<", "value": "<"},
37+
{"label": ">", "value": ">"},
38+
{"label": "!=", "value": "!="},
39+
],
40+
value="=", # Default value
41+
style={"width": "60px", "display": "inline-block", "margin": "0 8px"}
42+
)
43+
44+
3245
# Arrange as a sentence
3346
SEARCH_FORM_HTML = html.Div(
3447
[
3548
html.Span("Search ", className="mr-2", style={"margin-right": "8px"}),
3649
group_input,
3750
html.Span(" with ", className="mx-2", style={"margin": "0 8px"}),
3851
column_input,
39-
html.Span(" == ", className="mx-2", style={"margin": "0 8px"}),
52+
operator_input,
4053
value_input,
4154
],
4255
style={

0 commit comments

Comments
 (0)