@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.
Files changed (232) hide show
  1. package/README.md +13 -116
  2. package/bundles/worktile-gantt.umd.js +3369 -0
  3. package/bundles/worktile-gantt.umd.js.map +1 -0
  4. package/class/date-point.d.ts +15 -0
  5. package/{packages/gantt/src/class/event.ts → class/event.d.ts} +6 -12
  6. package/class/group.d.ts +22 -0
  7. package/{packages/gantt/src/class/index.ts → class/index.d.ts} +0 -0
  8. package/class/item.d.ts +70 -0
  9. package/class/view-type.d.ts +7 -0
  10. package/components/bar/bar-drag.d.ts +37 -0
  11. package/components/bar/bar.component.d.ts +26 -0
  12. package/components/calendar/calendar.component.d.ts +28 -0
  13. package/components/drag-backdrop/drag-backdrop.component.d.ts +9 -0
  14. package/components/icon/icon.component.d.ts +13 -0
  15. package/components/icon/icons.d.ts +8 -0
  16. package/components/links/links.component.d.ts +47 -0
  17. package/components/main/gantt-main.component.d.ts +21 -0
  18. package/components/range/range.component.d.ts +13 -0
  19. package/components/table/gantt-table.component.d.ts +37 -0
  20. package/esm2015/class/date-point.js +10 -0
  21. package/esm2015/class/event.js +13 -0
  22. package/esm2015/class/group.js +17 -0
  23. package/esm2015/class/index.js +6 -0
  24. package/esm2015/class/item.js +78 -0
  25. package/esm2015/class/view-type.js +9 -0
  26. package/esm2015/components/bar/bar-drag.js +269 -0
  27. package/esm2015/components/bar/bar.component.js +98 -0
  28. package/esm2015/components/calendar/calendar.component.js +86 -0
  29. package/esm2015/components/drag-backdrop/drag-backdrop.component.js +21 -0
  30. package/esm2015/components/icon/icon.component.js +38 -0
  31. package/esm2015/components/icon/icons.js +87 -0
  32. package/esm2015/components/links/links.component.js +213 -0
  33. package/esm2015/components/main/gantt-main.component.js +53 -0
  34. package/esm2015/components/range/range.component.js +37 -0
  35. package/esm2015/components/table/gantt-table.component.js +149 -0
  36. package/esm2015/gantt-abstract.js +3 -0
  37. package/esm2015/gantt-dom.service.js +103 -0
  38. package/esm2015/gantt-drag-container.js +60 -0
  39. package/esm2015/gantt-item-upper.js +58 -0
  40. package/esm2015/gantt-print.service.js +94 -0
  41. package/esm2015/gantt-upper.js +280 -0
  42. package/esm2015/gantt.component.js +135 -0
  43. package/esm2015/gantt.config.js +13 -0
  44. package/esm2015/gantt.module.js +85 -0
  45. package/esm2015/gantt.pipe.js +43 -0
  46. package/esm2015/gantt.styles.js +15 -0
  47. package/esm2015/public-api.js +19 -0
  48. package/esm2015/root.component.js +123 -0
  49. package/esm2015/table/gantt-column.component.js +37 -0
  50. package/esm2015/table/gantt-table.component.js +20 -0
  51. package/esm2015/utils/date.js +160 -0
  52. package/esm2015/utils/helpers.js +55 -0
  53. package/esm2015/views/day.js +54 -0
  54. package/esm2015/views/factory.js +23 -0
  55. package/esm2015/views/month.js +48 -0
  56. package/esm2015/views/quarter.js +51 -0
  57. package/esm2015/views/view.js +123 -0
  58. package/esm2015/views/week.js +49 -0
  59. package/esm2015/views/year.js +50 -0
  60. package/esm2015/worktile-gantt.js +5 -0
  61. package/fesm2015/worktile-gantt.js +2697 -0
  62. package/fesm2015/worktile-gantt.js.map +1 -0
  63. package/{packages/gantt/src/gantt-abstract.ts → gantt-abstract.d.ts} +1 -3
  64. package/gantt-dom.service.d.ts +32 -0
  65. package/gantt-drag-container.d.ts +24 -0
  66. package/gantt-item-upper.d.ts +20 -0
  67. package/gantt-print.service.d.ts +13 -0
  68. package/gantt-upper.d.ts +69 -0
  69. package/gantt.component.d.ts +30 -0
  70. package/gantt.config.d.ts +23 -0
  71. package/gantt.module.d.ts +21 -0
  72. package/gantt.pipe.d.ts +18 -0
  73. package/gantt.styles.d.ts +15 -0
  74. package/main.bundle.scss +645 -0
  75. package/package.json +16 -113
  76. package/{packages/gantt/src/public-api.ts → public-api.d.ts} +1 -4
  77. package/root.component.d.ts +28 -0
  78. package/table/gantt-column.component.d.ts +15 -0
  79. package/table/gantt-table.component.d.ts +10 -0
  80. package/utils/date.d.ts +59 -0
  81. package/utils/helpers.d.ts +12 -0
  82. package/views/day.d.ts +14 -0
  83. package/views/factory.d.ts +8 -0
  84. package/views/month.d.ts +12 -0
  85. package/views/quarter.d.ts +12 -0
  86. package/views/view.d.ts +58 -0
  87. package/views/week.d.ts +12 -0
  88. package/views/year.d.ts +12 -0
  89. package/worktile-gantt.d.ts +5 -0
  90. package/.all-contributorsrc +0 -53
  91. package/.angulardoc.json +0 -4
  92. package/.circleci/config.yml +0 -17
  93. package/.coveralls.yml +0 -1
  94. package/.docgenirc.js +0 -64
  95. package/.editorconfig +0 -22
  96. package/.prettierrc +0 -24
  97. package/.travis.yml +0 -23
  98. package/CHANGELOG.md +0 -564
  99. package/Dockerfile +0 -4
  100. package/LICENSE +0 -21
  101. package/angular.json +0 -136
  102. package/docs/guides/basic/components.md +0 -54
  103. package/docs/guides/basic/event.md +0 -70
  104. package/docs/guides/basic/index.md +0 -4
  105. package/docs/guides/basic/style.md +0 -68
  106. package/docs/guides/basic/type.md +0 -70
  107. package/docs/guides/basic/usage.md +0 -189
  108. package/docs/guides/index.md +0 -5
  109. package/docs/guides/intro/getting-started.md +0 -79
  110. package/docs/guides/intro/index.md +0 -51
  111. package/docs/index.md +0 -0
  112. package/example/browserslist +0 -12
  113. package/example/src/app/app-routing.module.ts +0 -26
  114. package/example/src/app/app.component.html +0 -2
  115. package/example/src/app/app.component.ts +0 -11
  116. package/example/src/app/app.module.ts +0 -57
  117. package/example/src/app/components/components.component.html +0 -6
  118. package/example/src/app/components/components.component.ts +0 -33
  119. package/example/src/app/configuration/parameters/api/zh-cn.js +0 -350
  120. package/example/src/app/configuration/parameters/doc/zh-cn.md +0 -5
  121. package/example/src/app/gantt/gantt.component.html +0 -51
  122. package/example/src/app/gantt/gantt.component.ts +0 -119
  123. package/example/src/app/gantt-advanced/component/flat.component.html +0 -30
  124. package/example/src/app/gantt-advanced/component/flat.component.ts +0 -72
  125. package/example/src/app/gantt-advanced/component/flat.scss +0 -31
  126. package/example/src/app/gantt-advanced/gantt-advanced.component.html +0 -32
  127. package/example/src/app/gantt-advanced/gantt-advanced.component.ts +0 -34
  128. package/example/src/app/gantt-advanced/mocks.ts +0 -158
  129. package/example/src/app/gantt-groups/gantt-groups.component.html +0 -42
  130. package/example/src/app/gantt-groups/gantt-groups.component.ts +0 -62
  131. package/example/src/app/gantt-range/gantt-range.component.html +0 -66
  132. package/example/src/app/gantt-range/gantt-range.component.ts +0 -67
  133. package/example/src/app/gantt-range/mocks.ts +0 -150
  134. package/example/src/app/helper.ts +0 -38
  135. package/example/src/assets/.gitkeep +0 -0
  136. package/example/src/environments/environment.prod.ts +0 -3
  137. package/example/src/environments/environment.ts +0 -16
  138. package/example/src/favicon.ico +0 -0
  139. package/example/src/index.html +0 -13
  140. package/example/src/main.ts +0 -12
  141. package/example/src/polyfills.ts +0 -63
  142. package/example/src/styles.scss +0 -56
  143. package/example/tsconfig.app.json +0 -18
  144. package/nginx.conf +0 -17
  145. package/packages/gantt/README.md +0 -24
  146. package/packages/gantt/karma.conf.js +0 -46
  147. package/packages/gantt/ng-package.json +0 -7
  148. package/packages/gantt/ng-package.prod.json +0 -7
  149. package/packages/gantt/package.json +0 -16
  150. package/packages/gantt/src/class/date-point.ts +0 -14
  151. package/packages/gantt/src/class/group.ts +0 -36
  152. package/packages/gantt/src/class/item.ts +0 -129
  153. package/packages/gantt/src/class/test/group.spec.ts +0 -21
  154. package/packages/gantt/src/class/test/item.spec.ts +0 -102
  155. package/packages/gantt/src/class/view-type.ts +0 -7
  156. package/packages/gantt/src/components/bar/bar-drag.ts +0 -298
  157. package/packages/gantt/src/components/bar/bar.component.html +0 -17
  158. package/packages/gantt/src/components/bar/bar.component.scss +0 -169
  159. package/packages/gantt/src/components/bar/bar.component.ts +0 -109
  160. package/packages/gantt/src/components/bar/test/bar.component.spec.ts +0 -54
  161. package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +0 -196
  162. package/packages/gantt/src/components/calendar/calendar.component.html +0 -52
  163. package/packages/gantt/src/components/calendar/calendar.component.scss +0 -77
  164. package/packages/gantt/src/components/calendar/calendar.component.ts +0 -100
  165. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +0 -6
  166. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +0 -48
  167. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +0 -13
  168. package/packages/gantt/src/components/icon/icon.component.scss +0 -13
  169. package/packages/gantt/src/components/icon/icon.component.ts +0 -28
  170. package/packages/gantt/src/components/icon/icons.ts +0 -86
  171. package/packages/gantt/src/components/links/links.component.html +0 -19
  172. package/packages/gantt/src/components/links/links.component.scss +0 -27
  173. package/packages/gantt/src/components/links/links.component.ts +0 -263
  174. package/packages/gantt/src/components/main/gantt-main.component.html +0 -35
  175. package/packages/gantt/src/components/main/gantt-main.component.ts +0 -35
  176. package/packages/gantt/src/components/range/range.component.html +0 -8
  177. package/packages/gantt/src/components/range/range.component.scss +0 -35
  178. package/packages/gantt/src/components/range/range.component.ts +0 -27
  179. package/packages/gantt/src/components/range/test/range.component.spec.ts +0 -80
  180. package/packages/gantt/src/components/table/gantt-table.component.html +0 -105
  181. package/packages/gantt/src/components/table/gantt-table.component.scss +0 -144
  182. package/packages/gantt/src/components/table/gantt-table.component.ts +0 -166
  183. package/packages/gantt/src/components/table/test/table.spec.ts +0 -129
  184. package/packages/gantt/src/gantt-dom.service.ts +0 -134
  185. package/packages/gantt/src/gantt-drag-container.ts +0 -73
  186. package/packages/gantt/src/gantt-item-upper.ts +0 -50
  187. package/packages/gantt/src/gantt-print.service.ts +0 -104
  188. package/packages/gantt/src/gantt-upper.ts +0 -289
  189. package/packages/gantt/src/gantt.component.html +0 -18
  190. package/packages/gantt/src/gantt.component.scss +0 -77
  191. package/packages/gantt/src/gantt.component.ts +0 -134
  192. package/packages/gantt/src/gantt.module.ts +0 -47
  193. package/packages/gantt/src/gantt.pipe.ts +0 -31
  194. package/packages/gantt/src/gantt.styles.ts +0 -28
  195. package/packages/gantt/src/root.component.html +0 -12
  196. package/packages/gantt/src/root.component.ts +0 -121
  197. package/packages/gantt/src/styles/index.scss +0 -9
  198. package/packages/gantt/src/styles/variables.scss +0 -46
  199. package/packages/gantt/src/table/gantt-column.component.ts +0 -25
  200. package/packages/gantt/src/table/gantt-table.component.ts +0 -14
  201. package/packages/gantt/src/table/test/table.spec.ts +0 -56
  202. package/packages/gantt/src/test/gantt.component.spec.ts +0 -404
  203. package/packages/gantt/src/test/mocks/data.ts +0 -303
  204. package/packages/gantt/src/test.ts +0 -21
  205. package/packages/gantt/src/utils/date.ts +0 -276
  206. package/packages/gantt/src/utils/helpers.ts +0 -66
  207. package/packages/gantt/src/utils/test/date.spec.ts +0 -105
  208. package/packages/gantt/src/utils/test/helpers.spec.ts +0 -73
  209. package/packages/gantt/src/utils/testing.ts +0 -64
  210. package/packages/gantt/src/views/day.ts +0 -74
  211. package/packages/gantt/src/views/factory.ts +0 -25
  212. package/packages/gantt/src/views/month.ts +0 -66
  213. package/packages/gantt/src/views/quarter.ts +0 -68
  214. package/packages/gantt/src/views/test/day.spec.ts +0 -45
  215. package/packages/gantt/src/views/test/factory.spec.ts +0 -41
  216. package/packages/gantt/src/views/test/mock.ts +0 -14
  217. package/packages/gantt/src/views/test/month.spec.ts +0 -45
  218. package/packages/gantt/src/views/test/quarter.spec.ts +0 -45
  219. package/packages/gantt/src/views/test/view.spec.ts +0 -144
  220. package/packages/gantt/src/views/test/week.spec.ts +0 -45
  221. package/packages/gantt/src/views/test/year.spec.ts +0 -45
  222. package/packages/gantt/src/views/view.ts +0 -186
  223. package/packages/gantt/src/views/week.ts +0 -66
  224. package/packages/gantt/src/views/year.ts +0 -62
  225. package/packages/gantt/tsconfig.lib.json +0 -20
  226. package/packages/gantt/tsconfig.lib.prod.json +0 -9
  227. package/packages/gantt/tsconfig.schematics.json +0 -25
  228. package/packages/gantt/tsconfig.spec.json +0 -17
  229. package/packages/gantt/tslint.json +0 -18
  230. package/scss-bundle.config.json +0 -7
  231. package/tsconfig.json +0 -26
  232. package/tslint.json +0 -51
