@worktile/gantt 14.0.2 → 14.0.3

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.
@@ -13,12 +13,13 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
13
13
  import { __decorate, __param } from 'tslib';
14
14
 
15
15
  class GanttDatePoint {
16
- constructor(start, text, x, y, additions) {
16
+ constructor(start, text, x, y, additions, style) {
17
17
  this.start = start;
18
18
  this.text = text;
19
19
  this.x = x;
20
20
  this.y = y;
21
21
  this.additions = additions;
22
+ this.style = style;
22
23
  }
23
24
  }
24
25
 
@@ -195,37 +196,6 @@ class GanttDate {
195
196
  }
196
197
  }
197
198
 
198
- var GanttViewType;
199
- (function (GanttViewType) {
200
- GanttViewType["day"] = "day";
201
- GanttViewType["quarter"] = "quarter";
202
- GanttViewType["month"] = "month";
203
- GanttViewType["year"] = "year";
204
- GanttViewType["week"] = "week";
205
- })(GanttViewType || (GanttViewType = {}));
206
- const ganttViews = [
207
- {
208
- name: '日',
209
- value: GanttViewType.day
210
- },
211
- {
212
- name: '周',
213
- value: GanttViewType.week
214
- },
215
- {
216
- name: '月',
217
- value: GanttViewType.month
218
- },
219
- {
220
- name: '季',
221
- value: GanttViewType.quarter
222
- },
223
- {
224
- name: '年',
225
- value: GanttViewType.year
226
- }
227
- ];
228
-
229
199
  var GanttLinkType;
