Skip to content

Commit

Permalink
Start fixing calculation reset
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkolenc committed Jan 13, 2025
1 parent e813acc commit cd43de6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 10 additions & 4 deletions source/package/pathways_app/controls/editable_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ def __init__(
),
padding=padding,
bgcolor=theme.colors.calculated_bg if self.is_calculated else None,
on_click=self.toggle_editing,
on_click=self.set_editing,
)

super().__init__(control=self.cell_content)

def toggle_editing(self, _):
self.is_editing = not self.is_editing
def set_editing(self, _):
self.is_editing = True
self.update_controls()

def set_not_editing(self, _):
self.is_editing = False
self.update_controls()

def update_controls(self):
if self.is_editing:
self.update_input()
else:
Expand Down Expand Up @@ -122,7 +128,7 @@ def __init__(self, source: object, value_attribute: str, on_finished_editing=Non
suffix_style=theme.text.textfield_symbol,
expand=True,
content_padding=ft.padding.symmetric(4, 6),
on_blur=self.toggle_editing,
on_blur=self.set_not_editing,
)

def on_finished_editing_internal(_):
Expand Down
9 changes: 5 additions & 4 deletions source/package/pathways_app/controls/metric_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, metric: Metric, value: MetricValue, on_finished_editing=None)
text_align=ft.TextAlign.RIGHT,
expand=True,
content_padding=ft.padding.symmetric(4, 6),
on_blur=self.toggle_editing,
on_blur=self.set_not_editing,
)
self.update_input()

Expand All @@ -50,9 +50,9 @@ def __init__(self, metric: Metric, value: MetricValue, on_finished_editing=None)
alignment=ft.alignment.center_right,
)

def on_edited(self):
def on_edited(self, _):
new_value = float(self.input_content.value)
print(new_value)

if new_value != self.value.value and self.value.is_estimate:
self.value.state = MetricValueState.OVERRIDE
self.value.value = new_value
Expand All @@ -62,7 +62,8 @@ def on_edited(self):

def on_reset_to_calculated(self):
self.value.state = MetricValueState.ESTIMATE
self.on_edited()
self.set_not_editing()
print(self.value)

def update_display(self):
self.display_content.value = self.metric.unit.format(self.value.value)
Expand Down

0 comments on commit cd43de6

Please sign in to comment.