Skip to content

Commit

Permalink
Merge pull request #3 from Zaloog/multiple-board-support
Browse files Browse the repository at this point in the history
Multiple board support
  • Loading branch information
Zaloog authored Nov 16, 2024
2 parents 57325bd + 5054c79 commit 101c1d8
Show file tree
Hide file tree
Showing 24 changed files with 1,571 additions and 366 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v0.4.0
- Add Multi Board support

## v0.3.2
- Bugfix: Attempting to move a task with h/j/k/l caused Error, when no task was present

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ NEXT_MAJOR := $(shell echo $$(($(MAJOR)+1)))
NEXT_MINOR := $(shell echo $$(($(MINOR)+1)))
NEXT_MICRO := $(shell echo $$(($(MICRO)+1)))

# most of it found here
# https://gist.github.com/grihabor/4a750b9d82c9aa55d5276bd5503829be
# -- Increment Tags ---
.PHONY: micro
micro:
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ ktui = "kanban_tui.__main__:cli"

[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
addopts = "--cov src/kanban_tui --cov-report term-missing --verbose --color=yes"# -n 4 --dist=loadgroup"
asyncio_default_fixture_loop_scope = "file"
addopts = "--cov src/kanban_tui --cov-report term-missing --verbose --color=yes -n 4 --dist=loadfile"
testpaths = ["tests"]

[build-system]
Expand All @@ -55,6 +55,7 @@ dev-dependencies = [
"pytest-xdist>=3.6.1",
"pytest-asyncio>=0.24.0",
"textual-dev>=1.6.1",
"freezegun>=1.5.1",
]

[tool.hatch.metadata]
Expand Down
30 changes: 27 additions & 3 deletions src/kanban_tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@

from kanban_tui.views.main_view import MainView
from kanban_tui.config import KanbanTuiConfig, init_new_config
from kanban_tui.database import init_new_db, get_all_tasks_db
from kanban_tui.database import (
init_new_db,
get_all_boards_db,
get_all_tasks_on_board_db,
init_first_board,
)
from kanban_tui.classes.task import Task
from kanban_tui.classes.board import Board
from kanban_tui.constants import DB_FULL_PATH, CONFIG_FULL_PATH


Expand All @@ -18,6 +24,8 @@ class KanbanTui(App):

cfg: KanbanTuiConfig
task_list: reactive[list[Task]] = reactive([], init=False)
board_list: reactive[list[Board]] = reactive([], init=False)
active_board: Board = None

def __init__(
self,
Expand All @@ -30,12 +38,28 @@ def __init__(
self.demo_mode = demo_mode

init_new_db(database=self.cfg.database_path)
init_first_board(database=self.cfg.database_path)
super().__init__()

def on_mount(self) -> None:
self.update_task_list()
self.update_board_list()
# self.update_task_list()
self.push_screen("MainView")

def update_task_list(self):
tasks = get_all_tasks_db(database=self.app.cfg.database_path)
tasks = get_all_tasks_on_board_db(
database=self.app.cfg.database_path, board_id=self.active_board.board_id
)
self.task_list = tasks

def update_board_list(self):
boards = get_all_boards_db(database=self.app.cfg.database_path)
self.board_list = boards
self.active_board = self.get_active_board()
self.update_task_list()

def get_active_board(self) -> None | Board:
for board in self.board_list:
if board.board_id == self.cfg.active_board:
return board
return None
89 changes: 89 additions & 0 deletions src/kanban_tui/assets/style.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,91 @@ ModalConfirmScreen {
}
}

ModalNewBoardScreen {
align:center middle;
Vertical{
width:60%;
border:$success;
height:auto;
align:center middle;
content-align:center middle;

Horizontal{
height:auto;
}
Label{
width:1fr;
height:auto;
background: $background;
align:center middle;
text-align:center;
padding: 1 0;
}

#input_board_icon{
width:3fr;
height: auto;
border: tall $success;
border-title-align:center;
text-align:center;
}
#input_board_name{
width:5fr;
height: auto;
border: tall $success;
border-title-align:center;
text-align:center;
}
#static_preview_icon{
width:2fr;
height: auto;
color: $text-disabled;
border: tall $success;
border-title-align:center;
text-align:center;
padding: 0 0 0 0;
}
Button {
width: 1fr;
height:auto;
}
}
}

ModalBoardOverviewScreen {
align:center middle;
Vertical{
width:70%;
border:$success;
height:60%;
align:center middle;
content-align:center middle;
#label_header{
width:1fr;
height: auto;
text-align:center;
padding:0 0 1 0;
}
BoardListItem{
height:auto;
content-align:center middle;
Label{
width: 1fr;
padding:1 0;
text-align:left;
}
Rule{
height:auto;
color:black;
}
}
Button {
width: 1fr;
height:auto;
}
}
}

CategoryColorPicker{
align:center middle;
Vertical {
Expand Down Expand Up @@ -322,6 +407,10 @@ FilterOverlay {
}
}

TabbedContent {
border:green;
}

SettingsView{
content-align:center middle;
height:1fr;
Expand Down
14 changes: 14 additions & 0 deletions src/kanban_tui/classes/board.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from datetime import datetime

from pydantic import BaseModel


class Board(BaseModel):
board_id: int
name: str
icon: str | None = None
creation_date: datetime = datetime.now().replace(microsecond=0)

@property
def full_name(self):
return f"{self.icon} {self.name}"
11 changes: 10 additions & 1 deletion src/kanban_tui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class KanbanTuiConfig(BaseModel):
config: dict[str, Any] = {}
tasks_always_expanded: bool = False
no_category_task_color: str = "#004578"
active_board: int = 1
category_color_dict: dict[str | None, str] = {}
column_dict: dict[str, bool] = {
"Ready": True,
Expand All @@ -35,6 +36,7 @@ def model_post_init(self, __context: Any) -> None:
self.no_category_task_color = self.config["kanban.settings"][
"no_category_task_color"
]
self.active_board = self.config["kanban.settings"]["active_board"]
self.category_color_dict = self.config["category.colors"]
self.column_dict = self.config["column.visibility"]
self.work_hour_dict = self.config["kanban.settings"]["work_hours"]
Expand All @@ -48,6 +50,11 @@ def visible_columns(self) -> list[str]:
def columns(self) -> list[str]:
return [column for column in self.config["column.visibility"].keys()]

def set_active_board(self, new_active_board: int) -> None:
self.active_board = new_active_board
self.config["kanban.settings"]["active_board"] = new_active_board
self.save()

def set_tasks_always_expanded(self, new_value: bool) -> None:
self.tasks_always_expanded = new_value
self.config["kanban.settings"]["tasks_always_expanded"] = new_value
Expand Down Expand Up @@ -91,7 +98,8 @@ def load(self) -> dict[str, Any]:

def save(self) -> None:
with open(self.config_path, "w") as yaml_file:
yaml_file.write(yaml.dump(self.config, sort_keys=False))
dump = yaml.dump(self.config, sort_keys=False, indent=4, line_break="\n")
yaml_file.write(dump)


def init_new_config(
Expand All @@ -114,6 +122,7 @@ def init_new_config(
}
config["kanban.settings"] = {
"tasks_always_expanded": False,
"active_board": 1,
"no_category_task_color": "#004578",
"work_hours": {
"start_hour": "00",
Expand Down
Loading

0 comments on commit 101c1d8

Please sign in to comment.