diff --git a/apps/server/src/modules/board/poc/board-node.do.spec.ts b/apps/server/src/modules/board/poc/board-node.do.spec.ts index ede78c07362..5cb78a639ef 100644 --- a/apps/server/src/modules/board/poc/board-node.do.spec.ts +++ b/apps/server/src/modules/board/poc/board-node.do.spec.ts @@ -1,5 +1,5 @@ import { boardNodeFactory } from './board-node.factory'; -import { INITIAL_PATH, joinPath } from './path-utils'; +import { ROOT_PATH, joinPath } from './path-utils'; describe('BoardNode', () => { describe('a new instance', () => { @@ -25,9 +25,9 @@ describe('BoardNode', () => { expect(boardNode.level).toBe(0); }); - it('should have initial path', () => { + it('should have root path', () => { const { boardNode } = setup(); - expect(boardNode.path).toBe(INITIAL_PATH); + expect(boardNode.path).toBe(ROOT_PATH); }); }); @@ -151,7 +151,7 @@ describe('BoardNode', () => { child.removeFromParent(parent); - expect(child.path).toEqual(INITIAL_PATH); + expect(child.path).toEqual(ROOT_PATH); }); }); @@ -193,7 +193,7 @@ describe('BoardNode', () => { parent.removeChild(child); - expect(child.path).toEqual(INITIAL_PATH); + expect(child.path).toEqual(ROOT_PATH); }); }); }); diff --git a/apps/server/src/modules/board/poc/board-node.do.ts b/apps/server/src/modules/board/poc/board-node.do.ts index 9d35be5bd14..63fa5b859ec 100644 --- a/apps/server/src/modules/board/poc/board-node.do.ts +++ b/apps/server/src/modules/board/poc/board-node.do.ts @@ -1,6 +1,6 @@ import { DomainObject } from '@shared/domain/domain-object'; import { EntityId } from '@shared/domain/types'; -import { INITIAL_PATH, PATH_SEPARATOR, joinPath } from './path-utils'; +import { ROOT_PATH, PATH_SEPARATOR, joinPath } from './path-utils'; export interface BoardNodeProps { id: EntityId; @@ -43,6 +43,7 @@ export class BoardNode extends DomainObject { } addToParent(parent: BoardNode, position?: { index1: string; index2: string }): void { + // TODO remove from potential previous parent (and its children)? if (this.parentId !== parent.id) { this.props.path = joinPath(parent.path, parent.id); // TODO set index (position) @@ -55,7 +56,7 @@ export class BoardNode extends DomainObject { removeFromParent(parent: BoardNode): void { if (this.parentId === parent.id) { - this.props.path = INITIAL_PATH; + this.props.path = ROOT_PATH; // TODO set index (position) this.props.level = 0; } diff --git a/apps/server/src/modules/board/poc/board-node.factory.ts b/apps/server/src/modules/board/poc/board-node.factory.ts index 755fb2f72f4..7edff5c6a00 100644 --- a/apps/server/src/modules/board/poc/board-node.factory.ts +++ b/apps/server/src/modules/board/poc/board-node.factory.ts @@ -2,14 +2,14 @@ import { BaseFactory } from '@shared/testing'; import { ObjectId } from 'bson'; import { BoardNode, BoardNodeProps } from './board-node.do'; -import { INITIAL_PATH } from './path-utils'; +import { ROOT_PATH } from './path-utils'; export const boardNodeFactory = BaseFactory.define(BoardNode, ({ sequence }) => { return { id: new ObjectId().toHexString(), - path: INITIAL_PATH, + path: ROOT_PATH, level: 0, - title: `column board #${sequence}`, + title: `board node #${sequence}`, position: 0, children: [], createdAt: new Date(), diff --git a/apps/server/src/modules/board/poc/board-node.repo.ts b/apps/server/src/modules/board/poc/board-node.repo.ts index 831107cb733..fd7a30b2f89 100644 --- a/apps/server/src/modules/board/poc/board-node.repo.ts +++ b/apps/server/src/modules/board/poc/board-node.repo.ts @@ -21,6 +21,8 @@ export class BoardNodeRepo { return boardNode; } + // TODO findByIds() + persist(boardNode: BoardNode | BoardNode[]): BoardNodeRepo { const boardNodes = Utils.asArray(boardNode); diff --git a/apps/server/src/modules/board/poc/path-utils.ts b/apps/server/src/modules/board/poc/path-utils.ts index 9bd835da8a6..1f0c2d05902 100644 --- a/apps/server/src/modules/board/poc/path-utils.ts +++ b/apps/server/src/modules/board/poc/path-utils.ts @@ -2,6 +2,6 @@ import { EntityId } from '@shared/domain/types'; export const PATH_SEPARATOR = ','; -export const INITIAL_PATH = PATH_SEPARATOR; +export const ROOT_PATH = PATH_SEPARATOR; export const joinPath = (path: string, id: EntityId): string => `${path}${id}${PATH_SEPARATOR}`;