Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(board): initialize column on updateSuccess if not created
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil143 committed Jul 23, 2018
1 parent 9b7f48a commit 5b1dd4b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class PlannerBoardComponent implements AfterViewChecked, OnInit, OnDestro

onDrop(args) {
const [el, target, source, sibling] = args;
let direction: string;
let direction: string | null;
let destinationWorkItemID: string;
if (sibling === null && el.previousElementSibling !== null) {
direction = 'below';
Expand All @@ -139,6 +139,7 @@ export class PlannerBoardComponent implements AfterViewChecked, OnInit, OnDestro
destinationWorkItemID = sibling.children[0].getAttribute('data-id');
} else if (sibling === null && el.previousElementSibling === null) {
// no reorder action dispatch only update action will dispatch
direction = null;
}
this.workItemQuery.getWorkItemWithId(el.children[0].getAttribute('data-id')).take(1).subscribe((workItem: WorkItemUI) => {
console.log('#### -1', target.getAttribute('data-id'), source.getAttribute('data-id'));
Expand Down
19 changes: 13 additions & 6 deletions src/app/effects/work-item.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,27 @@ export class WorkItemEffects {
let reorderPayload = wp.payload.reorder;
reorderPayload.workitem.version = workitem.attributes['version'];
const workItem = this.workItemMapper.toServiceModel(reorderPayload.workitem);
return this.workItemService.reOrderWorkItem(workItem, reorderPayload.destinationWorkitemID, reorderPayload.direction)
.map(w => {
console.log('#### - 4');
return this.resolveWorkItems([w], wp.state)[0];
});
return reorderPayload.direction ?
this.workItemService.reOrderWorkItem(workItem, reorderPayload.destinationWorkitemID, reorderPayload.direction) :
Observable.of(workitem);
})
.map(w => {
console.log('#### - 4');
let wi = this.resolveWorkItems([w], wp.state)[0];
console.log('#### - 4.1');
return wi;

})
.switchMap((w: WorkItemUI) => {
console.log('#### - 5', w);
return [
new WorkItemActions.UpdateSuccess(w),
new ColumnWorkItemActions.UpdateSuccess({
workItemId: w.id,
prevColumnId: wp.payload.prevColumnId,
newColumnIds: w.columnIds
})];
})
];
})
.catch((e) => {
try {
Expand Down
10 changes: 8 additions & 2 deletions src/app/reducers/column-workitem.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ export const ColumnWorkItemReducer: ActionReducer<ColumnWorkItemState> = (state
}
case ColumnWorkItemActions.UPDATE_SUCCESS: {
const cwState = {...state};
console.log('#### -- 1', cwState);
cwState[action.payload.prevColumnId].delete(action.payload.workItemId);
action.payload.newColumnIds.forEach(id => {
cwState[id].add(action.payload.workItemId);
action.payload.newColumnIds.forEach(col => {
if (cwState.hasOwnProperty(col)) {
cwState[col].add(action.payload.workItemId);
} else {
cwState[col] = new Set([action.payload.workItemId]);
}
});
console.log('#### -- 2', cwState);
return cwState;
}
default: {
Expand Down

0 comments on commit 5b1dd4b

Please sign in to comment.