@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,404 +0,0 @@
1
- import { GanttGroupInternal } from './../class/group';
2
- import { GanttItemInternal } from './../class/item';
3
- import { Component, DebugElement, ViewChild } from '@angular/core';
4
- import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
5
- import { By } from '@angular/platform-browser';
6
- import { GanttBarClickEvent, GanttGroup, GanttItem } from '../class';
7
- import { GanttViewType } from '../class/view-type';
8
- import { GanttPrintService } from '../gantt-print.service';
9
- import { NgxGanttComponent } from '../gantt.component';
10
- import { NgxGanttModule } from '../gantt.module';
11
- import { GanttDate } from '../utils/date';
12
- import { getMockGroupItems, getMockGroups, getMockItems } from './mocks/data';
13
- import { CommonModule } from '@angular/common';
14
- import { GanttCalendarComponent } from '../components/calendar/calendar.component';
15
- import { NgxGanttBarComponent } from '../components/bar/bar.component';
16
- import { GanttIconComponent } from '../components/icon/icon.component';
17
- import { NgxGanttRootComponent } from '../root.component';
18
- import { of } from 'rxjs';
19
- import { delay } from 'rxjs/operators';
20
-
21
- const mockItems = getMockItems();
22
- const mockGroupItems = getMockGroupItems();
23
- const mockGroups = getMockGroups();
24
-
25
- // Basic Component
26
- @Component({
27
- selector: 'test-gantt-basic',
28
- template: ` <ngx-gantt #gantt [start]="start" [end]="end" [items]="items" [viewType]="viewType" (barClick)="barClick($event)">
29
- <ngx-gantt-table>
30
- <ngx-gantt-column name="标题" width="200px">
31
- <ng-template #cell let-item="item">
32
- {{ item.title }}
33
- </ng-template>
34
- </ngx-gantt-column>
35
- </ngx-gantt-table>
36
- </ngx-gantt>`
37
- })
38
- export class TestGanttBasicComponent {
39
- @ViewChild('gantt') ganttComponent: NgxGanttComponent;
40
-
41
- constructor() {}
42
-
43
- start = new GanttDate('2020-09-02 00:00:00').getUnixTime();
44
-
45
- end = new GanttDate('2021-12-01 00:00:00').getUnixTime();
46
-
47
- viewType = 'month';
48
-
49
- items = mockItems;
50
-
51
- barClick(event: GanttBarClickEvent) {
52
- console.log(event);
53
- }
54
- }
55
-
56
- // With Group Component
57
- @Component({
58
- selector: 'test-gantt-with-groups',
59
- template: ` <button class="expand" (click)="gantt.expandAll()">全部展开</button>
60
- <button class="collapse" (click)="gantt.collapseAll()">全部收起</button>
61
- <ngx-gantt #gantt [groups]="groups" [items]="items" [viewType]="viewType" [disabledLoadOnScroll]="true">
62
- <ng-template #groupHeader let-group="group">
63
- <div class="test-gantt-with-groups-group-header"></div>
64
- </ng-template>
65
- <ng-template #group let-group="group">
66
- <div class="test-gantt-with-groups-group"></div>
67
- </ng-template>
68
- <ngx-gantt-table>
69
- <ngx-gantt-column name="标题" width="200px">
70
- <ng-template #cell let-item="item">
71
- {{ item.title }}
72
- </ng-template>
73
- </ngx-gantt-column>
74
- </ngx-gantt-table>
75
- </ngx-gantt>`
76
- })
77
- export class TestGanttWithGroupsComponent {
78
- @ViewChild('gantt') ganttComponent: NgxGanttComponent;
79
-
80
- constructor() {}
81
-
82
- viewType = 'month';
83
-
84
- groups = mockGroups;
85
-
86
- items = mockGroupItems;
87
- }
88
-
89
- // load children
90
- @Component({
91
- selector: 'test-gantt-load-children',
92
- template: ` <ngx-gantt #gantt [items]="items" [viewType]="viewType" [async]="async" [childrenResolve]="childrenResolve">
93
- <ngx-gantt-table>
94
- <ngx-gantt-column name="标题" width="200px">
95
- <ng-template #cell let-item="item">
96
- {{ item.title }}
97
- </ng-template>
98
- </ngx-gantt-column>
99
- </ngx-gantt-table>
100
- </ngx-gantt>`
101
- })
102
- export class TestGanttLoadChildrenComponent {
103
- @ViewChild('gantt') ganttComponent: NgxGanttComponent;
104
-
105
- constructor() {}
106
-
107
- viewType = 'month';
108
-
109
- items = mockItems;
110
-
111
- async = false;
112
-
113
- childrenResolve = this.getChildren.bind(this);
114
-
115
- getChildren() {
116
- return of([
117
- {
118
- id: new Date().getTime(),
119
- title: new Date().getTime(),
120
- start: Math.floor(new Date().getTime() / 1000),
121
- draggable: true,
122
- linkable: false
123
- }
124
- ]).pipe(delay(1000));
125
- }
126
- }
127
-
128
- interface TestGanttComponentBase {
129
- ganttComponent: NgxGanttComponent;
130
- }
131
-
132
- function assertGanttView<T extends TestGanttComponentBase>(
133
- fixture: ComponentFixture<T>,
134
- expected: {
135
- firstPrimaryDataPointText: string;
136
- lastPrimaryDataPointText: string;
137
- firstSecondaryDataPointText: string;
138
- lastSecondaryDataPointText: string;
139
- }
140
- ) {
141
- const calendarElement = fixture.debugElement.query(By.directive(GanttCalendarComponent));
142
- const primaryElements = calendarElement.queryAll(By.css('.primary-text'));
143
- const secondaryElements = calendarElement.queryAll(By.css('.secondary-text'));
144
- expect(primaryElements.length).toEqual(fixture.componentInstance.ganttComponent.view.primaryDatePoints.length);
145
- expect(secondaryElements.length).toEqual(fixture.componentInstance.ganttComponent.view.secondaryDatePoints.length);
146
- expect(primaryElements[0].nativeElement.textContent).toContain(expected.firstPrimaryDataPointText);
147
- expect(primaryElements[primaryElements.length - 1].nativeElement.textContent).toContain(expected.lastPrimaryDataPointText);
148
- expect(secondaryElements[0].nativeElement.textContent).toContain(expected.firstSecondaryDataPointText);
149
- expect(secondaryElements[secondaryElements.length - 1].nativeElement.textContent).toContain(expected.lastSecondaryDataPointText);
150
- }
151
-
152
- function assertItem(item: DebugElement, ganttItem: GanttItemInternal) {
153
- const elem = item.nativeElement as HTMLElement;
154
- const top = elem.style.getPropertyValue('top');
155
- const left = elem.style.getPropertyValue('left');
156
- const width = elem.style.getPropertyValue('width');
157
- expect(top).toEqual(ganttItem.refs.y + 'px');
158
- expect(left).toEqual(ganttItem.refs.x + 'px');
159
- expect(width).toEqual(ganttItem.refs.width + 'px');
160
- }
161
-
162
- function assertItems<T extends TestGanttComponentBase>(fixture: ComponentFixture<T>, expectedItems: GanttItem[]) {
163
- const ganttComponent = fixture.componentInstance.ganttComponent;
164
- const items = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent));
165
- expect(items.length).toEqual(expectedItems.length);
166
- items.forEach((item: DebugElement, index: number) => {
167
- expect(ganttComponent.items[index].id).toEqual(expectedItems[index].id);
168
- assertItem(item, ganttComponent.items[index]);
169
- });
170
- }
171
-
172
- function assertGroups<T extends TestGanttComponentBase>(fixture: ComponentFixture<T>, expectedGroups: GanttGroup[]) {
173
- const ganttComponent = fixture.componentInstance.ganttComponent;
174
- const groups = fixture.debugElement.queryAll(By.css('.gantt-group'));
175
- groups.forEach((group: DebugElement, groupIndex: number) => {
176
- expect(ganttComponent.groups[groupIndex].id).toEqual(expectedGroups[groupIndex].id);
177
- const items = group.queryAll(By.directive(NgxGanttBarComponent));
178
- items.forEach((item: DebugElement, itemIndex: number) => {
179
- assertItem(item, ganttComponent.groups[groupIndex].items[itemIndex]);
180
- });
181
- });
182
- }
183
-
184
- describe('ngx-gantt', () => {
185
- describe('#basic', () => {
186
- let fixture: ComponentFixture<TestGanttBasicComponent>;
187
- let ganttComponentInstance: TestGanttBasicComponent;
188
- let ganttDebugElement: DebugElement;
189
- let ganttComponent: NgxGanttComponent;
190
-
191
- beforeEach(async () => {
192
- TestBed.configureTestingModule({
193
- imports: [CommonModule, NgxGanttModule],
194
- declarations: [TestGanttBasicComponent],
195
- providers: [GanttPrintService]
196
- }).compileComponents();
197
- fixture = TestBed.createComponent(TestGanttBasicComponent);
198
- fixture.detectChanges();
199
- ganttDebugElement = fixture.debugElement.query(By.directive(NgxGanttComponent));
200
- ganttComponentInstance = fixture.componentInstance;
201
- ganttComponent = ganttComponentInstance.ganttComponent;
202
- fixture.detectChanges();
203
- });
204
-
205
- it('should create ganttComponent', () => {
206
- expect(ganttComponentInstance).toBeTruthy();
207
- });
208
-
209
- it('should render month view', () => {
210
- assertGanttView(fixture, {
211
- firstPrimaryDataPointText: '2020年Q3',
212
- lastPrimaryDataPointText: '2021年Q4',
213
- firstSecondaryDataPointText: '7月',
214
- lastSecondaryDataPointText: '12月'
215
- });
216
- });
217
-
218
- it('should render items', () => {
219
- assertItems(fixture, mockItems);
220
- });
221
-
222
- it('should bar click', fakeAsync(() => {
223
- const barClickSpy = spyOn(ganttComponentInstance, 'barClick').and.callFake((event: GanttBarClickEvent) => {
224
- expect(event.event.type).toEqual('click');
225
- expect(event.item.title).toEqual(mockItems[0].title);
226
- });
227
- const bar = fixture.debugElement.query(By.directive(NgxGanttBarComponent)).query(By.css('.gantt-bar-content'));
228
- bar.nativeElement.click();
229
- expect(barClickSpy).toHaveBeenCalledTimes(1);
230
- }));
231
-
232
- it('should register print service', () => {
233
- expect(TestBed.inject(GanttPrintService)['root']).toEqual(
234
- ganttDebugElement.query(By.directive(NgxGanttRootComponent)).nativeElement
235
- );
236
- });
237
-
238
- it('should re render view when change view type', () => {
239
- ganttComponentInstance.viewType = GanttViewType.day;
240
- fixture.detectChanges();
241
- assertGanttView(fixture, {
242
- firstPrimaryDataPointText: '2020年09月',
243
- lastPrimaryDataPointText: '2021年12月',
244
- firstSecondaryDataPointText: '31',
245
- lastSecondaryDataPointText: '5'
246
- });
247
- });
248
-
249
- it('should re render items when change items', () => {
250
- const newItems = mockItems.slice(0, 5);
251
- ganttComponentInstance.items = [...newItems];
252
- fixture.detectChanges();
253
- assertItems(fixture, newItems);
254
- });
255
-
256
- it('should has empty class when has no items', () => {
257
- ganttComponentInstance.items = [];
258
- fixture.detectChanges();
259
- const ganttTableElement = ganttDebugElement.query(By.css('.gantt-table'));
260
- expect(ganttTableElement.nativeElement.classList).toContain('gantt-table-empty');
261
- });
262
-
263
- it('should re render when scroll load', () => {});
264
- });
265
-
266
- describe('#with groups', () => {
267
- let fixture: ComponentFixture<TestGanttWithGroupsComponent>;
268
- let ganttComponentInstance: TestGanttWithGroupsComponent;
269
- let ganttDebugElement: DebugElement;
270
- let ganttComponent: NgxGanttComponent;
271
-
272
- beforeEach(async () => {
273
- TestBed.configureTestingModule({
274
- imports: [CommonModule, NgxGanttModule],
275
- declarations: [TestGanttWithGroupsComponent],
276
- providers: [GanttPrintService]
277
- }).compileComponents();
278
- fixture = TestBed.createComponent(TestGanttWithGroupsComponent);
279
- fixture.detectChanges();
280
- ganttDebugElement = fixture.debugElement.query(By.directive(NgxGanttComponent));
281
- ganttComponentInstance = fixture.componentInstance;
282
- ganttComponent = ganttComponentInstance.ganttComponent;
283
- fixture.detectChanges();
284
- });
285
-
286
- it('should render groups', () => {
287
- const groups = fixture.debugElement.queryAll(By.css('.gantt-group'));
288
- expect(groups.length).toEqual(mockGroups.length);
289
- });
290
-
291
- it('should render group items', () => {
292
- assertGroups(fixture, mockGroups);
293
- });
294
-
295
- it('should render custom group template', () => {
296
- const groups = fixture.debugElement.queryAll(By.css('.test-gantt-with-groups-group'));
297
- const groupHeaders = fixture.debugElement.queryAll(By.css('.test-gantt-with-groups-group-header'));
298
- expect(groups.length).toEqual(mockGroups.length);
299
- expect(groupHeaders.length).toEqual(mockGroups.length);
300
- });
301
-
302
- it('should re render groups when change groups', () => {
303
- const newGroups = mockItems.slice(0, 2);
304
- ganttComponentInstance.groups = [...newGroups];
305
- fixture.detectChanges();
306
- assertGroups(fixture, newGroups);
307
- });
308
-
309
- it('should group can be expanded', () => {
310
- const groupTitle = fixture.debugElement.query(By.css('.gantt-table-group-title'));
311
- groupTitle.nativeElement.click();
312
- const afterCollapseItems = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent));
313
- expect(ganttComponent.groups[0].expanded).toBe(false);
314
- expect(afterCollapseItems.length).toEqual(mockGroupItems.length - ganttComponent.groups[0].items.length);
315
-
316
- groupTitle.nativeElement.click();
317
- const afterExpandItems = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent));
318
- expect(ganttComponent.groups[0].expanded).toBe(true);
319
- expect(afterExpandItems.length).toEqual(mockGroupItems.length);
320
- });
321
-
322
- it('should expand all groups ', () => {
323
- const groupExpandAll = fixture.debugElement.query(By.css('.expand'));
324
- groupExpandAll.nativeElement.click();
325
- const afterExpandItems = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent));
326
- ganttComponent.groups.forEach((group: GanttGroupInternal) => {
327
- expect(group.expanded).toBe(true);
328
- });
329
- expect(afterExpandItems.length).toEqual(mockGroupItems.length);
330
- });
331
-
332
- it('should collapse all groups ', () => {
333
- const groupCollapseAll = fixture.debugElement.query(By.css('.collapse'));
334
- groupCollapseAll.nativeElement.click();
335
- const afterCollapseItems = fixture.debugElement.queryAll(By.directive(NgxGanttBarComponent));
336
- ganttComponent.groups.forEach((group: GanttGroupInternal) => {
337
- expect(group.expanded).toBe(false);
338
- });
339
- expect(afterCollapseItems.length).toEqual(0);
340
- });
341
- });
342
-
343
- describe('#load children', () => {
344
- let fixture: ComponentFixture<TestGanttLoadChildrenComponent>;
345
- let ganttComponentInstance: TestGanttLoadChildrenComponent;
346
- let ganttDebugElement: DebugElement;
347
- let ganttComponent: NgxGanttComponent;
348
-
349
- beforeEach(async () => {
350
- TestBed.configureTestingModule({
351
- imports: [CommonModule, NgxGanttModule],
352
- declarations: [TestGanttLoadChildrenComponent],
353
- providers: [GanttPrintService]
354
- }).compileComponents();
355
- fixture = TestBed.createComponent(TestGanttLoadChildrenComponent);
356
- fixture.detectChanges();
357
- ganttDebugElement = fixture.debugElement.query(By.directive(NgxGanttComponent));
358
- ganttComponentInstance = fixture.componentInstance;
359
- ganttComponent = ganttComponentInstance.ganttComponent;
360
- fixture.detectChanges();
361
- });
362
-
363
- it('should show expand icon and load children', () => {
364
- const ganttIcons = fixture.debugElement.queryAll(By.directive(GanttIconComponent));
365
- expect(ganttIcons.length).toEqual(2);
366
- });
367
-
368
- it('should load children', () => {
369
- const ganttIcon = fixture.debugElement.queryAll(By.directive(GanttIconComponent))[0];
370
- ganttIcon.nativeElement.click();
371
- fixture.detectChanges();
372
- const afterExpandItems = fixture.debugElement.queryAll(By.css('.gantt-table-item'));
373
- expect(ganttComponent.items[0].expanded).toBe(true);
374
- expect(afterExpandItems.length).toEqual(mockItems.length + ganttComponent.items[0].children.length);
375
-
376
- ganttIcon.nativeElement.click();
377
- fixture.detectChanges();
378
- const afterCollapseItems = fixture.debugElement.queryAll(By.css('.gantt-table-item'));
379
- expect(ganttComponent.items[0].expanded).toBe(false);
380
- expect(afterCollapseItems.length).toEqual(mockItems.length);
381
- });
382
-
383
- it('should load async children', fakeAsync(() => {
384
- ganttComponentInstance.async = true;
385
- fixture.detectChanges();
386
- const ganttIcon = fixture.debugElement.queryAll(By.directive(GanttIconComponent))[1];
387
- ganttIcon.nativeElement.click();
388
- tick(2000);
389
- fixture.detectChanges();
390
- const afterExpandItems = fixture.debugElement.queryAll(By.css('.gantt-table-item'));
391
- expect(ganttComponent.items[1].expanded).toBe(true);
392
- expect(afterExpandItems.length).toEqual(mockItems.length + 1);
393
-
394
- ganttIcon.nativeElement.click();
395
- tick(2000);
396
- fixture.detectChanges();
397
- const afterCollapseItems = fixture.debugElement.queryAll(By.css('.gantt-table-item'));
398
- expect(ganttComponent.items[1].expanded).toBe(false);
399
- expect(afterCollapseItems.length).toEqual(mockItems.length);
400
- }));
401
- });
402
-
403
- describe('#draggable', () => {});
404
- });