@worktile/gantt 11.0.2 → 12.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/.all-contributorsrc +53 -0
  2. package/.angulardoc.json +4 -0
  3. package/.circleci/config.yml +17 -0
  4. package/.coveralls.yml +1 -0
  5. package/.docgenirc.js +64 -0
  6. package/.editorconfig +22 -0
  7. package/.prettierrc +24 -0
  8. package/.travis.yml +23 -0
  9. package/CHANGELOG.md +564 -0
  10. package/Dockerfile +4 -0
  11. package/LICENSE +21 -0
  12. package/README.md +116 -13
  13. package/angular.json +136 -0
  14. package/docs/guides/basic/components.md +54 -0
  15. package/docs/guides/basic/event.md +70 -0
  16. package/docs/guides/basic/index.md +4 -0
  17. package/docs/guides/basic/style.md +68 -0
  18. package/docs/guides/basic/type.md +70 -0
  19. package/docs/guides/basic/usage.md +189 -0
  20. package/docs/guides/index.md +5 -0
  21. package/docs/guides/intro/getting-started.md +79 -0
  22. package/docs/guides/intro/index.md +51 -0
  23. package/docs/index.md +0 -0
  24. package/example/browserslist +12 -0
  25. package/example/src/app/app-routing.module.ts +26 -0
  26. package/example/src/app/app.component.html +2 -0
  27. package/example/src/app/app.component.ts +11 -0
  28. package/example/src/app/app.module.ts +57 -0
  29. package/example/src/app/components/components.component.html +6 -0
  30. package/example/src/app/components/components.component.ts +33 -0
  31. package/example/src/app/configuration/parameters/api/zh-cn.js +350 -0
  32. package/example/src/app/configuration/parameters/doc/zh-cn.md +5 -0
  33. package/example/src/app/gantt/gantt.component.html +51 -0
  34. package/example/src/app/gantt/gantt.component.ts +119 -0
  35. package/example/src/app/gantt-advanced/component/flat.component.html +30 -0
  36. package/example/src/app/gantt-advanced/component/flat.component.ts +72 -0
  37. package/example/src/app/gantt-advanced/component/flat.scss +31 -0
  38. package/example/src/app/gantt-advanced/gantt-advanced.component.html +32 -0
  39. package/example/src/app/gantt-advanced/gantt-advanced.component.ts +34 -0
  40. package/example/src/app/gantt-advanced/mocks.ts +158 -0
  41. package/example/src/app/gantt-groups/gantt-groups.component.html +42 -0
  42. package/example/src/app/gantt-groups/gantt-groups.component.ts +62 -0
  43. package/example/src/app/gantt-range/gantt-range.component.html +66 -0
  44. package/example/src/app/gantt-range/gantt-range.component.ts +67 -0
  45. package/example/src/app/gantt-range/mocks.ts +150 -0
  46. package/example/src/app/helper.ts +38 -0
  47. package/example/src/assets/.gitkeep +0 -0
  48. package/example/src/environments/environment.prod.ts +3 -0
  49. package/example/src/environments/environment.ts +16 -0
  50. package/example/src/favicon.ico +0 -0
  51. package/example/src/index.html +13 -0
  52. package/example/src/main.ts +12 -0
  53. package/example/src/polyfills.ts +63 -0
  54. package/example/src/styles.scss +56 -0
  55. package/example/tsconfig.app.json +18 -0
  56. package/nginx.conf +17 -0
  57. package/package.json +113 -17
  58. package/packages/gantt/README.md +24 -0
  59. package/packages/gantt/karma.conf.js +46 -0
  60. package/packages/gantt/ng-package.json +7 -0
  61. package/packages/gantt/ng-package.prod.json +7 -0
  62. package/packages/gantt/package.json +16 -0
  63. package/packages/gantt/src/class/date-point.ts +14 -0
  64. package/{class/event.d.ts → packages/gantt/src/class/event.ts} +12 -6
  65. package/packages/gantt/src/class/group.ts +36 -0
  66. package/{class/index.d.ts → packages/gantt/src/class/index.ts} +0 -0
  67. package/packages/gantt/src/class/item.ts +129 -0
  68. package/packages/gantt/src/class/test/group.spec.ts +21 -0
  69. package/packages/gantt/src/class/test/item.spec.ts +102 -0
  70. package/packages/gantt/src/class/view-type.ts +7 -0
  71. package/packages/gantt/src/components/bar/bar-drag.ts +298 -0
  72. package/packages/gantt/src/components/bar/bar.component.html +17 -0
  73. package/packages/gantt/src/components/bar/bar.component.scss +169 -0
  74. package/packages/gantt/src/components/bar/bar.component.ts +109 -0
  75. package/packages/gantt/src/components/bar/test/bar.component.spec.ts +54 -0
  76. package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +196 -0
  77. package/packages/gantt/src/components/calendar/calendar.component.html +52 -0
  78. package/packages/gantt/src/components/calendar/calendar.component.scss +77 -0
  79. package/packages/gantt/src/components/calendar/calendar.component.ts +100 -0
  80. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +6 -0
  81. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +48 -0
  82. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +13 -0
  83. package/packages/gantt/src/components/icon/icon.component.scss +13 -0
  84. package/packages/gantt/src/components/icon/icon.component.ts +28 -0
  85. package/packages/gantt/src/components/icon/icons.ts +86 -0
  86. package/packages/gantt/src/components/links/links.component.html +19 -0
  87. package/packages/gantt/src/components/links/links.component.scss +27 -0
  88. package/packages/gantt/src/components/links/links.component.ts +263 -0
  89. package/packages/gantt/src/components/main/gantt-main.component.html +35 -0
  90. package/packages/gantt/src/components/main/gantt-main.component.ts +35 -0
  91. package/packages/gantt/src/components/range/range.component.html +8 -0
  92. package/packages/gantt/src/components/range/range.component.scss +35 -0
  93. package/packages/gantt/src/components/range/range.component.ts +27 -0
  94. package/packages/gantt/src/components/range/test/range.component.spec.ts +80 -0
  95. package/packages/gantt/src/components/table/gantt-table.component.html +105 -0
  96. package/packages/gantt/src/components/table/gantt-table.component.scss +144 -0
  97. package/packages/gantt/src/components/table/gantt-table.component.ts +166 -0
  98. package/packages/gantt/src/components/table/test/table.spec.ts +129 -0
  99. package/packages/gantt/src/gantt-abstract.ts +14 -0
  100. package/packages/gantt/src/gantt-dom.service.ts +134 -0
  101. package/packages/gantt/src/gantt-drag-container.ts +73 -0
  102. package/packages/gantt/src/gantt-item-upper.ts +50 -0
  103. package/packages/gantt/src/gantt-print.service.ts +104 -0
  104. package/packages/gantt/src/gantt-upper.ts +289 -0
  105. package/packages/gantt/src/gantt.component.html +18 -0
  106. package/packages/gantt/src/gantt.component.scss +77 -0
  107. package/packages/gantt/src/gantt.component.ts +134 -0
  108. package/packages/gantt/src/gantt.module.ts +47 -0
  109. package/packages/gantt/src/gantt.pipe.ts +31 -0
  110. package/packages/gantt/src/gantt.styles.ts +28 -0
  111. package/{public-api.d.ts → packages/gantt/src/public-api.ts} +6 -0
  112. package/packages/gantt/src/root.component.html +12 -0
  113. package/packages/gantt/src/root.component.ts +121 -0
  114. package/packages/gantt/src/styles/index.scss +9 -0
  115. package/packages/gantt/src/styles/variables.scss +46 -0
  116. package/packages/gantt/src/table/gantt-column.component.ts +25 -0
  117. package/packages/gantt/src/table/gantt-table.component.ts +14 -0
  118. package/packages/gantt/src/table/test/table.spec.ts +56 -0
  119. package/packages/gantt/src/test/gantt.component.spec.ts +404 -0
  120. package/packages/gantt/src/test/mocks/data.ts +303 -0
  121. package/packages/gantt/src/test.ts +21 -0
  122. package/packages/gantt/src/utils/date.ts +276 -0
  123. package/packages/gantt/src/utils/helpers.ts +66 -0
  124. package/packages/gantt/src/utils/test/date.spec.ts +105 -0
  125. package/packages/gantt/src/utils/test/helpers.spec.ts +73 -0
  126. package/packages/gantt/src/utils/testing.ts +64 -0
  127. package/packages/gantt/src/views/day.ts +74 -0
  128. package/packages/gantt/src/views/factory.ts +25 -0
  129. package/packages/gantt/src/views/month.ts +66 -0
  130. package/packages/gantt/src/views/quarter.ts +68 -0
  131. package/packages/gantt/src/views/test/day.spec.ts +45 -0
  132. package/packages/gantt/src/views/test/factory.spec.ts +41 -0
  133. package/packages/gantt/src/views/test/mock.ts +14 -0
  134. package/packages/gantt/src/views/test/month.spec.ts +45 -0
  135. package/packages/gantt/src/views/test/quarter.spec.ts +45 -0
  136. package/packages/gantt/src/views/test/view.spec.ts +144 -0
  137. package/packages/gantt/src/views/test/week.spec.ts +45 -0
  138. package/packages/gantt/src/views/test/year.spec.ts +45 -0
  139. package/packages/gantt/src/views/view.ts +186 -0
  140. package/packages/gantt/src/views/week.ts +66 -0
  141. package/packages/gantt/src/views/year.ts +62 -0
  142. package/packages/gantt/tsconfig.lib.json +20 -0
  143. package/packages/gantt/tsconfig.lib.prod.json +9 -0
  144. package/packages/gantt/tsconfig.schematics.json +25 -0
  145. package/packages/gantt/tsconfig.spec.json +17 -0
  146. package/packages/gantt/tslint.json +18 -0
  147. package/scss-bundle.config.json +7 -0
  148. package/tsconfig.json +26 -0
  149. package/tslint.json +51 -0
  150. package/bundles/worktile-gantt.umd.js +0 -3129
  151. package/bundles/worktile-gantt.umd.js.map +0 -1
  152. package/bundles/worktile-gantt.umd.min.js +0 -16
  153. package/bundles/worktile-gantt.umd.min.js.map +0 -1
  154. package/class/date-point.d.ts +0 -15
  155. package/class/group.d.ts +0 -22
  156. package/class/item.d.ts +0 -70
  157. package/class/view-type.d.ts +0 -7
  158. package/components/bar/bar-drag.d.ts +0 -34
  159. package/components/bar/bar.component.d.ts +0 -23
  160. package/components/calendar/calendar.component.d.ts +0 -25
  161. package/components/drag-backdrop/drag-backdrop.component.d.ts +0 -6
  162. package/components/icon/icon.component.d.ts +0 -10
  163. package/components/icon/icons.d.ts +0 -8
  164. package/components/links/links.component.d.ts +0 -44
  165. package/components/main/gantt-main.component.d.ts +0 -18
  166. package/components/range/range.component.d.ts +0 -10
  167. package/components/table/gantt-table.component.d.ts +0 -31
  168. package/esm2015/class/date-point.js +0 -10
  169. package/esm2015/class/event.js +0 -13
  170. package/esm2015/class/group.js +0 -17
  171. package/esm2015/class/index.js +0 -6
  172. package/esm2015/class/item.js +0 -78
  173. package/esm2015/class/view-type.js +0 -9
  174. package/esm2015/components/bar/bar-drag.js +0 -266
  175. package/esm2015/components/bar/bar.component.js +0 -91
  176. package/esm2015/components/calendar/calendar.component.js +0 -82
  177. package/esm2015/components/drag-backdrop/drag-backdrop.component.js +0 -18
  178. package/esm2015/components/icon/icon.component.js +0 -36
  179. package/esm2015/components/icon/icons.js +0 -87
  180. package/esm2015/components/links/links.component.js +0 -207
  181. package/esm2015/components/main/gantt-main.component.js +0 -35
  182. package/esm2015/components/range/range.component.js +0 -32
  183. package/esm2015/components/table/gantt-table.component.js +0 -128
  184. package/esm2015/gantt-dom.service.js +0 -101
  185. package/esm2015/gantt-drag-container.js +0 -57
  186. package/esm2015/gantt-item-upper.js +0 -55
  187. package/esm2015/gantt-print.service.js +0 -92
  188. package/esm2015/gantt-upper.js +0 -231
  189. package/esm2015/gantt.component.js +0 -105
  190. package/esm2015/gantt.module.js +0 -43
  191. package/esm2015/gantt.pipe.js +0 -33
  192. package/esm2015/gantt.styles.js +0 -15
  193. package/esm2015/public-api.js +0 -16
  194. package/esm2015/root.component.js +0 -111
  195. package/esm2015/table/gantt-column.component.js +0 -28
  196. package/esm2015/table/gantt-table.component.js +0 -18
  197. package/esm2015/utils/date.js +0 -160
  198. package/esm2015/utils/helpers.js +0 -45
  199. package/esm2015/views/day.js +0 -54
  200. package/esm2015/views/factory.js +0 -23
  201. package/esm2015/views/month.js +0 -48
  202. package/esm2015/views/quarter.js +0 -51
  203. package/esm2015/views/view.js +0 -121
  204. package/esm2015/views/week.js +0 -49
  205. package/esm2015/views/year.js +0 -50
  206. package/esm2015/worktile-gantt.js +0 -16
  207. package/fesm2015/worktile-gantt.js +0 -2491
  208. package/fesm2015/worktile-gantt.js.map +0 -1
  209. package/gantt-dom.service.d.ts +0 -29
  210. package/gantt-drag-container.d.ts +0 -20
  211. package/gantt-item-upper.d.ts +0 -17
  212. package/gantt-print.service.d.ts +0 -10
  213. package/gantt-upper.d.ts +0 -62
  214. package/gantt.component.d.ts +0 -28
  215. package/gantt.module.d.ts +0 -2
  216. package/gantt.pipe.d.ts +0 -11
  217. package/gantt.styles.d.ts +0 -15
  218. package/root.component.d.ts +0 -25
  219. package/style.scss +0 -645
  220. package/table/gantt-column.component.d.ts +0 -12
  221. package/table/gantt-table.component.d.ts +0 -7
  222. package/utils/date.d.ts +0 -59
  223. package/utils/helpers.d.ts +0 -11
  224. package/views/day.d.ts +0 -14
  225. package/views/factory.d.ts +0 -8
  226. package/views/month.d.ts +0 -12
  227. package/views/quarter.d.ts +0 -12
  228. package/views/view.d.ts +0 -56
  229. package/views/week.d.ts +0 -12
  230. package/views/year.d.ts +0 -12
  231. package/worktile-gantt.d.ts +0 -15
  232. package/worktile-gantt.metadata.json +0 -1
