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

View pivot table #56

Merged
merged 38 commits into from
May 28, 2024
Merged
Changes from 24 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
32cd129
add .idea to ignore file
Apr 8, 2024
2b14d8c
add card controller
Apr 8, 2024
f74c796
view add
Apr 8, 2024
99b82dc
add get_all() method to repo
Apr 8, 2024
30c983e
init sored object realization done
Apr 8, 2024
277eedd
add get_all method to mock repo
Apr 8, 2024
162e9be
apply new object id
SardorSharipov Apr 20, 2024
7ea5dfb
add text object
Apr 30, 2024
d32d2aa
view by state machine
Apr 30, 2024
ea71f33
update controller and repo
Apr 30, 2024
67800b7
update required libs
Apr 30, 2024
c5d6eae
exclude view from test
Apr 30, 2024
7f5ab88
add font to class
May 1, 2024
17b6086
add tests to object with font
May 1, 2024
41950d6
card view
May 1, 2024
77ca6f4
update tests and methods
May 1, 2024
7ec577d
linter check
May 1, 2024
a9a98c4
add pen object
May 4, 2024
c887d9c
update test
May 4, 2024
2cce4e8
update pen tests
May 4, 2024
2116b84
added attributes
Aplsn May 8, 2024
0b32390
added pivot table
Aplsn May 10, 2024
8e466d4
fixed bugs
Aplsn May 10, 2024
80cb93b
merged main
May 26, 2024
f87a57b
add table to view
May 26, 2024
f81b6b4
update controller
May 26, 2024
a1671ef
add init file
May 26, 2024
14e6782
fixed events
Aplsn May 26, 2024
05a59cd
fixed submenu
Aplsn May 26, 2024
1d3457e
fixed serializing
Aplsn May 26, 2024
6dad4d7
fixed bugs
Aplsn May 26, 2024
16f7733
Merge remote-tracking branch 'origin/view-pivot-table' into view-pivo…
Aplsn May 26, 2024
4b050c6
fixed bugs
Aplsn May 26, 2024
a00a55c
add git ignore
May 28, 2024
50ddea0
main merged
May 28, 2024
99c0d59
change attributed controller
May 28, 2024
5b71a49
add pivot table
May 28, 2024
dd3fea2
fixed bugs
Aplsn May 28, 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
16 changes: 16 additions & 0 deletions src/internal/controller/impl/controller.py
Original file line number Diff line number Diff line change
@@ -327,6 +327,22 @@ def edit_linked_objects(
action.do()
self._undo_redo_manager.store_action(action)

def add_attribute(
self,
attr_name: str
# attr: internal.models.Attribute
):
for obj in self._repo.get_all():
if not isinstance(obj, internal.objects.interfaces.IBoardObjectCard):
continue

card: internal.objects.interfaces.IBoardObjectCard = obj
card.attributes[attr_name] = None
logging.debug(
'adding new attribute with name=%s',
attr_name
)

def undo_last_action(self):
logging.debug('controller was asked to undo last action')
self._undo_redo_manager.undo()
14 changes: 14 additions & 0 deletions src/internal/objects/impl/card.py
Original file line number Diff line number Diff line change
@@ -15,9 +15,11 @@
_COLOR_FIELD = 'color'
_WIDTH_FIELD = 'width'
_HEIGHT_FIELD = 'height'
_ATTRIBUTED_FIELD = 'attribute'


class BoardObjectCard(interfaces.IBoardObjectCard, BoardObjectWithFont):

def __init__(
self,
id: interfaces.ObjectId,
@@ -29,11 +31,13 @@ def __init__(
color: str = 'light yellow',
width: int = 150,
height: int = 150,
attribute: dict[str, str] = dict(), # noqa
):
super().__init__(id, types.BoardObjectType.CARD, create_dttm, position, pub_sub_broker, text, font)
self.color = color
self.width = width
self.height = height
self.attribute = attribute

@property
def color(self) -> str:
@@ -62,11 +66,20 @@ def height(self, height: int) -> None:
self._height = height
self._publish(events.EventObjectChangedSize(self.id))

@property
def attribute(self) -> int:
return self._attribute

@attribute.setter
def attribute(self, attribute: dict[str, str]) -> None:
self._attribute = attribute

def serialize(self) -> dict:
serialized = super().serialize()
serialized[_COLOR_FIELD] = self.color
serialized[_WIDTH_FIELD] = self.width
serialized[_HEIGHT_FIELD] = self.height
serialized[_ATTRIBUTED_FIELD] = self.attribute
return serialized

@staticmethod
@@ -85,4 +98,5 @@ def from_serialized(
data[_COLOR_FIELD],
data[_WIDTH_FIELD],
data[_HEIGHT_FIELD],
data[_ATTRIBUTED_FIELD],
)
7 changes: 6 additions & 1 deletion src/internal/objects/impl/test_card.py
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@ def test_board_object_card_serialization():
color = 'light blue'
width = 100
height = 150
attribute = {'age': 10}
broker = internal.pub_sub.mocks.MockPubSubBroker()

card = BoardObjectCard(id, create_dttm, position, broker, text, font, color, width, height)
card = BoardObjectCard(id, create_dttm, position, broker, text, font, color, width, height, attribute)
assert card.serialize() == {
'id': id,
'create_dttm': create_dttm.strftime('%Y-%m-%dT%H-%M-%SZ'),
@@ -30,6 +31,7 @@ def test_board_object_card_serialization():
'color': color,
'width': width,
'height': height,
'attribute': attribute,
}


@@ -43,6 +45,7 @@ def test_board_object_card_deserialization():
color = 'light blue'
width = 100
height = 150
attribute = {'age': '10'}
serialized = {
'id': id,
'create_dttm': create_dttm.strftime('%Y-%m-%dT%H-%M-%SZ'),
@@ -53,6 +56,7 @@ def test_board_object_card_deserialization():
'color': color,
'width': width,
'height': height,
'attribute': attribute,
}

broker = internal.pub_sub.mocks.MockPubSubBroker()
@@ -67,3 +71,4 @@ def test_board_object_card_deserialization():
assert card.color == color
assert card.width == width
assert card.height == height
assert card.attribute == attribute
10 changes: 10 additions & 0 deletions src/internal/objects/interfaces.py
Original file line number Diff line number Diff line change
@@ -112,6 +112,16 @@ def height(self) -> int:
def height(self, height: int) -> None:
pass

@property
@abc.abstractmethod
def attribute(self) -> dict[str, str]:
pass

@attribute.setter
@abc.abstractmethod
def attribute(self, attribute: dict[str, str]) -> None:
pass


class IBoardObjectPen(IBoardObject):
DEFAULT_WIDTH = 2
1 change: 1 addition & 0 deletions src/internal/objects/test_builder.py
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ def test_card_building():
'color': 'light yellow',
'width': 100,
'height': 150,
'attribute': {'age': '10'}
}
broker = internal.pub_sub.mocks.MockPubSubBroker()

1 change: 1 addition & 0 deletions src/internal/repositories/impl/test_repository.py
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ def _impl():
'color': 'light yellow',
'width': 100,
'height': 150,
'attribute': {'age': '10'},
}

