Skip to content

Commit

Permalink
fix(links): except items that has not start and end
Browse files Browse the repository at this point in the history
  • Loading branch information
HandsomeButterball authored and walkerkay committed Jul 4, 2020
1 parent bd994b3 commit 59ce8e1
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/gantt/src/components/links/links.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { GanttLineClickEvent } from '../../class/event';
import { GANTT_REF_TOKEN, GanttRef } from '../../gantt-ref';
import { GanttDragContainer } from '../../gantt-drag-container';
import { recursiveItems } from '../../utils/helpers';
import { GanttDate } from '../../utils/date';

enum LinkColors {
default = '#cacaca',
Expand All @@ -30,6 +31,8 @@ interface GanttLinkItem {
id: string;
before: { x: number; y: number };
after: { x: number; y: number };
start: GanttDate;
end: GanttDate;
origin: GanttItem;
links: string[];
}
Expand Down Expand Up @@ -167,17 +170,19 @@ export class GanttLinksComponent implements OnInit, OnChanges, OnDestroy {
this.computeItemPosition();
this.links = [];
this.linkItems.forEach((source) => {
source.links.forEach((linkId) => {
const target = this.linkItems.find((item) => item.id === linkId);
if (target) {
this.links.push({
path: this.generatePath(source, target),
source: source.origin,
target: target.origin,
color: source.origin.end > target.origin.start ? LinkColors.blocked : LinkColors.default
});
}
});
if (source.origin.start || source.origin.end) {
source.links.forEach((linkId) => {
const target = this.linkItems.find((item) => item.id === linkId);
if (target) {
this.links.push({
path: this.generatePath(source, target),
source: source.origin,
target: target.origin,
color: source.end.getTime() > target.start.getTime() ? LinkColors.blocked : LinkColors.default
});
}
});
}
});
}

Expand Down

0 comments on commit 59ce8e1

Please sign in to comment.