Skip to content

Commit

Permalink
fix: review code
Browse files Browse the repository at this point in the history
  • Loading branch information
mengshuicmq authored and HandsomeButterball committed Jun 30, 2021
1 parent 9ac28e7 commit 51d583f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion example/src/app/gantt/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class AppGanttExampleComponent implements OnInit {
groups = mockGroups;

options = {
viewType: GanttViewType.month,
viewType: GanttViewType.day,
draggable: true,
linkable: true,
async: true,
Expand Down
16 changes: 8 additions & 8 deletions packages/gantt/src/class/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,24 @@ export class GanttItemInternal {
this.progress = this.origin.progress;
// fill one month when start or end is null
if (item.start && !item.end) {
this.end = this.fillItemByViewType(item.start, true);
this.end = this.fillItemByViewType(item);
}
if (!item.start && item.end) {
this.start = this.fillItemByViewType(item.end, false);
this.start = this.fillItemByViewType(item);
}
}

fillItemByViewType(date: Date | string | number, hasStart?: boolean) {
let _date: GanttDate;
fillItemByViewType(item: GanttItem) {
let date: GanttDate;
switch (this.viewType) {
case GanttViewType.day:
_date = hasStart ? new GanttDate(date).endOfDay() : new GanttDate(date).startOfDay();
case GanttViewType.day || GanttViewType.week:
date = item.start ? new GanttDate(item.start).endOfDay() : new GanttDate(item.end).startOfDay();
break;
default:
_date = hasStart ? new GanttDate(date).addMonths(1).endOfDay() : new GanttDate(date).addMonths(-1).startOfDay();
date = item.start ? new GanttDate(item.start).addMonths(1).endOfDay() : new GanttDate(item.end).addMonths(-1).startOfDay();
break;
}
return _date;
return date;
}

updateRefs(refs: GanttItemRefs) {
Expand Down

0 comments on commit 51d583f

Please sign in to comment.