@visactor/vtable-gantt 1.26.3-alpha.0 → 1.26.4-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/Gantt.d.ts CHANGED
@@ -155,6 +155,7 @@ export declare class Gantt extends EventTarget {
155
155
  getRecordByIndex(taskShowIndex: number, sub_task_index?: number | number[]): any;
156
156
  _refreshTaskBar(taskShowIndex: number, sub_task_index?: number): void;
157
157
  _updateRecordToListTable(record: any, index: number | number[]): void;
158
+ private _refreshSortedTaskBarsAfterRecordUpdate;
158
159
  getTaskInfoByTaskListIndex(taskShowIndex: number, sub_task_index?: number | number[]): {
159
160
  taskRecord: any;
160
161
  taskDays: number;
package/cjs/Gantt.js CHANGED
@@ -368,6 +368,16 @@ class Gantt extends EventTarget_1.EventTarget {
368
368
  _updateRecordToListTable(record, index) {
369
369
  this.taskListTableInstance.updateRecords([ record ], [ index ]);
370
370
  }
371
+ _refreshSortedTaskBarsAfterRecordUpdate(recordIndex, taskShowIndex) {
372
+ var _a;
373
+ const sortState = null === (_a = this.taskListTableInstance) || void 0 === _a ? void 0 : _a.sortState;
374
+ if (!sortState || Array.isArray(sortState) && 0 === sortState.length) return !1;
375
+ const nextTaskShowIndex = this.getTaskShowIndexByRecordIndex(recordIndex);
376
+ if (!(0, vutils_1.isValid)(nextTaskShowIndex) || nextTaskShowIndex === taskShowIndex) return !1;
377
+ this._syncPropsFromTable(), this.scenegraph.refreshTaskBarsAndGrid();
378
+ const left = this.stateManager.scroll.horizontalBarPos, top = this.stateManager.scroll.verticalBarPos;
379
+ return this.scenegraph.setX(-left), this.scenegraph.setY(-top), !0;
380
+ }
371
381
  getTaskInfoByTaskListIndex(taskShowIndex, sub_task_index) {
372
382
  const taskRecord = this.getRecordByIndex(taskShowIndex, sub_task_index), isMilestone = null == taskRecord ? void 0 : taskRecord.type, startDateField = this.parsedOptions.startDateField, endDateField = this.parsedOptions.endDateField, progressField = this.parsedOptions.progressField, rawDateStartDateTime = (0,
373
383
  util_1.createDateAtMidnight)(null == taskRecord ? void 0 : taskRecord[startDateField]).getTime(), rawDateEndDateTime = (0,
@@ -434,8 +444,10 @@ class Gantt extends EventTarget_1.EventTarget {
434
444
  const taskRecord = this.getRecordByIndex(index, sub_task_index), startDateField = this.parsedOptions.startDateField, dateFormat = null !== (_a = this.parsedOptions.dateFormat) && void 0 !== _a ? _a : (0,
435
445
  util_1.parseDateFormat)(taskRecord[startDateField]), newStartDate = (0, util_1.formatDate)(startDate, dateFormat);
436
446
  if (taskRecord[startDateField] = newStartDate, (0, vutils_1.isValid)(sub_task_index)) Array.isArray(sub_task_index) && this.stateManager.updateProjectTaskTimes(sub_task_index); else {
437
- const indexs = this.getRecordIndexByTaskShowIndex(index);
438
- this._updateRecordToListTable(taskRecord, indexs), Array.isArray(indexs) && this.stateManager.updateProjectTaskTimes(indexs);
447
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
448
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
449
+ Array.isArray(recordIndex) && this.stateManager.updateProjectTaskTimes(recordIndex),
450
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index);
439
451
  }
440
452
  }
441
453
  _updateEndDateToTaskRecord(endDate, index, sub_task_index) {
@@ -443,8 +455,10 @@ class Gantt extends EventTarget_1.EventTarget {
443
455
  const taskRecord = this.getRecordByIndex(index, sub_task_index), endDateField = this.parsedOptions.endDateField, dateFormat = null !== (_a = this.parsedOptions.dateFormat) && void 0 !== _a ? _a : (0,
444
456
  util_1.parseDateFormat)(taskRecord[endDateField]), newEndDate = (0, util_1.formatDate)(endDate, dateFormat);
445
457
  if (taskRecord[endDateField] = newEndDate, (0, vutils_1.isValid)(sub_task_index)) Array.isArray(sub_task_index) && this.stateManager.updateProjectTaskTimes(sub_task_index); else {
446
- const indexs = this.getRecordIndexByTaskShowIndex(index);
447
- this._updateRecordToListTable(taskRecord, indexs), Array.isArray(indexs) && this.stateManager.updateProjectTaskTimes(indexs);
458
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
459
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
460
+ Array.isArray(recordIndex) && this.stateManager.updateProjectTaskTimes(recordIndex),
461
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index);
448
462
  }
449
463
  }
450
464
  _updateStartEndDateToTaskRecord(startDate, endDate, index, sub_task_index) {
@@ -454,16 +468,19 @@ class Gantt extends EventTarget_1.EventTarget {
454
468
  taskRecord[startDateField] = newStartDate;
455
469
  const newEndDate = (0, util_1.formatDate)(endDate, dateFormat);
456
470
  if (taskRecord[endDateField] = newEndDate, (0, vutils_1.isValid)(sub_task_index)) Array.isArray(sub_task_index) && this.stateManager.updateProjectTaskTimes(sub_task_index); else {
457
- const indexs = this.getRecordIndexByTaskShowIndex(index);
458
- this._updateRecordToListTable(taskRecord, indexs), Array.isArray(indexs) && this.stateManager.updateProjectTaskTimes(indexs);
471
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
472
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
473
+ Array.isArray(recordIndex) && this.stateManager.updateProjectTaskTimes(recordIndex),
474
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index);
459
475
  }
460
476
  }
461
477
  _updateProgressToTaskRecord(progress, index, sub_task_index) {
462
478
  const taskRecord = this.getRecordByIndex(index, sub_task_index), progressField = this.parsedOptions.progressField;
463
479
  if (progressField) {
464
480
  taskRecord[progressField] = progress;
465
- const indexs = this.getRecordIndexByTaskShowIndex(index);
466
- this._updateRecordToListTable(taskRecord, indexs), this._refreshTaskBar(index, sub_task_index);
481
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
482
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
483
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index) || this._refreshTaskBar(index, sub_task_index);
467
484
  }
468
485
  }
469
486
  _dragOrderTaskRecord(source_index, source_sub_task_index, target_index, target_sub_task_index) {