Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Dec 31, 2024
1 parent d33dff6 commit eee3ba2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export class BoardDragDirective {
draggableIds: (triggerNode: string) => {
const node = this.#boardFacade.getNode(triggerNode);

if (node && (isPanel(node) || isGroup(node))) {
if (
node &&
(isPanel(node) || isGroup(node)) &&
!node.content.unLocked
) {
const nodesInside = nodesInsideNode(
node,
this.#boardFacade.get().map((node) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ import { CopyPasteService } from '../../../../services/copy-paste.service';
import { BoardFacade } from '../../../../services/board-facade.service';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { VotesModalComponent } from '../votes-modal/votes-modal.component';
import { Group, NodePatch, Note, TuNode } from '@tapiz/board-commons';
import {
Group,
isGroup,
isPanel,
NodePatch,
Note,
Panel,
TuNode,
} from '@tapiz/board-commons';
import { CommentsStore } from '@tapiz/nodes/comments/comments.store';
import { NodesActions } from '@tapiz/nodes/services/nodes-actions';
import Pickr from '@simonwep/pickr';
Expand Down Expand Up @@ -306,6 +314,37 @@ export class BoardContextMenuComponent implements OnInit {
});
}

const nodeWithNested = currentNodes
.filter((node) => {
return isGroup(node) || isPanel(node);
})
.at(0) as TuNode<Group | Panel> | undefined;

if (nodeWithNested && currentNodes.length === 1) {
actions.push({
label: nodeWithNested.content.unLocked
? 'Lock Nested Items'
: 'Unlock Nested Items',
icon: 'unfold_more',
action: () => {
this.store.dispatch(
BoardActions.batchNodeActions({
history: true,
actions: currentNodes.map((node) => {
return this.nodesActions.patch({
type: node.type,
id: node.id,
content: {
unLocked: !nodeWithNested.content.unLocked,
},
});
}),
}),
);
},
});
}

return actions;
}

Expand Down
1 change: 1 addition & 0 deletions libs/board-commons/src/lib/models/group.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Group {
userId: string;
vote: number;
}[];
unLocked?: boolean;
}

export function isGroup(node: TuNode): node is TuNode<Group> {
Expand Down
1 change: 1 addition & 0 deletions libs/board-commons/src/lib/models/panel.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Panel {
borderRadius?: number | null;
textAlign?: 'start' | 'center' | 'end';
drawing: Drawing[];
unLocked?: boolean;
}

export function isPanel(node: TuNode): node is TuNode<Panel> {
Expand Down
1 change: 1 addition & 0 deletions libs/board-commons/src/lib/validators/group.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const group = z.object({
vote: z.number().int().min(0),
}),
),
unLocked: z.boolean().optional(),
});

export const patchGroup = group.partial();
Expand Down
1 change: 1 addition & 0 deletions libs/board-commons/src/lib/validators/panel.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const panel = z.object({
),
}),
),
unLocked: z.boolean().optional(),
});

export const patchPanel = panel.partial();
Expand Down

0 comments on commit eee3ba2

Please sign in to comment.