@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,144 +0,0 @@
1
- import { GanttDatePoint } from '../../class';
2
- import { GanttDate } from '../../utils/date';
3
-
4
- import { GanttView, GanttViewDate, GanttViewOptions } from '../view';
5
- import { date, today } from './mock';
6
-
7
- class GanttViewMock extends GanttView {
8
- constructor(start: GanttViewDate, end: GanttViewDate, options?: GanttViewOptions) {
9
- super(start, end, options);
10
- }
11
-
12
- startOf(): GanttDate {
13
- return new GanttDate('2020-01-01 00:00:00');
14
- }
15
-
16
- endOf(): GanttDate {
17
- return new GanttDate('2020-12-31 23:59:59');
18
- }
19
-
20
- getPrimaryWidth(): number {
21
- return 3640;
22
- }
23
-
24
- getDayOccupancyWidth(): number {
25
- return 10;
26
- }
27
-
28
- getPrimaryDatePoints(): GanttDatePoint[] {
29
- return [
30
- {
31
- text: '2020年',
32
- x: 1820,
33
- y: 18,
34
- start: new GanttDate('2020-01-01 00:00:00')
35
- }
36
- ];
37
- }
38
-
39
- getSecondaryDatePoints(): GanttDatePoint[] {
40
- return [
41
- {
42
- text: 'Q1',
43
- x: 455,
44
- y: 36,
45
- start: new GanttDate('2020-01-01 00:00:00')
46
- },
47
- {
48
- text: 'Q2',
49
- x: 1365,
50
- y: 36,
51
- start: new GanttDate('2020-04-01 00:00:00')
52
- },
53
- { text: 'Q3', x: 2275, y: 36, start: new GanttDate('2020-07-01 00:00:00') },
54
- { text: 'Q4', x: 3185, y: 36, start: new GanttDate('2020-10-01 00:00:00') }
55
- ];
56
- }
57
- }
58
-
59
- describe('GanttView', () => {
60
- let ganttView: GanttView;
61
-
62
- beforeEach(() => {
63
- ganttView = new GanttViewMock(date.start, date.end, {
64
- cellWidth: 20,
65
- start: today.startOfYear().startOfWeek({ weekStartsOn: 1 }),
66
- end: today.endOfYear().endOfWeek({ weekStartsOn: 1 })
67
- });
68
- });
69
-
70
- it(`should has correct view options`, () => {
71
- const options = ganttView.options;
72
- const cellWidth = options.cellWidth;
73
- const start = options.start.getUnixTime();
74
- const end = options.end.getUnixTime();
75
- const max = options.max.getUnixTime();
76
- const min = options.min.getUnixTime();
77
-
78
- expect(cellWidth).toEqual(20);
79
- expect(start).toEqual(new GanttDate('2019-12-30 00:00:00').getUnixTime());
80
- expect(end).toEqual(new GanttDate('2021-01-03 23:59:59').getUnixTime());
81
- expect(max).toEqual(new GanttDate().addYears(1).endOfYear().getUnixTime());
82
- expect(min).toEqual(new GanttDate().addYears(-1).startOfYear().getUnixTime());
83
- });
84
-
85
- it(`should has correct start and end`, () => {
86
- const start = ganttView.start.getUnixTime();
87
- const end = ganttView.end.getUnixTime();
88
- expect(start).toEqual(new GanttDate('2020-01-01 00:00:00').getUnixTime());
89
- expect(end).toEqual(new GanttDate('2020-12-31 23:59:59').getUnixTime());
90
- });
91
-
92
- it(`should add start date`, () => {
93
- const newDate = ganttView.addStartDate();
94
- if (ganttView.options.min.value > new GanttDate('2020-01-01 00:00:00').value) {
95
- expect(newDate).toBe(null);
96
- } else {
97
- expect(newDate.start.getUnixTime()).toEqual(new GanttDate('2020-01-01 00:00:00').getUnixTime());
98
- expect(newDate.end.getUnixTime()).toEqual(new GanttDate('2020-01-01 00:00:00').getUnixTime());
99
- }
100
- });
101
-
102
- it(`should add end date`, () => {
103
- const newDate = ganttView.addEndDate();
104
- expect(newDate.start.getUnixTime()).toEqual(new GanttDate('2020-12-31 23:59:59').getUnixTime());
105
- expect(newDate.end.getUnixTime()).toEqual(new GanttDate('2020-12-31 23:59:59').getUnixTime());
106
- });
107
-
108
- it(`should update date`, () => {
109
- ganttView.updateDate(new GanttDate('2020-10-01 00:00:00'), new GanttDate('2023-02-01 00:00:00'));
110
- expect(ganttView.start.getUnixTime()).toEqual(new GanttDate('2020-01-01 00:00:00').getUnixTime());
111
- expect(ganttView.end.getUnixTime()).toEqual(new GanttDate('2020-12-31 23:59:59').getUnixTime());
112
- });
113
-
114
- it(`should get width`, () => {
115
- const width = ganttView.getWidth();
116
- expect(width).toEqual(80);
117
- });
118
-
119
- it(`should get cell width`, () => {
120
- const cellWidth = ganttView.getCellWidth();
121
- expect(cellWidth).toEqual(20);
122
- });
123
-
124
- it(`should get today x point`, () => {
125
- const xPoint = ganttView.getTodayXPoint();
126
- expect(xPoint).toEqual(null);
127
- });
128
-
129
- it(`should get x point by date`, () => {
130
- const xPoint = ganttView.getXPointByDate(new GanttDate('2020-02-01 00:00:00'));
131
- expect(xPoint).toEqual(310);
132
- });
133
-
134
- it(`should get date by x point`, () => {
135
- ganttView.getSecondaryDatePoints();
136
- const pointDate = ganttView.getDateByXPoint(60);
137
- expect(pointDate.getUnixTime()).toEqual(new GanttDate('2020-10-01 00:00:00').getUnixTime());
138
- });
139
-
140
- it(`should get date range width`, () => {
141
- const width = ganttView.getDateRangeWidth(new GanttDate('2020-03-01 00:00:00'), new GanttDate('2020-05-01 00:00:00'));
142
- expect(width).toEqual(610);
143
- });
144
- });
@@ -1,45 +0,0 @@
1
- import { GanttDate } from '../../utils/date';
2
- import { GanttViewWeek } from '../week';
3
- import { date, today } from './mock';
4
-
5
- describe('GanttViewWeek', () => {
6
- let ganttViewWeek: GanttViewWeek;
7
-
8
- beforeEach(() => {
9
- ganttViewWeek = new GanttViewWeek(date.start, date.end, {
10
- cellWidth: 140,
11
- start: today.startOfYear().startOfWeek({ weekStartsOn: 1 }),
12
- end: today.endOfYear().endOfWeek({ weekStartsOn: 1 })
13
- });
14
- });
15
-
16
- it(`should has correct view start`, () => {
17
- const startOfWeek = ganttViewWeek.startOf(date.start.date).getUnixTime();
18
- expect(startOfWeek).toEqual(new GanttDate('2019-12-30 00:00:00').getUnixTime());
19
- });
20
-
21
- it(`should has correct view end`, () => {
22
- const endOfWeek = ganttViewWeek.endOf(date.end.date).getUnixTime();
23
- expect(endOfWeek).toEqual(new GanttDate('2021-01-03 23:59:59').getUnixTime());
24
- });
25
-
26
- it(`should has correct cell width`, () => {
27
- const weekCellWidth = ganttViewWeek.getDayOccupancyWidth();
28
- expect(weekCellWidth).toEqual(20);
29
- });
30
-
31
- it(`should has correct primary width`, () => {
32
- const weekPrimaryWidth = ganttViewWeek.getPrimaryWidth();
33
- expect(weekPrimaryWidth).toEqual(140);
34
- });
35
-
36
- it(`should has correct primary date points`, () => {
37
- const weekPoints = ganttViewWeek.getPrimaryDatePoints();
38
- expect(weekPoints.length).toBe(54);
39
- });
40
-
41
- it(`should has correct secondary date points`, () => {
42
- const weekPoints = ganttViewWeek.getSecondaryDatePoints();
43
- expect(weekPoints.length).toBe(54);
44
- });
45
- });
@@ -1,45 +0,0 @@
1
- import { GanttViewYear } from '../year';
2
- import { GanttDate } from '../../utils/date';
3
- import { date, today } from './mock';
4
-
5
- describe('GanttViewYear', () => {
6
- let ganttViewYear: GanttViewYear;
7
-
8
- beforeEach(() => {
9
- ganttViewYear = new GanttViewYear(date.start, date.end, {
10
- cellWidth: 732,
11
- start: today.addYears(-1).startOfYear(),
12
- end: today.addYears(1).endOfYear()
13
- });
14
- });
15
-
16
- it(`should has correct view start`, () => {
17
- const startOfDay = ganttViewYear.startOf(date.start.date).getUnixTime();
18
- expect(startOfDay).toEqual(new GanttDate('2020-01-01 00:00:00').getUnixTime());
19
- });
20
-
21
- it(`should has correct view end`, () => {
22
- const endOfDay = ganttViewYear.endOf(date.end.date).getUnixTime();
23
- expect(endOfDay).toEqual(new GanttDate('2020-12-31 23:59:59').getUnixTime());
24
- });
25
-
26
- it(`should has correct cell width`, () => {
27
- const yearCellWidth = ganttViewYear.getDayOccupancyWidth(date.start.date);
28
- expect(yearCellWidth).toEqual(2);
29
- });
30
-
31
- it(`should has correct primary width`, () => {
32
- const yearPrimaryWidth = ganttViewYear.getPrimaryWidth();
33
- expect(yearPrimaryWidth).toEqual(732);
34
- });
35
-
36
- it(`should has correct primary date points`, () => {
37
- const yearPoints = ganttViewYear.getPrimaryDatePoints();
38
- expect(yearPoints.length).toBe(1);
39
- });
40
-
41
- it(`should has correct secondary date points`, () => {
42
- const yearPoints = ganttViewYear.getSecondaryDatePoints();
43
- expect(yearPoints.length).toBe(1);
44
- });
45
- });
@@ -1,186 +0,0 @@
1
- import { GanttDate, differenceInDays, GanttDateUtil } from '../utils/date';
2
- import { GanttDatePoint } from '../class/date-point';
3
- import { BehaviorSubject } from 'rxjs';
4
-
5
- export const primaryDatePointTop = 18;
6
-
7
- export const secondaryDatePointTop = 36;
8
-
9
- export interface GanttViewDate {
10
- date: GanttDate;
11
- isCustom?: boolean;
12
- }
13
-
14
- export interface GanttViewOptions {
15
- start?: GanttDate;
16
- end?: GanttDate;
17
- min?: GanttDate;
18
- max?: GanttDate;
19
- cellWidth?: number;
20
- addAmount?: number;
21
- addUnit?: GanttDateUtil;
22
- }
23
-
24
- const viewOptions: GanttViewOptions = {
25
- min: new GanttDate().addYears(-1).startOfYear(),
26
- max: new GanttDate().addYears(1).endOfYear()
27
- };
28
-
29
- export abstract class GanttView {
30
- start$: BehaviorSubject<GanttDate>;
31
-
32
- end$: BehaviorSubject<GanttDate>;
33
-
34
- get start() {
35
- return this.start$.getValue();
36
- }
37
-
38
- get end() {
39
- return this.end$.getValue();
40
- }
41
-
42
- primaryDatePoints: GanttDatePoint[];
43
-
44
- secondaryDatePoints: GanttDatePoint[];
45
-
46
- width: number;
47
-
48
- cellWidth: number;
49
-
50
- primaryWidth: number;
51
-
52
- showTimeline = true;
53
-
54
- showWeekBackdrop: boolean;
55
-
56
- options: GanttViewOptions;
57
-
58
- constructor(start: GanttViewDate, end: GanttViewDate, options: GanttViewOptions) {
59
- this.options = Object.assign({}, viewOptions, options);
60
- const startDate = start.isCustom
61
- ? this.startOf(start.date)
62
- : this.startOf(start.date.value < this.options.start.value ? start.date : this.options.start);
63
- const endDate = end.isCustom
64
- ? this.endOf(end.date)
65
- : this.endOf(end.date.value > this.options.end.value ? end.date : this.options.end);
66
- this.start$ = new BehaviorSubject<GanttDate>(startDate);
67
- this.end$ = new BehaviorSubject<GanttDate>(endDate);
68
- this.initialize();
69
- }
70
-
71
- abstract startOf(date: GanttDate): GanttDate;
72
-
73
- abstract endOf(date: GanttDate): GanttDate;
74
-
75
- // 获取一级时间网格合并后的宽度
76
- abstract getPrimaryWidth(): number;
77
-
78
- // 获取当前视图下每一天占用的宽度
79
- abstract getDayOccupancyWidth(date: GanttDate): number;
80
-
81
- // 获取一级时间点(坐标,显示名称)
82
- abstract getPrimaryDatePoints(): GanttDatePoint[];
83
-
84
- // 获取二级时间点(坐标,显示名称)
85
- abstract getSecondaryDatePoints(): GanttDatePoint[];
86
-
87
- protected getDateIntervalWidth(start: GanttDate, end: GanttDate) {
88
- let result = 0;
89
- const days = differenceInDays(end.value, start.value);
90
- for (let i = 0; i < Math.abs(days); i++) {
91
- result += this.getDayOccupancyWidth(start.addDays(i));
92
- }
93
- result = days >= 0 ? result : -result;
94
- return Number(result.toFixed(3));
95
- }
96
-
97
- protected initialize() {
98
- this.primaryDatePoints = this.getPrimaryDatePoints();
99
- this.secondaryDatePoints = this.getSecondaryDatePoints();
100
- this.width = this.getWidth();
101
- this.cellWidth = this.getCellWidth();
102
- this.primaryWidth = this.getPrimaryWidth();
103
- }
104
-
105
- addStartDate() {
106
- const start = this.startOf(this.start.add(this.options.addAmount * -1, this.options.addUnit));
107
- if (start.value >= this.options.min.value) {
108
- const origin = this.start;
109
- this.start$.next(start);
110
- this.initialize();
111
- return { start: this.start, end: origin };
112
- }
113
- return null;
114
- }
115
-
116
- addEndDate() {
117
- const end = this.endOf(this.end.add(this.options.addAmount, this.options.addUnit));
118
- if (end.value <= this.options.max.value) {
119
- const origin = this.end;
120
- this.end$.next(end);
121
- this.initialize();
122
- return { start: origin, end: this.end };
123
- }
124
- return null;
125
- }
126
-
127
- updateDate(start: GanttDate, end: GanttDate) {
128
- start = this.startOf(start);
129
- end = this.endOf(end);
130
- if (start.value < this.start.value) {
131
- this.start$.next(start);
132
- }
133
- if (end.value > this.end.value) {
134
- this.end$.next(end);
135
- }
136
- this.initialize();
137
- }
138
-
139
- // 获取View的宽度
140
- getWidth() {
141
- return this.getCellWidth() * this.secondaryDatePoints.length;
142
- }
143
-
144
- // 获取单个网格的宽度
145
- getCellWidth() {
146
- return this.options.cellWidth;
147
- }
148
-
149
- // 获取当前时间的X坐标
150
- getTodayXPoint(): number {
151
- const toady = new GanttDate().startOfDay();
152
- if (toady.value > this.start.value && toady.value < this.end.value) {
153
- const x = this.getXPointByDate(toady) + this.getDayOccupancyWidth(toady) / 2;
154
- return x;
155
- } else {
156
- return null;
157
- }
158
- }
159
-
160
- // 获取指定时间的X坐标
161
- getXPointByDate(date: GanttDate) {
162
- return this.getDateIntervalWidth(this.start, date);
163
- }
164
-
165
- // 根据X坐标获取对应时间
166
- getDateByXPoint(x: number) {
167
- const indexOfSecondaryDate = Math.floor(x / this.getCellWidth());
168
- const matchDate = this.secondaryDatePoints[indexOfSecondaryDate];
169
- const dayWidth = this.getDayOccupancyWidth(matchDate?.start);
170
- if (dayWidth === this.getCellWidth()) {
171
- return matchDate?.start;
172
- } else {
173
- const day = Math.floor((x % this.getCellWidth()) / dayWidth) + 1;
174
- if (this.getCellWidth() / dayWidth === 7) {
175
- return matchDate?.start.addDays(day);
176
- }
177
- return matchDate?.start.setDate(day);
178
- }
179
- }
180
-
181
- // 获取指定时间范围的宽度
182
- getDateRangeWidth(start: GanttDate, end: GanttDate) {
183
- // addSeconds(1) 是因为计算相差天会以一个整天来计算 end时间一般是59分59秒不是一个整天,所以需要加1
184
- return this.getDateIntervalWidth(start, end.addSeconds(1));
185
- }
186
- }
@@ -1,66 +0,0 @@
1
- import { GanttDatePoint } from '../class/date-point';
2
- import { eachWeekOfInterval, GanttDate } from '../utils/date';
3
- import { GanttView, GanttViewDate, GanttViewOptions, primaryDatePointTop, secondaryDatePointTop } from './view';
4
-
5
- const viewOptions: GanttViewOptions = {
6
- cellWidth: 280,
7
- start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
8
- end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
9
- addAmount: 1,
10
- addUnit: 'month'
11
- };
12
-
13
- export class GanttViewWeek extends GanttView {
14
- constructor(start: GanttViewDate, end: GanttViewDate, options?: GanttViewOptions) {
15
- super(start, end, Object.assign({}, viewOptions, options));
16
- }
17
-
18
- startOf(date: GanttDate) {
19
- return date.startOfWeek({ weekStartsOn: 1 });
20
- }
21
-
22
- endOf(date: GanttDate) {
23
- return date.endOfWeek({ weekStartsOn: 1 });
24
- }
25
-
26
- getPrimaryWidth() {
27
- return this.getCellWidth();
28
- }
29
-
30
- getDayOccupancyWidth(): number {
31
- return this.cellWidth / 7;
32
- }
33
-
34
- getPrimaryDatePoints(): GanttDatePoint[] {
35
- const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.addSeconds(1).value }, { weekStartsOn: 1 });
36
- const points: GanttDatePoint[] = [];
37
- for (let i = 0; i < weeks.length; i++) {
38
- const weekStart = new GanttDate(weeks[i]);
39
- const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
40
- const point = new GanttDatePoint(
41
- weekStart,
42
- weekStart.addWeeks(increaseWeek).format('yyyy年'),
43
- this.getCellWidth() / 2 + i * this.getCellWidth(),
44
- primaryDatePointTop
45
- );
46
- points.push(point);
47
- }
48
- return points;
49
- }
50
-
51
- getSecondaryDatePoints(): GanttDatePoint[] {
52
- const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.value });
53
- const points: GanttDatePoint[] = [];
54
- for (let i = 0; i < weeks.length; i++) {
55
- const start = new GanttDate(weeks[i]);
56
- const point = new GanttDatePoint(
57
- start,
58
- `第${start.format('w')}周`,
59
- i * this.getCellWidth() + this.getCellWidth() / 2,
60
- secondaryDatePointTop
61
- );
62
- points.push(point);
63
- }
64
- return points;
65
- }
66
- }
@@ -1,62 +0,0 @@
1
- import { GanttView, GanttViewOptions, primaryDatePointTop, secondaryDatePointTop, GanttViewDate } from './view';
2
- import { GanttDate } from '../utils/date';
3
- import { GanttDatePoint } from '../class/date-point';
4
- import { eachYearOfInterval, differenceInCalendarYears } from 'date-fns';
5
-
6
- const viewOptions: GanttViewOptions = {
7
- cellWidth: 480,
8
- start: new GanttDate().addYears(-2).startOfYear(),
9
- end: new GanttDate().addYears(2).endOfYear(),
10
- addAmount: 1,
11
- addUnit: 'year'
12
- };
13
-
14
- export class GanttViewYear extends GanttView {
15
- constructor(start: GanttViewDate, end: GanttViewDate, options?: GanttViewOptions) {
16
- super(start, end, Object.assign({}, viewOptions, options));
17
- }
18
-
19
- startOf(date: GanttDate) {
20
- return date.startOfYear();
21
- }
22
-
23
- endOf(date: GanttDate) {
24
- return date.endOfYear();
25
- }
26
-
27
- getPrimaryWidth() {
28
- return this.getCellWidth();
29
- }
30
-
31
- getDayOccupancyWidth(date: GanttDate): number {
32
- return this.cellWidth / date.getDaysInYear();
33
- }
34
-
35
- getPrimaryDatePoints(): GanttDatePoint[] {
36
- const years = eachYearOfInterval({ start: this.start.value, end: this.end.value });
37
- const points: GanttDatePoint[] = [];
38
- for (let i = 0; i < years.length; i++) {
39
- const start = new GanttDate(years[i]);
40
- const point = new GanttDatePoint(start, ``, this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
41
- points.push(point);
42
- }
43
- return points;
44
- }
45
-
46
- getSecondaryDatePoints(): GanttDatePoint[] {
47
- const years = differenceInCalendarYears(this.end.value, this.start.value);
48
- const points: GanttDatePoint[] = [];
49
- const pointTop = 27;
50
- for (let i = 0; i <= years; i++) {
51
- const start = this.start.addYears(i);
52
- const point = new GanttDatePoint(
53
- start,
54
- `${start.format('yyyy')}年`,
55
- i * this.getCellWidth() + this.getCellWidth() / 2,
56
- pointTop
57
- );
58
- points.push(point);
59
- }
60
- return points;
61
- }
62
- }
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../out-tsc/lib",
5
- "declarationMap": true,
6
- "target": "es2015",
7
- "declaration": true,
8
- "inlineSources": true,
9
- "types": [],
10
- "lib": ["dom", "es2018"]
11
- },
12
- "angularCompilerOptions": {
13
- "skipTemplateCodegen": true,
14
- "strictMetadataEmit": true,
15
- "fullTemplateTypeCheck": true,
16
- "strictInjectionParameters": true,
17
- "enableResourceInlining": true,
18
- },
19
- "exclude": ["src/test.ts", "**/*.spec.ts"]
20
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.lib.json",
3
- "compilerOptions": {
4
- "declarationMap": false
5
- },
6
- "angularCompilerOptions": {
7
- "compilationMode": "partial"
8
- }
9
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": ".",
4
- "lib": ["es2018", "dom"],
5
- "declaration": true,
6
- "module": "commonjs",
7
- "moduleResolution": "node",
8
- "noEmitOnError": true,
9
- "noFallthroughCasesInSwitch": true,
10
- "noImplicitAny": true,
11
- "noImplicitThis": true,
12
- "noUnusedParameters": true,
13
- "noUnusedLocals": true,
14
- "rootDir": "schematics",
15
- "outDir": "../../dist/gantt/schematics",
16
- "skipDefaultLibCheck": true,
17
- "skipLibCheck": true,
18
- "sourceMap": true,
19
- "strictNullChecks": true,
20
- "target": "es6",
21
- "types": ["jasmine", "node"]
22
- },
23
- "include": ["schematics/**/*"],
24
- "exclude": ["schematics/*/files/**/*"]
25
- }
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../out-tsc/spec",
5
- "types": [
6
- "jasmine",
7
- "node"
8
- ]
9
- },
10
- "files": [
11
- "src/test.ts"
12
- ],
13
- "include": [
14
- "**/*.spec.ts",
15
- "**/*.d.ts"
16
- ]
17
- }
@@ -1,18 +0,0 @@
1
- {
2
- "extends": "../../tslint.json",
3
- "rules": {
4
- "directive-selector": [
5
- true,
6
- "attribute",
7
- "ngx",
8
- "camelCase"
9
- ],
10
- "component-selector": [
11
- true,
12
- "element",
13
- "ngx",
14
- "gantt",
15
- "kebab-case"
16
- ]
17
- }
18
- }
@@ -1,7 +0,0 @@
1
- {
2
- "bundlerOptions": {
3
- "entryFile": "./packages/gantt/src/styles/index.scss",
4
- "rootDir": "./",
5
- "outFile": "dist/gantt/main.bundle.scss"
6
- }
7
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compileOnSave": false,
3
- "compilerOptions": {
4
- "baseUrl": "./",
5
- "outDir": "./dist/out-tsc",
6
- "sourceMap": true,
7
- "declaration": false,
8
- "downlevelIteration": true,
9
- "experimentalDecorators": true,
10
- "module": "esnext",
11
- "moduleResolution": "node",
12
- "importHelpers": true,
13
- "target": "es2015",
14
- "typeRoots": ["node_modules/@types"],
15
- "lib": ["es2018", "dom"],
16
- "paths": {
17
- "ngx-gantt": ["packages/gantt/src/public-api.ts"],
18
- "ngx-gantt/*": ["packages/gantt/src/*"]
19
- }
20
- },
21
- "angularCompilerOptions": {
22
- "fullTemplateTypeCheck": true,
23
- "strictInjectionParameters": true,
24
- "skipLibCheck": true
25
- }
26
- }