Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple board support #3

Merged
merged 23 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2d7a756
Prepare for next release
Zaloog Oct 19, 2024
a129979
New DB Table
Zaloog Oct 19, 2024
7dc54e1
:sparkles: feat: new board db
Zaloog Oct 19, 2024
e0ac2c2
:construction: First Step for multi boards
Zaloog Nov 9, 2024
757625c
:construction: Add initial Board creation
Zaloog Nov 9, 2024
813b5dc
:sparkles: Add Board Creation Modal
Zaloog Nov 9, 2024
781e70d
:wrench: Add 2 Boards to Demo command
Zaloog Nov 9, 2024
dbd2b23
:wrench: Change Yaml fmt and add board modal
Zaloog Nov 9, 2024
8224107
:tada: Show Boards on BoardOverview works
Zaloog Nov 10, 2024
6ac536a
:construction: Add initial Board ListView
Zaloog Nov 10, 2024
aa39452
:sparkles: Add switching between boards
Zaloog Nov 10, 2024
208c268
:sparkles: Add multi board funtionality
Zaloog Nov 10, 2024
2f63da1
:bug: Fix deletion of active Board
Zaloog Nov 10, 2024
63ed9b1
:bug: Fix focus bug on board change
Zaloog Nov 10, 2024
89988b2
:bug: FIX ListView idx to ActiveBoard idx mapper
Zaloog Nov 10, 2024
0ceb6ad
:rotating_light: ADD Test for board creation
Zaloog Nov 12, 2024
9ba4131
:rotating_light: ADD Test for modal board screen
Zaloog Nov 12, 2024
c2aa0dc
:rotating_light: Add Tests for Task Creation
Zaloog Nov 14, 2024
af9709d
:sparkles: Add Board Overview Infos
Zaloog Nov 15, 2024
762ae28
:bug: FIX Focus and Test bugs
Zaloog Nov 15, 2024
58078fe
Change pytest to 4 workers when testing parallel
Zaloog Nov 15, 2024
8440303
:bug: FIX test_edit_task with a short pause
Zaloog Nov 15, 2024
5054c79
:sparkles: ADD copy option of boards
Zaloog Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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