fix deletion again
This commit is contained in:
parent
a72c6fbaab
commit
2624bfc3ee
@ -23,12 +23,18 @@ def add_thing(
|
|||||||
|
|
||||||
def update_thing(
|
def update_thing(
|
||||||
item_id: int,
|
item_id: int,
|
||||||
|
deleted: bool | None = None,
|
||||||
|
type: str | None = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> Thing:
|
) -> Thing:
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
thing = Thing.get_by_id(item_id)
|
thing = Thing.get_by_id(item_id)
|
||||||
new_data = thing.data | kwargs
|
updates = {"data": thing.data | kwargs}
|
||||||
query = Thing.update(data=new_data).where(Thing.id == item_id)
|
if deleted is not None:
|
||||||
|
updates["deleted"] = deleted
|
||||||
|
if type is not None:
|
||||||
|
updates["type"] = type
|
||||||
|
query = Thing.update(**updates).where(Thing.id == item_id)
|
||||||
query.execute()
|
query.execute()
|
||||||
thing = Thing.get_by_id(item_id)
|
thing = Thing.get_by_id(item_id)
|
||||||
return thing
|
return thing
|
||||||
|
@ -37,7 +37,7 @@ class TableEditor(App):
|
|||||||
width: 10;
|
width: 10;
|
||||||
content-align: left middle;
|
content-align: left middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#input_widget {
|
#input_widget {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -230,6 +230,8 @@ class TableEditor(App):
|
|||||||
ConfirmModal(f"delete [green]{current_value}[/]?"),
|
ConfirmModal(f"delete [green]{current_value}[/]?"),
|
||||||
self._delete_item_callback,
|
self._delete_item_callback,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
raise Exception("FIXME")
|
||||||
|
|
||||||
def _delete_item_callback(self, confirm):
|
def _delete_item_callback(self, confirm):
|
||||||
if confirm and self.table.cursor_column == 0:
|
if confirm and self.table.cursor_column == 0:
|
||||||
@ -239,6 +241,8 @@ class TableEditor(App):
|
|||||||
self.update_item_callback(item_id, deleted=True)
|
self.update_item_callback(item_id, deleted=True)
|
||||||
self._save_cursor()
|
self._save_cursor()
|
||||||
self.refresh_data()
|
self.refresh_data()
|
||||||
|
else:
|
||||||
|
raise Exception(f"{confirm=} {self.table.cursor_column=}")
|
||||||
|
|
||||||
def action_add_item(self):
|
def action_add_item(self):
|
||||||
# the new item should use the selected value if filtered
|
# the new item should use the selected value if filtered
|
||||||
|
Loading…
Reference in New Issue
Block a user