@worktile/gantt 12.0.1 → 12.0.2

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 (230) hide show
  1. package/README.md +13 -116
  2. package/bundles/worktile-gantt.umd.js +3303 -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 +36 -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 +264 -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 +146 -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 +59 -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 +254 -0
  42. package/esm2015/gantt.component.js +131 -0
  43. package/esm2015/gantt.module.js +74 -0
  44. package/esm2015/gantt.pipe.js +43 -0
  45. package/esm2015/gantt.styles.js +15 -0
  46. package/esm2015/public-api.js +18 -0
  47. package/esm2015/root.component.js +123 -0
  48. package/esm2015/table/gantt-column.component.js +37 -0
  49. package/esm2015/table/gantt-table.component.js +20 -0
  50. package/esm2015/utils/date.js +160 -0
  51. package/esm2015/utils/helpers.js +55 -0
  52. package/esm2015/views/day.js +54 -0
  53. package/esm2015/views/factory.js +23 -0
  54. package/esm2015/views/month.js +48 -0
  55. package/esm2015/views/quarter.js +51 -0
  56. package/esm2015/views/view.js +121 -0
  57. package/esm2015/views/week.js +49 -0
  58. package/esm2015/views/year.js +50 -0
  59. package/esm2015/worktile-gantt.js +5 -0
  60. package/fesm2015/worktile-gantt.js +2637 -0
  61. package/fesm2015/worktile-gantt.js.map +1 -0
  62. package/{packages/gantt/src/gantt-abstract.ts → gantt-abstract.d.ts} +1 -3
  63. package/gantt-dom.service.d.ts +32 -0
  64. package/gantt-drag-container.d.ts +23 -0
  65. package/gantt-item-upper.d.ts +20 -0
  66. package/gantt-print.service.d.ts +13 -0
  67. package/gantt-upper.d.ts +64 -0
  68. package/gantt.component.d.ts +29 -0
  69. package/gantt.module.d.ts +21 -0
  70. package/gantt.pipe.d.ts +18 -0
  71. package/gantt.styles.d.ts +15 -0
  72. package/main.bundle.scss +645 -0
  73. package/package.json +16 -113
  74. package/{packages/gantt/src/public-api.ts → public-api.d.ts} +0 -4
  75. package/root.component.d.ts +28 -0
  76. package/table/gantt-column.component.d.ts +15 -0
  77. package/table/gantt-table.component.d.ts +10 -0
  78. package/utils/date.d.ts +59 -0
  79. package/utils/helpers.d.ts +12 -0
  80. package/views/day.d.ts +14 -0
  81. package/views/factory.d.ts +8 -0
  82. package/views/month.d.ts +12 -0
  83. package/views/quarter.d.ts +12 -0
  84. package/views/view.d.ts +56 -0
  85. package/views/week.d.ts +12 -0
  86. package/views/year.d.ts +12 -0
  87. package/worktile-gantt.d.ts +5 -0
  88. package/.all-contributorsrc +0 -53
  89. package/.angulardoc.json +0 -4
  90. package/.circleci/config.yml +0 -17
  91. package/.coveralls.yml +0 -1
  92. package/.docgenirc.js +0 -64
  93. package/.editorconfig +0 -22
  94. package/.prettierrc +0 -24
  95. package/.travis.yml +0 -23
  96. package/CHANGELOG.md +0 -564
  97. package/Dockerfile +0 -4
  98. package/LICENSE +0 -21
  99. package/angular.json +0 -136
  100. package/docs/guides/basic/components.md +0 -54
  101. package/docs/guides/basic/event.md +0 -70
  102. package/docs/guides/basic/index.md +0 -4
  103. package/docs/guides/basic/style.md +0 -68
  104. package/docs/guides/basic/type.md +0 -70
  105. package/docs/guides/basic/usage.md +0 -189
  106. package/docs/guides/index.md +0 -5
  107. package/docs/guides/intro/getting-started.md +0 -79
  108. package/docs/guides/intro/index.md +0 -51
  109. package/docs/index.md +0 -0
  110. package/example/browserslist +0 -12
  111. package/example/src/app/app-routing.module.ts +0 -26
  112. package/example/src/app/app.component.html +0 -2
  113. package/example/src/app/app.component.ts +0 -11
  114. package/example/src/app/app.module.ts +0 -57
  115. package/example/src/app/components/components.component.html +0 -6
  116. package/example/src/app/components/components.component.ts +0 -33
  117. package/example/src/app/configuration/parameters/api/zh-cn.js +0 -350
  118. package/example/src/app/configuration/parameters/doc/zh-cn.md +0 -5
  119. package/example/src/app/gantt/gantt.component.html +0 -51
  120. package/example/src/app/gantt/gantt.component.ts +0 -119
  121. package/example/src/app/gantt-advanced/component/flat.component.html +0 -30
  122. package/example/src/app/gantt-advanced/component/flat.component.ts +0 -72
  123. package/example/src/app/gantt-advanced/component/flat.scss +0 -31
  124. package/example/src/app/gantt-advanced/gantt-advanced.component.html +0 -32
  125. package/example/src/app/gantt-advanced/gantt-advanced.component.ts +0 -34
  126. package/example/src/app/gantt-advanced/mocks.ts +0 -158
  127. package/example/src/app/gantt-groups/gantt-groups.component.html +0 -42
  128. package/example/src/app/gantt-groups/gantt-groups.component.ts +0 -62
  129. package/example/src/app/gantt-range/gantt-range.component.html +0 -66
  130. package/example/src/app/gantt-range/gantt-range.component.ts +0 -67
  131. package/example/src/app/gantt-range/mocks.ts +0 -150
  132. package/example/src/app/helper.ts +0 -38
  133. package/example/src/assets/.gitkeep +0 -0
  134. package/example/src/environments/environment.prod.ts +0 -3
  135. package/example/src/environments/environment.ts +0 -16
  136. package/example/src/favicon.ico +0 -0
  137. package/example/src/index.html +0 -13
  138. package/example/src/main.ts +0 -12
  139. package/example/src/polyfills.ts +0 -63
  140. package/example/src/styles.scss +0 -56
  141. package/example/tsconfig.app.json +0 -18
  142. package/nginx.conf +0 -17
  143. package/packages/gantt/README.md +0 -24
  144. package/packages/gantt/karma.conf.js +0 -46
  145. package/packages/gantt/ng-package.json +0 -7
  146. package/packages/gantt/ng-package.prod.json +0 -7
  147. package/packages/gantt/package.json +0 -16
  148. package/packages/gantt/src/class/date-point.ts +0 -14
  149. package/packages/gantt/src/class/group.ts +0 -36
  150. package/packages/gantt/src/class/item.ts +0 -129
  151. package/packages/gantt/src/class/test/group.spec.ts +0 -21
  152. package/packages/gantt/src/class/test/item.spec.ts +0 -102
  153. package/packages/gantt/src/class/view-type.ts +0 -7
  154. package/packages/gantt/src/components/bar/bar-drag.ts +0 -298
  155. package/packages/gantt/src/components/bar/bar.component.html +0 -17
  156. package/packages/gantt/src/components/bar/bar.component.scss +0 -169
  157. package/packages/gantt/src/components/bar/bar.component.ts +0 -109
  158. package/packages/gantt/src/components/bar/test/bar.component.spec.ts +0 -54
  159. package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +0 -196
  160. package/packages/gantt/src/components/calendar/calendar.component.html +0 -52
  161. package/packages/gantt/src/components/calendar/calendar.component.scss +0 -77
  162. package/packages/gantt/src/components/calendar/calendar.component.ts +0 -100
  163. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +0 -6
  164. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +0 -48
  165. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +0 -13
  166. package/packages/gantt/src/components/icon/icon.component.scss +0 -13
  167. package/packages/gantt/src/components/icon/icon.component.ts +0 -28
  168. package/packages/gantt/src/components/icon/icons.ts +0 -86
  169. package/packages/gantt/src/components/links/links.component.html +0 -19
  170. package/packages/gantt/src/components/links/links.component.scss +0 -27
  171. package/packages/gantt/src/components/links/links.component.ts +0 -263
  172. package/packages/gantt/src/components/main/gantt-main.component.html +0 -35
  173. package/packages/gantt/src/components/main/gantt-main.component.ts +0 -35
  174. package/packages/gantt/src/components/range/range.component.html +0 -8
  175. package/packages/gantt/src/components/range/range.component.scss +0 -35
  176. package/packages/gantt/src/components/range/range.component.ts +0 -27
  177. package/packages/gantt/src/components/range/test/range.component.spec.ts +0 -80
  178. package/packages/gantt/src/components/table/gantt-table.component.html +0 -105
  179. package/packages/gantt/src/components/table/gantt-table.component.scss +0 -144
  180. package/packages/gantt/src/components/table/gantt-table.component.ts +0 -166
  181. package/packages/gantt/src/components/table/test/table.spec.ts +0 -129
  182. package/packages/gantt/src/gantt-dom.service.ts +0 -134
  183. package/packages/gantt/src/gantt-drag-container.ts +0 -73
  184. package/packages/gantt/src/gantt-item-upper.ts +0 -50
  185. package/packages/gantt/src/gantt-print.service.ts +0 -104
  186. package/packages/gantt/src/gantt-upper.ts +0 -289
  187. package/packages/gantt/src/gantt.component.html +0 -18
  188. package/packages/gantt/src/gantt.component.scss +0 -77
  189. package/packages/gantt/src/gantt.component.ts +0 -134
  190. package/packages/gantt/src/gantt.module.ts +0 -47
  191. package/packages/gantt/src/gantt.pipe.ts +0 -31
  192. package/packages/gantt/src/gantt.styles.ts +0 -28
  193. package/packages/gantt/src/root.component.html +0 -12
  194. package/packages/gantt/src/root.component.ts +0 -121
  195. package/packages/gantt/src/styles/index.scss +0 -9
  196. package/packages/gantt/src/styles/variables.scss +0 -46
  197. package/packages/gantt/src/table/gantt-column.component.ts +0 -25
  198. package/packages/gantt/src/table/gantt-table.component.ts +0 -14
  199. package/packages/gantt/src/table/test/table.spec.ts +0 -56
  200. package/packages/gantt/src/test/gantt.component.spec.ts +0 -404
  201. package/packages/gantt/src/test/mocks/data.ts +0 -303
  202. package/packages/gantt/src/test.ts +0 -21
  203. package/packages/gantt/src/utils/date.ts +0 -276
  204. package/packages/gantt/src/utils/helpers.ts +0 -66
  205. package/packages/gantt/src/utils/test/date.spec.ts +0 -105
  206. package/packages/gantt/src/utils/test/helpers.spec.ts +0 -73
  207. package/packages/gantt/src/utils/testing.ts +0 -64
  208. package/packages/gantt/src/views/day.ts +0 -74
  209. package/packages/gantt/src/views/factory.ts +0 -25
  210. package/packages/gantt/src/views/month.ts +0 -66
  211. package/packages/gantt/src/views/quarter.ts +0 -68
  212. package/packages/gantt/src/views/test/day.spec.ts +0 -45
  213. package/packages/gantt/src/views/test/factory.spec.ts +0 -41
  214. package/packages/gantt/src/views/test/mock.ts +0 -14
  215. package/packages/gantt/src/views/test/month.spec.ts +0 -45
  216. package/packages/gantt/src/views/test/quarter.spec.ts +0 -45
  217. package/packages/gantt/src/views/test/view.spec.ts +0 -144
  218. package/packages/gantt/src/views/test/week.spec.ts +0 -45
  219. package/packages/gantt/src/views/test/year.spec.ts +0 -45
  220. package/packages/gantt/src/views/view.ts +0 -186
  221. package/packages/gantt/src/views/week.ts +0 -66
  222. package/packages/gantt/src/views/year.ts +0 -62
  223. package/packages/gantt/tsconfig.lib.json +0 -20
  224. package/packages/gantt/tsconfig.lib.prod.json +0 -9
  225. package/packages/gantt/tsconfig.schematics.json +0 -25
  226. package/packages/gantt/tsconfig.spec.json +0 -17
  227. package/packages/gantt/tslint.json +0 -18
  228. package/scss-bundle.config.json +0 -7
  229. package/tsconfig.json +0 -26
  230. package/tslint.json +0 -51
