fix bug with buggling and saving
This commit is contained in:
parent
bf0fe6f2d7
commit
525f29aa7a
@ -108,15 +108,13 @@ def save_view(name: str, *, filters: dict, sort_string: str) -> SavedSearch:
|
||||
filters_json = json.dumps(filters)
|
||||
|
||||
with db.atomic():
|
||||
if SavedSearch.select(SavedSearch.name == name).exists():
|
||||
if SavedSearch.select().where(SavedSearch.name == name).exists():
|
||||
query = SavedSearch.update(
|
||||
filters=filters_json, sort_string=sort_string
|
||||
).where(SavedSearch.name == name)
|
||||
query.execute()
|
||||
else:
|
||||
return SavedSearch.create(
|
||||
name=name, filters=filters_json, sort_string=sort_string
|
||||
)
|
||||
SavedSearch.create(name=name, filters=filters_json, sort_string=sort_string)
|
||||
|
||||
|
||||
def get_saved_view_names() -> list[str]:
|
||||
|
@ -87,14 +87,14 @@ class TT(TableEditor):
|
||||
# Override to add save/load view
|
||||
if self.mode == "save-view":
|
||||
save_view(event.value, filters=self.filters, sort_string=self.sort_string)
|
||||
self._hide_input()
|
||||
event.prevent_default()
|
||||
elif self.mode == "load-view":
|
||||
self._load_view(event.value)
|
||||
self.refresh_tasks(restore_cursor=False)
|
||||
else:
|
||||
# https://textual.textualize.io/guide/events/#bubbling
|
||||
# not needed
|
||||
# super().on_input_submitted(event)
|
||||
return
|
||||
self._hide_input()
|
||||
event.prevent_default()
|
||||
# if event isn't handled here it will bubble to parent
|
||||
|
||||
def refresh_items(self):
|
||||
items = get_tasks(
|
||||
|
Loading…
Reference in New Issue
Block a user