@progress/kendo-angular-gantt 0.2.0-dev.202111231320 → 0.2.0-dev.202111241002

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 (61) hide show
  1. package/dist/cdn/js/kendo-angular-gantt.js +2 -2
  2. package/dist/cdn/main.js +2 -2
  3. package/dist/es/common/default-callbacks.js +4 -0
  4. package/dist/es/gantt.component.js +187 -32
  5. package/dist/es/gantt.module.js +3 -1
  6. package/dist/es/main.js +1 -0
  7. package/dist/es/package-metadata.js +1 -1
  8. package/dist/es/rendering/gantt-milestone-task.component.js +1 -1
  9. package/dist/es/rendering/gantt-summary-task.component.js +1 -1
  10. package/dist/es/rendering/gantt-task-base.js +8 -4
  11. package/dist/es/rendering/gantt-task.component.js +1 -1
  12. package/dist/es/rendering/gantt-tasks-table-body.component.js +3 -3
  13. package/dist/es/selection/selectable.directive.js +141 -0
  14. package/dist/es/selection/selection-change-event.js +4 -0
  15. package/dist/es/timeline/gantt-timeline.component.js +5 -1
  16. package/dist/es/utils.js +5 -1
  17. package/dist/es2015/common/default-callbacks.d.ts +4 -0
  18. package/dist/es2015/common/default-callbacks.js +4 -0
  19. package/dist/es2015/gantt.component.d.ts +66 -18
  20. package/dist/es2015/gantt.component.js +191 -34
  21. package/dist/es2015/gantt.module.js +3 -1
  22. package/dist/es2015/index.metadata.json +1 -1
  23. package/dist/es2015/main.d.ts +2 -0
  24. package/dist/es2015/main.js +1 -0
  25. package/dist/es2015/models/events/cell-click-event.interface.d.ts +31 -8
  26. package/dist/es2015/models/events/task-click-event.interface.d.ts +13 -5
  27. package/dist/es2015/models/models.d.ts +2 -0
  28. package/dist/es2015/package-metadata.js +1 -1
  29. package/dist/es2015/rendering/gantt-milestone-task.component.js +1 -0
  30. package/dist/es2015/rendering/gantt-summary-task.component.js +1 -0
  31. package/dist/es2015/rendering/gantt-task-base.d.ts +2 -1
  32. package/dist/es2015/rendering/gantt-task-base.js +8 -4
  33. package/dist/es2015/rendering/gantt-task.component.js +1 -0
  34. package/dist/es2015/rendering/gantt-tasks-table-body.component.d.ts +1 -1
  35. package/dist/es2015/rendering/gantt-tasks-table-body.component.js +5 -2
  36. package/dist/es2015/selection/selectable.directive.d.ts +42 -0
  37. package/dist/es2015/selection/selectable.directive.js +122 -0
  38. package/dist/es2015/selection/selection-change-event.d.ts +25 -0
  39. package/dist/es2015/selection/selection-change-event.js +4 -0
  40. package/dist/es2015/timeline/gantt-timeline.component.d.ts +1 -0
  41. package/dist/es2015/timeline/gantt-timeline.component.js +5 -0
  42. package/dist/es2015/utils.d.ts +5 -0
  43. package/dist/es2015/utils.js +5 -1
  44. package/dist/fesm2015/index.js +334 -39
  45. package/dist/fesm5/index.js +347 -42
  46. package/dist/npm/common/default-callbacks.js +4 -0
  47. package/dist/npm/gantt.component.js +187 -32
  48. package/dist/npm/gantt.module.js +3 -1
  49. package/dist/npm/main.js +2 -0
  50. package/dist/npm/package-metadata.js +1 -1
  51. package/dist/npm/rendering/gantt-milestone-task.component.js +1 -1
  52. package/dist/npm/rendering/gantt-summary-task.component.js +1 -1
  53. package/dist/npm/rendering/gantt-task-base.js +8 -4
  54. package/dist/npm/rendering/gantt-task.component.js +1 -1
  55. package/dist/npm/rendering/gantt-tasks-table-body.component.js +3 -3
  56. package/dist/npm/selection/selectable.directive.js +143 -0
  57. package/dist/npm/selection/selection-change-event.js +6 -0
  58. package/dist/npm/timeline/gantt-timeline.component.js +5 -1
  59. package/dist/npm/utils.js +4 -0
  60. package/dist/systemjs/kendo-angular-gantt.js +1 -1
  61. package/package.json +1 -1
