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