moving forward on toml fields

This commit is contained in:
jpt 2025-04-10 22:47:36 -05:00
parent 0d6c20cff6
commit 77ac5a5cd2
2 changed files with 16 additions and 20 deletions

View File

@ -245,11 +245,7 @@ class TableEditor(App):
continue
val = self.filters.get(fc.field, fc.default)
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)
self.refresh_data(restore_cursor=False)
@ -263,21 +259,21 @@ class TableEditor(App):
def _active_item_id(self):
return int(self.table.get_cell_at((self.table.cursor_row, 0)))
def action_toggle_cell(self):
cur_row = self.table.cursor_row
cur_col = self.table.cursor_column
cconf = self._active_column_config()
# def action_toggle_cell(self):
# cur_row = self.table.cursor_row
# cur_col = self.table.cursor_column
# cconf = self._active_column_config()
if cconf.enum:
item_id = self._active_item_id()
current_val = self.table.get_cell_at((cur_row, cur_col))
next_val = advance_enum_val(cconf.enum, current_val)
self.table.update_cell_at((cur_row, cur_col), next_val)
# trigger item_id to be saved on the next cursor move
# this avoids filtered columns disappearing right away
# and tons of DB writes
update = {cconf.field: next_val}
self._register_save_on_move(item_id, **update)
# if cconf.enum:
# item_id = self._active_item_id()
# current_val = self.table.get_cell_at((cur_row, cur_col))
# next_val = advance_enum_val(cconf.enum, current_val)
# self.table.update_cell_at((cur_row, cur_col), next_val)
# # trigger item_id to be saved on the next cursor move
# # this avoids filtered columns disappearing right away
# # and tons of DB writes
# update = {cconf.field: next_val}
# self._register_save_on_move(item_id, **update)
def _register_save_on_move(self, item_id, **kwargs):
if self.save_on_move and self.save_on_move["item_id"] != item_id:

View File

@ -26,7 +26,7 @@ class TaskGenEditor(TableEditor):
enum=GeneratorType,
),
TableColumnConfig("val", "Value", default="1"),
TableColumnConfig("next_at", "Next @", default="", read_only=True),
TableColumnConfig("next_at", "Next @", read_only=True),
)
def __init__(self):