Skip to content

Commit

Permalink
feat: note on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Dec 17, 2024
1 parent 5ae10b4 commit 8b297de
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
34 changes: 19 additions & 15 deletions apps/web/src/app/services/board-facade.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,26 @@ export class BoardFacade {
}
selectCursors() {
return this.getUsers().pipe(
concatLatestFrom(() => [this.store.select(pageFeature.selectUserId), this.store.select(pageFeature.selectBoardUsers)]),
concatLatestFrom(() => [
this.store.select(pageFeature.selectUserId),
this.store.select(pageFeature.selectBoardUsers),
]),
map(([users, currentUser, boardUsers]) => {
console.log('users board facade', users);
return users.filter((user) => {
return (
!!user.content.cursor &&
user.content.connected &&
user.id !== currentUser
);
}).map((user) => {
const boardUser = boardUsers.find((bu) => bu.id === user.id);
return {
...user.content,
picture: boardUser?.picture
};
});
return users
.filter((user) => {
return (
!!user.content.cursor &&
user.content.connected &&
user.id !== currentUser
);
})
.map((user) => {
const boardUser = boardUsers.find((bu) => bu.id === user.id);
return {
...user.content,
picture: boardUser?.picture,
};
});
}),
);
}
Expand Down
3 changes: 3 additions & 0 deletions libs/cdk/src/lib/services/multi-drag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Draggable {
destroyRef: DestroyRef;
position: () => Point;
preventDrag?: () => boolean;
drop?: () => void;
}

interface SetupConfig {
Expand Down Expand Up @@ -277,6 +278,8 @@ export class MultiDragService {
initialIndex: dragElement.initialIndex,
finalPosition: dragElement.final,
});

dragElement.draggable.drop?.();
}
});

Expand Down
5 changes: 5 additions & 0 deletions libs/nodes/src/lib/node-space/node-space.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ViewChild,
computed,
inject,
output,
} from '@angular/core';
import { Point, Resizable, Rotatable, TuNode } from '@tapiz/board-commons';
import { MultiDragService } from '@tapiz/cdk/services/multi-drag.service';
Expand Down Expand Up @@ -78,6 +79,7 @@ export class NodeSpaceComponent implements AfterViewInit {
resize = input(false);
rotate = input(false);
cursor = input('grab');
drop = output();

@ViewChild('drag')
drag!: ElementRef<HTMLElement>;
Expand Down Expand Up @@ -118,6 +120,9 @@ export class NodeSpaceComponent implements AfterViewInit {
preventDrag: () => this.preventDrag,
position: () => this.position,
destroyRef: this.#destroyRef,
drop: () => {
this.drop.emit();
},
});
}
}
3 changes: 2 additions & 1 deletion libs/nodes/src/lib/note/note.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[resize]="true"
[rotate]="false"
[enabled]="!edit() && focus()"
[cursor]="cursor()">
[cursor]="cursor()"
(drop)="onDrop()">
<div class="inner">
<div class="top-info">
@if (comments()) {
Expand Down
4 changes: 4 additions & 0 deletions libs/nodes/src/lib/note/note.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,8 @@ export class NoteComponent {
);
}
}

onDrop() {
// pass
}
}

0 comments on commit 8b297de

Please sign in to comment.