feat: add nojhan's theme, remane delete as remove

fix hint column display
This commit is contained in:
Johann Dreo 2023-07-31 09:40:17 +02:00
commit 94118b0c2c
3 changed files with 28 additions and 10 deletions

View file

@ -8,9 +8,8 @@ details_key = DETAILS
tags_key = TAGS
deadline_key = DEADLINE
show_keys = ID,TITLE,DETAILS,TAGS
layout = vertical-compact
theme = nojhan
[options.add]
details = ""
tags = ""
deadline = ""
status = TODO

View file

@ -10,6 +10,7 @@
10,"DONE","fix delete","'delete' print the kanban not updated","bug","","2023-07-29T17:48:14.950376"
11,"TODO","fix quotes","After 'add', empty columns got remaining quotes.","bug","","2023-07-29T17:49:33.862442"
12,"TODO","multiple select","Allow to pass several IDs or ranges to commands.","feat","","2023-07-29T17:49:05.411800"
13,"DOING","card widgets","Refactor into cards/list of cards with widget classes.","feat,UX","","2023-07-30T15:26:41.900699"
13,"DOING","card widgets","Refactor into cards/list of cards with widget classes.","feat","","2023-07-31T09:24:34.469400"
14,"DONE","highlight last action","Use a virtual hint column to point to the last touched task.","feat,UX","","2023-07-30T10:20:36.795048"
15,"TODO","hide old done tasks","Hide tasks with last status that haven't been touched since a long time.","feat","","2023-07-30T10:16:39.517669"
16,"TODO","sort by priority","Add a priority column and a sorting option.","feat","","2023-07-31T09:19:16.258603"

1 ID STATUS TITLE DETAILS TAGS DEADLINE TOUCHED
10 10 DONE fix delete 'delete' print the kanban not updated bug 2023-07-29T17:48:14.950376
11 11 TODO fix quotes After 'add', empty columns got remaining quotes. bug 2023-07-29T17:49:33.862442
12 12 TODO multiple select Allow to pass several IDs or ranges to commands. feat 2023-07-29T17:49:05.411800
13 13 DOING card widgets Refactor into cards/list of cards with widget classes. feat,UX feat 2023-07-30T15:26:41.900699 2023-07-31T09:24:34.469400
14 14 DONE highlight last action Use a virtual hint column to point to the last touched task. feat,UX 2023-07-30T10:20:36.795048
15 15 TODO hide old done tasks Hide tasks with last status that haven't been touched since a long time. feat 2023-07-30T10:16:39.517669
16 16 TODO sort by priority Add a priority column and a sorting option. feat 2023-07-31T09:19:16.258603

View file

@ -134,7 +134,7 @@ def check_id(context, param, value):
@click.option('-S', '--show-keys' , default='ID,TITLE,DETAILS,TAGS', type=str , show_default=True, help="Comma-separated, ordered list of fields that should be shown (use 'all' for everything).")
@click.option('-G', '--highlight', type = int, default = None, help="Highlight a specific task.")
@click.option('-L', '--layout', type = click.Choice(['vertical-compact', 'vertical-fancy']), default = 'vertical-compact', help="How to display tasks.") # TODO , 'horizontal-compact', 'horizontal-fancy'
@click.option('-T', '--theme', type = click.Choice(['none', 'user', 'BW', 'BY', 'RW'], case_sensitive=False), default = 'none', help="How to display tasks.")
@click.option('-T', '--theme', type = click.Choice(['none', 'user', 'BW', 'BY', 'RW', 'nojhan'], case_sensitive=False), default = 'none', help="How to display tasks.")
# Low-level configuration options.
@click.option('--status-key' , default='STATUS' , type=str, show_default=True, help="Header key defining the status of tasks.")
@click.option('--status-list' , default='TODO,DOING,HOLD,DONE', type=str, show_default=True, help="Comma-separated, ordered list of possible values for the status of tasks.")
@ -219,6 +219,18 @@ def cli(context, **kwargs):
'row_odd' : '',
'row_even': '',
}),
'nojhan': Theme({
'H': '#4E9A06',
context.obj['id_key']: 'bold color(214)',
context.obj['status_key']: 'bold italic white',
context.obj['title_key']: 'bold white',
context.obj['details_key']: 'white',
context.obj['tags_key']: 'color(27)',
context.obj['deadline_key']: 'white',
context.obj['touched_key']: 'color(240)',
'row_odd' : '', # on #262121
'row_even': 'on #2d2929',
}),
}
context.obj['theme'] = context.obj['themes'][kwargs['theme']]
@ -282,14 +294,23 @@ class Vertical(Layout):
sections = []
if self.context.obj['highlight'] is not None:
df.loc[self.context.obj['highlight'], 'H'] = ':arrow_forward:'
# Group by status.
tables = df.groupby(self.context.obj['status_key'])
# Loop over the asked ordered status groups.
for section in self.context.obj['status_list']: # Ordered.
if section in tables.groups:
df = tables.get_group(section)
# Bring back TID as a regular column.
df = df.reset_index().fillna("")
# Always consider the hint column.
if 'H' not in self.context.obj['show_keys']:
self.context.obj['show_keys'] = ['H'] + self.context.obj['show_keys']
try:
# Print asked columns.
t = df[self.context.obj['show_keys']]
@ -347,9 +368,6 @@ def show(context, tid):
if tid is None:
if context.obj['highlight'] is not None:
df.loc[context.obj['highlight'], 'H'] = ':arrow_forward:'
layout = context.obj['layouts'][context.obj['layout']](context)
console = rconsole.Console(theme = context.obj['theme'])
console.print(layout)
@ -477,9 +495,9 @@ def check_yes(context, param, value):
@cli.command()
@click.argument('TID', required=True, type=int, is_eager=True, callback=check_id)
@click.option('-y', '--yes', is_flag=True, expose_value=False, callback=check_yes, prompt="Permanently delete task from records?")
@click.option('-y', '--yes', is_flag=True, expose_value=False, callback=check_yes, prompt="Permanently remove task from records?")
@click.pass_context
def delete(context, tid):
def remove(context, tid):
"""Delete a task."""
df = context.obj['data']
df = df.drop(index=tid)