@@ -5,14 +5,14 @@
5
5
  import * as tslib_1 from "tslib";
6
6
  var GanttComponent_1;
7
7
  import { Component, forwardRef, HostBinding, Input, Output, EventEmitter, ViewChild, ContentChildren, ContentChild, QueryList, isDevMode, Renderer2, ElementRef, NgZone } from '@angular/core';
8
- import { DataBoundTreeComponent, ExpandableTreeComponent } from '@progress/kendo-angular-treelist';
9
- import { TreeListComponent } from '@progress/kendo-angular-treelist';
8
+ import { TreeListComponent, DataBoundTreeComponent, ExpandableTreeComponent } from '@progress/kendo-angular-treelist';
9
+ import { Day } from '@progress/kendo-date-math';
10
10
  import { Subscription } from 'rxjs';
11
11
  import { validatePackage } from '@progress/kendo-licensing';
12
12
  import { packageMetadata } from './package-metadata';
13
13
  import { anyChanged, hasObservers } from '@progress/kendo-angular-common';
14
14
  import { GanttColumnBase } from './columns/columns';
15
- import { fetchChildren, hasChildren, rowClassCallback, taskClassCallback } from './common/default-callbacks';
15
+ import { fetchChildren, hasChildren, isSelected, rowClassCallback, taskClassCallback } from './common/default-callbacks';
16
16
  import { TimelineViewService } from './timeline/timeline-view.service';
17
17
  import { TimelineDayViewService } from './timeline/timeline-day-view.service';
18
18
  import { TimelineWeekViewService } from './timeline/timeline-week-view.service';
@@ -30,7 +30,6 @@ import { GanttSummaryTaskTemplateDirective } from './template-directives/summary
30
30
  import { GanttTaskContentTemplateDirective } from './template-directives/task-content-template.directive';
31
31
  import { ToolbarTemplateDirective } from './toolbar/toolbar-template.directive';
32
32
  import { ViewBase } from './timeline/view-base';
33
- import { Day } from '@progress/kendo-date-math';
34
33
  import { getEditItem } from './editing/util';
35
34
  const TREELIST_GROUP_COLUMNS_CLASS = 'k-gantt-treelist-nested-columns';
36
35
  const DEFAULT_VIEW = 'week';
@@ -118,6 +117,27 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
118
117
  this.hostElement = hostElement;
119
118
  this.zone = zone;
120
119
  this.hostClasses = true;
120
+ /**
121
+ * Provides a callback that determines if the given task is selected ([see example]({% slug selection_gantt %}#toc-custom-selection))
122
+ *
123
+ * > The [`selectable`]({% slug gantt_api_ganttcomponent %}#toc-selectable) prop has to be set to `true` in order for this callback to be executed.
124
+ */
125
+ this.isSelected = isSelected;
126
+ /**
127
+ * Fires when the Gantt selection is changed through user interaction.
128
+ *
129
+ * Holds data about the affected [`items`]({% slug api_gantt_selectionchangeevent %}#toc-items) and the attempted [`action`]({% slug api_gantt_selectionchangeevent %}#toc-action):
130
+ * - `select` - Triggered on `click` or `ctrl + click` on deselected items.
131
+ * - `remove` - Triggered on `ctrl + click` on selected items.
132
+ */
133
+ this.selectionChange = new EventEmitter();
134
+ /**
135
+ * Enables or disables the Gantt selection mechanism ([see example]({% slug selection_gantt %}#toc-custom-selection)).
136
+ *
137
+ * > When set to `true`, the [`isSelected`]({% slug gantt_api_ganttcomponent %}#toc-isselected) callback has to be provided.
138
+ * > When applied, the [`SelectableDirective`]({% slug api_gantt_selectabledirective %}) sets `selectable` to `true` internally.
139
+ */
140
+ this.selectable = false;
121
141
  /**
122
142
  * The position of the toolbar.
123
143
  *
@@ -286,6 +306,14 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
286
306
  * Fires when the user changes the locked state of the columns from the column menu or by reordering the columns.
287
307
  */