return _impl
2 changes: 1 addition & 1 deletion src/internal/repositories/mocks/repository.py
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@ def delete(self, object_id: internal.objects.interfaces.ObjectId) -> None:
raise NotImplementedError()

def get_updated(self) -> dict[internal.objects.interfaces.ObjectId, Optional[dict]]:
raise NotImplementedError()
raise NotImplementedError()
21 changes: 21 additions & 0 deletions src/internal/view/modules/pivot_table/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import annotations

import internal.view.dependencies
from .states import add_attribute_state, show_axis_state
from .pivot_table_view import open_window as open_window


def create_states(dependencies: internal.view.dependencies):
dependencies.state_machine.add_state(add_attribute_state.create_state(dependencies.state_machine))
dependencies.state_machine.add_state(show_axis_state.create_state(dependencies.state_machine))


def register_module_menu(dependencies: internal.view.dependencies):
dependencies.menu.add_command_to_menu(add_attribute_state.ADD_ATTR_MENU_ENTRY_NAME)
dependencies.menu.add_command_to_menu(show_axis_state.SHOW_TABLE_MENU_ENTRY_NAME)


@internal.view.modules.modules.register_module('pivot_table')
def init_module(dependencies: internal.view.dependencies):
create_states(dependencies)
register_module_menu(dependencies)
Loading