@worktile/gantt 12.0.1 → 12.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -116
- package/bundles/worktile-gantt.umd.js +3369 -0
- package/bundles/worktile-gantt.umd.js.map +1 -0
- package/class/date-point.d.ts +15 -0
- package/{packages/gantt/src/class/event.ts → class/event.d.ts} +6 -12
- package/class/group.d.ts +22 -0
- package/{packages/gantt/src/class/index.ts → class/index.d.ts} +0 -0
- package/class/item.d.ts +70 -0
- package/class/view-type.d.ts +7 -0
- package/components/bar/bar-drag.d.ts +37 -0
- package/components/bar/bar.component.d.ts +26 -0
- package/components/calendar/calendar.component.d.ts +28 -0
- package/components/drag-backdrop/drag-backdrop.component.d.ts +9 -0
- package/components/icon/icon.component.d.ts +13 -0
- package/components/icon/icons.d.ts +8 -0
- package/components/links/links.component.d.ts +47 -0
- package/components/main/gantt-main.component.d.ts +21 -0
- package/components/range/range.component.d.ts +13 -0
- package/components/table/gantt-table.component.d.ts +37 -0
- package/esm2015/class/date-point.js +10 -0
- package/esm2015/class/event.js +13 -0
- package/esm2015/class/group.js +17 -0
- package/esm2015/class/index.js +6 -0
- package/esm2015/class/item.js +78 -0
- package/esm2015/class/view-type.js +9 -0
- package/esm2015/components/bar/bar-drag.js +269 -0
- package/esm2015/components/bar/bar.component.js +98 -0
- package/esm2015/components/calendar/calendar.component.js +86 -0
- package/esm2015/components/drag-backdrop/drag-backdrop.component.js +21 -0
- package/esm2015/components/icon/icon.component.js +38 -0
- package/esm2015/components/icon/icons.js +87 -0
- package/esm2015/components/links/links.component.js +213 -0
- package/esm2015/components/main/gantt-main.component.js +53 -0
- package/esm2015/components/range/range.component.js +37 -0
- package/esm2015/components/table/gantt-table.component.js +149 -0
- package/esm2015/gantt-abstract.js +3 -0
- package/esm2015/gantt-dom.service.js +103 -0
- package/esm2015/gantt-drag-container.js +60 -0
- package/esm2015/gantt-item-upper.js +58 -0
- package/esm2015/gantt-print.service.js +94 -0
- package/esm2015/gantt-upper.js +280 -0
- package/esm2015/gantt.component.js +135 -0
- package/esm2015/gantt.config.js +13 -0
- package/esm2015/gantt.module.js +85 -0
- package/esm2015/gantt.pipe.js +43 -0
- package/esm2015/gantt.styles.js +15 -0
- package/esm2015/public-api.js +19 -0
- package/esm2015/root.component.js +123 -0
- package/esm2015/table/gantt-column.component.js +37 -0
- package/esm2015/table/gantt-table.component.js +20 -0
- package/esm2015/utils/date.js +160 -0
- package/esm2015/utils/helpers.js +55 -0
- package/esm2015/views/day.js +54 -0
- package/esm2015/views/factory.js +23 -0
- package/esm2015/views/month.js +48 -0
- package/esm2015/views/quarter.js +51 -0
- package/esm2015/views/view.js +123 -0
- package/esm2015/views/week.js +49 -0
- package/esm2015/views/year.js +50 -0
- package/esm2015/worktile-gantt.js +5 -0
- package/fesm2015/worktile-gantt.js +2697 -0
- package/fesm2015/worktile-gantt.js.map +1 -0
- package/{packages/gantt/src/gantt-abstract.ts → gantt-abstract.d.ts} +1 -3
- package/gantt-dom.service.d.ts +32 -0
- package/gantt-drag-container.d.ts +24 -0
- package/gantt-item-upper.d.ts +20 -0
- package/gantt-print.service.d.ts +13 -0
- package/gantt-upper.d.ts +69 -0
- package/gantt.component.d.ts +30 -0
- package/gantt.config.d.ts +23 -0
- package/gantt.module.d.ts +21 -0
- package/gantt.pipe.d.ts +18 -0
- package/gantt.styles.d.ts +15 -0
- package/main.bundle.scss +645 -0
- package/package.json +16 -113
- package/{packages/gantt/src/public-api.ts → public-api.d.ts} +1 -4
- package/root.component.d.ts +28 -0
- package/table/gantt-column.component.d.ts +15 -0
- package/table/gantt-table.component.d.ts +10 -0
- package/utils/date.d.ts +59 -0
- package/utils/helpers.d.ts +12 -0
- package/views/day.d.ts +14 -0
- package/views/factory.d.ts +8 -0
- package/views/month.d.ts +12 -0
- package/views/quarter.d.ts +12 -0
- package/views/view.d.ts +58 -0
- package/views/week.d.ts +12 -0
- package/views/year.d.ts +12 -0
- package/worktile-gantt.d.ts +5 -0
- package/.all-contributorsrc +0 -53
- package/.angulardoc.json +0 -4
- package/.circleci/config.yml +0 -17
- package/.coveralls.yml +0 -1
- package/.docgenirc.js +0 -64
- package/.editorconfig +0 -22
- package/.prettierrc +0 -24
- package/.travis.yml +0 -23
- package/CHANGELOG.md +0 -564
- package/Dockerfile +0 -4
- package/LICENSE +0 -21
- package/angular.json +0 -136
- package/docs/guides/basic/components.md +0 -54
- package/docs/guides/basic/event.md +0 -70
- package/docs/guides/basic/index.md +0 -4
- package/docs/guides/basic/style.md +0 -68
- package/docs/guides/basic/type.md +0 -70
- package/docs/guides/basic/usage.md +0 -189
- package/docs/guides/index.md +0 -5
- package/docs/guides/intro/getting-started.md +0 -79
- package/docs/guides/intro/index.md +0 -51
- package/docs/index.md +0 -0
- package/example/browserslist +0 -12
- package/example/src/app/app-routing.module.ts +0 -26
- package/example/src/app/app.component.html +0 -2
- package/example/src/app/app.component.ts +0 -11
- package/example/src/app/app.module.ts +0 -57
- package/example/src/app/components/components.component.html +0 -6
- package/example/src/app/components/components.component.ts +0 -33
- package/example/src/app/configuration/parameters/api/zh-cn.js +0 -350
- package/example/src/app/configuration/parameters/doc/zh-cn.md +0 -5
- package/example/src/app/gantt/gantt.component.html +0 -51
- package/example/src/app/gantt/gantt.component.ts +0 -119
- package/example/src/app/gantt-advanced/component/flat.component.html +0 -30
- package/example/src/app/gantt-advanced/component/flat.component.ts +0 -72
- package/example/src/app/gantt-advanced/component/flat.scss +0 -31
- package/example/src/app/gantt-advanced/gantt-advanced.component.html +0 -32
- package/example/src/app/gantt-advanced/gantt-advanced.component.ts +0 -34
- package/example/src/app/gantt-advanced/mocks.ts +0 -158
- package/example/src/app/gantt-groups/gantt-groups.component.html +0 -42
- package/example/src/app/gantt-groups/gantt-groups.component.ts +0 -62
- package/example/src/app/gantt-range/gantt-range.component.html +0 -66
- package/example/src/app/gantt-range/gantt-range.component.ts +0 -67
- package/example/src/app/gantt-range/mocks.ts +0 -150
- package/example/src/app/helper.ts +0 -38
- package/example/src/assets/.gitkeep +0 -0
- package/example/src/environments/environment.prod.ts +0 -3
- package/example/src/environments/environment.ts +0 -16
- package/example/src/favicon.ico +0 -0
- package/example/src/index.html +0 -13
- package/example/src/main.ts +0 -12
- package/example/src/polyfills.ts +0 -63
- package/example/src/styles.scss +0 -56
- package/example/tsconfig.app.json +0 -18
- package/nginx.conf +0 -17
- package/packages/gantt/README.md +0 -24
- package/packages/gantt/karma.conf.js +0 -46
- package/packages/gantt/ng-package.json +0 -7
- package/packages/gantt/ng-package.prod.json +0 -7
- package/packages/gantt/package.json +0 -16
- package/packages/gantt/src/class/date-point.ts +0 -14
- package/packages/gantt/src/class/group.ts +0 -36
- package/packages/gantt/src/class/item.ts +0 -129
- package/packages/gantt/src/class/test/group.spec.ts +0 -21
- package/packages/gantt/src/class/test/item.spec.ts +0 -102
- package/packages/gantt/src/class/view-type.ts +0 -7
- package/packages/gantt/src/components/bar/bar-drag.ts +0 -298
- package/packages/gantt/src/components/bar/bar.component.html +0 -17
- package/packages/gantt/src/components/bar/bar.component.scss +0 -169
- package/packages/gantt/src/components/bar/bar.component.ts +0 -109
- package/packages/gantt/src/components/bar/test/bar.component.spec.ts +0 -54
- package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +0 -196
- package/packages/gantt/src/components/calendar/calendar.component.html +0 -52
- package/packages/gantt/src/components/calendar/calendar.component.scss +0 -77
- package/packages/gantt/src/components/calendar/calendar.component.ts +0 -100
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +0 -6
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +0 -48
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +0 -13
- package/packages/gantt/src/components/icon/icon.component.scss +0 -13
- package/packages/gantt/src/components/icon/icon.component.ts +0 -28
- package/packages/gantt/src/components/icon/icons.ts +0 -86
- package/packages/gantt/src/components/links/links.component.html +0 -19
- package/packages/gantt/src/components/links/links.component.scss +0 -27
- package/packages/gantt/src/components/links/links.component.ts +0 -263
- package/packages/gantt/src/components/main/gantt-main.component.html +0 -35
- package/packages/gantt/src/components/main/gantt-main.component.ts +0 -35
- package/packages/gantt/src/components/range/range.component.html +0 -8
- package/packages/gantt/src/components/range/range.component.scss +0 -35
- package/packages/gantt/src/components/range/range.component.ts +0 -27
- package/packages/gantt/src/components/range/test/range.component.spec.ts +0 -80
- package/packages/gantt/src/components/table/gantt-table.component.html +0 -105
- package/packages/gantt/src/components/table/gantt-table.component.scss +0 -144
- package/packages/gantt/src/components/table/gantt-table.component.ts +0 -166
- package/packages/gantt/src/components/table/test/table.spec.ts +0 -129
- package/packages/gantt/src/gantt-dom.service.ts +0 -134
- package/packages/gantt/src/gantt-drag-container.ts +0 -73
- package/packages/gantt/src/gantt-item-upper.ts +0 -50
- package/packages/gantt/src/gantt-print.service.ts +0 -104
- package/packages/gantt/src/gantt-upper.ts +0 -289
- package/packages/gantt/src/gantt.component.html +0 -18
- package/packages/gantt/src/gantt.component.scss +0 -77
- package/packages/gantt/src/gantt.component.ts +0 -134
- package/packages/gantt/src/gantt.module.ts +0 -47
- package/packages/gantt/src/gantt.pipe.ts +0 -31
- package/packages/gantt/src/gantt.styles.ts +0 -28
- package/packages/gantt/src/root.component.html +0 -12
- package/packages/gantt/src/root.component.ts +0 -121
- package/packages/gantt/src/styles/index.scss +0 -9
- package/packages/gantt/src/styles/variables.scss +0 -46
- package/packages/gantt/src/table/gantt-column.component.ts +0 -25
- package/packages/gantt/src/table/gantt-table.component.ts +0 -14
- package/packages/gantt/src/table/test/table.spec.ts +0 -56
- package/packages/gantt/src/test/gantt.component.spec.ts +0 -404
- package/packages/gantt/src/test/mocks/data.ts +0 -303
- package/packages/gantt/src/test.ts +0 -21
- package/packages/gantt/src/utils/date.ts +0 -276
- package/packages/gantt/src/utils/helpers.ts +0 -66
- package/packages/gantt/src/utils/test/date.spec.ts +0 -105
- package/packages/gantt/src/utils/test/helpers.spec.ts +0 -73
- package/packages/gantt/src/utils/testing.ts +0 -64
- package/packages/gantt/src/views/day.ts +0 -74
- package/packages/gantt/src/views/factory.ts +0 -25
- package/packages/gantt/src/views/month.ts +0 -66
- package/packages/gantt/src/views/quarter.ts +0 -68
- package/packages/gantt/src/views/test/day.spec.ts +0 -45
- package/packages/gantt/src/views/test/factory.spec.ts +0 -41
- package/packages/gantt/src/views/test/mock.ts +0 -14
- package/packages/gantt/src/views/test/month.spec.ts +0 -45
- package/packages/gantt/src/views/test/quarter.spec.ts +0 -45
- package/packages/gantt/src/views/test/view.spec.ts +0 -144
- package/packages/gantt/src/views/test/week.spec.ts +0 -45
- package/packages/gantt/src/views/test/year.spec.ts +0 -45
- package/packages/gantt/src/views/view.ts +0 -186
- package/packages/gantt/src/views/week.ts +0 -66
- package/packages/gantt/src/views/year.ts +0 -62
- package/packages/gantt/tsconfig.lib.json +0 -20
- package/packages/gantt/tsconfig.lib.prod.json +0 -9
- package/packages/gantt/tsconfig.schematics.json +0 -25
- package/packages/gantt/tsconfig.spec.json +0 -17
- package/packages/gantt/tslint.json +0 -18
- package/scss-bundle.config.json +0 -7
- package/tsconfig.json +0 -26
- package/tslint.json +0 -51
|
@@ -1,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
|
-
});
|