288
308
  this.columnLockedChange = new EventEmitter();
309
+ /**
310
+ * Fires when a cell is clicked.
311
+ */
312
+ this.cellClick = new EventEmitter();
313
+ /**
314
+ * Fires when a task is clicked.
315
+ */
316
+ this.taskClick = new EventEmitter();
289
317
  /**
290
318
  * @hidden
291
319
  *
@@ -311,9 +339,6 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
311
339
  this.optionChangesSubscriptions = new Subscription();
312
340
  this.editServiceSubscription = new Subscription();
313
341
  validatePackage(packageMetadata);
314
- this.handleTimelineDblClick = this.handleTimelineDblClick.bind(this);
315
- this.handleTimelineMouseDown = this.handleTimelineMouseDown.bind(this);
316
- this.handleDoubleClick = this.handleDoubleClick.bind(this);
317
342
  this.optionChangesSubscriptions.add(this.optionChangesService.viewChanges.subscribe(() => {
318
343
  this.loadTimelineData();
319
344
  }));
@@ -486,6 +511,15 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
486
511
  // TODO: review if this is a performance concern?
487
512
  return this.timelineViewService.service(this.activeView);
488
513
  }
514
+ /**
515
+ * @hidden
516
+ *
517
+ * Retrieves the `isSelected` callback if `selectable` is set to `true`
518
+ * Otherwise returns the default callback, which always returns `false`.
519
+ */
520
+ get isTaskSelected() {
521
+ return this.selectable ? this.isSelected : isSelected;
522
+ }
489
523
  /**
490
524
  * @hidden
491
525
  *
@@ -580,6 +614,14 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
580
614
  this.treeList.reorderColumn(source, destIndex, options);
581
615
  }
582
616
  }
617
+ /**
618
+ * Updates the data of the Gantt and forces row-related callbacks to be called anew.
619
+ */
620
+ updateView() {
621
+ if (isPresent(this.treeList)) {
622
+ this.treeList.updateView();
623
+ }
624
+ }
583
625
  /**
584
626
  * Opens the task editing dialog.
585
627
  */
@@ -640,16 +682,6 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
640
682
  this.dependencyDomService.notifyChanges();
641
683
  }
642
684
  }
643
- /**
644
- * @hidden
645
- *
646
- * Used by the GanttExpandableDirective.
647
- */
648
- updateView() {
649
- if (isPresent(this.treeList)) {
650
- this.treeList.updateView();
651
- }
652
- }
653
685
  /**
654
686
  * @hidden
655
687
  */
@@ -687,24 +719,89 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
687
719
  /**
688
720
  * @hidden
689
721
  */