@@ -1,8 +0,0 @@
1
- <ng-container *ngIf="item.start && item.end">
2
- <div class="gantt-range-main">
3
- <div class="gantt-range-main-progress" *ngIf="item.progress >= 0" [style.width.%]="item.progress * 100"></div>
4
- </div>
5
- <div class="gantt-range-triangle left"></div>
6
- <div class="gantt-range-triangle right"></div>
7
- <ng-template [ngTemplateOutlet]="template" [ngTemplateOutletContext]="{ item: item.origin, refs: item.refs }"></ng-template>
8
- </ng-container>
@@ -1,35 +0,0 @@
1
- .gantt-range {
2
- position: absolute;
3
- z-index: 2;
4
- .gantt-range-main {
5
- height: 10px;
6
- background: #dfdfdf;
7
- border: 1px solid #888;
8
- border-radius: 4px 4px 0 0;
9
- box-sizing: border-box;
10
- position: relative;
11
- .gantt-range-main-progress {
12
- position: absolute;
13
- left: 0;
14
- top: 0;
15
- height: 100%;
16
- background: #888;
17
- }
18
- }
19
- .gantt-range-triangle {
20
- width: 0;
21
- height: 0;
22
- border-top: 7px solid #888;
23
- position: absolute;
24
- top: 10px;
25
-
26
- &.left {
27
- border-right: 6px solid transparent;
28
- left: 0;
29
- }
30
- &.right {
31
- border-left: 6px solid transparent;
32
- right: 0;
33
- }
34
- }
35
- }
@@ -1,27 +0,0 @@
1
- import { Component, OnInit, HostBinding, ElementRef, OnChanges, OnDestroy, Inject } from '@angular/core';
2
- import { GANTT_UPPER_TOKEN, GanttUpper } from '../../gantt-upper';
3
- import { GanttItemUpper } from '../../gantt-item-upper';
4
-
5
- @Component({
6
- selector: 'ngx-gantt-range,gantt-range',
7
- templateUrl: './range.component.html'
8
- })
9
- export class NgxGanttRangeComponent extends GanttItemUpper implements OnInit, OnChanges, OnDestroy {
10
- @HostBinding('class.gantt-range') ganttRangeClass = true;
11
-
12
- constructor(elementRef: ElementRef<HTMLDivElement>, @Inject(GANTT_UPPER_TOKEN) ganttUpper: GanttUpper) {
13
- super(elementRef, ganttUpper);
14
- }
15
-
16
- ngOnInit() {
17
- super.onInit();
18
- }
19
-
20
- ngOnChanges(): void {
21
- super.onChanges();
22
- }
23
-
24
- ngOnDestroy() {
25
- super.onDestroy();
26
- }
27
- }
@@ -1,80 +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
- import { NgxGanttRangeComponent } from '../range.component';
9
-
10
- const mockRangeItems = [
11
- {
12
- id: 'item-0101',
13
- title: 'VERSION 0101',
14
- start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
15
- type: 'range',
16
- progress: 0.5,
17
- color: '#FF0000',
18
- children: [
19
- {
20
- id: 'item-child-0101',
21
- title: 'VERSION Children 0101',
22
- start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
23
- color: '#FF0000',
24
- linkable: false,
25
- type: 'range'
26
- }
27
- ]
28
- },
29
- {
30
- id: 'item-0102',
31
- title: 'VERSION 0102',
32
- start: new GanttDate('2020-05-31 22:34:35').getUnixTime(),
33
- end: new GanttDate('2020-06-05 08:53:20').getUnixTime(),
34
- color: '#9ACD32',
35
- expandable: true,
36
- type: 'range'
37
- }
38
- ];
39
-
40
- @Component({
41
- selector: 'test-gantt-range',
42
- template: ` <ngx-gantt #gantt [items]="items" [viewType]="viewType">
43
- <ngx-gantt-table>
44
- <ngx-gantt-column name="标题" width="200px">
45
- <ng-template #cell let-item="item">
46
- {{ item.title }}
47
- </ng-template>
48
- </ngx-gantt-column>
49
- </ngx-gantt-table>
50
- </ngx-gantt>`
51
- })
52
- export class TestGanttRangeComponent {
53
- constructor() {}
54
-
55
- viewType = 'month';
56
-
57
- items = mockRangeItems;
58
- }
59
-
60
- describe('ngx-gantt-range', () => {
61
- let fixture: ComponentFixture<TestGanttRangeComponent>;
62
- beforeEach(async () => {
63
- TestBed.configureTestingModule({
64
- imports: [CommonModule, NgxGanttModule],
65
- declarations: [TestGanttRangeComponent]
66
- }).compileComponents();
67
- fixture = TestBed.createComponent(TestGanttRangeComponent);
68
- fixture.detectChanges();
69
- });
70
-
71
- it('should render range item', () => {
72
- const rangeItems = fixture.debugElement.queryAll(By.directive(NgxGanttRangeComponent));
73
- expect(rangeItems.length).toEqual(mockRangeItems.length);
74
- });
75
-
76
- it('should has range progress', () => {
77
- const rangeProgress = fixture.debugElement.queryAll(By.css('.gantt-range-main-progress'));
78
- expect(rangeProgress.length).toEqual(1);
79
- });
80
- });
@@ -1,105 +0,0 @@
1
- <div class="gantt-table-header gantt-table-row">
2
- <div class="gantt-table-column" *ngFor="let column of columnList; let i = index" [style.width]="column.columnWidth">
3
- <ng-container *ngIf="column.headerTemplateRef; else default" [ngTemplateOutlet]="column.headerTemplateRef"></ng-container>
4
- <ng-template #default>
5
- {{ column.name }}
6
- </ng-template>
7
- <div
8
- class="gantt-table-drag-trigger"
9
- cdkDrag
10
- cdkDragLockAxis="x"
11
- cdkDragBoundary=".gantt"
12
- (cdkDragMoved)="dragMoved($event, column)"
13
- (cdkDragStarted)="dragStarted($event)"
14
- (cdkDragEnded)="columnDragEnded($event, column)"
15
- ></div>
16
- </div>
17
- </div>
18
- <div class="gantt-table-body">
19
- <ng-container *ngIf="!groups.length && !items.length">
20
- <ng-container *ngIf="!emptyTemplate">
21
- <gantt-icon class="empty-icon" iconName="empty"></gantt-icon>
22
- <div class="empty-text">没有数据</div>
23
- </ng-container>
24
- <ng-template [ngTemplateOutlet]="emptyTemplate"></ng-template>
25
- </ng-container>
26
-
27
- <ng-container *ngIf="groups && groups.length > 0; else itemsTemplate">
28
- <ng-container *ngFor="let group of groups">
29
- <div class="gantt-table-group" [ngClass]="group.class">
30
- <div class="gantt-table-group-title" [class.expanded]="group.expanded" (click)="expandGroup(group)">
31
- <gantt-icon class="expand-icon" [iconName]="group.expanded ? 'angle-down' : 'angle-right'"></gantt-icon>
32
- <ng-container *ngIf="groupTemplate; else default">
33
- <ng-template
34
- [ngTemplateOutlet]="groupTemplate"
35
- [ngTemplateOutletContext]="{ $implicit: group.origin, group: group.origin }"
36
- ></ng-template>
37
- </ng-container>
38
- <ng-template #default>
39
- <span class="group-title">{{ group.title }}</span>
40
- </ng-template>
41
- </div>
42
- </div>
43
-
44
- <ng-container *ngIf="group.expanded">
45
- <ng-template
46
- [ngTemplateOutlet]="ganttItems"
47
- [ngTemplateOutletContext]="{ group: group, items: group.items, level: 0 }"
48
- ></ng-template>
49
- </ng-container>
50
- </ng-container>
51
- </ng-container>
52
- </div>
53
-
54
- <div
55
- class="gantt-table-drag-trigger"
56
- cdkDrag
57
- cdkDragLockAxis="x"
58
- cdkDragBoundary=".gantt"
59
- (cdkDragMoved)="dragMoved($event)"
60
- (cdkDragStarted)="dragStarted($event)"
61
- (cdkDragEnded)="tableDragEnded($event)"
62
- ></div>
63
-
64
- <div #dragLine class="gantt-table-drag-auxiliary-line"></div>
65
-
66
- <ng-template #itemsTemplate>
67
- <ng-template [ngTemplateOutlet]="ganttItems" [ngTemplateOutletContext]="{ items: items, level: 0 }"></ng-template>
68
- </ng-template>
69
-
70
- <ng-template #ganttItems let-group="group" let-items="items" let-level="level">
71
- <ng-container *ngFor="let item of items">
72
- <div
73
- class="gantt-table-item gantt-table-row"
74
- [class.gantt-table-item-first-level-group]="level === 0 && (item.type | isGanttRangeItem)"
75
- [class.gantt-table-item-with-group]="group"
76
- [style.height.px]="gantt.styles.lineHeight"
77
- [style.lineHeight.px]="gantt.styles.lineHeight"
78
- >
79
- <div class="gantt-table-column" *ngFor="let column of columnList; let first = first" [style.width]="column.columnWidth">
80
- <div *ngIf="first" class="gantt-expand-icon" [style.marginLeft.px]="level * 20">
81
- <ng-container *ngIf="level < gantt.maxLevel - 1 && item.expandable">
82
- <gantt-icon
83
- *ngIf="!item.loading"
84
- class="expand-icon"
85
- [iconName]="item.expanded ? 'angle-down' : 'angle-right'"
86
- (click)="expandChildren(item)"
87
- ></gantt-icon>
88
- <gantt-icon *ngIf="item.loading" [iconName]="'loading'"></gantt-icon>
89
- </ng-container>
90
- </div>
91
- <div class="gantt-table-column-content">
92
- <ng-template
93
- [ngTemplateOutlet]="column.templateRef"
94
- [ngTemplateOutletContext]="{ $implicit: item.origin, item: item.origin }"
95
- ></ng-template>
96
- </div>
97
- </div>
98
- </div>
99
- <ng-template
100
- *ngIf="item.children && item.expanded"
101
- [ngTemplateOutlet]="ganttItems"
102
- [ngTemplateOutletContext]="{ items: item.children, level: level + 1, group: group }"
103
- ></ng-template>
104
- </ng-container>
105
- </ng-template>
@@ -1,144 +0,0 @@
1
- .gantt-table {
2
- display: block;
3
- &-empty {
4
- height: 100%;
5
- position: relative;
6
- .gantt-table-body {
7
- position: absolute;
8
- text-align: center;
9
- top: 50%;
10
- left: 50%;
11
- transform: translate(-50%, -50%);
12
- margin-top: 22px;
13
- .empty-icon {
14
- svg {
15
- height: 78px;
16
- width: 78px;
17
- }
18
- }
19
- .empty-text {
20
- color: #cacaca;
21
- }
22
- }
23
- }
24
-
25
- &-drag-trigger {
26
- width: $gantt-table-header-drag-line-width;
27
- position: absolute;
28
- top: 0;
29
- right: 0;
30
- bottom: 0;
31
- cursor: ew-resize;
32
- z-index: 1;
33
-
34
- &:hover {
35
- background: $gantt-table-header-drag-line-color;
36
- z-index: 2;
37
- }
38
- }
39
-
40
- &-drag-auxiliary-line {
41
- width: $gantt-table-header-drag-line-width;
42
- background: $gantt-table-header-drag-line-color;
43
- position: absolute;
44
- top: 0;
45
- bottom: 0;
46
- z-index: 100;
47
- display: none;
48
- }
49
-
50
- .gantt-table-row {
51
- display: flex;
52
- box-sizing: border-box;
53
- border-bottom: 1px solid $gantt-border-color;
54
-
55
- .gantt-table-column {
56
- overflow: hidden;
57
- border-right: 1px solid $gantt-border-color;
58
- box-sizing: border-box;
59
- position: relative;
60
-
61
- &:last-child {
62
- border-right: none;
63
- }
64
- }
65
- }
66
-
67
- .gantt-table-header {
68
- text-align: center;
69
- position: sticky;
70
- top: 0;
71
- background: #fff;
72
- z-index: 2;
73
- height: $gantt-header-height;
74
- line-height: $gantt-header-height;
75
-
76
- .gantt-table-column {
77
- font-weight: 400;
78
- }
79
- }
80
-
81
- .gantt-table-body {
82
- .gantt-table-group {
83
- display: flex;
84
- height: $gantt-group-height;
85
- background: $gantt-group-background-color;
86
- padding: 0 10px;
87
- align-items: center;
88
- border-bottom: 1px solid $gantt-border-color;
89
- box-sizing: border-box;
90
- position: relative;
91
-
92
- .gantt-table-group-title {
93
- cursor: pointer;
94
-
95
- .expand-icon {
96
- color: #aaa;
97
- margin-right: 6px;
98
- }
99
- }
100
- }
101
-
102
- .gantt-table-item {
103
- cursor: pointer;
104
- &-first-level-group {
105
- background: $gantt-group-background-color;
106
- }
107
-
108
- &-with-group {
109
- .gantt-table-column {
110
- &:first-child {
111
- padding: 0 15px 0 32px;
112
- }
113
- }
114
- }
115
-
116
- .gantt-table-column {
117
- display: flex;
118
- padding: $gantt-table-td-padding;
119
-
120
- &:last-child {
121
- border-right: none;
122
- }
123
- }
124
-
125
- .gantt-table-column-content {
126
- flex: 1;
127
- position: relative;
128
- overflow: hidden;
129
- text-overflow: ellipsis;
130
- white-space: nowrap;
131
- }
132
-
133
- &:hover {
134
- background-color: $gantt-container-background-color;
135
- }
136
- }
137
-
138
- .gantt-expand-icon {
139
- display: inline-block;
140
- width: 20px;
141
- color: #aaa;
142
- }
143
- }
144
- }
@@ -1,166 +0,0 @@
1
- import {
2
- Component,
3
- HostBinding,
4
- TemplateRef,
5
- QueryList,
6
- Input,
7
- OnInit,
8
- ViewChild,
9
- ElementRef,
10
- OnChanges,
11
- SimpleChanges,
12
- Inject
13
- } from '@angular/core';
14
- import { GanttItemInternal, GanttGroupInternal } from '../../class';
15
- import { NgxGanttTableColumnComponent } from '../../table/gantt-column.component';
16
- // import { defaultColumnWidth, minColumnWidth } from '../../gantt.component';
17
- import { CdkDragEnd, CdkDragMove, CdkDragStart } from '@angular/cdk/drag-drop';
18
- import { coerceCssPixelValue } from '@angular/cdk/coercion';
19
- import { GanttAbstractComponent, GANTT_ABSTRACT_TOKEN } from '../../gantt-abstract';
20
-
21
- export const defaultColumnWidth = 100;
22
- export const minColumnWidth = 80;
23
-
24
- interface DragFixedConfig {
25
- target: HTMLElement;
26
- originWidth: number;
27
- movedWidth: number;
28
- minWidth: number;
29
- }
30
- @Component({
31
- selector: 'gantt-table',
32
- templateUrl: './gantt-table.component.html'
33
- })
34
- export class GanttTableComponent implements OnInit, OnChanges {
35
- public columnList: QueryList<NgxGanttTableColumnComponent>;
36
-
37
- public dragStartLeft: number;
38
-
39
- @Input() groups: GanttGroupInternal[];
40
-
41
- @Input() items: GanttItemInternal[];
42
-
43
- @Input()
44
- set columns(columns: QueryList<NgxGanttTableColumnComponent>) {
45
- columns.forEach((column) => {
46
- if (!column.columnWidth) {
47
- column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
48
- }
49
- });
50
- this.columnList = columns;
51
- }
52
-
53
- @Input() groupTemplate: TemplateRef<any>;
54
-
55
- @Input() emptyTemplate: TemplateRef<any>;
56
-
57
- @ViewChild('dragLine', { static: true }) draglineElementRef: ElementRef<HTMLElement>;
58
-
59
- @HostBinding('class.gantt-table') ganttTableClass = true;
60
-
61
- @HostBinding('class.gantt-table-empty') ganttTableEmptyClass = false;
62
-
63
- constructor(@Inject(GANTT_ABSTRACT_TOKEN) public gantt: GanttAbstractComponent, private elementRef: ElementRef) {}
64
-
65
- ngOnInit() {}
66
-
67
- ngOnChanges(changes: SimpleChanges) {
68
- if (!changes.groups.currentValue?.length && !changes.items.currentValue?.length) {
69
- this.ganttTableEmptyClass = true;
70
- } else {
71
- this.ganttTableEmptyClass = false;
72
- }
73
- }
74
-
75
- private dragFixed(config: DragFixedConfig) {
76
- if (config.movedWidth < config.minWidth) {
77
- config.target.style.transform = `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`;
78
- }
79
- }
80
-
81
- expandGroup(group: GanttGroupInternal) {
82
- this.gantt.expandGroup(group);
83
- }
84
-
85
- expandChildren(item: GanttItemInternal) {
86
- this.gantt.expandChildren(item);
87
- }
88
-
89
- dragStarted(event: CdkDragStart) {
90
- const target = event.source.element.nativeElement;
91
- this.dragStartLeft = target.getBoundingClientRect().left;
92
- }
93
-
94
- dragMoved(event: CdkDragMove, column?: NgxGanttTableColumnComponent) {
95
- const target = event.source.element.nativeElement;
96
- const left = target.getBoundingClientRect().left;
97
-
98
- let originWidth: number;
99
- let movedWidth: number;
100
- let minWidth: number;
101
- if (column) {
102
- originWidth = parseInt(column.columnWidth, 10);
103
- movedWidth = originWidth + (left - this.dragStartLeft);
104
- minWidth = minColumnWidth;
105
- } else {
106
- originWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
107
- movedWidth = originWidth + (left - this.dragStartLeft);
108
- minWidth = minColumnWidth * this.columnList.length;
109
- }
110
-
111
- this.dragFixed({
112
- target,
113
- originWidth,
114
- movedWidth,
115
- minWidth
116
- });
117
-
118
- this.showAuxiliaryLine(event);
119
- }
120
-
121
- columnDragEnded(event: CdkDragEnd, column: NgxGanttTableColumnComponent) {
122
- const target = event.source.element.nativeElement;
123
- const left = target.getBoundingClientRect().left;
124
- const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
125
- const columnWidth = Math.max(width || 0, minColumnWidth);
126
- column.columnWidth = coerceCssPixelValue(columnWidth);
127
- if (this.gantt.table) {
128
- this.gantt.table.columnChanges.emit({ columns: this.columnList });
129
- }
130
-
131
- this.hideAuxiliaryLine();
132
- event.source.reset();
133
- }
134
-
135
- tableDragEnded(event: CdkDragEnd) {
136
- const target = event.source.element.nativeElement;
137
- const left = target.getBoundingClientRect().left;
138
- const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
139
- const dragWidth = left - this.dragStartLeft;
140
- this.columnList.forEach((column) => {
141
- const lastColumnWidth = parseInt(column.columnWidth, 10);
142
- const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
143
- const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
144
- column.columnWidth = coerceCssPixelValue(columnWidth);
145
- });
146
-
147
- if (this.gantt.table) {
148
- this.gantt.table.columnChanges.emit({ columns: this.columnList });
149
- }
150
-
151
- this.hideAuxiliaryLine();
152
- event.source.reset();
153
- }
154
-
155
- private showAuxiliaryLine(event: CdkDragMove) {
156
- const tableRect = this.elementRef.nativeElement.getBoundingClientRect();
157
- const targetRect = event.source.element.nativeElement.getBoundingClientRect();
158
- const distance = { x: targetRect.left - tableRect.left, y: targetRect.top - tableRect.top };
159
- this.draglineElementRef.nativeElement.style.left = `${distance.x}px`;
160
- this.draglineElementRef.nativeElement.style.display = 'block';
161
- }
162
-
163
- private hideAuxiliaryLine() {
164
- this.draglineElementRef.nativeElement.style.display = 'none';
165
- }
166
- }
@@ -1,129 +0,0 @@
1
- import { fakeAsync, TestBed, ComponentFixture, async, inject, flush } from '@angular/core/testing';
2
- import { Component, ViewChild, DebugElement } from '@angular/core';
3
- import { NgxGanttModule } from 'ngx-gantt';
4
- import { By } from '@angular/platform-browser';
5
- import { GanttTableComponent } from '../gantt-table.component';
6
- import { getMockGroupItems, getMockGroups} from '../../../test/mocks/data';
7
- import { dispatchMouseEvent } from '../../../utils/testing';
8
- @Component({
9
- selector: 'test-gantt-table',
10
- template: `
11
- <ngx-gantt #gantt [items]="items" [groups]="groups">
12
- <ngx-gantt-table>
13
- <ngx-gantt-column [width]="200" name="标题">
14
- <ng-template #cell let-item="item">
15
- {{ item.title }}
16
- </ng-template>
17
- </ngx-gantt-column>
18
- </ngx-gantt-table>
19
- </ngx-gantt>
20
- `,
21
- providers: []
22
- })
23
- export class TestGanttTableComponent {
24
- @ViewChild(GanttTableComponent, { static: true }) ganttTableComponent: GanttTableComponent;
25
-
26
- items = getMockGroupItems();
27
-
28
- groups = getMockGroups();
29
-
30
- constructor() {}
31
- }
32
-
33
- describe('GanttTable', () => {
34
- let component: TestGanttTableComponent;
35
- let fixture: ComponentFixture<TestGanttTableComponent>;
36
-
37
- beforeEach(async(() => {
38
- TestBed.configureTestingModule({
39
- imports: [NgxGanttModule],
40
- declarations: [TestGanttTableComponent]
41
- }).compileComponents();
42
- }));
43
-
44
- beforeEach(() => {
45
- fixture = TestBed.createComponent(TestGanttTableComponent);
46
- component = fixture.componentInstance;
47
- fixture.detectChanges();
48
- });
49
-
50
- it('should create gantt-table', () => {
51
- expect(component).toBeDefined();
52
- const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
53
- expect(ganttTable).toBeTruthy();
54
- expect(ganttTable.nativeElement).toBeTruthy();
55
- });
56
-
57
- it('should expand groups', () => {
58
- const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
59
- expect(ganttTable.query(By.css('.gantt-table-group-title')).nativeNode.classList.contains('expanded')).toBeTruthy();
60
- ganttTable.query(By.css('.gantt-table-group-title')).nativeNode.click();
61
- fixture.detectChanges();
62
- expect(ganttTable.query(By.css('.gantt-table-group-title')).nativeNode.classList.contains('expanded')).toBeFalsy();
63
- });
64
-
65
- it('should expand children', () => {
66
- const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
67
- const tableChildrenLength = ganttTable.query(By.css('.gantt-table-body')).children.length;
68
- ganttTable.nativeElement.querySelector('.gantt-table-item-with-group .gantt-expand-icon .expand-icon').click();
69
- fixture.detectChanges();
70
- expect(ganttTable.query(By.css('.gantt-table-body')).children.length).toEqual(tableChildrenLength + 1);
71
- });
72
-
73
- it('should column drag', fakeAsync(() => {
74
- const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
75
- const dragTrigger = ganttTable.nativeElement.querySelector('.gantt-table-header .gantt-table-column .gantt-table-drag-trigger');
76
- fixture.detectChanges();
77
- flush();
78
-
79
- const dragTriggerRight = dragTrigger.getBoundingClientRect().right;
80
-
81
- dispatchMouseEvent(dragTrigger, 'mousedown');
82
- fixture.detectChanges();
83
- flush();
84
-
85
- dispatchMouseEvent(document, 'mousemove', 200);
86
- fixture.detectChanges();
87
- flush();
88
- fixture.detectChanges();
89
-
90
- dispatchMouseEvent(document, 'mousemove', 250);
91
- fixture.detectChanges();
92
- flush();
93
- fixture.detectChanges();
94
-
95
- dispatchMouseEvent(document, 'mouseup');
96
- fixture.detectChanges();
97
- flush();
98
-
99
- expect(dragTrigger.getBoundingClientRect().right).not.toBe(dragTriggerRight);
100
- }));
101
-
102
- it('should table drag', fakeAsync(() => {
103
- const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
104
- const dragTrigger = ganttTable.nativeElement.children[2];
105
- fixture.detectChanges();
106
-
107
- const dragTriggerRight = dragTrigger.getBoundingClientRect().right;
108
-
109
- dispatchMouseEvent(dragTrigger, 'mousedown');
110
- fixture.detectChanges();
111
- flush();
112
-
113
- dispatchMouseEvent(document, 'mousemove', 250, 150);
114
- fixture.detectChanges();
115
- flush();
116
- fixture.detectChanges();
117
-
118
- dispatchMouseEvent(document, 'mousemove', 50, 50);
119
- fixture.detectChanges();
120
- flush();
121
- fixture.detectChanges();
122
-
123
- dispatchMouseEvent(document, 'mouseup');
124
- fixture.detectChanges();
125
- flush();
126
-
127
- expect(dragTrigger.getBoundingClientRect().left).not.toBe(dragTriggerRight);
128
- }));
129
- });