Compare commits

...

10 Commits

Author SHA1 Message Date
Gustavo Henrique Miranda 35f37f5926
Merge pull request #46 from gmbrax/fix/move-create-diary-to-modal
Fix/move create diary to modal
2025-07-15 17:28:22 -03:00
Gustavo Henrique Miranda 4f153c5a5b
Merge branch 'development' into fix/move-create-diary-to-modal 2025-07-15 17:25:06 -03:00
Gustavo Henrique Santos Souza de Miranda f838a5b421 Add the auto-open option to the new_diary_modal.py 2025-07-15 15:51:30 -03:00
Gustavo Henrique Santos Souza de Miranda 18760e174c 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 2025-07-15 02:14:53 -03:00
Gustavo Henrique Miranda 3bef353939
Merge pull request #42
Fixed the edit diary modal to accept the key "enter" and automatically the function
2025-07-14 18:24:14 -03:00
Gustavo Henrique Miranda a80ecc24f5
Merge pull request #43
Fixed the new diary modal to accept the key "enter" and automatically the function
2025-07-14 18:23:58 -03:00
Gustavo Henrique Miranda 7f193d0fbb
Merge pull request #44 from gmbrax/dependabot/pip/textual-approx-eq-4.0.0
origin/dependabot/pip/textual-approx-eq-4.0.0
2025-07-14 18:17:49 -03:00
Gustavo Henrique Miranda 7dfeec20f1
Merge pull request #45 from gmbrax/dependabot/pip/typing-extensions-4.14.1
origin/dependabot/pip/typing-extensions-4.14.1
2025-07-14 18:17:32 -03:00
Gustavo Henrique Miranda d1545ad2e2
Merge branch 'staging' into dependabot/pip/typing-extensions-4.14.1 2025-07-14 18:17:15 -03:00
dependabot[bot] d2e69ae770
Bump typing-extensions from 4.14.0 to 4.14.1
Bumps [typing-extensions](https://github.com/python/typing_extensions) from 4.14.0 to 4.14.1.
- [Release notes](https://github.com/python/typing_extensions/releases)
- [Changelog](https://github.com/python/typing_extensions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/python/typing_extensions/compare/4.14.0...4.14.1)

---
updated-dependencies:
- dependency-name: typing-extensions
  dependency-version: 4.14.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-14 17:45:35 +00:00
2 changed files with 38 additions and 24 deletions

View File

@ -207,28 +207,16 @@ class DiaryListScreen(Screen):
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)
"""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"""

View File

@ -4,14 +4,17 @@ from textual.containers import Vertical, Horizontal
from textual.screen import ModalScreen
from textual.widgets import Label, Input, Button
from pilgrim.ui.screens.edit_entry_screen import EditEntryScreen
class NewDiaryModal(ModalScreen[str]):
BINDINGS = [
Binding("escape", "cancel", "Cancel"),
Binding("enter", "create_diary", "Create",priority=True),
]
def __init__(self):
def __init__(self,autoopen=True):
super().__init__()
self.auto_open = autoopen
self.name_input = Input(id="NewDiaryModal-NameInput",classes="NewDiaryModal-NameInput") # This ID is fine, it's specific to the input
def compose(self) -> ComposeResult:
@ -34,7 +37,7 @@ class NewDiaryModal(ModalScreen[str]):
if event.button.id == "create_diary_button":
self.action_create_diary()
elif event.button.id == "cancel_button":
self.dismiss("")
self.dismiss()
def action_cancel(self) -> None:
"""Action to cancel the modal."""
@ -43,7 +46,9 @@ class NewDiaryModal(ModalScreen[str]):
def action_create_diary(self) -> None:
diary_name = self.name_input.value.strip()
if diary_name:
self.dismiss(diary_name)
self.call_later(self._async_create_diary, diary_name)
else:
self.notify("Diary name cannot be empty.", severity="warning")
self.name_input.focus()
@ -52,3 +57,24 @@ class NewDiaryModal(ModalScreen[str]):
if event.input.id == "NewDiaryModal-NameInput":
self.action_create_diary()
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.dismiss(name)
if self.auto_open:
self.app.push_screen(EditEntryScreen(diary_id=created_diary.id))
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)}")