Compare commits
	
		
			No commits in common. "48d29b4d0cfb970b4051f4600c0c301dba6a9015" and "257b8795bc95933b67c46228154f53232a15a58e" have entirely different histories.
		
	
	
		
			48d29b4d0c
			...
			257b8795bc
		
	
		
					 4 changed files with 17 additions and 61 deletions
				
			
		|  | @ -39,10 +39,6 @@ class Task(BaseModel): | |||
|         self.updated_at = datetime.now() | ||||
|         return super(Task, self).save(*args, **kwargs) | ||||
| 
 | ||||
|     @property | ||||
|     def due_week(self): | ||||
|         return self.due.isocalendar()[1] - 12 | ||||
| 
 | ||||
| 
 | ||||
| class SavedSearch(BaseModel): | ||||
|     name = CharField(unique=True) | ||||
|  |  | |||
|  | @ -211,11 +211,7 @@ class TableEditor(App): | |||
|             self.table.move_cursor(row=0, column=1) | ||||
| 
 | ||||
|     def action_delete_item(self): | ||||
|         if self.table.cursor_column == 0: | ||||
|             current_value = self.table.get_cell_at( | ||||
|                 (self.table.cursor_row, 1) # assumes col 1 is name | ||||
|             ) | ||||
|             self.push_screen(ConfirmModal(f"delete [green]{current_value}[/]?"), self._delete_item_callback) | ||||
|         self.push_screen(ConfirmModal(f"delete ?"), self._delete_item_callback) | ||||
| 
 | ||||
|     def _delete_item_callback(self, confirm): | ||||
|         if confirm and self.table.cursor_column == 0: | ||||
|  |  | |||
|  | @ -14,10 +14,6 @@ class ConfirmModal(ModalScreen): | |||
|         align: center middle; | ||||
|         background: $primary 30%; | ||||
|     } | ||||
|     ConfirmModal Vertical { | ||||
|         border: double teal; | ||||
|         height: 4; | ||||
|     } | ||||
|     """ | ||||
| 
 | ||||
|     BINDINGS = [ | ||||
|  | @ -30,9 +26,9 @@ class ConfirmModal(ModalScreen): | |||
|         super().__init__() | ||||
| 
 | ||||
|     def compose(self): | ||||
|         with Vertical(): | ||||
|         yield Label(self.message) | ||||
|             yield Label("[b](y)[/]es    [b](n)[/]o") | ||||
|         yield Label("(y)es") | ||||
|         yield Label("(n)o") | ||||
| 
 | ||||
|     def action_confirm(self): | ||||
|         self.dismiss(True) | ||||
|  | @ -47,15 +43,6 @@ class ChoiceModal(ModalScreen): | |||
|         align: center middle; | ||||
|         background: $primary 30%; | ||||
|     } | ||||
|     ChoiceModal Vertical { | ||||
|         border: double teal; | ||||
|         height: 10; | ||||
|         width: 38; | ||||
|     } | ||||
|     ChoiceModal Label.hints { | ||||
|         border: solid grey; | ||||
|         height: 4; | ||||
|     } | ||||
|     ChoiceModal Label { | ||||
|         height: 1; | ||||
|     } | ||||
|  | @ -85,28 +72,21 @@ class ChoiceModal(ModalScreen): | |||
|         super().__init__() | ||||
| 
 | ||||
|     def compose(self): | ||||
|         with Vertical(): | ||||
|         for idx, e in enumerate(self._enum): | ||||
|             yield Label( | ||||
|                     (f"> {idx} " if idx == self.sel_idx else f"  {idx} ") | ||||
|                     + get_color_enum(e.value, self._enum), | ||||
|                 ("> " if idx == self.sel_idx else "  ") + | ||||
|                      get_color_enum(e.value, self._enum), | ||||
|                 classes="selected" if idx == self.sel_idx else "", | ||||
|             ) | ||||
|             yield Label("""(h/j/k/l) move (0-9) quick select | ||||
| (enter) confirm (esc) quit""", classes="hints") | ||||
| 
 | ||||
|     def _move_cursor(self, dir): | ||||
|         labels = self.query(Label) | ||||
|         # reset old | ||||
|         labels[self.sel_idx].update( | ||||
|             f"  {self.sel_idx} " + get_color_enum(self.enum_by_idx[self.sel_idx], self._enum) | ||||
|         ) | ||||
|         labels[self.sel_idx].update("  " + get_color_enum(self.enum_by_idx[self.sel_idx], self._enum)) | ||||
|         # move cursor | ||||
|         self.sel_idx = (self.sel_idx + dir) % len(self._enum) | ||||
|         # reset new | ||||
|         labels[self.sel_idx].update( | ||||
|             f"> {self.sel_idx} " + get_color_enum(self.enum_by_idx[self.sel_idx], self._enum) | ||||
|         ) | ||||
|         labels[self.sel_idx].update("> " + get_color_enum(self.enum_by_idx[self.sel_idx], self._enum)) | ||||
| 
 | ||||
|     def action_cursor_down(self): | ||||
|         self._move_cursor(1) | ||||
|  | @ -120,12 +100,6 @@ class ChoiceModal(ModalScreen): | |||
|     def action_cancel(self): | ||||
|         self.app.pop_screen() | ||||
| 
 | ||||
|     def on_key(self, event) -> None: | ||||
|         key = event.key | ||||
|         if key in "0123456789": | ||||
|             idx = int(key) | ||||
|             self.dismiss(self.enum_by_idx[idx]) | ||||
| 
 | ||||
| 
 | ||||
| class DateModal(ModalScreen): | ||||
|     CSS = """ | ||||
|  | @ -138,6 +112,8 @@ class DateModal(ModalScreen): | |||
|         height: 10; | ||||
|         width: 50; | ||||
|     } | ||||
|     DateModal Horizonal { | ||||
|     } | ||||
|     DateModal Label { | ||||
|         border: solid white; | ||||
|         align: center middle; | ||||
|  | @ -179,15 +155,9 @@ class DateModal(ModalScreen): | |||
|         with Vertical(): | ||||
|             with Horizontal(): | ||||
|                 for i in range(3): | ||||
|                     yield Label( | ||||
|                         f"{self.pieces[i]}", | ||||
|                         classes="selected-date" if self.selected == i else "", | ||||
|                     ) | ||||
|             yield Label( | ||||
|                 """(h/j/k/l) move (enter) confirm (esc) quit | ||||
| (p)ast (t)oday (f)uture""", | ||||
|                 classes="hints", | ||||
|             ) | ||||
|                     yield Label(f"{self.pieces[i]}", classes="selected-date" if self.selected == i else "") | ||||
|             yield Label("""(h/j/k/l) move (enter) confirm (esc) quit | ||||
| (p)ast (t)oday (f)uture""", classes="hints") | ||||
| 
 | ||||
|     def action_future(self): | ||||
|         self.pieces = list(SPECIAL_DATES_PIECES["future"]) | ||||
|  |  | |||
							
								
								
									
										6
									
								
								tt.toml
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								tt.toml
									
									
									
									
									
								
							|  | @ -58,12 +58,6 @@ field_name = "due" | |||
| field_type = "date" | ||||
| default = "1999-01-01" | ||||
| 
 | ||||
| [[views.columns]] | ||||
| field_name = "due_week" | ||||
| read_only = true | ||||
| #field_type = "date" | ||||
| #default = "1999-01-01" | ||||
| 
 | ||||
| [[views.columns]] | ||||
| field_name = "project" | ||||
| display_name = "Project" | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue