@worktile/gantt 12.1.2 → 12.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -559,6 +559,20 @@
559
559
  GanttViewType["week"] = "week";
560
560
  })(exports.GanttViewType || (exports.GanttViewType = {}));
561
561
 
562
+ var GanttLinkType;
563
+ (function (GanttLinkType) {
564
+ GanttLinkType[GanttLinkType["fs"] = 0] = "fs";
565
+ GanttLinkType[GanttLinkType["ss"] = 1] = "ss";
566
+ GanttLinkType[GanttLinkType["ff"] = 2] = "ff";
567
+ GanttLinkType[GanttLinkType["sf"] = 3] = "sf";
568
+ })(GanttLinkType || (GanttLinkType = {}));
569
+ var LinkColors;
570
+ (function (LinkColors) {
571
+ LinkColors["default"] = "#cacaca";
572
+ LinkColors["blocked"] = "#FF7575";
573
+ LinkColors["active"] = "#348FE4";
574
+ })(LinkColors || (LinkColors = {}));
575
+
562
576
  exports.GanttItemType = void 0;
563
577
  (function (GanttItemType) {
564
578
  GanttItemType["bar"] = "bar";
@@ -571,7 +585,17 @@
571
585
  this.refs$ = new rxjs.BehaviorSubject(null);
572
586
  this.origin = item;
573
587
  this.id = this.origin.id;
574
- this.links = this.origin.links || [];
588
+ this.links = (this.origin.links || []).map(function (link) {
589
+ if (typeof link === 'string') {
590
+ return {
591
+ type: GanttLinkType.fs,
592
+ link: link
593
+ };
594
+ }
595
+ else {
596
+ return link;
597
+ }
598
+ });
575
599
  this.color = this.origin.color;
576
600
  this.barStyle = this.origin.barStyle;
577
601
  this.linkable = this.origin.linkable === undefined ? true : this.origin.linkable;
@@ -635,7 +659,7 @@
635
659
  this.origin.expanded = expanded;
636
660
  };
637
661
  GanttItemInternal.prototype.addLink = function (linkId) {
638
- this.links = __spreadArray(__spreadArray([], __read(this.links)), [linkId]);
662
+ this.links = __spreadArray(__spreadArray([], __read(this.links)), [{ type: GanttLinkType.fs, link: linkId }]);
639
663
  this.origin.links = this.links;
640
664
  };
641
665
  return GanttItemInternal;
@@ -2253,12 +2277,6 @@
2253
2277
  args: ['mainTemplate', { static: true }]
2254
2278
  }] } });
2255
2279
 
2256
- var LinkColors;
2257
- (function (LinkColors) {
2258
- LinkColors["default"] = "#cacaca";
2259
- LinkColors["blocked"] = "#FF7575";
2260
- LinkColors["active"] = "#348FE4";
2261
- })(LinkColors || (LinkColors = {}));
2262
2280
  var GanttLinksComponent = /** @class */ (function () {
2263
2281
  function GanttLinksComponent(ganttUpper, cdr, elementRef, ganttDragContainer) {
2264
2282
  this.ganttUpper = ganttUpper;
@@ -2335,12 +2353,45 @@
2335
2353
  });
2336
2354
  }
2337
2355
  };
2338
- GanttLinksComponent.prototype.generatePath = function (source, target) {
2356
+ GanttLinksComponent.prototype.generatePath = function (source, target, type) {
2339
2357
  if (source.before && source.after && target.before && target.after) {
2340
2358
  var x1 = source.after.x;
2341
2359
  var y1 = source.after.y;
2342
2360
  var x4 = target.before.x;
2343
2361
  var y4 = target.before.y;
2362
+ var isMirror = void 0;
2363
+ var control = Math.abs(y4 - y1) / 2;
2364
+ switch (type) {
2365
+ case GanttLinkType.ss:
2366
+ x1 = source.before.x;
2367
+ y1 = source.before.y;
2368
+ x4 = target.before.x;
2369
+ y4 = target.before.y;
2370
+ isMirror = y4 > y1 ? 0 : 1;
2371
+ if (x4 > x1) {
2372
+ return "M " + x1 + " " + y1 + "\n A " + control + " " + control + " 0 1 " + isMirror + " " + x1 + " " + y4 + "\n L " + x1 + " " + y4 + " " + x4 + " " + y4;
2373
+ }
2374
+ else {
2375
+ return "M " + x1 + " " + y1 + "\n L " + x1 + " " + y1 + " " + x4 + " " + y1 + "\n A " + control + " " + control + " 0 1 " + isMirror + " " + x4 + " " + y4;
2376
+ }
2377
+ case GanttLinkType.ff:
2378
+ x1 = source.after.x;
2379
+ y1 = source.after.y;
2380
+ x4 = target.after.x;
2381
+ y4 = target.after.y;
2382
+ isMirror = y4 > y1 ? 1 : 0;
2383
+ if (x4 > x1) {
2384
+ return "M " + x1 + " " + y1 + "\n L " + x1 + " " + y1 + " " + x4 + " " + y1 + "\n A " + control + " " + control + " 0 1 " + isMirror + " " + x4 + " " + y4;
2385
+ }
2386
+ else {
2387
+ return "M " + x1 + " " + y1 + "\n A " + control + " " + control + " 0 1 " + isMirror + " " + x1 + " " + y4 + "\n L " + x1 + " " + y4 + " " + x4 + " " + y4;
2388
+ }
2389
+ case GanttLinkType.sf:
2390
+ x1 = target.after.x;
2391
+ y1 = target.after.y;
2392
+ x4 = source.before.x;
2393
+ y4 = source.before.y;
2394
+ }
2344
2395
  var dx = Math.abs(x4 - x1) * this.bezierWeight;
2345
2396
  var x2 = x1 - dx;
2346
2397
  var x3 = x4 + dx;
@@ -2377,13 +2428,14 @@
2377
2428
  this.links = [];
2378
2429
  this.linkItems.forEach(function (source) {
2379
2430
  if (source.origin.start || source.origin.end) {
2380
- source.links.forEach(function (linkId) {
2381
- var target = _this.linkItems.find(function (item) { return item.id === linkId; });
2431
+ source.links.forEach(function (link) {
2432
+ var target = _this.linkItems.find(function (item) { return item.id === link.link; });
2382
2433
  if (target && (target.origin.start || target.origin.end)) {
2383
2434
  _this.links.push({
2384
- path: _this.generatePath(source, target),
2435
+ path: _this.generatePath(source, target, link.type),
2385
2436
  source: source.origin,
2386
2437
  target: target.origin,
2438
+ type: link.type,
2387
2439
  color: source.end.getTime() > target.start.getTime() ? LinkColors.blocked : LinkColors.default
2388
2440
  });
2389
2441
  }
@@ -2418,7 +2470,7 @@
2418
2470
  return GanttLinksComponent;
2419
2471
  }());
2420
2472
  GanttLinksComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0__namespace.ChangeDetectorRef }, { token: i0__namespace.ElementRef }, { token: GanttDragContainer }], target: i0__namespace.ɵɵFactoryTarget.Component });
2421
- GanttLinksComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0__namespace, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path [attr.d]=\"link.path\" fill=\"transparent\" stroke-width=\"2\" [attr.stroke]=\"link.color\" pointer-events=\"none\"></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2473
+ GanttLinksComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0__namespace, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [style]=\"'marker-end: url(#triangle' + i + ')'\"\n ></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <!-- <defs>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </defs> -->\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2422
2474
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinksComponent, decorators: [{
2423
2475
  type: i0.Component,
2424
2476
  args: [{