690
- handleCellClick(event) {
691
- this._cellClickEvent = event;
722
+ handleTimelineRightClick(event) {
723
+ const target = event.target;
724
+ const gantt = this.hostElement.nativeElement;
725
+ if (!isTask(target, gantt) || isClearButton(target, gantt)) {
726
+ return;
727
+ }
728
+ if (hasObservers(this.taskClick)) {
729
+ const taskIndex = getClosestTaskIndex(target, gantt);
730
+ const task = this.renderedTreeListItems[taskIndex];
731
+ this.zone.run(() => this.emitTaskClick(event, task, taskIndex));
732
+ }
733
+ }
734
+ /**
735
+ * @hidden
736
+ */
737
+ handleTimelineClick(event) {
738
+ const target = event.target;
739
+ const gantt = this.hostElement.nativeElement;
740
+ if (!isTask(target, gantt) || isClearButton(target, gantt)) {
741
+ return;
742
+ }
743
+ const taskIndex = getClosestTaskIndex(target, gantt);
744
+ const task = this.renderedTreeListItems[taskIndex];
745
+ const selectionAction = this.getSelectionAction(event, task);
746
+ if ((hasObservers(this.selectionChange) && !this.isSameSelection(selectionAction, task)) ||
747
+ hasObservers(this.taskClick)) {
748
+ this.zone.run(() => {
749
+ this.emitSelectionChange(task, selectionAction);
750
+ this.emitTaskClick(event, task, taskIndex);
751
+ });
752
+ }
692
753
  }
693
754
  /**
694
755
  * @hidden
695
756
  */
696
- handleDoubleClick(event) {
697
- const cell = this._cellClickEvent.originalEvent.target;
698
- if (event.target !== cell) {
757
+ handleTreeListDoubleClick(event) {
758
+ if (!isPresent(this.lastTreeListCellClick) || event.target !== this.lastTreeListCellClick.originalEvent.target) {
699
759
  return;
700
760
  }
701
- this.editItem = getEditItem(this._cellClickEvent.dataItem, this.treeList.view.data, this.mapper);
761
+ this.editItem = getEditItem(this.lastTreeListCellClick.dataItem, this.treeList.view.data, this.mapper);
702
762
  if (hasObservers(this.cellDblClick)) {
703
763
  this.zone.run(() => {
704
- this.cellDblClick.emit(Object.assign({}, this._cellClickEvent, { sender: this }));
764
+ this.cellDblClick.emit({
765
+ column: this.lastTreeListCellClick.column,
766
+ columnIndex: this.lastTreeListCellClick.columnIndex,
767
+ dataItem: this.lastTreeListCellClick.dataItem,
768
+ isEdited: this.lastTreeListCellClick.isEdited,
769
+ originalEvent: this.lastTreeListCellClick.originalEvent,
770
+ rowIndex: this.lastTreeListCellClick.rowIndex,
771
+ type: 'dblclick',
772
+ sender: this
773
+ });
705
774
  });
706
775
  }
707
776
  }
777
+ /**
778
+ * @hidden
779
+ */
780
+ handleTreeListSelectionChange(event) {
781
+ // prevent selection change from right-click
782
+ if (isPresent(this.lastTreeListCellClick) && this.lastTreeListCellClick.type === 'contextmenu') {
783
+ return;
784
+ }
785
+ const task = event.items.map(item => item.dataItem)[0]; // single selection only currently available
786
+ const action = event.action;
787
+ this.emitSelectionChange(task, action);
788
+ }
789
+ /**
790
+ * @hidden
791
+ */
792
+ handleTreeListCellClick(event) {
793
+ this.lastTreeListCellClick = event;
794
+ this.cellClick.emit({
795
+ column: event.column,
796
+ columnIndex: event.columnIndex,
797
+ dataItem: event.dataItem,
798
+ isEdited: event.isEdited,
799
+ originalEvent: event.originalEvent,
800
+ rowIndex: event.rowIndex,
801
+ type: event.type,
802
+ sender: this
803
+ });
804
+ }
708
805
  /**
709
806
  * @hidden
710
807
  */
@@ -731,13 +828,17 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
731
828
  if (!isTask(target, gantt) || isClearButton(target, gantt)) {
732
829
  return;
733
830
  }
734
- const taskIndex = getClosestTaskIndex(target, gantt);
735
- const task = this.renderedTreeListItems[taskIndex];
736
- this.zone.run(() => this.taskDblClick.emit({
737
- dataItem: task,
738
- originalEvent: event,
739
- sender: this
740
- }));
831
+ if (hasObservers(this.taskDblClick)) {
832
+ const taskIndex = getClosestTaskIndex(target, gantt);
833
+ const task = this.renderedTreeListItems[taskIndex];
834
+ this.zone.run(() => this.taskDblClick.emit({
835
+ dataItem: task,
836
+ originalEvent: event,
837
+ sender: this,
838
+ rowIndex: taskIndex,
839
+ type: 'dblclick'
840
+ }));
841
+ }
741
842
  }
742
843
  /**
743
844
  * @hidden
@@ -745,6 +846,26 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
745
846
  getText(token) {
746
847
  return this.localizationService.get(token);
747
848
  }
849
+ emitTaskClick(event, dataItem, itemIndex) {
850
+ this.taskClick.emit({
851
+ originalEvent: event,
852
+ dataItem: dataItem,
853
+ rowIndex: itemIndex,
854
+ type: event.type,
855
+ sender: this
856
+ });
857
+ }
858
+ emitSelectionChange(dataItem, action) {
859
+ if (this.isSameSelection(action, dataItem)) {
860
+ return;
861
+ }
862
+ this.selectionChange.emit({
863
+ action: action,
864
+ items: [dataItem],
865
+ sender: this
866
+ });
867
+ this.updateView();
868
+ }
748
869
  updateTreeListGroupClass(columns = this.columns) {
749
870
  if (!isPresent(this.treeList)) {
750
871
  return;
@@ -771,6 +892,13 @@ let GanttComponent = GanttComponent_1 = class GanttComponent {
771
892
  }
772
893
  return this.views.find(view => view.type === this.activeView);
773
894
  }
895
+ isSameSelection(action, dataItem) {
896
+ return action === 'select' && this.isSelected(dataItem);
897
+ }
898
+ getSelectionAction({ ctrlKey, metaKey }, dataItem) {
899
+ const shouldToggleSelection = ctrlKey || metaKey;
900
+ return (shouldToggleSelection && this.isSelected(dataItem)) ? 'remove' : 'select';
901
+ }
774
902
  };
775
903
  tslib_1.__decorate([
776
904
  ViewChild(TreeListComponent, { static: true }),
@@ -830,6 +958,18 @@ tslib_1.__decorate([
830
958
  tslib_1.__metadata("design:type", Array),
831
959
  tslib_1.__metadata("design:paramtypes", [Array])
832
960
  ], GanttComponent.prototype, "data", null);
961
+ tslib_1.__decorate([
962
+ Input(),
963
+ tslib_1.__metadata("design:type", Function)
964
+ ], GanttComponent.prototype, "isSelected", void 0);
965
+ tslib_1.__decorate([
966
+ Output(),
967
+ tslib_1.__metadata("design:type", EventEmitter)
968
+ ], GanttComponent.prototype, "selectionChange", void 0);
969
+ tslib_1.__decorate([
970
+ Input(),
971
+ tslib_1.__metadata("design:type", Boolean)
972
+ ], GanttComponent.prototype, "selectable", void 0);
833
973
  tslib_1.__decorate([
834
974
  Input(),
835
975
  tslib_1.__metadata("design:type", String)
@@ -998,6 +1138,14 @@ tslib_1.__decorate([
998
1138
  Output(),
999
1139
  tslib_1.__metadata("design:type", EventEmitter)
1000
1140
  ], GanttComponent.prototype, "columnLockedChange", void 0);
1141
+ tslib_1.__decorate([
1142
+ Output(),
1143
+ tslib_1.__metadata("design:type", EventEmitter)
1144
+ ], GanttComponent.prototype, "cellClick", void 0);
1145
+ tslib_1.__decorate([
1146
+ Output(),
1147
+ tslib_1.__metadata("design:type", EventEmitter)
1148
+ ], GanttComponent.prototype, "taskClick", void 0);
1001
1149
  GanttComponent = GanttComponent_1 = tslib_1.__decorate([
1002
1150
  Component({
1003
1151
  selector: 'kendo-gantt',
@@ -1218,6 +1366,8 @@ GanttComponent = GanttComponent_1 = tslib_1.__decorate([
1218
1366
  [reorderable]="columnsReorderable"
1219
1367
  [resizable]="columnsResizable"
1220
1368
  [rowClass]="rowClass"
1369
+ [isSelected]="isSelected"
1370
+ [selectable]="selectable"
1221
1371
  [sortable]="sortable"
1222
1372
  [sort]="sort"
1223
1373
  [filterable]="filterMenu"
@@ -1235,11 +1385,14 @@ GanttComponent = GanttComponent_1 = tslib_1.__decorate([
1235
1385
  (columnResize)="columnResize.emit($event)"
1236
1386
  (columnVisibilityChange)="handleColumnVisibilityChange($event)"
1237
1387
  (columnLockedChange)="columnLockedChange.emit($event)"
1238
- (cellClick)="handleCellClick($event)"
1388
+ (selectionChange)="handleTreeListSelectionChange($event)"
1389
+ (cellClick)="handleTreeListCellClick($event)"
1239
1390
  (cellClose)="handleCellClose($event)"
1240
1391
  [kendoEventsOutsideAngular]="{
1241
- dblclick: handleDoubleClick
1242
- }">
1392
+ dblclick: handleTreeListDoubleClick
1393
+ }"
1394
+ [scope]="this"
1395
+ >
1243
1396
  <kendo-treelist-messages [kendoGanttTreeListMessages]="localizationService"></kendo-treelist-messages>
1244
1397
  </kendo-treelist>
1245
1398
  </kendo-splitter-pane>
@@ -1266,10 +1419,14 @@ GanttComponent = GanttComponent_1 = tslib_1.__decorate([
1266
1419
  [taskClass]="taskClass"
1267
1420
  [dependencies]="dependencies"
1268
1421
  [hasChildren]="hasChildren"
1422
+ [isTaskSelected]="isTaskSelected"
1269
1423
  [kendoEventsOutsideAngular]="{
1424
+ click: handleTimelineClick,
1425
+ contextmenu: handleTimelineRightClick,
1270
1426
  dblclick: handleTimelineDblClick,
1271
1427
  mousedown: handleTimelineMouseDown
1272
1428
  }"
1429
+ [scope]="this"
1273
1430
  ></kendo-gantt-timeline>
1274
1431
  </kendo-splitter-pane>
1275
1432
  </kendo-splitter>
@@ -8,6 +8,7 @@ import { CommonModule } from '@angular/common';
8
8
  import { SplitterModule } from '@progress/kendo-angular-layout';
9
9
  import { TreeListModule } from '@progress/kendo-angular-treelist';
10
10
  import { ButtonsModule } from '@progress/kendo-angular-buttons';
11
+ import { EventsModule } from '@progress/kendo-angular-common';
11
12
  import { DialogModule } from '@progress/kendo-angular-dialog';
12
13
  import { GanttComponent } from './gantt.component';
13
14
  import { GanttTimelineComponent } from './timeline/gantt-timeline.component';
@@ -22,6 +23,7 @@ import { GanttMilestoneTaskComponent } from './rendering/gantt-milestone-task.co
22
23
  import { GanttFlatBindingDirective } from './binding-directives/flat-binding.directive';
23
24
  import { GanttHierarchyBindingDirective } from './binding-directives/hierarchy-binding.directive';
24
25
  import { GanttExpandableDirective } from './expanded-state/expandable.directive';
26
+ import { SelectableDirective } from './selection/selectable.directive';
25
27
  import { ToolbarComponent } from './toolbar/toolbar.component';
26
28
  import { ToolbarTemplateDirective } from './toolbar/toolbar-template.directive';
27
29
  import { ViewSelectorComponent } from './toolbar/view-selector.component';
@@ -39,7 +41,6 @@ import { CustomMessagesComponent } from './localization/custom-messages.componen
39
41
  import { L10N_PREFIX } from '@progress/kendo-angular-l10n';
40
42
  import { LocalizedMessagesDirective } from './localization/localized-messages.directive';
41
43
  import { GanttTreeListMessagesDirective } from './localization/treelist-messages.directive';
42
- import { EventsModule } from '@progress/kendo-angular-common';
43
44
  const IMPORTED_MODULES = [
44
45
  CommonModule,
45
46
  ReactiveFormsModule,
@@ -84,6 +85,7 @@ const DECLARATIONS = [
84
85
  TimelineDayViewComponent,
85
86
  TimelineWeekViewComponent,
86
87
  TimelineMonthViewComponent,
88
+ SelectableDirective,
87
89
  EditDialogComponent,
88
90
  CustomMessagesComponent,
89
91
  LocalizedMessagesDirective,