mirror of https://github.com/gmbrax/Pilgrim.git
				
				
				
			Compare commits
	
		
			No commits in common. "3bef353939cfc224e380fd5b75091dd5280e2105" and "417bc0d3e571c0bae33c26cad5665b6f13b5c0f0" have entirely different histories.
		
	
	
		
			3bef353939
			...
			417bc0d3e5
		
	
		| 
						 | 
					@ -3,4 +3,4 @@ SQLAlchemy==2.0.41
 | 
				
			||||||
typing_extensions==4.14.1
 | 
					typing_extensions==4.14.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
textual~=4.0.0
 | 
					textual~=3.6.0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,6 @@ from textual.widgets import Label, Input, Button
 | 
				
			||||||
class EditDiaryModal(ModalScreen[tuple[int,str]]):
 | 
					class EditDiaryModal(ModalScreen[tuple[int,str]]):
 | 
				
			||||||
    BINDINGS = [
 | 
					    BINDINGS = [
 | 
				
			||||||
        Binding("escape", "cancel", "Cancel"),
 | 
					        Binding("escape", "cancel", "Cancel"),
 | 
				
			||||||
        Binding("enter", "edit_diary", "Save",priority=True),
 | 
					 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, diary_id: int):
 | 
					    def __init__(self, diary_id: int):
 | 
				
			||||||
| 
						 | 
					@ -33,15 +32,6 @@ class EditDiaryModal(ModalScreen[tuple[int,str]]):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_button_pressed(self, event: Button.Pressed) -> None:
 | 
					    def on_button_pressed(self, event: Button.Pressed) -> None:
 | 
				
			||||||
        if event.button.id == "save_diary_button":
 | 
					        if event.button.id == "save_diary_button":
 | 
				
			||||||
            self.action_edit_diary()
 | 
					 | 
				
			||||||
        elif event.button.id == "cancel_button":
 | 
					 | 
				
			||||||
            self.dismiss(None)
 | 
					 | 
				
			||||||
    def on_key(self, event):
 | 
					 | 
				
			||||||
        if event.key == "enter":
 | 
					 | 
				
			||||||
            self.action_edit_diary()
 | 
					 | 
				
			||||||
            event.prevent_default()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def action_edit_diary(self) -> None:
 | 
					 | 
				
			||||||
            new_diary_name = self.name_input.value.strip()
 | 
					            new_diary_name = self.name_input.value.strip()
 | 
				
			||||||
            if new_diary_name and new_diary_name != self.current_diary_name:
 | 
					            if new_diary_name and new_diary_name != self.current_diary_name:
 | 
				
			||||||
                self.dismiss((self.diary_id, new_diary_name))
 | 
					                self.dismiss((self.diary_id, new_diary_name))
 | 
				
			||||||
| 
						 | 
					@ -51,10 +41,8 @@ class EditDiaryModal(ModalScreen[tuple[int,str]]):
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.notify("Diary name cannot be empty.", severity="warning")
 | 
					                self.notify("Diary name cannot be empty.", severity="warning")
 | 
				
			||||||
                self.name_input.focus()
 | 
					                self.name_input.focus()
 | 
				
			||||||
 | 
					        elif event.button.id == "cancel_button":
 | 
				
			||||||
    def on_input_submitted(self, event: Input.Submitted) -> None:
 | 
					            self.dismiss(None)
 | 
				
			||||||
        if event.input.id == "edit_diary_name_input":
 | 
					 | 
				
			||||||
            self.action_edit_diary()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def action_cancel(self) -> None:
 | 
					    def action_cancel(self) -> None:
 | 
				
			||||||
        self.dismiss(None)
 | 
					        self.dismiss(None)
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,6 @@ from textual.widgets import Label, Input, Button
 | 
				
			||||||
class NewDiaryModal(ModalScreen[str]):
 | 
					class NewDiaryModal(ModalScreen[str]):
 | 
				
			||||||
    BINDINGS = [
 | 
					    BINDINGS = [
 | 
				
			||||||
        Binding("escape", "cancel", "Cancel"),
 | 
					        Binding("escape", "cancel", "Cancel"),
 | 
				
			||||||
        Binding("enter", "create_diary", "Create",priority=True),
 | 
					 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
    def __init__(self):
 | 
					    def __init__(self):
 | 
				
			||||||
        super().__init__()
 | 
					        super().__init__()
 | 
				
			||||||
| 
						 | 
					@ -32,23 +31,15 @@ class NewDiaryModal(ModalScreen[str]):
 | 
				
			||||||
    def on_button_pressed(self, event: Button.Pressed) -> None:
 | 
					    def on_button_pressed(self, event: Button.Pressed) -> None:
 | 
				
			||||||
        """Handles button clicks."""
 | 
					        """Handles button clicks."""
 | 
				
			||||||
        if event.button.id == "create_diary_button":
 | 
					        if event.button.id == "create_diary_button":
 | 
				
			||||||
            self.action_create_diary()
 | 
					 | 
				
			||||||
        elif event.button.id == "cancel_button":
 | 
					 | 
				
			||||||
            self.dismiss("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def action_cancel(self) -> None:
 | 
					 | 
				
			||||||
        """Action to cancel the modal."""
 | 
					 | 
				
			||||||
        self.dismiss("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def action_create_diary(self) -> None:
 | 
					 | 
				
			||||||
            diary_name = self.name_input.value.strip()
 | 
					            diary_name = self.name_input.value.strip()
 | 
				
			||||||
            if diary_name:
 | 
					            if diary_name:
 | 
				
			||||||
                self.dismiss(diary_name)
 | 
					                self.dismiss(diary_name)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.notify("Diary name cannot be empty.", severity="warning")
 | 
					                self.notify("Diary name cannot be empty.", severity="warning")
 | 
				
			||||||
                self.name_input.focus()
 | 
					                self.name_input.focus()
 | 
				
			||||||
 | 
					        elif event.button.id == "cancel_button":
 | 
				
			||||||
 | 
					            self.dismiss("")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_input_submitted(self, event: Input.Submitted) -> None:
 | 
					    def action_cancel(self) -> None:
 | 
				
			||||||
        if event.input.id == "NewDiaryModal-NameInput":
 | 
					        """Action to cancel the modal."""
 | 
				
			||||||
            self.action_create_diary()
 | 
					        self.dismiss("")
 | 
				
			||||||
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue