mirror of
https://github.com/gmbrax/Pilgrim.git
synced 2026-11-10 02:30:18 +00:00
Add a functionality that automatically opens the diary after creation, Change the responsibility of diary creation to the new_diary_modal.py instead of the diary_list_screen.py
This commit is contained in:
parent
3bef353939
commit
18760e174c
@@ -206,29 +206,17 @@ class DiaryListScreen(Screen):
|
||||
"""Action to create new diary"""
|
||||
self.app.push_screen(NewDiaryModal(),self._on_new_diary_submitted)
|
||||
|
||||
def _on_new_diary_submitted(self,result):
|
||||
self.notify(str(result))
|
||||
if result:
|
||||
self.notify(f"Creating Diary:{result}'...")
|
||||
self.call_later(self._async_create_diary,result)
|
||||
def _on_new_diary_submitted(self, result):
|
||||
"""Callback after diary creation"""
|
||||
if result: # Se result não é string vazia, o diário foi criado
|
||||
self.notify(f"Returning to diary list...")
|
||||
# Atualiza a lista de diários
|
||||
self.refresh_diaries()
|
||||
else:
|
||||
self.notify(f"Canceled...")
|
||||
|
||||
async def _async_create_diary(self,name: str):
|
||||
|
||||
try:
|
||||
service = self.app.service_manager.get_travel_diary_service()
|
||||
created_diary = await service.async_create(name)
|
||||
if created_diary:
|
||||
self.diary_id_map[created_diary.id] = created_diary.id
|
||||
await self.async_refresh_diaries()
|
||||
self.notify(f"Diary: '{name}' created!")
|
||||
else:
|
||||
self.notify("Error Creating the diary")
|
||||
except Exception as e:
|
||||
self.notify(f"Exception on creating the diary: {str(e)}")
|
||||
|
||||
self.notify(f"Creation canceled...")
|
||||
|
||||
def _on_screen_resume(self) -> None:
|
||||
self.refresh_diaries()
|
||||
|
||||
def action_edit_selected_diary(self):
|
||||
"""Action to edit selected diary"""
|
||||
|
||||
Reference in New Issue
Block a user