moving forward on toml fields
This commit is contained in:
		
							parent
							
								
									0d6c20cff6
								
							
						
					
					
						commit
						77ac5a5cd2
					
				
					 2 changed files with 16 additions and 20 deletions
				
			
		| 
						 | 
					@ -245,10 +245,6 @@ class TableEditor(App):
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
            val = self.filters.get(fc.field, fc.default)
 | 
					            val = self.filters.get(fc.field, fc.default)
 | 
				
			||||||
            if val is not None:
 | 
					            if val is not None:
 | 
				
			||||||
                # enums use comma separated filters
 | 
					 | 
				
			||||||
                if fc.enum:
 | 
					 | 
				
			||||||
                    prepopulated[fc.field] = val.split(",")[0]
 | 
					 | 
				
			||||||
                else:
 | 
					 | 
				
			||||||
                prepopulated[fc.field] = val
 | 
					                prepopulated[fc.field] = val
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        new_item = self.add_item_callback(**prepopulated)
 | 
					        new_item = self.add_item_callback(**prepopulated)
 | 
				
			||||||
| 
						 | 
					@ -263,21 +259,21 @@ class TableEditor(App):
 | 
				
			||||||
    def _active_item_id(self):
 | 
					    def _active_item_id(self):
 | 
				
			||||||
        return int(self.table.get_cell_at((self.table.cursor_row, 0)))
 | 
					        return int(self.table.get_cell_at((self.table.cursor_row, 0)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def action_toggle_cell(self):
 | 
					    # def action_toggle_cell(self):
 | 
				
			||||||
        cur_row = self.table.cursor_row
 | 
					    #     cur_row = self.table.cursor_row
 | 
				
			||||||
        cur_col = self.table.cursor_column
 | 
					    #     cur_col = self.table.cursor_column
 | 
				
			||||||
        cconf = self._active_column_config()
 | 
					    #     cconf = self._active_column_config()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if cconf.enum:
 | 
					    #     if cconf.enum:
 | 
				
			||||||
            item_id = self._active_item_id()
 | 
					    #         item_id = self._active_item_id()
 | 
				
			||||||
            current_val = self.table.get_cell_at((cur_row, cur_col))
 | 
					    #         current_val = self.table.get_cell_at((cur_row, cur_col))
 | 
				
			||||||
            next_val = advance_enum_val(cconf.enum, current_val)
 | 
					    #         next_val = advance_enum_val(cconf.enum, current_val)
 | 
				
			||||||
            self.table.update_cell_at((cur_row, cur_col), next_val)
 | 
					    #         self.table.update_cell_at((cur_row, cur_col), next_val)
 | 
				
			||||||
            # trigger item_id to be saved on the next cursor move
 | 
					    #         # trigger item_id to be saved on the next cursor move
 | 
				
			||||||
            # this avoids filtered columns disappearing right away
 | 
					    #         # this avoids filtered columns disappearing right away
 | 
				
			||||||
            # and tons of DB writes
 | 
					    #         # and tons of DB writes
 | 
				
			||||||
            update = {cconf.field: next_val}
 | 
					    #         update = {cconf.field: next_val}
 | 
				
			||||||
            self._register_save_on_move(item_id, **update)
 | 
					    #         self._register_save_on_move(item_id, **update)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _register_save_on_move(self, item_id, **kwargs):
 | 
					    def _register_save_on_move(self, item_id, **kwargs):
 | 
				
			||||||
        if self.save_on_move and self.save_on_move["item_id"] != item_id:
 | 
					        if self.save_on_move and self.save_on_move["item_id"] != item_id:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ class TaskGenEditor(TableEditor):
 | 
				
			||||||
            enum=GeneratorType,
 | 
					            enum=GeneratorType,
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        TableColumnConfig("val", "Value", default="1"),
 | 
					        TableColumnConfig("val", "Value", default="1"),
 | 
				
			||||||
        TableColumnConfig("next_at", "Next @", default="", read_only=True),
 | 
					        TableColumnConfig("next_at", "Next @", read_only=True),
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self):
 | 
					    def __init__(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue