我正在尝试生成一个包含用户及其用户故事的表,标题包含他们所处的当前状态。 现在,我想为整个表创建CdkDropLists,以便可以在用户和不同状态之间移动usertory。但是,我正在努力将所有这些列表连接在一起。我想在HTML中提供所有CdkDropList的列表,以便可以将它们彼此连接。
我在互联网上四处寻找解决方案,但我发现很难提出解决方案。
现在所有列表都具有相同的#name,但是我需要能够生成名称并将所有这些列表链接在一起的功能。这样拖放功能就可以在表格中使用了。
<table>
<tr><th></th><th>to do</th><th>doing</th><th>test</th><th>done</th></tr>
<tr *ngFor="let user of users"><td>{{user.name}}</td>
<td *ngFor="let status of status">
<div cdkDropList
[cdkDropListData]="getStatusStories(user.id, status.name)"
[cdkDropListConnectedTo]="unasignedList"
(cdkDropListDropped)="onDrop($event, user.id, status.name)"
#dropList="cdkDropList" style="width: 25%; border: 1px solid black;">
<div cdkDrag *ngFor="let story of getStatusStories(user.id, status.name)" class="item">{{story.name}}</div>
</div>
</td>
</tr>
</table>
private sprints: Sprint[];
private userStories: Userstory[];
private users: User[];
private status: Status[] = [
{ id: "1", name: "to do" } as Status,
{ id: "2", name: "doing" } as Status,
{ id: "3", name: "test" } as Status,
{ id: "4", name: "done" } as Status
];
ngOnInit() {
this.firebaseService.getSprints().subscribe(sprints => (this.sprints = sprints));
this.firebaseService.getStories().subscribe(stories => (this.userStories = stories));
this.firebaseService.getUsers().subscribe(users => (this.users = users));
}
getStatusStories(userId: string, statusName: string): Userstory[] {
const filteredStories = [];
this.userStories.forEach(element => {
if (element.status === statusName && element.user_id === userId) {
filteredStories.push(element);
}
});
return filteredStories;
}