@worktile/gantt 19.0.8-next.2 → 19.0.8-next.4
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.
- package/fesm2022/worktile-gantt.mjs +41 -20
- package/fesm2022/worktile-gantt.mjs.map +1 -1
- package/gantt.component.scss +4 -0
- package/package.json +1 -1
- package/views/day.d.ts +1 -0
- package/views/view.d.ts +7 -0
|
@@ -1005,6 +1005,18 @@ class GanttView {
|
|
|
1005
1005
|
return this.getDayOccupancyWidth(date);
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* 根据起始日期和宽度计算结束日期
|
|
1010
|
+
* @param start 起始日期
|
|
1011
|
+
* @param width 视觉宽度
|
|
1012
|
+
* @returns 结束日期
|
|
1013
|
+
*/
|
|
1014
|
+
getEndDateByWidth(start, width) {
|
|
1015
|
+
const startX = this.getXPointByDate(start);
|
|
1016
|
+
// 减去偏移量避免因为 getDateRangeWidth 加了 1 秒而多算一天
|
|
1017
|
+
const endX = startX + width - 0.1;
|
|
1018
|
+
return this.getDateByXPoint(endX);
|
|
1019
|
+
}
|
|
1008
1020
|
}
|
|
1009
1021
|
|
|
1010
1022
|
const viewOptions$5 = {
|
|
@@ -1065,6 +1077,30 @@ class GanttViewDay extends GanttView {
|
|
|
1065
1077
|
}
|
|
1066
1078
|
return points;
|
|
1067
1079
|
}
|
|
1080
|
+
getEndDateByWidth(start, width) {
|
|
1081
|
+
if (!this.options.hoilday?.hideHoliday) {
|
|
1082
|
+
return super.getEndDateByWidth(start, width);
|
|
1083
|
+
}
|
|
1084
|
+
// 通过宽度计算包含多少个工作日(每个工作日的宽度是 cellWidth)
|
|
1085
|
+
const workingDaysCount = Math.round(width / this.getCellWidth());
|
|
1086
|
+
let end = start;
|
|
1087
|
+
let addedWorkingDays = 0;
|
|
1088
|
+
let attempts = 0;
|
|
1089
|
+
const maxAttempts = 365;
|
|
1090
|
+
while (addedWorkingDays < workingDaysCount && attempts < maxAttempts) {
|
|
1091
|
+
if (this.getDayOccupancyWidth(end) > 0) {
|
|
1092
|
+
addedWorkingDays++;
|
|
1093
|
+
if (addedWorkingDays < workingDaysCount) {
|
|
1094
|
+
end = end.addDays(1);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
end = end.addDays(1);
|
|
1099
|
+
}
|
|
1100
|
+
attempts++;
|
|
1101
|
+
}
|
|
1102
|
+
return end;
|
|
1103
|
+
}
|
|
1068
1104
|
}
|
|
1069
1105
|
|
|
1070
1106
|
const viewOptions$4 = {
|
|
@@ -2398,25 +2434,13 @@ class GanttBarDrag {
|
|
|
2398
2434
|
}
|
|
2399
2435
|
barDragMove() {
|
|
2400
2436
|
const currentX = this.item().refs.x + this.barDragMoveDistance + this.dragScrollDistance;
|
|
2401
|
-
const
|
|
2402
|
-
const
|
|
2403
|
-
const currentEndDate = this.ganttUpper.view.getDateByXPoint(currentX + this.item().refs.width);
|
|
2404
|
-
const diffs = this.ganttUpper.view.differenceByPrecisionUnit(currentEndDate, currentDate);
|
|
2405
|
-
let start = currentDate;
|
|
2406
|
-
let end = currentDate.add(diffs, this.ganttUpper.view?.options?.datePrecisionUnit);
|
|
2407
|
-
// 日视图特殊逻辑处理
|
|
2408
|
-
if (this.ganttUpper.view.viewType === GanttViewType.day) {
|
|
2409
|
-
const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
|
|
2410
|
-
if (currentX > currentStartX + dayWidth / 2) {
|
|
2411
|
-
start = start.addDays(1);
|
|
2412
|
-
end = end.addDays(1);
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2437
|
+
const start = this.ganttUpper.view.getDateByXPoint(currentX);
|
|
2438
|
+
const end = this.ganttUpper.view.getEndDateByWidth(start, this.item().refs.width);
|
|
2415
2439
|
if (this.dragScrolling) {
|
|
2416
2440
|
const left = currentX - this.barDragMoveDistance;
|
|
2417
2441
|
this.barElement.style.left = left + 'px';
|
|
2418
2442
|
}
|
|
2419
|
-
this.openDragBackdrop(this.barElement,
|
|
2443
|
+
this.openDragBackdrop(this.barElement, start, end);
|
|
2420
2444
|
if (!this.isStartOrEndInsideView(start, end)) {
|
|
2421
2445
|
return;
|
|
2422
2446
|
}
|
|
@@ -2694,9 +2718,6 @@ class NgxGanttBarComponent extends GanttItemUpper {
|
|
|
2694
2718
|
let style = { ...(this.item.barStyle || {}) };
|
|
2695
2719
|
const contentElement = this.contentElementRef.nativeElement;
|
|
2696
2720
|
const barElement = this.elementRef.nativeElement;
|
|
2697
|
-
if (this.item.barStyle && Object.prototype.hasOwnProperty.call(this.item.barStyle, 'visibility')) {
|
|
2698
|
-
barElement.style.visibility = this.item.barStyle?.visibility;
|
|
2699
|
-
}
|
|
2700
2721
|
if (this.item.refs?.width) {
|
|
2701
2722
|
const color = this.item.color || barBackground;
|
|
2702
2723
|
if (this.item.origin.start && this.item.origin.end) {
|
|
@@ -3804,7 +3825,7 @@ class GanttMainComponent {
|
|
|
3804
3825
|
this.ganttRoot.scrollToDate(date);
|
|
3805
3826
|
}
|
|
3806
3827
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: GanttMainComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: GanttDomService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3807
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", type: GanttMainComponent, isStandalone: true, selector: "gantt-main", inputs: { viewportItems: "viewportItems", flatItems: "flatItems", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate", baselineTemplate: "baselineTemplate", ganttRoot: "ganttRoot", quickTimeFocus: "quickTimeFocus" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [flatItems]=\"flatItems\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n @for (data of viewportItems; track trackBy($index, data)) {\n @if (data | isGanttGroup) {\n <div class=\"gantt-group\" [style.height.px]=\"ganttUpper.styles.lineHeight\" [ngClass]=\"data.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n }\n @if (!(data | isGanttGroup)) {\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [style]=\"data.laneStyle\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n @if (data.type | isGanttCustomItem) {\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n }\n @if ((data.type | isGanttRangeItem) || (data.type | isGanttBarItem)) {\n @if (data.type | isGanttRangeItem) {\n <gantt-range [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n }\n @if (data.type | isGanttBarItem) {\n <gantt-bar [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n }\n @if (ganttUpper.baselineItemsMap[data.id]) {\n <gantt-baseline [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\" [template]=\"baselineTemplate\"></gantt-baseline>\n }\n }\n </div>\n }\n }\n</div>\n\n@if (quickTimeFocus) {\n <div class=\"gantt-quick-time-focus-container\" [style.width.px]=\"ganttUpper.view.width\">\n <div class=\"gantt-quick-time-focus\" [style.width.px]=\"dom.visibleRangeX().max - dom.visibleRangeX().min\">\n @for (data of viewportItems; track trackBy(i, data); let i = $index) {\n @let item = toItemType(data);\n <div
|
|
3828
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", type: GanttMainComponent, isStandalone: true, selector: "gantt-main", inputs: { viewportItems: "viewportItems", flatItems: "flatItems", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate", baselineTemplate: "baselineTemplate", ganttRoot: "ganttRoot", quickTimeFocus: "quickTimeFocus" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [flatItems]=\"flatItems\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n @for (data of viewportItems; track trackBy($index, data)) {\n @if (data | isGanttGroup) {\n <div class=\"gantt-group\" [style.height.px]=\"ganttUpper.styles.lineHeight\" [ngClass]=\"data.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n }\n @if (!(data | isGanttGroup)) {\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [style]=\"data.laneStyle\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n @if (data.type | isGanttCustomItem) {\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n }\n @if ((data.type | isGanttRangeItem) || (data.type | isGanttBarItem)) {\n @if (data.type | isGanttRangeItem) {\n <gantt-range [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n }\n @if (data.type | isGanttBarItem) {\n <gantt-bar [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n }\n @if (ganttUpper.baselineItemsMap[data.id]) {\n <gantt-baseline [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\" [template]=\"baselineTemplate\"></gantt-baseline>\n }\n }\n </div>\n }\n }\n</div>\n\n@if (quickTimeFocus) {\n <div class=\"gantt-quick-time-focus-container\" [style.width.px]=\"ganttUpper.view.width\">\n <div class=\"gantt-quick-time-focus\" [style.width.px]=\"dom.visibleRangeX().max - dom.visibleRangeX().min\">\n @for (data of viewportItems; track trackBy(i, data); let i = $index) {\n @let item = toItemType(data);\n <div\n class=\"gantt-quick-time-focus-item\"\n [ngClass]=\"{ 'gantt-quick-time-focus-item-hide': !item?.refs?.width }\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n >\n <span class=\"ml-2\">\n @if (item.refs?.x < dom.visibleRangeX().min && item.refs?.width) {\n <a class=\"gantt-quick-time-focus-item-arrow link-secondary\" href=\"javascript:;\" (click)=\"quickTime(item.origin, 'left')\">\n <gantt-icon iconName=\"arrow-left\"></gantt-icon>\n </a>\n }\n </span>\n <span class=\"mr-2\">\n @if (item.refs?.x + item.refs?.width > dom.visibleRangeX().max && item.refs?.width) {\n <a class=\"gantt-quick-time-focus-item-arrow link-secondary\" href=\"javascript:;\" (click)=\"quickTime(item.origin, 'right')\">\n <gantt-icon iconName=\"arrow-right\"></gantt-icon>\n </a>\n }\n </span>\n </div>\n }\n </div>\n </div>\n}\n", dependencies: [{ kind: "component", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["flatItems"], outputs: ["lineClick"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { kind: "component", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }, { kind: "component", type: NgxGanttBaselineComponent, selector: "ngx-gantt-baseline,gantt-baseline", inputs: ["baselineItem", "template"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }, { kind: "pipe", type: IsGanttBarItemPipe, name: "isGanttBarItem" }, { kind: "pipe", type: IsGanttCustomItemPipe, name: "isGanttCustomItem" }, { kind: "pipe", type: IsGanttGroupPipe, name: "isGanttGroup" }, { kind: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }] }); }
|
|
3808
3829
|
}
|
|
3809
3830
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: GanttMainComponent, decorators: [{
|
|
3810
3831
|
type: Component,
|
|
@@ -3820,7 +3841,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
|
|
|
3820
3841
|
IsGanttCustomItemPipe,
|
|
3821
3842
|
IsGanttGroupPipe,
|
|
3822
3843
|
GanttIconComponent
|
|
3823
|
-
], template: "<gantt-links-overlay [flatItems]=\"flatItems\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n @for (data of viewportItems; track trackBy($index, data)) {\n @if (data | isGanttGroup) {\n <div class=\"gantt-group\" [style.height.px]=\"ganttUpper.styles.lineHeight\" [ngClass]=\"data.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n }\n @if (!(data | isGanttGroup)) {\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [style]=\"data.laneStyle\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n @if (data.type | isGanttCustomItem) {\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n }\n @if ((data.type | isGanttRangeItem) || (data.type | isGanttBarItem)) {\n @if (data.type | isGanttRangeItem) {\n <gantt-range [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n }\n @if (data.type | isGanttBarItem) {\n <gantt-bar [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n }\n @if (ganttUpper.baselineItemsMap[data.id]) {\n <gantt-baseline [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\" [template]=\"baselineTemplate\"></gantt-baseline>\n }\n }\n </div>\n }\n }\n</div>\n\n@if (quickTimeFocus) {\n <div class=\"gantt-quick-time-focus-container\" [style.width.px]=\"ganttUpper.view.width\">\n <div class=\"gantt-quick-time-focus\" [style.width.px]=\"dom.visibleRangeX().max - dom.visibleRangeX().min\">\n @for (data of viewportItems; track trackBy(i, data); let i = $index) {\n @let item = toItemType(data);\n <div
|
|
3844
|
+
], template: "<gantt-links-overlay [flatItems]=\"flatItems\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n @for (data of viewportItems; track trackBy($index, data)) {\n @if (data | isGanttGroup) {\n <div class=\"gantt-group\" [style.height.px]=\"ganttUpper.styles.lineHeight\" [ngClass]=\"data.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n }\n @if (!(data | isGanttGroup)) {\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [style]=\"data.laneStyle\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n @if (data.type | isGanttCustomItem) {\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n }\n @if ((data.type | isGanttRangeItem) || (data.type | isGanttBarItem)) {\n @if (data.type | isGanttRangeItem) {\n <gantt-range [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n }\n @if (data.type | isGanttBarItem) {\n <gantt-bar [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n }\n @if (ganttUpper.baselineItemsMap[data.id]) {\n <gantt-baseline [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\" [template]=\"baselineTemplate\"></gantt-baseline>\n }\n }\n </div>\n }\n }\n</div>\n\n@if (quickTimeFocus) {\n <div class=\"gantt-quick-time-focus-container\" [style.width.px]=\"ganttUpper.view.width\">\n <div class=\"gantt-quick-time-focus\" [style.width.px]=\"dom.visibleRangeX().max - dom.visibleRangeX().min\">\n @for (data of viewportItems; track trackBy(i, data); let i = $index) {\n @let item = toItemType(data);\n <div\n class=\"gantt-quick-time-focus-item\"\n [ngClass]=\"{ 'gantt-quick-time-focus-item-hide': !item?.refs?.width }\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n >\n <span class=\"ml-2\">\n @if (item.refs?.x < dom.visibleRangeX().min && item.refs?.width) {\n <a class=\"gantt-quick-time-focus-item-arrow link-secondary\" href=\"javascript:;\" (click)=\"quickTime(item.origin, 'left')\">\n <gantt-icon iconName=\"arrow-left\"></gantt-icon>\n </a>\n }\n </span>\n <span class=\"mr-2\">\n @if (item.refs?.x + item.refs?.width > dom.visibleRangeX().max && item.refs?.width) {\n <a class=\"gantt-quick-time-focus-item-arrow link-secondary\" href=\"javascript:;\" (click)=\"quickTime(item.origin, 'right')\">\n <gantt-icon iconName=\"arrow-right\"></gantt-icon>\n </a>\n }\n </span>\n </div>\n }\n </div>\n </div>\n}\n" }]
|
|
3824
3845
|
}], ctorParameters: () => [{ type: GanttUpper, decorators: [{
|
|
3825
3846
|
type: Inject,
|
|
3826
3847
|
args: [GANTT_UPPER_TOKEN]
|