@@ -1,169 +0,0 @@
1
- $gantt-bar-layer-append-width: 32px;
2
- $gantt-bar-layer-append-height: 42px;
3
- $gantt-bar-link-height: 16px;
4
- $gantt-bar-link-drop-border: 5px;
5
-
6
- @mixin link-handles {
7
- .link-handles {
8
- .handle {
9
- position: absolute;
10
- display: inline-block;
11
- cursor: pointer;
12
- width: $gantt-bar-link-height;
13
- height: $gantt-bar-link-height;
14
- display: flex;
15
- align-items: center;
16
- justify-content: center;
17
- z-index: 1001;
18
-
19
- &:first-child {
20
- left: 0;
21
- top: 0;
22
- }
23
-
24
- &:last-child {
25
- right: 0;
26
- bottom: 0;
27
- }
28
-
29
- .point {
30
- color: #348fe4;
31
- width: 10px;
32
- height: 10px;
33
- border-radius: 50%;
34
- background: #348fe4;
35
- transition: 0.3 ease;
36
-
37
- &:hover {
38
- width: 12px;
39
- height: 12px;
40
- }
41
- }
42
- }
43
- }
44
- }
45
-
46
- @mixin drag-handles {
47
- .drag-handles {
48
- background: $gantt-bar-layer-bg;
49
- width: 100%;
50
- height: calc(100% - #{$gantt-bar-link-height} * 2);
51
- position: absolute;
52
- border-radius: 4px;
53
- top: $gantt-bar-link-height;
54
- box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.15);
55
-
56
- .handle {
57
- width: 15px;
58
- height: 100%;
59
- position: absolute;
60
- cursor: col-resize;
61
- display: flex;
62
- align-items: center;
63
- justify-content: center;
64
-
65
- &:before,
66
- &:after {
67
- content: '';
68
- display: inline-block;
69
- width: 1px;
70
- height: $gantt-bar-handle-height;
71
- background: $gantt-bar-handle-color;
72
- }
73
-
74
- &::before {
75
- margin-right: 2px;
76
- }
77
-
78
- &:first-child {
79
- left: 0;
80
- }
81
-
82
- &:last-child {
83
- right: 0;
84
- }
85
- }
86
- }
87
- }
88
-
89
- @mixin active-bar {
90
- z-index: 1000;
91
-
92
- .gantt-bar-layer {
93
- display: block;
94
- z-index: 1;
95
- }
96
-
97
- .gantt-bar-content {
98
- z-index: 1;
99
- box-shadow: none;
100
- }
101
-
102
- .cdk-drag {
103
- transition: none;
104
- }
105
- }
106
-
107
- .gantt-bar {
108
- position: absolute;
109
- border-radius: 4px;
110
- z-index: 2;
111
- background: $gantt-bar-bg;
112
-
113
- .gantt-bar-layer {
114
- width: calc(100% + #{$gantt-bar-layer-append-width});
115
- height: calc(100% + #{$gantt-bar-layer-append-height});
116
- position: absolute;
117
- border-radius: 4px;
118
- left: $gantt-bar-layer-append-width / 2 * -1;
119
- top: $gantt-bar-layer-append-height / 2 * -1;
120
- display: none;
121
- @include drag-handles();
122
- @include link-handles();
123
- }
124
-
125
- .gantt-bar-border {
126
- width: calc(100% + #{$gantt-bar-link-drop-border} * 2);
127
- height: calc(100% + #{$gantt-bar-link-drop-border} * 2);
128
- position: absolute;
129
- border-radius: 4px;
130
- left: $gantt-bar-link-drop-border * -1;
131
- top: $gantt-bar-link-drop-border * -1;
132
- display: none;
133
- background: #fff;
134
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
135
- }
136
-
137
- .gantt-bar-content {
138
- width: 100%;
139
- height: 100%;
140
- position: absolute;
141
- cursor: pointer;
142
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
143
- border-radius: 4px;
144
- background: $gantt-bar-background-color;
145
- overflow: hidden;
146
- box-sizing: border-box;
147
- .gantt-bar-content-progress {
148
- position: absolute;
149
- left: 0;
150
- top: 0;
151
- height: 100%;
152
- }
153
-
154
- }
155
-
156
- &-active {
157
- @include active-bar();
158
- }
159
-
160
- &-link-drop {
161
- .gantt-bar-border {
162
- display: block;
163
- }
164
-
165
- .gantt-bar-content {
166
- box-shadow: none;
167
- }
168
- }
169
- }
@@ -1,109 +0,0 @@
1
- import {
2
- Component,
3
- OnInit,
4
- Input,
5
- TemplateRef,
6
- HostBinding,
7
- ElementRef,
8
- OnChanges,
9
- OnDestroy,
10
- Inject,
11
- ViewChild,
12
- Output,
13
- EventEmitter,
14
- AfterViewInit
15
- } from '@angular/core';
16
- import { takeUntil } from 'rxjs/operators';
17
- import { GanttBarDrag } from './bar-drag';
18
- import { hexToRgb } from '../../utils/helpers';
19
- import { GanttDragContainer } from '../../gantt-drag-container';
20
- import { barBackground } from '../../gantt.styles';
21
- import { GanttBarClickEvent } from '../../class';
22
- import { GANTT_UPPER_TOKEN, GanttUpper } from '../../gantt-upper';
23
- import { GanttItemUpper } from '../../gantt-item-upper';
24
-
25
- function linearGradient(sideOrCorner: string, color: string, stop: string) {
26
- return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
27
- }
28
-
29
- @Component({
30
- selector: 'ngx-gantt-bar,gantt-bar',
31
- templateUrl: './bar.component.html',
32
- providers: [GanttBarDrag]
33
- })
34
- export class NgxGanttBarComponent extends GanttItemUpper implements OnInit, AfterViewInit, OnChanges, OnDestroy {
35
- @Output() barClick = new EventEmitter<GanttBarClickEvent>();
36
-
37
- @ViewChild('content') contentElementRef: ElementRef<HTMLDivElement>;
38
-
39
- @HostBinding('class.gantt-bar') ganttItemClass = true;
40
-
41
- color = 'red';
42
-
43
- constructor(
44
- private dragContainer: GanttDragContainer,
45
- private drag: GanttBarDrag,
46
- elementRef: ElementRef<HTMLDivElement>,
47
- @Inject(GANTT_UPPER_TOKEN) public ganttUpper: GanttUpper
48
- ) {
49
- super(elementRef, ganttUpper);
50
- }
51
-
52
- ngOnInit() {
53
- super.onInit();
54
- this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
55
- this.setContentBackground();
56
- });
57
- }
58
-
59
- ngAfterViewInit() {
60
- this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
61
- this.setContentBackground();
62
- }
63
-
64
- ngOnChanges(): void {
65
- super.onChanges();
66
- }
67
-
68
- onBarClick(event: Event) {
69
- this.barClick.emit({ event, item: this.item.origin });
70
- }
71
-
72
- private setContentBackground() {
73
- const contentElement = this.contentElementRef.nativeElement;
74
- const color = this.item.color || barBackground;
75
- const style: Partial<CSSStyleDeclaration> = this.item.barStyle || {};
76
- if (this.item.origin.start && this.item.origin.end) {
77
- style.background = color;
78
- style.borderRadius = '';
79
- }
80
- if (this.item.origin.start && !this.item.origin.end) {
81
- style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
82
- style.borderRadius = '4px 12.5px 12.5px 4px';
83
- }
84
- if (!this.item.origin.start && this.item.origin.end) {
85
- style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
86
- style.borderRadius = '12.5px 4px 4px 12.5px';
87
- }
88
- if (this.item.progress >= 0) {
89
- const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress') as HTMLDivElement;
90
- style.background = hexToRgb(color, 0.3);
91
- style.borderRadius = '';
92
- contentProgressElement.style.background = color;
93
- }
94
-
95
- for (const key in style) {
96
- if (style.hasOwnProperty(key)) {
97
- contentElement.style[key] = style[key];
98
- }
99
- }
100
- }
101
-
102
- stopPropagation(event: Event) {
103
- event.stopPropagation();
104
- }
105
-
106
- ngOnDestroy() {
107
- super.onDestroy();
108
- }
109
- }
@@ -1,54 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Component, DebugElement } from '@angular/core';
3
- import { ComponentFixture, TestBed } from '@angular/core/testing';
4
- import { By } from '@angular/platform-browser';
5
- import { NgxGanttComponent } from '../../../gantt.component';
6
- import { NgxGanttModule } from '../../../gantt.module';
7
- import { GanttDate } from '../../../utils/date';
8
-
9
- const mockBarItems = [
10
- {
11
- id: 'item-0101',
12
- title: 'VERSION 0101',
13
- start: new GanttDate('2020-05-31 22:34:35').getUnixTime(),
14
- end: new GanttDate('2020-06-05 08:53:20').getUnixTime(),
15
- progress: 0.5
16
- }
17
- ];
18
-
19
- @Component({
20
- selector: 'test-gantt-bar',
21
- template: ` <ngx-gantt #gantt [items]="items" [viewType]="viewType">
22
- <ngx-gantt-table>
23
- <ngx-gantt-column name="标题" width="200px">
24
- <ng-template #cell let-item="item">
25
- {{ item.title }}
26
- </ng-template>
27
- </ngx-gantt-column>
28
- </ngx-gantt-table>
29
- </ngx-gantt>`
30
- })
31
- export class TestGanttBarComponent {
32
- constructor() {}
33
-
34
- viewType = 'month';
35
-
36
- items = mockBarItems;
37
- }
38
-
39
- describe('ngx-gantt-bar', () => {
40
- let fixture: ComponentFixture<TestGanttBarComponent>;
41
- beforeEach(async () => {
42
- TestBed.configureTestingModule({
43
- imports: [CommonModule, NgxGanttModule],
44
- declarations: [TestGanttBarComponent]
45
- }).compileComponents();
46
- fixture = TestBed.createComponent(TestGanttBarComponent);
47
- fixture.detectChanges();
48
- });
49
-
50
- it('should has bar progress', () => {
51
- const barProgress = fixture.debugElement.queryAll(By.css('.gantt-bar-content-progress'));
52
- expect(barProgress.length).toEqual(1);
53
- });
54
- });
@@ -1,196 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Component, DebugElement, Directive } from '@angular/core';
3
- import { ComponentFixture, TestBed, fakeAsync, tick, flush } from '@angular/core/testing';
4
- import { By } from '@angular/platform-browser';
5
- import { GanttDragEvent, GanttLinkDragEvent } from '../../../class';
6
- import { NgxGanttComponent } from '../../../gantt.component';
7
- import { NgxGanttModule } from '../../../gantt.module';
8
- import { NgxGanttRootComponent } from '../../../root.component';
9
- import { GanttDate } from '../../../utils/date';
10
- import { dispatchMouseEvent } from '../../../utils/testing';
11
- import { NgxGanttBarComponent } from '../bar.component';
12
-
13
- const activeClass = 'gantt-bar-active';
14
-
15
- const mockBarItems = [
16
- {
17
- id: 'item-0101',
18
- title: 'VERSION 0101',
19
- start: new GanttDate('2020-03-31 22:34:35').getUnixTime(),
20
- end: new GanttDate('2020-06-05 08:53:20').getUnixTime(),
21
- color: '#FF0000'
22
- },
23
- {
24
- id: 'item-0203',
25
- title: 'VERSION 0203',
26
- start: new GanttDate('2020-04-23 20:07:55').getUnixTime(),
27
- end: new GanttDate('2020-06-23 00:00:00').getUnixTime(),
28
- links: ['item-0204']
29
- },
30
- {
31
- id: 'item-0204',
32
- title: 'VERSION 0204',
33
- start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
34
- end: new GanttDate('2020-06-18 02:26:40').getUnixTime(),
35
- links: ['item-0101']
36
- }
37
- ];
38
-
39
- @Component({
40
- selector: 'test-gantt-bar',
41
- template: ` <ngx-gantt
42
- #gantt
43
- [items]="items"
44
- [viewType]="viewType"
45
- [draggable]="draggable"
46
- [linkable]="linkable"
47
- (dragEnded)="dragEnded($event)"
48
- (dragStarted)="dragStarted($event)"
49
- (linkDragEnded)="linkDragEnded($event)"
50
- (linkDragStarted)="linkDragStarted($event)"
51
- >
52
- <ngx-gantt-table>
53
- <ngx-gantt-column name="标题" width="200px">
54
- <ng-template #cell let-item="item">
55
- {{ item.title }}
56
- </ng-template>
57
- </ngx-gantt-column>
58
- </ngx-gantt-table>
59
- </ngx-gantt>`
60
- })
61
- export class TestGanttBarComponent {
62
- constructor() {}
63
-
64
- viewType = 'month';
65
-
66
- items = mockBarItems;
67
-
68
- draggable = true;
69
-
70
- linkable = true;
71
-
72
- dragEnded(event: GanttDragEvent) {
73
- console.log(event);
74
- }
75
-
76
- dragStarted(event: GanttDragEvent) {
77
- console.log(event);
78
- }
79
-
80
- linkDragEnded(event: GanttLinkDragEvent) {
81
- console.log(event);
82
- }
83
-
84
- linkDragStarted(event: GanttLinkDragEvent) {
85
- console.log(event);
86
- }
87
- }
88
-
89
- function dragEvent(fixture: ComponentFixture<TestGanttBarComponent>, dragElement: HTMLElement, barElement?: HTMLElement) {
90
- const dragMaskElement = fixture.debugElement.query(By.css('.gantt-drag-mask')).nativeElement;
91
- const dragBackdropElement = fixture.debugElement.query(By.css('.gantt-drag-backdrop')).nativeElement;
92
- const dragStartSpy = spyOn(fixture.componentInstance, 'dragStarted');
93
- const dragEndSpy = spyOn(fixture.componentInstance, 'dragEnded');
94
- barElement = barElement || dragElement;
95
-
96
- dispatchMouseEvent(dragElement, 'mousedown');
97
- fixture.detectChanges();
98
-
99
- dispatchMouseEvent(document, 'mousemove', 50);
100
- fixture.detectChanges();
101
- expect(dragStartSpy).toHaveBeenCalledTimes(1);
102
- expect(barElement.style.getPropertyValue('pointer-events')).toEqual('none');
103
- expect(barElement.classList).toContain('gantt-bar-draggable-drag');
104
-
105
- dispatchMouseEvent(document, 'mousemove', 200);
106
- fixture.detectChanges();
107
- expect(dragMaskElement.style.getPropertyValue('display')).toEqual('block');
108
- expect(dragBackdropElement.style.getPropertyValue('display')).toEqual('block');
109
-
110
- dispatchMouseEvent(document, 'mouseup', 200);
111
- fixture.detectChanges();
112
- expect(barElement.style.getPropertyValue('pointer-events')).toEqual('');
113
- expect(barElement.classList).not.toContain('gantt-bar-draggable-drag');
114
- expect(dragMaskElement.style.getPropertyValue('display')).toEqual('none');
115
- expect(dragBackdropElement.style.getPropertyValue('display')).toEqual('none');
116
- expect(dragEndSpy).toHaveBeenCalledTimes(1);
117
- }
118
-
119
- function linkDragEvent(fixture: ComponentFixture<TestGanttBarComponent>, dragElement: HTMLElement) {
120
- const root = fixture.debugElement.query(By.directive(NgxGanttRootComponent));
121
-
122
- dispatchMouseEvent(dragElement, 'mousedown');
123
- fixture.detectChanges();
124
-
125
- dispatchMouseEvent(document, 'mousemove', 10, 10);
126
- fixture.detectChanges();
127
-
128
- const ganttLinkDragContainer = root.nativeElement.querySelector('.gantt-link-drag-container');
129
- const linkDraggingLine = root.nativeElement.querySelector('.link-dragging-line');
130
- expect(ganttLinkDragContainer).toBeTruthy();
131
- expect(linkDraggingLine).toBeTruthy();
132
-
133
- dispatchMouseEvent(document, 'mousemove', 200, -30);
134
- fixture.detectChanges();
135
-
136
- dispatchMouseEvent(document, 'mouseup', 200, -30);
137
- fixture.detectChanges();
138
- }
139
-
140
- describe('bar-drag', () => {
141
- let fixture: ComponentFixture<TestGanttBarComponent>;
142
- let ganttComponentInstance: TestGanttBarComponent;
143
- let ganttDebugElement: DebugElement;
144
-
145
- beforeEach(async () => {
146
- TestBed.configureTestingModule({
147
- imports: [CommonModule, NgxGanttModule],
148
- declarations: [TestGanttBarComponent]
149
- }).compileComponents();
150
- fixture = TestBed.createComponent(TestGanttBarComponent);
151
- ganttDebugElement = fixture.debugElement.query(By.directive(NgxGanttComponent));
152
- ganttComponentInstance = fixture.componentInstance;
153
- fixture.detectChanges();
154
- });
155
-
156
- it('should active when mouse enter bar', () => {
157
- const barElement = fixture.debugElement.query(By.directive(NgxGanttBarComponent)).nativeElement;
158
- dispatchMouseEvent(barElement, 'mouseenter');
159
- expect(barElement.classList).toContain(activeClass);
160
- dispatchMouseEvent(barElement, 'mouseleave');
161
- expect(barElement.classList).not.toContain(activeClass);
162
- });
163
-
164
- it('should bar drag', () => {
165
- const bar = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent))[0];
166
- dragEvent(fixture, bar.nativeElement);
167
- expect(bar.componentInstance.item.start.getUnixTime()).toEqual(new GanttDate('2020-04-21 00:00:00').getUnixTime());
168
- expect(bar.componentInstance.item.end.getUnixTime()).toEqual(new GanttDate('2020-06-26 23:59:59').getUnixTime());
169
- });
170
-
171
- it('should first bar handle drag', () => {
172
- const bar = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent))[1];
173
- const firstHandleElement = bar.queryAll(By.css('.drag-handles .handle'))[0].nativeElement;
174
- dragEvent(fixture, firstHandleElement, bar.nativeElement);
175
- expect(bar.componentInstance.item.start.getUnixTime()).toEqual(new GanttDate('2020-05-14 00:00:00').getUnixTime());
176
- });
177
-
178
- it('should last bar handles drag', () => {
179
- const bar = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent))[1];
180
- const lastHandleElement = bar.queryAll(By.css('.drag-handles .handle'))[1].nativeElement;
181
- dragEvent(fixture, lastHandleElement, bar.nativeElement);
182
- expect(bar.componentInstance.item.end.getUnixTime()).toEqual(new GanttDate('2020-07-15 23:59:59').getUnixTime());
183
- });
184
-
185
- it('should first bar link handle drag', () => {
186
- const bar = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent))[2];
187
- const firstHandleElement = bar.queryAll(By.css('.link-handles .handle'))[0].nativeElement;
188
- linkDragEvent(fixture, firstHandleElement);
189
- });
190
-
191
- it('should last bar link handles drag', () => {
192
- const bar = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent))[2];
193
- const lastHandleElement = bar.queryAll(By.css('.link-handles .handle'))[1].nativeElement;
194
- linkDragEvent(fixture, lastHandleElement);
195
- });
196
- });
@@ -1,52 +0,0 @@
1
- <div class="gantt-calendar-today-overlay" [style.width.px]="view.width">
2
- <span class="today-rect" [hidden]="ganttUpper.viewType !== viewTypes.day"> </span>
3
- <span class="today-line" *ngIf="ganttUpper.showTodayLine"> </span>
4
- </div>
5
-
6
- <svg class="gantt-calendar-overlay-main" [attr.width]="view.width" [attr.height]="headerHeight">
7
- <g>
8
- <text class="primary-text" *ngFor="let point of view.primaryDatePoints; trackBy: trackBy" [attr.x]="point.x" [attr.y]="point.y">
9
- {{ point.text }}
10
- </text>
11
- <ng-container *ngFor="let point of view.secondaryDatePoints; trackBy: trackBy">
12
- <text class="secondary-text" [class.secondary-text-weekend]="point.additions?.isWeekend" [attr.x]="point.x" [attr.y]="point.y">
13
- {{ point.text }}
14
- </text>
15
- </ng-container>
16
-
17
- <g>
18
- <line
19
- *ngFor="let point of view.primaryDatePoints; let i = index; trackBy: trackBy"
20
- [attr.x1]="(i + 1) * view.primaryWidth"
21
- [attr.x2]="(i + 1) * view.primaryWidth"
22
- [attr.y1]="0"
23
- [attr.y2]="mainHeight"
24
- class="primary-line"
25
- ></line>
26
- </g>
27
-
28
- <g>
29
- <line [attr.x1]="0" [attr.x2]="view.width" [attr.y1]="headerHeight" [attr.y2]="headerHeight" class="header-line"></line>
30
- </g>
31
- </g>
32
- <g>
33
- <g *ngIf="view.showTimeline">
34
- <line
35
- *ngFor="let point of view.secondaryDatePoints; let i = index; trackBy: trackBy"
36
- [attr.x1]="(i + 1) * view.cellWidth"
37
- [attr.x2]="(i + 1) * view.cellWidth"
38
- [attr.y1]="headerHeight"
39
- [attr.y2]="mainHeight"
40
- class="secondary-line"
41
- ></line>
42
- <line
43
- *ngFor="let point of view.primaryDatePoints; let i = index; trackBy: trackBy"
44
- [attr.x1]="(i + 1) * view.primaryWidth"
45
- [attr.x2]="(i + 1) * view.primaryWidth"
46
- [attr.y1]="0"
47
- [attr.y2]="mainHeight"
48
- class="primary-line"
49
- ></line>
50
- </g>
51
- </g>
52
- </svg>
@@ -1,77 +0,0 @@
1
- .gantt-calendar-overlay {
2
- display: block;
3
- height: 100%;
4
- overflow: hidden;
5
-
6
- .gantt-calendar-today-overlay {
7
- position: relative;
8
- z-index: 2;
9
- .today-rect {
10
- width: 35px;
11
- height: 24px;
12
- position: absolute;
13
- background: $gantt-date-today-color;
14
- color: $gantt-date-today-text-color;
15
- text-align: center;
16
- border-radius: 4px;
17
- }
18
- .today-line {
19
- position: absolute;
20
- width: 3px;
21
- background: $gantt-date-today-color;
22
- transform: scaleX(0.5);
23
- transform-origin: 100% 0;
24
- margin-left: -2px;
25
- }
26
- }
27
-
28
- .gantt-calendar-overlay-main {
29
- position: relative;
30
- z-index: 1;
31
- background-color: $gantt-bg-color;
32
- }
33
-
34
- svg {
35
- overflow: visible;
36
- }
37
-
38
- line {
39
- shape-rendering: crispEdges;
40
- }
41
-
42
- .primary-text {
43
- fill: $gantt-date-primary-color;
44
- font-size: $gantt-date-primary-font-size;
45
- }
46
-
47
- .secondary-text {
48
- fill: $gantt-date-secondary-color;
49
- font-size: $gantt-date-secondary-font-size;
50
-
51
- &-weekend {
52
- fill: $gantt-date-secondary-weekend-color;
53
- }
54
- }
55
-
56
- .primary-text,
57
- .secondary-text {
58
- text-anchor: middle;
59
- }
60
-
61
- .primary-line {
62
- stroke: $gantt-date-primary-border;
63
- }
64
-
65
- .secondary-line {
66
- stroke-dasharray: 2px 5px;
67
- stroke: #cacaca;
68
- }
69
-
70
- .header-line {
71
- stroke: $gantt-border-color;
72
- }
73
-
74
- .secondary-backdrop {
75
- fill: $gantt-date-week-backdrop-bg;
76
- }
77
- }