@@ -0,0 +1,303 @@
1
+ import { GanttDate } from './../../utils/date';
2
+
3
+ export function getMockItems() {
4
+ return [
5
+ {
6
+ id: 'item-0101',
7
+ title: 'VERSION 0101',
8
+ start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
9
+ color: '#FF0000',
10
+ children: [
11
+ {
12
+ id: 'item-child-0101',
13
+ title: 'VERSION Children 0101',
14
+ start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
15
+ color: '#FF0000',
16
+ linkable: false
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ id: 'item-0102',
22
+ title: 'VERSION 0102',
23
+ start: new GanttDate('2020-05-31 22:34:35').getUnixTime(),
24
+ end: new GanttDate('2020-06-05 08:53:20').getUnixTime(),
25
+ color: '#9ACD32',
26
+ expandable: true
27
+ },
28
+ {
29
+ id: 'item-0103',
30
+ title: 'VERSION 0103',
31
+ end: new GanttDate('2020-06-13 11:20:00').getUnixTime()
32
+ },
33
+ {
34
+ id: 'item-0104',
35
+ title: 'VERSION 0104',
36
+
37
+ links: ['item-0301']
38
+ },
39
+ {
40
+ id: 'item-0201',
41
+ title: 'VERSION 0201'
42
+ },
43
+ {
44
+ id: 'item-0202',
45
+ title: 'VERSION 0202',
46
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
47
+ end: new GanttDate('2020-06-25 01:06:40').getUnixTime(),
48
+ links: ['item-0203'],
49
+ color: 'rgb(52, 143, 228, 0.5)',
50
+ barStyle: {
51
+ border: '1px solid rgb(52, 143, 228)'
52
+ }
53
+ },
54
+ {
55
+ id: 'item-0203',
56
+ title: 'VERSION 0203',
57
+ start: new GanttDate('2020-05-23 20:07:55').getUnixTime(),
58
+ end: new GanttDate('2020-06-10 00:00:00').getUnixTime(),
59
+ links: ['item-0204']
60
+ },
61
+ {
62
+ id: 'item-0204',
63
+ title: 'VERSION 0204',
64
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
65
+ end: new GanttDate('2020-06-18 02:26:40').getUnixTime(),
66
+ links: ['item-0301', 'item-0402']
67
+ },
68
+
69
+ {
70
+ id: 'item-0301',
71
+ title: 'VERSION 0301',
72
+ start: new GanttDate('2020-07-29 23:14:35').getUnixTime(),
73
+ end: new GanttDate('2020-09-02 11:46:40').getUnixTime()
74
+ },
75
+ {
76
+ id: 'item-0302',
77
+ title: 'VERSION 0302',
78
+ start: new GanttDate('2020-06-13 16:07:55').getUnixTime(),
79
+ end: new GanttDate('2020-08-21 22:00:00').getUnixTime()
80
+ },
81
+ {
82
+ id: 'item-0303',
83
+ title: 'VERSION 0303',
84
+ start: new GanttDate('2020-05-22 16:21:15').getUnixTime(),
85
+ end: new GanttDate('2020-07-06 14:53:20').getUnixTime()
86
+ },
87
+ {
88
+ id: 'item-0401',
89
+ title: 'VERSION 0401',
90
+ start: new GanttDate('2020-05-09 22:47:55').getUnixTime(),
91
+ end: new GanttDate('2020-07-06 14:53:20').getUnixTime()
92
+ },
93
+ {
94
+ id: 'item-0402',
95
+ title: 'VERSION 0402',
96
+ start: new GanttDate('2020-07-29 23:14:35').getUnixTime(),
97
+ end: new GanttDate('2020-09-12 21:46:40').getUnixTime()
98
+ },
99
+ {
100
+ id: 'item-0403',
101
+ title: 'VERSION 0403',
102
+ start: new GanttDate('2020-06-25 05:54:35').getUnixTime(),
103
+ end: new GanttDate('2020-09-02 11:46:40').getUnixTime()
104
+ },
105
+ {
106
+ id: 'item-0404',
107
+ title: 'VERSION 0404',
108
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
109
+ end: new GanttDate('2020-06-23 21:20:00').getUnixTime()
110
+ },
111
+ {
112
+ id: 'item-0501',
113
+ title: 'VERSION 0501',
114
+ start: new GanttDate('2020-09-13 02:34:35').getUnixTime(),
115
+ end: new GanttDate('2020-10-07 05:06:40').getUnixTime()
116
+ },
117
+ {
118
+ id: 'item-0502',
119
+ title: 'VERSION 0502',
120
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
121
+ end: new GanttDate('2020-07-06 14:53:20').getUnixTime()
122
+ },
123
+ {
124
+ id: 'item-0503',
125
+ title: 'VERSION 0503',
126
+ start: new GanttDate('2020-07-18 09:27:55').getUnixTime(),
127
+ end: new GanttDate('2020-09-02 11:46:40').getUnixTime()
128
+ }
129
+ ];
130
+ }
131
+
132
+ export function getMockGroupItems() {
133
+ return [
134
+ {
135
+ id: 'item-0101',
136
+ title: 'VERSION 0101',
137
+ start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
138
+ group_id: '00001',
139
+ color: '#FF0000',
140
+ children: [
141
+ {
142
+ id: 'item-child-0101',
143
+ title: 'VERSION Children 0101',
144
+ start: new GanttDate('2020-05-21 12:34:35').getUnixTime(),
145
+ group_id: '00001',
146
+ color: '#FF0000',
147
+ linkable: false
148
+ }
149
+ ]
150
+ },
151
+ {
152
+ id: 'item-0102',
153
+ title: 'VERSION 0102',
154
+ start: new GanttDate('2020-05-31 22:34:35').getUnixTime(),
155
+ end: new GanttDate('2020-06-05 08:53:20').getUnixTime(),
156
+ color: '#9ACD32',
157
+ group_id: '00001',
158
+ expandable: true
159
+ },
160
+ {
161
+ id: 'item-0103',
162
+ title: 'VERSION 0103',
163
+ end: new GanttDate('2020-06-13 11:20:00').getUnixTime(),
164
+ group_id: '00001'
165
+ },
166
+ {
167
+ id: 'item-0104',
168
+ title: 'VERSION 0104',
169
+ group_id: '00001',
170
+ links: ['item-0301']
171
+ },
172
+ {
173
+ id: 'item-0201',
174
+ title: 'VERSION 0201',
175
+ group_id: '00002'
176
+ },
177
+ {
178
+ id: 'item-0202',
179
+ title: 'VERSION 0202',
180
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
181
+ end: new GanttDate('2020-06-25 01:06:40').getUnixTime(),
182
+ group_id: '00002',
183
+ links: ['item-0203'],
184
+ color: 'rgb(52, 143, 228, 0.5)',
185
+ barStyle: {
186
+ border: '1px solid rgb(52, 143, 228)'
187
+ }
188
+ },
189
+ {
190
+ id: 'item-0203',
191
+ title: 'VERSION 0203',
192
+ start: new GanttDate('2020-05-23 20:07:55').getUnixTime(),
193
+ end: new GanttDate('2020-06-10 00:00:00').getUnixTime(),
194
+ group_id: '00002',
195
+ links: ['item-0204']
196
+ },
197
+ {
198
+ id: 'item-0204',
199
+ title: 'VERSION 0204',
200
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
201
+ end: new GanttDate('2020-06-18 02:26:40').getUnixTime(),
202
+ group_id: '00002',
203
+ links: ['item-0301', 'item-0402']
204
+ },
205
+
206
+ {
207
+ id: 'item-0301',
208
+ title: 'VERSION 0301',
209
+ start: new GanttDate('2020-07-29 23:14:35').getUnixTime(),
210
+ end: new GanttDate('2020-09-02 11:46:40').getUnixTime(),
211
+ group_id: '00003'
212
+ },
213
+ {
214
+ id: 'item-0302',
215
+ title: 'VERSION 0302',
216
+ start: new GanttDate('2020-06-13 16:07:55').getUnixTime(),
217
+ end: new GanttDate('2020-08-21 22:00:00').getUnixTime(),
218
+ group_id: '00003'
219
+ },
220
+ {
221
+ id: 'item-0303',
222
+ title: 'VERSION 0303',
223
+ start: new GanttDate('2020-05-22 16:21:15').getUnixTime(),
224
+ end: new GanttDate('2020-07-06 14:53:20').getUnixTime(),
225
+ group_id: '00003'
226
+ },
227
+ {
228
+ id: 'item-0401',
229
+ title: 'VERSION 0401',
230
+ start: new GanttDate('2020-05-09 22:47:55').getUnixTime(),
231
+ end: new GanttDate('2020-07-06 14:53:20').getUnixTime(),
232
+ group_id: '00004'
233
+ },
234
+ {
235
+ id: 'item-0402',
236
+ title: 'VERSION 0402',
237
+ start: new GanttDate('2020-07-29 23:14:35').getUnixTime(),
238
+ end: new GanttDate('2020-09-12 21:46:40').getUnixTime(),
239
+ group_id: '00004'
240
+ },
241
+ {
242
+ id: 'item-0403',
243
+ title: 'VERSION 0403',
244
+ start: new GanttDate('2020-06-25 05:54:35').getUnixTime(),
245
+ end: new GanttDate('2020-09-02 11:46:40').getUnixTime(),
246
+ group_id: '00004'
247
+ },
248
+ {
249
+ id: 'item-0404',
250
+ title: 'VERSION 0404',
251
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
252
+ end: new GanttDate('2020-06-23 21:20:00').getUnixTime(),
253
+ group_id: '00004'
254
+ },
255
+ {
256
+ id: 'item-0501',
257
+ title: 'VERSION 0501',
258
+ start: new GanttDate('2020-09-13 02:34:35').getUnixTime(),
259
+ end: new GanttDate('2020-10-07 05:06:40').getUnixTime(),
260
+ group_id: '00005'
261
+ },
262
+ {
263
+ id: 'item-0502',
264
+ title: 'VERSION 0502',
265
+ start: new GanttDate('2020-06-02 02:21:15').getUnixTime(),
266
+ end: new GanttDate('2020-07-06 14:53:20').getUnixTime(),
267
+ group_id: '00005'
268
+ },
269
+ {
270
+ id: 'item-0503',
271
+ title: 'VERSION 0503',
272
+ start: new GanttDate('2020-07-18 09:27:55').getUnixTime(),
273
+ end: new GanttDate('2020-09-02 11:46:40').getUnixTime(),
274
+ group_id: '00005'
275
+ }
276
+ ];
277
+ }
278
+
279
+ export function getMockGroups() {
280
+ return [
281
+ {
282
+ id: '00001',
283
+ title: 'Project 1',
284
+ class: 'test'
285
+ },
286
+ {
287
+ id: '00002',
288
+ title: 'Project 2'
289
+ },
290
+ {
291
+ id: '00003',
292
+ title: 'Project 3'
293
+ },
294
+ {
295
+ id: '00004',
296
+ title: 'Project 4'
297
+ },
298
+ {
299
+ id: '00005',
300
+ title: 'Project 5'
301
+ }
302
+ ];
303
+ }
@@ -0,0 +1,21 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js';
4
+ import 'zone.js/testing';
5
+ import { getTestBed } from '@angular/core/testing';
6
+ import {
7
+ BrowserDynamicTestingModule,
8
+ platformBrowserDynamicTesting
9
+ } from '@angular/platform-browser-dynamic/testing';
10
+
11
+ declare const require: any;
12
+
13
+ // First, initialize the Angular testing environment.
14
+ getTestBed().initTestEnvironment(
15
+ BrowserDynamicTestingModule,
16
+ platformBrowserDynamicTesting()
17
+ );
18
+ // Then we find all the tests.
19
+ const context = require.context('./', true, /\.spec\.ts$/);
20
+ // And load the modules.
21
+ context.keys().map(context);
@@ -0,0 +1,276 @@
1
+ import {
2
+ addYears,
3
+ addMonths,
4
+ addDays,
5
+ addWeeks,
6
+ addQuarters,
7
+ getUnixTime,
8
+ startOfDay,
9
+ startOfWeek,
10
+ startOfMonth,
11
+ startOfQuarter,
12
+ startOfYear,
13
+ endOfDay,
14
+ endOfWeek,
15
+ endOfMonth,
16
+ endOfQuarter,
17
+ endOfYear,
18
+ format,
19
+ fromUnixTime,
20
+ getDaysInMonth,
21
+ addSeconds,
22
+ setDate,
23
+ addMinutes,
24
+ addHours,
25
+ differenceInCalendarDays,
26
+ isWeekend,
27
+ getWeek,
28
+ isToday,
29
+ differenceInDays,
30
+ differenceInCalendarQuarters,
31
+ eachMonthOfInterval,
32
+ eachWeekOfInterval,
33
+ eachDayOfInterval
34
+ } from 'date-fns';
35
+
36
+ export {
37
+ addYears,
38
+ addMonths,
39
+ addDays,
40
+ addWeeks,
41
+ addQuarters,
42
+ getUnixTime,
43
+ startOfDay,
44
+ startOfWeek,
45
+ startOfMonth,
46
+ startOfQuarter,
47
+ startOfYear,
48
+ endOfDay,
49
+ endOfWeek,
50
+ endOfMonth,
51
+ endOfQuarter,
52
+ endOfYear,
53
+ format,
54
+ fromUnixTime,
55
+ getDaysInMonth,
56
+ addSeconds,
57
+ setDate,
58
+ addMinutes,
59
+ addHours,
60
+ differenceInCalendarDays,
61
+ isWeekend,
62
+ getWeek,
63
+ isToday,
64
+ differenceInDays,
65
+ differenceInCalendarQuarters,
66
+ eachMonthOfInterval,
67
+ eachWeekOfInterval,
68
+ eachDayOfInterval
69
+ } from 'date-fns';
70
+
71
+ export type GanttDateUtil = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
72
+
73
+ export class GanttDate {
74
+ value: Date;
75
+
76
+ constructor(date?: Date | string | number) {
77
+ if (date) {
78
+ if (date instanceof Date) {
79
+ this.value = date;
80
+ } else if (typeof date === 'string' || typeof date === 'number') {
81
+ if (date.toString().length < 13) {
82
+ this.value = fromUnixTime(+date);
83
+ } else {
84
+ this.value = new Date(date);
85
+ }
86
+ } else {
87
+ throw new Error(
88
+ `The input date type is not supported expect Date | string
89
+ | number | { date: number; with_time: 0 | 1}, actual ${JSON.stringify(date)}`
90
+ );
91
+ }
92
+ } else {
93
+ this.value = new Date();
94
+ }
95
+ }
96
+
97
+ getYear(): number {
98
+ return this.value.getFullYear();
99
+ }
100
+
101
+ getMonth(): number {
102
+ return this.value.getMonth();
103
+ }
104
+
105
+ getDay(): number {
106
+ return this.value.getDay();
107
+ }
108
+
109
+ getTime(): number {
110
+ return this.value.getTime();
111
+ }
112
+
113
+ getDate(): number {
114
+ return this.value.getDate();
115
+ }
116
+
117
+ getHours(): number {
118
+ return this.value.getHours();
119
+ }
120
+
121
+ getMinutes(): number {
122
+ return this.value.getMinutes();
123
+ }
124
+
125
+ getSeconds(): number {
126
+ return this.value.getSeconds();
127
+ }
128
+
129
+ getMilliseconds(): number {
130
+ return this.value.getMilliseconds();
131
+ }
132
+
133
+ getWeek(options: { locale?: Locale; weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 } = { weekStartsOn: 1 }): number {
134
+ return getWeek(this.value, options);
135
+ }
136
+
137
+ getDaysInMonth() {
138
+ return getDaysInMonth(this.value);
139
+ }
140
+
141
+ getDaysInQuarter() {
142
+ return differenceInCalendarDays(this.endOfQuarter().addSeconds(1).value, this.startOfQuarter().value);
143
+ }
144
+
145
+ getDaysInYear() {
146
+ return differenceInCalendarDays(this.endOfYear().addSeconds(1).value, this.startOfYear().value);
147
+ }
148
+
149
+ setDate(dayOfMonth: number): GanttDate {
150
+ return new GanttDate(setDate(this.value, dayOfMonth));
151
+ }
152
+
153
+ clone(): GanttDate {
154
+ return new GanttDate(new Date(this.value));
155
+ }
156
+
157
+ add(amount: number, unit?: GanttDateUtil) {
158
+ switch (unit) {
159
+ case 'second':
160
+ return new GanttDate(this.value).addSeconds(amount);
161
+ case 'minute':
162
+ return new GanttDate(this.value).addMinutes(amount);
163
+ case 'hour':
164
+ return new GanttDate(this.value).addHours(amount);
165
+ case 'day':
166
+ return new GanttDate(this.value).addDays(amount);
167
+ case 'week':
168
+ return new GanttDate(this.value).addWeeks(amount);
169
+ case 'month':
170
+ return new GanttDate(this.value).addMonths(amount);
171
+ case 'quarter':
172
+ return new GanttDate(this.value).addQuarters(amount);
173
+ case 'year':
174
+ return new GanttDate(this.value).addYears(amount);
175
+ default:
176
+ return new GanttDate(this.value).addSeconds(amount);
177
+ }
178
+ }
179
+
180
+ addSeconds(amount: number): GanttDate {
181
+ return new GanttDate(addSeconds(this.value, amount));
182
+ }
183
+
184
+ addMinutes(amount: number): GanttDate {
185
+ return new GanttDate(addMinutes(this.value, amount));
186
+ }
187
+
188
+ addHours(amount: number): GanttDate {
189
+ return new GanttDate(addHours(this.value, amount));
190
+ }
191
+
192
+ addDays(amount: number): GanttDate {
193
+ return new GanttDate(addDays(this.value, amount));
194
+ }
195
+
196
+ addWeeks(amount: number) {
197
+ return new GanttDate(addWeeks(this.value, amount));
198
+ }
199
+
200
+ addMonths(amount: number): GanttDate {
201
+ return new GanttDate(addMonths(this.value, amount));
202
+ }
203
+
204
+ addQuarters(amount: number): GanttDate {
205
+ return new GanttDate(addQuarters(this.value, amount));
206
+ }
207
+
208
+ addYears(amount: number): GanttDate {
209
+ return new GanttDate(addYears(this.value, amount));
210
+ }
211
+
212
+ startOfDay(): GanttDate {
213
+ return new GanttDate(startOfDay(this.value));
214
+ }
215
+
216
+ startOfWeek(options?: { locale?: Locale; weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 }): GanttDate {
217
+ return new GanttDate(startOfWeek(this.value, options));
218
+ }
219
+
220
+ startOfMonth(): GanttDate {
221
+ return new GanttDate(startOfMonth(this.value));
222
+ }
223
+
224
+ startOfQuarter(): GanttDate {
225
+ return new GanttDate(startOfQuarter(this.value));
226
+ }
227
+
228
+ startOfYear(): GanttDate {
229
+ return new GanttDate(startOfYear(this.value));
230
+ }
231
+
232
+ endOfDay(): GanttDate {
233
+ return new GanttDate(endOfDay(this.value));
234
+ }
235
+
236
+ endOfWeek(options?: { locale?: Locale; weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 }): GanttDate {
237
+ return new GanttDate(endOfWeek(this.value, options));
238
+ }
239
+
240
+ endOfMonth(): GanttDate {
241
+ return new GanttDate(endOfMonth(this.value));
242
+ }
243
+
244
+ endOfQuarter(): GanttDate {
245
+ return new GanttDate(endOfQuarter(this.value));
246
+ }
247
+
248
+ endOfYear(): GanttDate {
249
+ return new GanttDate(endOfYear(this.value));
250
+ }
251
+
252
+ getUnixTime(): number {
253
+ return getUnixTime(this.value);
254
+ }
255
+
256
+ format(
257
+ mat: string,
258
+ options?: {
259
+ locale?: Locale;
260
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
261
+ firstWeekContainsDate?: number;
262
+ useAdditionalWeekYearTokens?: boolean;
263
+ useAdditionalDayOfYearTokens?: boolean;
264
+ }
265
+ ) {
266
+ return format(this.value, mat, options);
267
+ }
268
+
269
+ isWeekend() {
270
+ return isWeekend(this.value);
271
+ }
272
+
273
+ isToday() {
274
+ return isToday(this.value);
275
+ }
276
+ }
@@ -0,0 +1,66 @@
1
+ import { GanttItem, GanttItemInternal } from '../class/item';
2
+
3
+ export interface Dictionary<T = unknown> {
4
+ [key: string]: T;
5
+ }
6
+
7
+ export function isNumber(value: any) {
8
+ return typeof value === 'number';
9
+ }
10
+
11
+ export function isString(value: any) {
12
+ return typeof value === 'string';
13
+ }
14
+
15
+ export function isUndefined(value: any) {
16
+ return value === undefined;
17
+ }
18
+
19
+ export function hexToRgb(color: string, opacity = 1) {
20
+ if (/^#/g.test(color)) {
21
+ return `rgba(${parseInt(color.slice(1, 3), 16)},${parseInt(color.slice(3, 5), 16)},${parseInt(color.slice(5, 7), 16)},${opacity})`;
22
+ } else {
23
+ return color;
24
+ }
25
+ }
26
+
27
+ export function uniqBy<T = unknown>(array: T[], key: keyof T) {
28
+ const valuesMap: Dictionary<T> = {};
29
+ const result = [];
30
+ (array || []).forEach((value) => {
31
+ const _key = value[key as string];
32
+ if (!valuesMap[_key]) {
33
+ valuesMap[_key] = value;
34
+ result.push(value);
35
+ }
36
+ });
37
+ return result;
38
+ }
39
+
40
+ export function flatten<T = unknown>(array: T[]) {
41
+ return array.reduce((pre, cur) => {
42
+ return pre.concat(Array.isArray(cur) ? flatten(cur) : cur);
43
+ }, []);
44
+ }
45
+
46
+ export function recursiveItems(items: GanttItemInternal[]) {
47
+ const result = [];
48
+ (items || []).forEach((item) => {
49
+ result.push(item);
50
+ if (item.expanded && item.children) {
51
+ result.push(...recursiveItems(item.children));
52
+ }
53
+ });
54
+ return result;
55
+ }
56
+
57
+ export function getFlatItems(items: GanttItem[]) {
58
+ const result = [];
59
+ (items || []).forEach((item) => {
60
+ result.push(item);
61
+ if (item.children) {
62
+ result.push(...getFlatItems(item.children));
63
+ }
64
+ });
65
+ return result;
66
+ }