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