Add due date color coding for tasks

This commit is contained in:
2026-10-04 15:55:55 +02:00
parent a273130d4a
commit a28e4b4066
2 changed files with 19 additions and 3 deletions
+1
View File
@@ -27,6 +27,7 @@ type Column struct {
Position int `json:"position"`
Name string `json:"name"`
Tasks []Task `json:"tasks"`
IsFinal bool `json:"isFinal"`
}
type Task struct {
+18 -3
View File
@@ -4,6 +4,7 @@ import (
"ArinDash/apis/kaneo"
"ArinDash/util"
"context"
"fmt"
"sort"
"strings"
"time"
@@ -60,7 +61,7 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid
name = name + strings.Repeat(" ", colWidth-len(name))
}
if err := widget.Write(name, text.WriteCellOpts(cell.FgColor(cell.ColorGreen))); err != nil {
if err := widget.Write(name, text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil {
return nil
}
}
@@ -72,7 +73,7 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid
return err
}
for i := range 6 {
for i := range 10 {
if i != 0 {
if err := writeMiddle(widget, colWidth, widget.board.Columns); err != nil {
return err
@@ -99,7 +100,21 @@ func createBoard(ctx context.Context, _ terminalapi.Terminal, _ interface{}) wid
if len(title) < colWidth {
title = title + strings.Repeat(" ", colWidth-len(title))
}
if err := widget.Write(title, text.WriteCellOpts(cell.FgColor(cell.ColorWhite))); err != nil {
color := cell.ColorGreen
durr := int(column.Tasks[i].DueDate.Sub(time.Now()).Hours() / 24)
if durr < 14 && !column.IsFinal {
color = cell.ColorRed
d := fmt.Sprintf("%02dd", durr)
title = title[0:colWidth-3] + d
}
if durr < 28 && !column.IsFinal {
color = cell.ColorYellow
d := fmt.Sprintf("%02dd", durr)
title = title[0:colWidth-3] + d
}
if err := widget.Write(title, text.WriteCellOpts(cell.FgColor(color))); err != nil {
return nil
}
} else {