68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
from typing import List
|
|
from pydantic import BaseModel, Field
|
|
from webcomponents.models.tasks import TaskList,TaskCategory,TaskStatus
|
|
|
|
class TaskHtml(BaseModel):
|
|
name: str
|
|
category: str
|
|
icon_color: str
|
|
background_color: str
|
|
is_highlighted: bool = False
|
|
icon_svg: str = Field(default='svg/rocket_black.svg')
|
|
action_svg: str = Field(default='svg/clip_black.svg')
|
|
|
|
class TaskListHtml(BaseModel):
|
|
tasks: List[TaskHtml] = []
|
|
|
|
def convert_task_list_to_html(task_list: TaskList) -> TaskListHtml:
|
|
task_list_html = TaskListHtml()
|
|
|
|
# Define color schemes for different categories
|
|
category_colors = {
|
|
TaskCategory.BUG: ("#E74C3C", "#FDEDEC"), # Red
|
|
TaskCategory.QUESTION: ("#3498DB", "#EBF5FB"), # Blue
|
|
TaskCategory.STORY: ("#9B59B6", "#F4ECF7"), # Purple
|
|
TaskCategory.TASK: ("#2ECC71", "#E8F8F5"), # Green
|
|
TaskCategory.VARIA: ("#F1C40F", "#FEF9E7"), # Yellow
|
|
TaskCategory.FEATURE: ("#E67E22", "#FDF2E9"), # Orange
|
|
}
|
|
|
|
# Define icons for different categories
|
|
category_icons = {
|
|
TaskCategory.BUG: "svg/gauge_black.svg",
|
|
TaskCategory.QUESTION: "svg/question_black.svg",
|
|
TaskCategory.STORY: "svg/book_black.svg",
|
|
TaskCategory.TASK: "svg/gauge_black.svg",
|
|
TaskCategory.VARIA: "svg/gauge_black.svg",
|
|
TaskCategory.FEATURE: "svg/gauge_black.svg",
|
|
}
|
|
|
|
for task in task_list.get_tasks():
|
|
# Get colors for the task category
|
|
icon_color, background_color = category_colors[task.category]
|
|
|
|
# Get icon for the task category
|
|
icon_svg = category_icons[task.category]
|
|
|
|
# Determine if the task should be highlighted (high priority, overdue, or blocked)
|
|
is_highlighted = (
|
|
task.priority >= 4 or
|
|
task.is_overdue() or
|
|
task.status == TaskStatus.BLOCKED
|
|
)
|
|
|
|
# Create TaskHtml object
|
|
task_html = TaskHtml(
|
|
name=task.name,
|
|
category=task.category.value,
|
|
icon_color=icon_color,
|
|
background_color=background_color,
|
|
is_highlighted=is_highlighted,
|
|
icon_svg=icon_svg,
|
|
action_svg='svg/clip_black.svg' if task.remarks else 'svg/world_black.svg'
|
|
)
|
|
|
|
task_list_html.tasks.append(task_html)
|
|
|
|
return task_list_html
|