Skip to content

Commit

Permalink
fix: group drag in the same layer if its layer 0
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Feb 20, 2025
1 parent 9821338 commit 438cf93
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { MultiDragService } from '@tapiz/cdk/services/multi-drag.service';
import { BoardFacade } from '../../../../services/board-facade.service';
import { Store } from '@ngrx/store';
import { boardPageFeature } from '../../reducers/boardPage.reducer';
import { isGroup, isPanel } from '@tapiz/board-commons';
import {
BoardTuNode,
isBoardTuNode,
isGroup,
isPanel,
} from '@tapiz/board-commons';
import { nodesInsideNode } from '@tapiz/cdk/utils/nodes-inside';
import { getNodeSize } from '../../../../shared/node-size';
import { NodesActions } from '../../services/nodes-actions';
Expand All @@ -28,26 +33,38 @@ export class BoardDragDirective {
relativePosition: this.#store.select(boardPageFeature.selectPosition),
draggableIds: (triggerNode: string) => {
const node = this.#boardFacade.getNode(triggerNode);

if (
node &&
(isPanel(node) || isGroup(node)) &&
!node.content.unLocked
) {
const nodesInside = nodesInsideNode(
node,
this.#boardFacade.get().map((node) => {
const { width, height } = getNodeSize(node);
this.#boardFacade
.get()
.filter((itNode): itNode is BoardTuNode => {
if (!isBoardTuNode(itNode)) {
return false;
}

if (node.content.layer === 1) {
return true;
}

return itNode.content.layer === node.content.layer;
})
.map((node) => {
const { width, height } = getNodeSize(node);

return {
...node,
content: {
...node.content,
width,
height,
},
};
}),
return {
...node,
content: {
...node.content,
width,
height,
},
};
}),
);

const nodeIds = nodesInside.map((node) => node.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface BoardPageState {
nodeSelection: boolean;
userHighlight: User['id'] | null;
showUserVotes: User['id'] | null;
boardMode: number;
boardMode: number; // 0 - normal, 1 - edit mode
popupOpen: string;
popupPinned: boolean;
isAdmin: boolean;
Expand Down

0 comments on commit 438cf93

Please sign in to comment.