230
200
  (function (GanttLinkType) {
231
201
  GanttLinkType[GanttLinkType["fs"] = 1] = "fs";
@@ -275,34 +245,28 @@ class GanttItemInternal {
275
245
  this.expanded = this.origin.expanded === undefined ? false : this.origin.expanded;
276
246
  this.start = item.start ? new GanttDate(item.start) : null;
277
247
  this.end = item.end ? new GanttDate(item.end) : null;
278
- this.viewType = options && options.viewType ? options.viewType : GanttViewType.month;
248
+ // 默认填充 30
249
+ this.fillDays = options?.fillDays || 30;
279
250
  this.children = (item.children || []).map((subItem) => {
280
- return new GanttItemInternal(subItem, { viewType: this.viewType });
251
+ return new GanttItemInternal(subItem, { fillDays: this.fillDays });
281
252
  });
282
253
  this.type = this.origin.type || GanttItemType.bar;
283
254
  this.progress = this.origin.progress;
284
- // fill one month when start or end is null
255
+ // fill days when start or end is null
285
256
  this.fillItemStartOrEnd(item);
286
257
  }
287
258
  get refs() {
288
259
  return this.refs$.getValue();
289
260
  }
290
261
  fillItemStartOrEnd(item) {
291
- let addInterval;
292
- switch (this.viewType) {
293
- case GanttViewType.day:
294
- case GanttViewType.week:
295
- addInterval = 0;
296
- break;
297
- default:
298
- addInterval = 30;
299
- break;
300
- }
301
- if (item.start && !item.end) {
302
- this.end = new GanttDate(item.start).addDays(addInterval).endOfDay();
303
- }
304
- if (!item.start && item.end) {
305
- this.start = new GanttDate(item.end).addDays(-addInterval).startOfDay();
262
+ if (this.fillDays > 0) {
263
+ const fillDays = this.fillDays - 1;
264
+ if (item.start && !item.end) {
265
+ this.end = new GanttDate(item.start).addDays(fillDays).endOfDay();
266
+ }
267
+ if (!item.start && item.end) {
268
+ this.start = new GanttDate(item.end).addDays(-fillDays).startOfDay();
269
+ }
306
270
  }
307
271
  }
308
272
  updateRefs(refs) {
@@ -317,7 +281,7 @@ class GanttItemInternal {
317
281
  addChildren(items) {
318
282
  this.origin.children = items;
319
283
  this.children = (items || []).map((subItem) => {
320
- return new GanttItemInternal(subItem, { viewType: this.viewType });
284
+ return new GanttItemInternal(subItem, { fillDays: this.fillDays });
321
285
  });
322
286
  }
323
287
  setExpand(expanded) {
@@ -347,6 +311,37 @@ class GanttGroupInternal {
347
311
  }
348
312
  }
349
313
 
314
+ var GanttViewType;
315
+ (function (GanttViewType) {
316
+ GanttViewType["day"] = "day";
317
+ GanttViewType["quarter"] = "quarter";
318
+ GanttViewType["month"] = "month";
319
+ GanttViewType["year"] = "year";
320
+ GanttViewType["week"] = "week";
321
+ })(GanttViewType || (GanttViewType = {}));
322
+ const ganttViews = [
323
+ {
324
+ name: '日',
325
+ value: GanttViewType.day
326
+ },
327
+ {
328
+ name: '周',
329
+ value: GanttViewType.week
330
+ },
331
+ {
332
+ name: '月',
333
+ value: GanttViewType.month
334
+ },
335
+ {
336
+ name: '季',
337
+ value: GanttViewType.quarter
338
+ },
339
+ {
340
+ name: '年',
341
+ value: GanttViewType.year
342
+ }
343
+ ];
344
+
350
345
  class GanttBaselineItemInternal {
351
346
  constructor(item) {
352
347
  this.refs$ = new BehaviorSubject(null);
@@ -505,7 +500,8 @@ const viewOptions$4 = {
505
500
  end: new GanttDate().endOfQuarter().addQuarters(2),
506
501
  cellWidth: 280,
507
502
  addAmount: 1,
508
- addUnit: 'quarter'
503
+ addUnit: 'quarter',
504
+ fillDays: 30
509
505
  };
510
506
  class GanttViewMonth extends GanttView {
511
507
  constructor(start, end, options) {
@@ -553,7 +549,8 @@ const viewOptions$3 = {
553
549
  max: new GanttDate().addYears(2).endOfYear(),
554
550
  cellWidth: 500,
555
551
  addAmount: 1,
556
- addUnit: 'year'
552
+ addUnit: 'year',
553
+ fillDays: 30
557
554
  };
558
555
  class GanttViewQuarter extends GanttView {
559
556
  constructor(start, end, options) {
@@ -599,7 +596,8 @@ const viewOptions$2 = {
599
596
  start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
600
597
  end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
601
598
  addAmount: 1,
602
- addUnit: 'month'
599
+ addUnit: 'month',
600
+ fillDays: 1
603
601
  };
604
602
  class GanttViewDay extends GanttView {
605
603
  constructor(start, end, options) {
@@ -651,7 +649,8 @@ const viewOptions$1 = {
651
649
  start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
652
650
  end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
653
651
  addAmount: 1,
654
- addUnit: 'month'
652
+ addUnit: 'month',
653
+ fillDays: 1
655
654
  };
656
655
  class GanttViewWeek extends GanttView {
657
656
  constructor(start, end, options) {
@@ -698,7 +697,8 @@ const viewOptions = {
698
697
  start: new GanttDate().addYears(-2).startOfYear(),
699
698
  end: new GanttDate().addYears(2).endOfYear(),
700
699
  addAmount: 1,
701
- addUnit: 'year'
700
+ addUnit: 'year',
701
+ fillDays: 30
702
702
  };
703
703
  class GanttViewYear extends GanttView {
704
704
  constructor(start, end, options) {
@@ -922,14 +922,14 @@ class GanttUpper {
922
922
  this.originItems.forEach((origin) => {
923
923
  const group = this.groupsMap[origin.group_id];
924
924
  if (group) {
925
- const item = new GanttItemInternal(origin, { viewType: this.viewType });
925
+ const item = new GanttItemInternal(origin, { fillDays: this.view.options?.fillDays });
926
926
  group.items.push(item);
927
927
  }
928
928
  });
929
929
  }
930
930
  else {
931
931
  this.originItems.forEach((origin) => {
932
- const item = new GanttItemInternal(origin, { viewType: this.viewType });
932
+ const item = new GanttItemInternal(origin, { fillDays: this.view.options?.fillDays });
933
933
  this.items.push(item);
934
934
  });
935
935
  }
@@ -1045,10 +1045,10 @@ class GanttUpper {
1045
1045
  ngOnChanges(changes) {
1046
1046
  if (!this.firstChange) {
1047
1047
  if (changes.viewType && changes.viewType.currentValue && changes.viewType.currentValue !== changes.viewType.previousValue) {
1048
- this.viewTypeChange(changes.viewType.currentValue);
1048
+ this.changeView(changes.viewType.currentValue);
1049
1049
  }
1050
1050
  if (changes.viewOptions) {
1051
- this.viewTypeChange(this.viewType);
1051
+ this.changeView(this.viewType);
1052
1052
  }
1053
1053
  if (changes.originItems || changes.originGroups) {
1054
1054
  this.setupExpandedState();
@@ -1115,7 +1115,7 @@ class GanttUpper {
1115
1115
  }
1116
1116
  return this.selectionModel.isSelected(id);
1117
1117
  }
1118
- viewTypeChange(type) {
1118
+ changeView(type) {
1119
1119
  this.viewType = type;
1120
1120
  this.createView();
1121
1121
  this.setupGroups();
@@ -1125,8 +1125,8 @@ class GanttUpper {
1125
1125
  this.computeItemsRefs(...this.baselineItems);
1126
1126
  this.viewChange.emit(this.view);
1127
1127
  }
1128
- renderView(type) {
1129
- this.viewTypeChange(type);
1128
+ rerenderView() {
1129
+ this.changeView(this.viewType);
1130
1130
  }
1131
1131
  }
1132
1132
  GanttUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.11", ngImport: i0, type: GanttUpper, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Directive });
@@ -2315,10 +2315,10 @@ class GanttCalendarComponent {
2315
2315
  }
2316
2316
  }
2317
2317
  GanttCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.11", ngImport: i0, type: GanttCalendarComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
2318
- GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.11", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2318
+ GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.11", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
2319
2319
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.11", ngImport: i0, type: GanttCalendarComponent, decorators: [{
2320
2320
  type: Component,
2321
- args: [{ selector: 'gantt-calendar-overlay', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n" }]
2321
+ args: [{ selector: 'gantt-calendar-overlay', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n" }]
2322
2322
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2323
2323
  type: Inject,
2324
2324
  args: [GANTT_UPPER_TOKEN]
@@ -2334,7 +2334,7 @@ class NgxGanttToolbarComponent {
2334
2334
  this.ganttViewsMap = keyBy(ganttViews, 'value');
2335
2335
  }
2336
2336
  selectView(view) {
2337
- this.ganttUpper.viewTypeChange(view);
2337
+ this.ganttUpper.changeView(view);
2338
2338
  }
2339
2339
  }
2340
2340
  NgxGanttToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.11", ngImport: i0, type: NgxGanttToolbarComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });