Skip to content

Commit

Permalink
[Timeline]: fixed bugs with deadline only.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Jul 25, 2024
1 parent d9be3b9 commit b6f555b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/src/demo/tables/editableTable/TaskBar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
border-radius: 3px 0 0 3px;
}

.taskBarDeadlineOnly {
border-radius: 3px 3px 3px 3px;
}

.taskBarOnTime {
border-radius: 3px 3px 3px 3px;
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/demo/tables/editableTable/TaskBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function TaskBar({ task, timelineController }: { task: Task, timelineCont
className={ cx(
css.taskBar,
css[`taskBarStatus${statusTags[task.status] ?? 'None'}`],
isMissingDeadline ? css.taskBarWithMissingDeadline : css.taskBarOnTime,
isMissingDeadline && positionConfig.taskBarWidth ? css.taskBarWithMissingDeadline : css.taskBarOnTime,
) }
>
{ positionConfig.taskBarWidth > 50 && (
Expand All @@ -213,7 +213,11 @@ export function TaskBar({ task, timelineController }: { task: Task, timelineCont
) }
</div>
<div
className={ classNames(css.taskBar, css.taskBarDeadline) }
className={ classNames(
css.taskBar,
css.taskBarDeadline,
isMissingDeadline && positionConfig.taskBarWidth === 0 ? css.taskBarDeadlineOnly : undefined,
) }
style={ { width: `${deadlineWidth}px` } }
>
</div>
Expand Down
8 changes: 6 additions & 2 deletions app/src/demo/tables/editableTable/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,14 @@ export const getWidth = (from: Date, to: Date, t: TimelineTransform) => {
};

export const getTaskBarWidth = (from: Date, deadline: Date, estimatedTo: Date, t: TimelineTransform) => {
if (!deadline || deadline.getTime() < from.getTime()) {
if (!deadline) {
return getWidth(from, estimatedTo, t);
}

const to = deadline.getTime() < estimatedTo.getTime() ? deadline : estimatedTo;
let realDeadline = deadline;
if (deadline.getTime() < from.getTime()) {
realDeadline = from;
}
const to = realDeadline.getTime() < estimatedTo.getTime() ? realDeadline : estimatedTo;
return getWidth(from, to, t);
};

0 comments on commit b6f555b

Please sign in to comment.