@worktile/gantt 12.0.1 → 12.1.1
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/README.md +13 -116
- package/bundles/worktile-gantt.umd.js +3369 -0
- package/bundles/worktile-gantt.umd.js.map +1 -0
- package/class/date-point.d.ts +15 -0
- package/{packages/gantt/src/class/event.ts → class/event.d.ts} +6 -12
- package/class/group.d.ts +22 -0
- package/{packages/gantt/src/class/index.ts → class/index.d.ts} +0 -0
- package/class/item.d.ts +70 -0
- package/class/view-type.d.ts +7 -0
- package/components/bar/bar-drag.d.ts +37 -0
- package/components/bar/bar.component.d.ts +26 -0
- package/components/calendar/calendar.component.d.ts +28 -0
- package/components/drag-backdrop/drag-backdrop.component.d.ts +9 -0
- package/components/icon/icon.component.d.ts +13 -0
- package/components/icon/icons.d.ts +8 -0
- package/components/links/links.component.d.ts +47 -0
- package/components/main/gantt-main.component.d.ts +21 -0
- package/components/range/range.component.d.ts +13 -0
- package/components/table/gantt-table.component.d.ts +37 -0
- package/esm2015/class/date-point.js +10 -0
- package/esm2015/class/event.js +13 -0
- package/esm2015/class/group.js +17 -0
- package/esm2015/class/index.js +6 -0
- package/esm2015/class/item.js +78 -0
- package/esm2015/class/view-type.js +9 -0
- package/esm2015/components/bar/bar-drag.js +269 -0
- package/esm2015/components/bar/bar.component.js +98 -0
- package/esm2015/components/calendar/calendar.component.js +86 -0
- package/esm2015/components/drag-backdrop/drag-backdrop.component.js +21 -0
- package/esm2015/components/icon/icon.component.js +38 -0
- package/esm2015/components/icon/icons.js +87 -0
- package/esm2015/components/links/links.component.js +213 -0
- package/esm2015/components/main/gantt-main.component.js +53 -0
- package/esm2015/components/range/range.component.js +37 -0
- package/esm2015/components/table/gantt-table.component.js +149 -0
- package/esm2015/gantt-abstract.js +3 -0
- package/esm2015/gantt-dom.service.js +103 -0
- package/esm2015/gantt-drag-container.js +60 -0
- package/esm2015/gantt-item-upper.js +58 -0
- package/esm2015/gantt-print.service.js +94 -0
- package/esm2015/gantt-upper.js +280 -0
- package/esm2015/gantt.component.js +135 -0
- package/esm2015/gantt.config.js +13 -0
- package/esm2015/gantt.module.js +85 -0
- package/esm2015/gantt.pipe.js +43 -0
- package/esm2015/gantt.styles.js +15 -0
- package/esm2015/public-api.js +19 -0
- package/esm2015/root.component.js +123 -0
- package/esm2015/table/gantt-column.component.js +37 -0
- package/esm2015/table/gantt-table.component.js +20 -0
- package/esm2015/utils/date.js +160 -0
- package/esm2015/utils/helpers.js +55 -0
- package/esm2015/views/day.js +54 -0
- package/esm2015/views/factory.js +23 -0
- package/esm2015/views/month.js +48 -0
- package/esm2015/views/quarter.js +51 -0
- package/esm2015/views/view.js +123 -0
- package/esm2015/views/week.js +49 -0
- package/esm2015/views/year.js +50 -0
- package/esm2015/worktile-gantt.js +5 -0
- package/fesm2015/worktile-gantt.js +2697 -0
- package/fesm2015/worktile-gantt.js.map +1 -0
- package/{packages/gantt/src/gantt-abstract.ts → gantt-abstract.d.ts} +1 -3
- package/gantt-dom.service.d.ts +32 -0
- package/gantt-drag-container.d.ts +24 -0
- package/gantt-item-upper.d.ts +20 -0
- package/gantt-print.service.d.ts +13 -0
- package/gantt-upper.d.ts +69 -0
- package/gantt.component.d.ts +30 -0
- package/gantt.config.d.ts +23 -0
- package/gantt.module.d.ts +21 -0
- package/gantt.pipe.d.ts +18 -0
- package/gantt.styles.d.ts +15 -0
- package/main.bundle.scss +645 -0
- package/package.json +16 -113
- package/{packages/gantt/src/public-api.ts → public-api.d.ts} +1 -4
- package/root.component.d.ts +28 -0
- package/table/gantt-column.component.d.ts +15 -0
- package/table/gantt-table.component.d.ts +10 -0
- package/utils/date.d.ts +59 -0
- package/utils/helpers.d.ts +12 -0
- package/views/day.d.ts +14 -0
- package/views/factory.d.ts +8 -0
- package/views/month.d.ts +12 -0
- package/views/quarter.d.ts +12 -0
- package/views/view.d.ts +58 -0
- package/views/week.d.ts +12 -0
- package/views/year.d.ts +12 -0
- package/worktile-gantt.d.ts +5 -0
- package/.all-contributorsrc +0 -53
- package/.angulardoc.json +0 -4
- package/.circleci/config.yml +0 -17
- package/.coveralls.yml +0 -1
- package/.docgenirc.js +0 -64
- package/.editorconfig +0 -22
- package/.prettierrc +0 -24
- package/.travis.yml +0 -23
- package/CHANGELOG.md +0 -564
- package/Dockerfile +0 -4
- package/LICENSE +0 -21
- package/angular.json +0 -136
- package/docs/guides/basic/components.md +0 -54
- package/docs/guides/basic/event.md +0 -70
- package/docs/guides/basic/index.md +0 -4
- package/docs/guides/basic/style.md +0 -68
- package/docs/guides/basic/type.md +0 -70
- package/docs/guides/basic/usage.md +0 -189
- package/docs/guides/index.md +0 -5
- package/docs/guides/intro/getting-started.md +0 -79
- package/docs/guides/intro/index.md +0 -51
- package/docs/index.md +0 -0
- package/example/browserslist +0 -12
- package/example/src/app/app-routing.module.ts +0 -26
- package/example/src/app/app.component.html +0 -2
- package/example/src/app/app.component.ts +0 -11
- package/example/src/app/app.module.ts +0 -57
- package/example/src/app/components/components.component.html +0 -6
- package/example/src/app/components/components.component.ts +0 -33
- package/example/src/app/configuration/parameters/api/zh-cn.js +0 -350
- package/example/src/app/configuration/parameters/doc/zh-cn.md +0 -5
- package/example/src/app/gantt/gantt.component.html +0 -51
- package/example/src/app/gantt/gantt.component.ts +0 -119
- package/example/src/app/gantt-advanced/component/flat.component.html +0 -30
- package/example/src/app/gantt-advanced/component/flat.component.ts +0 -72
- package/example/src/app/gantt-advanced/component/flat.scss +0 -31
- package/example/src/app/gantt-advanced/gantt-advanced.component.html +0 -32
- package/example/src/app/gantt-advanced/gantt-advanced.component.ts +0 -34
- package/example/src/app/gantt-advanced/mocks.ts +0 -158
- package/example/src/app/gantt-groups/gantt-groups.component.html +0 -42
- package/example/src/app/gantt-groups/gantt-groups.component.ts +0 -62
- package/example/src/app/gantt-range/gantt-range.component.html +0 -66
- package/example/src/app/gantt-range/gantt-range.component.ts +0 -67
- package/example/src/app/gantt-range/mocks.ts +0 -150
- package/example/src/app/helper.ts +0 -38
- package/example/src/assets/.gitkeep +0 -0
- package/example/src/environments/environment.prod.ts +0 -3
- package/example/src/environments/environment.ts +0 -16
- package/example/src/favicon.ico +0 -0
- package/example/src/index.html +0 -13
- package/example/src/main.ts +0 -12
- package/example/src/polyfills.ts +0 -63
- package/example/src/styles.scss +0 -56
- package/example/tsconfig.app.json +0 -18
- package/nginx.conf +0 -17
- package/packages/gantt/README.md +0 -24
- package/packages/gantt/karma.conf.js +0 -46
- package/packages/gantt/ng-package.json +0 -7
- package/packages/gantt/ng-package.prod.json +0 -7
- package/packages/gantt/package.json +0 -16
- package/packages/gantt/src/class/date-point.ts +0 -14
- package/packages/gantt/src/class/group.ts +0 -36
- package/packages/gantt/src/class/item.ts +0 -129
- package/packages/gantt/src/class/test/group.spec.ts +0 -21
- package/packages/gantt/src/class/test/item.spec.ts +0 -102
- package/packages/gantt/src/class/view-type.ts +0 -7
- package/packages/gantt/src/components/bar/bar-drag.ts +0 -298
- package/packages/gantt/src/components/bar/bar.component.html +0 -17
- package/packages/gantt/src/components/bar/bar.component.scss +0 -169
- package/packages/gantt/src/components/bar/bar.component.ts +0 -109
- package/packages/gantt/src/components/bar/test/bar.component.spec.ts +0 -54
- package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +0 -196
- package/packages/gantt/src/components/calendar/calendar.component.html +0 -52
- package/packages/gantt/src/components/calendar/calendar.component.scss +0 -77
- package/packages/gantt/src/components/calendar/calendar.component.ts +0 -100
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +0 -6
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +0 -48
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +0 -13
- package/packages/gantt/src/components/icon/icon.component.scss +0 -13
- package/packages/gantt/src/components/icon/icon.component.ts +0 -28
- package/packages/gantt/src/components/icon/icons.ts +0 -86
- package/packages/gantt/src/components/links/links.component.html +0 -19
- package/packages/gantt/src/components/links/links.component.scss +0 -27
- package/packages/gantt/src/components/links/links.component.ts +0 -263
- package/packages/gantt/src/components/main/gantt-main.component.html +0 -35
- package/packages/gantt/src/components/main/gantt-main.component.ts +0 -35
- package/packages/gantt/src/components/range/range.component.html +0 -8
- package/packages/gantt/src/components/range/range.component.scss +0 -35
- package/packages/gantt/src/components/range/range.component.ts +0 -27
- package/packages/gantt/src/components/range/test/range.component.spec.ts +0 -80
- package/packages/gantt/src/components/table/gantt-table.component.html +0 -105
- package/packages/gantt/src/components/table/gantt-table.component.scss +0 -144
- package/packages/gantt/src/components/table/gantt-table.component.ts +0 -166
- package/packages/gantt/src/components/table/test/table.spec.ts +0 -129
- package/packages/gantt/src/gantt-dom.service.ts +0 -134
- package/packages/gantt/src/gantt-drag-container.ts +0 -73
- package/packages/gantt/src/gantt-item-upper.ts +0 -50
- package/packages/gantt/src/gantt-print.service.ts +0 -104
- package/packages/gantt/src/gantt-upper.ts +0 -289
- package/packages/gantt/src/gantt.component.html +0 -18
- package/packages/gantt/src/gantt.component.scss +0 -77
- package/packages/gantt/src/gantt.component.ts +0 -134
- package/packages/gantt/src/gantt.module.ts +0 -47
- package/packages/gantt/src/gantt.pipe.ts +0 -31
- package/packages/gantt/src/gantt.styles.ts +0 -28
- package/packages/gantt/src/root.component.html +0 -12
- package/packages/gantt/src/root.component.ts +0 -121
- package/packages/gantt/src/styles/index.scss +0 -9
- package/packages/gantt/src/styles/variables.scss +0 -46
- package/packages/gantt/src/table/gantt-column.component.ts +0 -25
- package/packages/gantt/src/table/gantt-table.component.ts +0 -14
- package/packages/gantt/src/table/test/table.spec.ts +0 -56
- package/packages/gantt/src/test/gantt.component.spec.ts +0 -404
- package/packages/gantt/src/test/mocks/data.ts +0 -303
- package/packages/gantt/src/test.ts +0 -21
- package/packages/gantt/src/utils/date.ts +0 -276
- package/packages/gantt/src/utils/helpers.ts +0 -66
- package/packages/gantt/src/utils/test/date.spec.ts +0 -105
- package/packages/gantt/src/utils/test/helpers.spec.ts +0 -73
- package/packages/gantt/src/utils/testing.ts +0 -64
- package/packages/gantt/src/views/day.ts +0 -74
- package/packages/gantt/src/views/factory.ts +0 -25
- package/packages/gantt/src/views/month.ts +0 -66
- package/packages/gantt/src/views/quarter.ts +0 -68
- package/packages/gantt/src/views/test/day.spec.ts +0 -45
- package/packages/gantt/src/views/test/factory.spec.ts +0 -41
- package/packages/gantt/src/views/test/mock.ts +0 -14
- package/packages/gantt/src/views/test/month.spec.ts +0 -45
- package/packages/gantt/src/views/test/quarter.spec.ts +0 -45
- package/packages/gantt/src/views/test/view.spec.ts +0 -144
- package/packages/gantt/src/views/test/week.spec.ts +0 -45
- package/packages/gantt/src/views/test/year.spec.ts +0 -45
- package/packages/gantt/src/views/view.ts +0 -186
- package/packages/gantt/src/views/week.ts +0 -66
- package/packages/gantt/src/views/year.ts +0 -62
- package/packages/gantt/tsconfig.lib.json +0 -20
- package/packages/gantt/tsconfig.lib.prod.json +0 -9
- package/packages/gantt/tsconfig.schematics.json +0 -25
- package/packages/gantt/tsconfig.spec.json +0 -17
- package/packages/gantt/tslint.json +0 -18
- package/scss-bundle.config.json +0 -7
- package/tsconfig.json +0 -26
- package/tslint.json +0 -51
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { GanttDate } from '../utils/date';
|
|
2
|
-
import { BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { GanttViewType } from './view-type';
|
|
4
|
-
|
|
5
|
-
interface GanttItemRefs {
|
|
6
|
-
width: number;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export enum GanttItemType {
|
|
12
|
-
bar = 'bar',
|
|
13
|
-
range = 'range',
|
|
14
|
-
custom = 'custom'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface GanttItem<T = unknown> {
|
|
18
|
-
id: string;
|
|
19
|
-
title: string;
|
|
20
|
-
start?: number;
|
|
21
|
-
end?: number;
|
|
22
|
-
group_id?: string;
|
|
23
|
-
links?: string[];
|
|
24
|
-
draggable?: boolean;
|
|
25
|
-
linkable?: boolean;
|
|
26
|
-
expandable?: boolean;
|
|
27
|
-
expanded?: boolean;
|
|
28
|
-
children?: GanttItem[];
|
|
29
|
-
color?: string;
|
|
30
|
-
barStyle?: Partial<CSSStyleDeclaration>;
|
|
31
|
-
origin?: T;
|
|
32
|
-
type?: GanttItemType;
|
|
33
|
-
progress?: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class GanttItemInternal {
|
|
37
|
-
id: string;
|
|
38
|
-
title: string;
|
|
39
|
-
start: GanttDate;
|
|
40
|
-
end: GanttDate;
|
|
41
|
-
links: string[];
|
|
42
|
-
color?: string;
|
|
43
|
-
barStyle?: Partial<CSSStyleDeclaration>;
|
|
44
|
-
draggable?: boolean;
|
|
45
|
-
linkable?: boolean;
|
|
46
|
-
origin: GanttItem;
|
|
47
|
-
expandable?: boolean;
|
|
48
|
-
expanded?: boolean;
|
|
49
|
-
loading: boolean;
|
|
50
|
-
children: GanttItemInternal[];
|
|
51
|
-
type?: GanttItemType;
|
|
52
|
-
progress?: number;
|
|
53
|
-
viewType?: GanttViewType;
|
|
54
|
-
|
|
55
|
-
get refs() {
|
|
56
|
-
return this.refs$.getValue();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
refs$ = new BehaviorSubject<{ width: number; x?: number; y?: number }>(null);
|
|
60
|
-
|
|
61
|
-
constructor(item: GanttItem, options?: { viewType: GanttViewType }) {
|
|
62
|
-
this.origin = item;
|
|
63
|
-
this.id = this.origin.id;
|
|
64
|
-
this.links = this.origin.links || [];
|
|
65
|
-
this.color = this.origin.color;
|
|
66
|
-
this.barStyle = this.origin.barStyle;
|
|
67
|
-
this.linkable = this.origin.linkable === undefined ? true : this.origin.linkable;
|
|
68
|
-
this.draggable = this.origin.draggable === undefined ? true : this.origin.draggable;
|
|
69
|
-
this.expandable = this.origin.expandable || (this.origin.children || []).length > 0;
|
|
70
|
-
this.expanded = this.origin.expanded === undefined ? false : this.origin.expanded;
|
|
71
|
-
this.start = item.start ? new GanttDate(item.start) : null;
|
|
72
|
-
this.end = item.end ? new GanttDate(item.end) : null;
|
|
73
|
-
this.viewType = options && options.viewType ? options.viewType : GanttViewType.month;
|
|
74
|
-
this.children = (item.children || []).map((subItem) => {
|
|
75
|
-
return new GanttItemInternal(subItem, { viewType: this.viewType });
|
|
76
|
-
});
|
|
77
|
-
this.type = this.origin.type || GanttItemType.bar;
|
|
78
|
-
this.progress = this.origin.progress;
|
|
79
|
-
// fill one month when start or end is null
|
|
80
|
-
this.fillItemStartOrEnd(item);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
fillItemStartOrEnd(item: GanttItem) {
|
|
84
|
-
let addInterval: number;
|
|
85
|
-
switch (this.viewType) {
|
|
86
|
-
case GanttViewType.day:
|
|
87
|
-
case GanttViewType.week:
|
|
88
|
-
addInterval = 0;
|
|
89
|
-
break;
|
|
90
|
-
default:
|
|
91
|
-
addInterval = 30;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (item.start && !item.end) {
|
|
95
|
-
this.end = new GanttDate(item.start).addDays(addInterval).endOfDay();
|
|
96
|
-
}
|
|
97
|
-
if (!item.start && item.end) {
|
|
98
|
-
this.start = new GanttDate(item.end).addDays(-addInterval).startOfDay();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
updateRefs(refs: GanttItemRefs) {
|
|
103
|
-
this.refs$.next(refs);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
updateDate(start: GanttDate, end: GanttDate) {
|
|
107
|
-
this.start = start.startOfDay();
|
|
108
|
-
this.end = end.endOfDay();
|
|
109
|
-
this.origin.start = this.start.getUnixTime();
|
|
110
|
-
this.origin.end = this.end.getUnixTime();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
addChildren(items: GanttItem[]) {
|
|
114
|
-
this.origin.children = items;
|
|
115
|
-
this.children = (items || []).map((subItem) => {
|
|
116
|
-
return new GanttItemInternal(subItem, { viewType: this.viewType });
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setExpand(expanded: boolean) {
|
|
121
|
-
this.expanded = expanded;
|
|
122
|
-
this.origin.expanded = expanded;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
addLink(linkId: string) {
|
|
126
|
-
this.links = [...this.links, linkId];
|
|
127
|
-
this.origin.links = this.links;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { GanttDate } from '../../utils/date';
|
|
2
|
-
import { GanttGroup, GanttGroupInternal } from '../group';
|
|
3
|
-
|
|
4
|
-
const group: GanttGroup = {
|
|
5
|
-
id: '00001',
|
|
6
|
-
title: 'Project 1',
|
|
7
|
-
class: 'test'
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
describe('GanttGroupInternal', () => {
|
|
11
|
-
let ganttGroupInternal: GanttGroupInternal;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
ganttGroupInternal = new GanttGroupInternal(group);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it(`should set expand`, () => {
|
|
18
|
-
ganttGroupInternal.setExpand(true);
|
|
19
|
-
expect(ganttGroupInternal.expanded).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { GanttDate } from '../../utils/date';
|
|
2
|
-
import { GanttItem, GanttItemInternal } from '../item';
|
|
3
|
-
import { GanttViewType } from '../view-type';
|
|
4
|
-
|
|
5
|
-
describe('GanttItemInternal', () => {
|
|
6
|
-
let ganttItemInternal: GanttItemInternal;
|
|
7
|
-
let ganttItem: GanttItem;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
ganttItem = {
|
|
11
|
-
id: 'item-0101',
|
|
12
|
-
title: 'VERSION 0101',
|
|
13
|
-
start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
|
|
14
|
-
group_id: '00001',
|
|
15
|
-
color: '#FF0000',
|
|
16
|
-
children: [
|
|
17
|
-
{
|
|
18
|
-
id: 'item-child-0101',
|
|
19
|
-
title: 'VERSION Children 0101',
|
|
20
|
-
start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
|
|
21
|
-
group_id: '00001',
|
|
22
|
-
color: '#FF0000',
|
|
23
|
-
linkable: false
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
ganttItemInternal = new GanttItemInternal(ganttItem);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it(`should has correct children`, () => {
|
|
31
|
-
expect(ganttItemInternal.children.length).toBe(1);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it(`should has correct end`, () => {
|
|
35
|
-
expect(ganttItemInternal.end.getUnixTime()).toBe(new GanttDate('2020-06-20 23:59:59').getUnixTime());
|
|
36
|
-
|
|
37
|
-
ganttItem.end = null;
|
|
38
|
-
ganttItem.start = new GanttDate('2020-05-21 12:34:35').getUnixTime();
|
|
39
|
-
ganttItemInternal = new GanttItemInternal(ganttItem);
|
|
40
|
-
expect(ganttItemInternal.end.getUnixTime()).toBe(new GanttDate('2020-06-20 23:59:59').getUnixTime());
|
|
41
|
-
|
|
42
|
-
ganttItemInternal = new GanttItemInternal(ganttItem, { viewType: GanttViewType.day });
|
|
43
|
-
expect(ganttItemInternal.end.getUnixTime()).toBe(new GanttDate('2020-05-21 23:59:59').getUnixTime());
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it(`should has correct start`, () => {
|
|
47
|
-
ganttItem.start = null;
|
|
48
|
-
ganttItem.end = new GanttDate('2020-05-21 12:34:35').getUnixTime();
|
|
49
|
-
ganttItemInternal = new GanttItemInternal(ganttItem);
|
|
50
|
-
expect(ganttItemInternal.start.getUnixTime()).toBe(new GanttDate('2020-04-21 00:00:00').getUnixTime());
|
|
51
|
-
|
|
52
|
-
ganttItemInternal = new GanttItemInternal(ganttItem, { viewType: GanttViewType.day });
|
|
53
|
-
expect(ganttItemInternal.start.getUnixTime()).toBe(new GanttDate('2020-05-21 00:00:00').getUnixTime());
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it(`should update refs`, () => {
|
|
57
|
-
const refs = { width: 200, x: 200, y: 200 };
|
|
58
|
-
ganttItemInternal.updateRefs(refs);
|
|
59
|
-
expect(ganttItemInternal.refs.width).toBe(refs.width);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it(`should update date`, () => {
|
|
63
|
-
const start = new GanttDate('2020-04-21 12:34:35');
|
|
64
|
-
const end = new GanttDate('2020-09-21 12:34:35');
|
|
65
|
-
ganttItemInternal.updateDate(start, end);
|
|
66
|
-
expect(ganttItemInternal.start.getUnixTime()).toBe(start.startOfDay().getUnixTime());
|
|
67
|
-
expect(ganttItemInternal.end.getUnixTime()).toBe(end.endOfDay().getUnixTime());
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it(`should add children`, () => {
|
|
71
|
-
const items = [
|
|
72
|
-
{
|
|
73
|
-
id: 'item-child-0102',
|
|
74
|
-
title: 'VERSION Children 0102',
|
|
75
|
-
start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
|
|
76
|
-
group_id: '00001',
|
|
77
|
-
color: '#FF0000',
|
|
78
|
-
linkable: false
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: 'item-child-0103',
|
|
82
|
-
title: 'VERSION Children 0103',
|
|
83
|
-
start: new GanttDate('2020-06-21 12:34:35').getUnixTime(),
|
|
84
|
-
group_id: '00001',
|
|
85
|
-
color: '#FF0000',
|
|
86
|
-
linkable: false
|
|
87
|
-
}
|
|
88
|
-
];
|
|
89
|
-
ganttItemInternal.addChildren(items);
|
|
90
|
-
expect(ganttItemInternal.children.length).toBe(2);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it(`should set expand`, () => {
|
|
94
|
-
ganttItemInternal.setExpand(true);
|
|
95
|
-
expect(ganttItemInternal.expanded).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it(`should add link`, () => {
|
|
99
|
-
ganttItemInternal.addLink('0102');
|
|
100
|
-
expect(ganttItemInternal.links).toContain('0102');
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { Injectable, ElementRef, OnDestroy, NgZone } from '@angular/core';
|
|
2
|
-
import { DragRef, DragDrop } from '@angular/cdk/drag-drop';
|
|
3
|
-
import { GanttDomService } from '../../gantt-dom.service';
|
|
4
|
-
import { GanttDragContainer } from '../../gantt-drag-container';
|
|
5
|
-
import { GanttItemInternal } from '../../class/item';
|
|
6
|
-
import { GanttDate, differenceInCalendarDays } from '../../utils/date';
|
|
7
|
-
import { fromEvent, Subject } from 'rxjs';
|
|
8
|
-
import { takeUntil } from 'rxjs/operators';
|
|
9
|
-
import { GanttUpper } from '../../gantt-upper';
|
|
10
|
-
|
|
11
|
-
const dragMinWidth = 10;
|
|
12
|
-
const activeClass = 'gantt-bar-active';
|
|
13
|
-
const linkDropClass = 'gantt-bar-link-drop';
|
|
14
|
-
|
|
15
|
-
function createSvgElement(qualifiedName: string, className: string) {
|
|
16
|
-
const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
|
|
17
|
-
element.classList.add(className);
|
|
18
|
-
return element;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Injectable()
|
|
22
|
-
export class GanttBarDrag implements OnDestroy {
|
|
23
|
-
private ganttUpper: GanttUpper;
|
|
24
|
-
|
|
25
|
-
private barElement: HTMLElement;
|
|
26
|
-
|
|
27
|
-
private item: GanttItemInternal;
|
|
28
|
-
|
|
29
|
-
private get dragDisabled() {
|
|
30
|
-
return !this.item.draggable || !this.ganttUpper.draggable;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private get linkDragDisabled() {
|
|
34
|
-
return !this.item.linkable || !this.ganttUpper.linkable;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private linkDraggingLine: SVGElement;
|
|
38
|
-
|
|
39
|
-
private barDragRef: DragRef;
|
|
40
|
-
|
|
41
|
-
private dragRefs: DragRef[] = [];
|
|
42
|
-
|
|
43
|
-
private destroy$ = new Subject();
|
|
44
|
-
|
|
45
|
-
constructor(private dragDrop: DragDrop, private dom: GanttDomService, private dragContainer: GanttDragContainer) {}
|
|
46
|
-
|
|
47
|
-
private createMouseEvents() {
|
|
48
|
-
fromEvent(this.barElement, 'mouseenter')
|
|
49
|
-
.pipe(takeUntil(this.destroy$))
|
|
50
|
-
.subscribe(() => {
|
|
51
|
-
if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
|
|
52
|
-
if (this.item.linkable) {
|
|
53
|
-
this.barElement.classList.add(linkDropClass);
|
|
54
|
-
this.dragContainer.emitLinkDragEntered(this.item);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
this.barElement.classList.add(activeClass);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
fromEvent(this.barElement, 'mouseleave')
|
|
62
|
-
.pipe(takeUntil(this.destroy$))
|
|
63
|
-
.subscribe(() => {
|
|
64
|
-
if (!this.dragContainer.linkDraggingId) {
|
|
65
|
-
this.barElement.classList.remove(activeClass);
|
|
66
|
-
} else {
|
|
67
|
-
this.dragContainer.emitLinkDragLeaved();
|
|
68
|
-
}
|
|
69
|
-
this.barElement.classList.remove(linkDropClass);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private createBarDrag() {
|
|
74
|
-
const dragRef = this.dragDrop.createDrag(this.barElement);
|
|
75
|
-
dragRef.lockAxis = 'x';
|
|
76
|
-
dragRef.started.subscribe(() => {
|
|
77
|
-
this.setDraggingStyles();
|
|
78
|
-
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
79
|
-
});
|
|
80
|
-
dragRef.moved.subscribe((event) => {
|
|
81
|
-
const x = this.item.refs.x + event.distance.x;
|
|
82
|
-
const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
|
|
83
|
-
const start = this.ganttUpper.view.getDateByXPoint(x);
|
|
84
|
-
const end = start.addDays(days);
|
|
85
|
-
this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), end);
|
|
86
|
-
});
|
|
87
|
-
dragRef.ended.subscribe((event) => {
|
|
88
|
-
const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
|
|
89
|
-
const start = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x);
|
|
90
|
-
const end = start.addDays(days);
|
|
91
|
-
this.item.updateDate(start, end);
|
|
92
|
-
this.clearDraggingStyles();
|
|
93
|
-
this.closeDragBackdrop();
|
|
94
|
-
event.source.reset();
|
|
95
|
-
this.dragContainer.dragEnded.emit({ item: this.item.origin });
|
|
96
|
-
});
|
|
97
|
-
this.barDragRef = dragRef;
|
|
98
|
-
return dragRef;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private createBarHandleDrags() {
|
|
102
|
-
const dragRefs = [];
|
|
103
|
-
const handles = this.barElement.querySelectorAll<HTMLElement>('.drag-handles .handle');
|
|
104
|
-
handles.forEach((handle, index) => {
|
|
105
|
-
const isBefore = index === 0;
|
|
106
|
-
const dragRef = this.dragDrop.createDrag(handle);
|
|
107
|
-
dragRef.lockAxis = 'x';
|
|
108
|
-
dragRef.withBoundaryElement(this.dom.root as HTMLElement);
|
|
109
|
-
|
|
110
|
-
dragRef.started.subscribe(() => {
|
|
111
|
-
this.setDraggingStyles();
|
|
112
|
-
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
dragRef.moved.subscribe((event) => {
|
|
116
|
-
if (isBefore) {
|
|
117
|
-
const x = this.item.refs.x + event.distance.x;
|
|
118
|
-
const width = this.item.refs.width + event.distance.x * -1;
|
|
119
|
-
if (width > dragMinWidth) {
|
|
120
|
-
this.barElement.style.width = width + 'px';
|
|
121
|
-
this.barElement.style.left = x + 'px';
|
|
122
|
-
this.openDragBackdrop(
|
|
123
|
-
this.barElement,
|
|
124
|
-
this.ganttUpper.view.getDateByXPoint(x),
|
|
125
|
-
this.ganttUpper.view.getDateByXPoint(x + width)
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
const width = this.item.refs.width + event.distance.x;
|
|
130
|
-
if (width > dragMinWidth) {
|
|
131
|
-
this.barElement.style.width = width + 'px';
|
|
132
|
-
this.openDragBackdrop(
|
|
133
|
-
this.barElement,
|
|
134
|
-
this.ganttUpper.view.getDateByXPoint(this.item.refs.x),
|
|
135
|
-
this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width)
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
event.source.reset();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
dragRef.ended.subscribe((event) => {
|
|
143
|
-
if (isBefore) {
|
|
144
|
-
const width = this.item.refs.width + event.distance.x * -1;
|
|
145
|
-
if (width > dragMinWidth) {
|
|
146
|
-
this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
|
|
147
|
-
} else {
|
|
148
|
-
this.item.updateDate(this.item.end.startOfDay(), this.item.end);
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
const width = this.item.refs.width + event.distance.x;
|
|
152
|
-
if (width > dragMinWidth) {
|
|
153
|
-
this.item.updateDate(
|
|
154
|
-
this.item.start,
|
|
155
|
-
this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x)
|
|
156
|
-
);
|
|
157
|
-
} else {
|
|
158
|
-
this.item.updateDate(this.item.start, this.item.start.endOfDay());
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
this.clearDraggingStyles();
|
|
162
|
-
this.closeDragBackdrop();
|
|
163
|
-
this.dragContainer.dragEnded.emit({ item: this.item.origin });
|
|
164
|
-
});
|
|
165
|
-
dragRefs.push(dragRef);
|
|
166
|
-
});
|
|
167
|
-
return dragRefs;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private createLinkHandleDrags() {
|
|
171
|
-
const dragRefs = [];
|
|
172
|
-
const handles = this.barElement.querySelectorAll<HTMLElement>('.link-handles .handle');
|
|
173
|
-
handles.forEach((handle, index) => {
|
|
174
|
-
const isBefore = index === 0;
|
|
175
|
-
const dragRef = this.dragDrop.createDrag(handle);
|
|
176
|
-
dragRef.withBoundaryElement(this.dom.root as HTMLElement);
|
|
177
|
-
dragRef.beforeStarted.subscribe(() => {
|
|
178
|
-
handle.style.pointerEvents = 'none';
|
|
179
|
-
if (this.barDragRef) {
|
|
180
|
-
this.barDragRef.disabled = true;
|
|
181
|
-
}
|
|
182
|
-
this.createLinkDraggingLine();
|
|
183
|
-
this.dragContainer.emitLinkDragStarted(isBefore ? 'target' : 'source', this.item);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
dragRef.moved.subscribe(() => {
|
|
187
|
-
const positions = this.calcLinkLinePositions(handle, isBefore);
|
|
188
|
-
this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
|
|
189
|
-
this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
|
|
190
|
-
this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
|
|
191
|
-
this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
dragRef.ended.subscribe((event) => {
|
|
195
|
-
event.source.reset();
|
|
196
|
-
handle.style.pointerEvents = '';
|
|
197
|
-
if (this.barDragRef) {
|
|
198
|
-
this.barDragRef.disabled = false;
|
|
199
|
-
}
|
|
200
|
-
this.barElement.classList.remove(activeClass);
|
|
201
|
-
this.destroyLinkDraggingLine();
|
|
202
|
-
this.dragContainer.emitLinkDragEnded();
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
dragRefs.push(dragRef);
|
|
206
|
-
});
|
|
207
|
-
return dragRefs;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
private openDragBackdrop(dragElement: HTMLElement, start: GanttDate, end: GanttDate) {
|
|
211
|
-
const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask') as HTMLElement;
|
|
212
|
-
const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop') as HTMLElement;
|
|
213
|
-
const rootRect = this.dom.root.getBoundingClientRect();
|
|
214
|
-
const dragRect = dragElement.getBoundingClientRect();
|
|
215
|
-
const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
|
|
216
|
-
const width = dragRect.right - dragRect.left;
|
|
217
|
-
dragMaskElement.style.left = left + 'px';
|
|
218
|
-
dragMaskElement.style.width = width + 'px';
|
|
219
|
-
dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
|
|
220
|
-
dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
|
|
221
|
-
dragMaskElement.style.display = 'block';
|
|
222
|
-
dragBackdropElement.style.display = 'block';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private closeDragBackdrop() {
|
|
226
|
-
const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask') as HTMLElement;
|
|
227
|
-
const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop') as HTMLElement;
|
|
228
|
-
dragMaskElement.style.display = 'none';
|
|
229
|
-
dragBackdropElement.style.display = 'none';
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private setDraggingStyles() {
|
|
233
|
-
this.barElement.style.pointerEvents = 'none';
|
|
234
|
-
this.barElement.classList.add('gantt-bar-draggable-drag');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
private clearDraggingStyles() {
|
|
238
|
-
this.barElement.style.pointerEvents = '';
|
|
239
|
-
this.barElement.classList.remove('gantt-bar-draggable-drag');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
private calcLinkLinePositions(target: HTMLElement, isBefore: boolean) {
|
|
243
|
-
const rootRect = this.dom.root.getBoundingClientRect();
|
|
244
|
-
const targetRect = target.getBoundingClientRect();
|
|
245
|
-
const layerRect = target.parentElement.parentElement.getBoundingClientRect();
|
|
246
|
-
return {
|
|
247
|
-
x1: layerRect.left + (isBefore ? 0 : layerRect.width) - rootRect.left,
|
|
248
|
-
y1: layerRect.top + layerRect.height / 2 - rootRect.top,
|
|
249
|
-
x2: targetRect.left - rootRect.left + targetRect.width / 2,
|
|
250
|
-
y2: targetRect.top - rootRect.top + targetRect.height / 2
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
private createLinkDraggingLine() {
|
|
255
|
-
if (!this.linkDraggingLine) {
|
|
256
|
-
const svgElement = createSvgElement('svg', 'gantt-link-drag-container');
|
|
257
|
-
const linElement = createSvgElement('line', 'link-dragging-line');
|
|
258
|
-
svgElement.appendChild(linElement);
|
|
259
|
-
this.dom.root.appendChild(svgElement);
|
|
260
|
-
this.linkDraggingLine = linElement;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
private destroyLinkDraggingLine() {
|
|
265
|
-
if (this.linkDraggingLine) {
|
|
266
|
-
this.linkDraggingLine.parentElement.remove();
|
|
267
|
-
this.linkDraggingLine = null;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
createDrags(elementRef: ElementRef, item: GanttItemInternal, ganttUpper: GanttUpper) {
|
|
272
|
-
this.item = item;
|
|
273
|
-
this.barElement = elementRef.nativeElement;
|
|
274
|
-
this.ganttUpper = ganttUpper;
|
|
275
|
-
|
|
276
|
-
if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
|
|
277
|
-
return;
|
|
278
|
-
} else {
|
|
279
|
-
this.createMouseEvents();
|
|
280
|
-
if (!this.dragDisabled) {
|
|
281
|
-
const dragRef = this.createBarDrag();
|
|
282
|
-
const dragHandlesRefs = this.createBarHandleDrags();
|
|
283
|
-
this.dragRefs.push(dragRef, ...dragHandlesRefs);
|
|
284
|
-
}
|
|
285
|
-
if (!this.linkDragDisabled) {
|
|
286
|
-
const linkDragRefs = this.createLinkHandleDrags();
|
|
287
|
-
this.dragRefs.push(...linkDragRefs);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
ngOnDestroy() {
|
|
293
|
-
this.closeDragBackdrop();
|
|
294
|
-
this.dragRefs.forEach((dragRef) => dragRef.dispose());
|
|
295
|
-
this.destroy$.next();
|
|
296
|
-
this.destroy$.complete();
|
|
297
|
-
}
|
|
298
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<div class="gantt-bar-layer">
|
|
2
|
-
<div *ngIf="item.draggable && ganttUpper.draggable" class="drag-handles">
|
|
3
|
-
<ng-container>
|
|
4
|
-
<span class="handle" (mousedown)="stopPropagation($event)"></span>
|
|
5
|
-
<span class="handle" (mousedown)="stopPropagation($event)"></span>
|
|
6
|
-
</ng-container>
|
|
7
|
-
</div>
|
|
8
|
-
<div *ngIf="item.linkable && ganttUpper.linkable" class="link-handles">
|
|
9
|
-
<span class="handle"><span class="point"></span></span>
|
|
10
|
-
<span class="handle"> <span class="point"></span></span>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
<div class="gantt-bar-border"></div>
|
|
14
|
-
<div #content class="gantt-bar-content" (click)="onBarClick($event)">
|
|
15
|
-
<div class="gantt-bar-content-progress" *ngIf="item.progress >= 0" [style.width.%]="item.progress * 100"></div>
|
|
16
|
-
<ng-template [ngTemplateOutlet]="template" [ngTemplateOutletContext]="{ item: item.origin, refs: item.refs }"></ng-template>
|
|
17
|
-
</div>
|