Hello, my problem is in old codebase i have to add an feature the feature is if the is an item under another item in calendar it should become a siblings like in picture below i tried to do like this :
lanes.forEach((lane)=>{
lane.forEach((l)=>{
if(l.item){
if(l.span > 1 && l.item.firstDay['_d'] != l.item.lastDay['_d']){
let otherItems = []
items.map((item) => {
if(item.workOrderId != l.item.workOrderId && moment(item.get('firstDay')).isSame(l.item.get('lastDay', 'day'))){
otherItems.push(item)
}
});
otherItems.forEach(function(item){
// l.item.siblings.push(item.workOrderId)
console.log(l.item)
});
}else{
l.item.set("siblings", l.siblings)
}
}
})
})
the code is :
weekTeams: computed("teams", "teams.@each.position", "from", "to", "items.@each.updatedAt", function(){
const within = moment.range(this.get("from"), this.get("to")),
allItems = this.get("items"),
teams = this.get("teams");
return teams.map((team)=>{
const items = allItems.filterBy("assignee.id", team.get("foreman.id")),
teamDays = [];
within.by("days", (d)=>{
const dItems = items.filter(function(i){
return i.withinRange(moment(d).subtract("hour", 1), moment(d).add("hour", 1));
});
teamDays.push({
day: d.toDate(),
dayDef: this.dayDefFor(d),
items: dItems
});
});
const lanes = getLanes(teamDays);
lanes.get("lastObject").last = true;
return {
teamId: items.get("firstObject.assignee.id"),
team: team.get("foreman"),
boardTeam: team,
position: team.get("position"),
firstLane: lanes[0],
otherLanes: lanes.slice(1),
lanesLength: lanes.length
};
});
}),
teamSort: ["position:asc"],
teamsSorted: sort("weekTeams", "teamSort")