@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/es/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/es/Gantt.js CHANGED
@@ -382,6 +382,16 @@ export class Gantt extends EventTarget {
382
382
  _updateRecordToListTable(record, index) {
383
383
  this.taskListTableInstance.updateRecords([ record ], [ index ]);
384
384
  }
385
+ _refreshSortedTaskBarsAfterRecordUpdate(recordIndex, taskShowIndex) {
386
+ var _a;
387
+ const sortState = null === (_a = this.taskListTableInstance) || void 0 === _a ? void 0 : _a.sortState;
388
+ if (!sortState || Array.isArray(sortState) && 0 === sortState.length) return !1;
389
+ const nextTaskShowIndex = this.getTaskShowIndexByRecordIndex(recordIndex);
390
+ if (!isValid(nextTaskShowIndex) || nextTaskShowIndex === taskShowIndex) return !1;
391
+ this._syncPropsFromTable(), this.scenegraph.refreshTaskBarsAndGrid();
392
+ const left = this.stateManager.scroll.horizontalBarPos, top = this.stateManager.scroll.verticalBarPos;
393
+ return this.scenegraph.setX(-left), this.scenegraph.setY(-top), !0;
394
+ }
385
395
  getTaskInfoByTaskListIndex(taskShowIndex, sub_task_index) {
386
396
  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 = createDateAtMidnight(null == taskRecord ? void 0 : taskRecord[startDateField]).getTime(), rawDateEndDateTime = createDateAtMidnight(null == taskRecord ? void 0 : taskRecord[endDateField]).getTime();
387
397
  if (isMilestone && !(null == taskRecord ? void 0 : taskRecord[startDateField]) || !isMilestone && (rawDateEndDateTime < this.parsedOptions._minDateTime || rawDateStartDateTime > this.parsedOptions._maxDateTime || !(null == taskRecord ? void 0 : taskRecord[startDateField]) || !(null == taskRecord ? void 0 : taskRecord[endDateField]))) return {
@@ -444,16 +454,20 @@ export class Gantt extends EventTarget {
444
454
  var _a;
445
455
  const taskRecord = this.getRecordByIndex(index, sub_task_index), startDateField = this.parsedOptions.startDateField, dateFormat = null !== (_a = this.parsedOptions.dateFormat) && void 0 !== _a ? _a : parseDateFormat(taskRecord[startDateField]), newStartDate = formatDate(startDate, dateFormat);
446
456
  if (taskRecord[startDateField] = newStartDate, isValid(sub_task_index)) Array.isArray(sub_task_index) && this.stateManager.updateProjectTaskTimes(sub_task_index); else {
447
- const indexs = this.getRecordIndexByTaskShowIndex(index);
448
- this._updateRecordToListTable(taskRecord, indexs), Array.isArray(indexs) && this.stateManager.updateProjectTaskTimes(indexs);
457
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
458
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
459
+ Array.isArray(recordIndex) && this.stateManager.updateProjectTaskTimes(recordIndex),
460
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index);
449
461
  }
450
462
  }
451
463
  _updateEndDateToTaskRecord(endDate, index, sub_task_index) {
452
464
  var _a;
453
465
  const taskRecord = this.getRecordByIndex(index, sub_task_index), endDateField = this.parsedOptions.endDateField, dateFormat = null !== (_a = this.parsedOptions.dateFormat) && void 0 !== _a ? _a : parseDateFormat(taskRecord[endDateField]), newEndDate = formatDate(endDate, dateFormat);
454
466
  if (taskRecord[endDateField] = newEndDate, isValid(sub_task_index)) Array.isArray(sub_task_index) && this.stateManager.updateProjectTaskTimes(sub_task_index); else {
455
- const indexs = this.getRecordIndexByTaskShowIndex(index);
456
- this._updateRecordToListTable(taskRecord, indexs), Array.isArray(indexs) && this.stateManager.updateProjectTaskTimes(indexs);
467
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
468
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
469
+ Array.isArray(recordIndex) && this.stateManager.updateProjectTaskTimes(recordIndex),
470
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index);
457
471
  }
458
472
  }
459
473
  _updateStartEndDateToTaskRecord(startDate, endDate, index, sub_task_index) {
@@ -462,16 +476,19 @@ export class Gantt extends EventTarget {
462
476
  taskRecord[startDateField] = newStartDate;
463
477
  const newEndDate = formatDate(endDate, dateFormat);
464
478
  if (taskRecord[endDateField] = newEndDate, isValid(sub_task_index)) Array.isArray(sub_task_index) && this.stateManager.updateProjectTaskTimes(sub_task_index); else {
465
- const indexs = this.getRecordIndexByTaskShowIndex(index);
466
- this._updateRecordToListTable(taskRecord, indexs), Array.isArray(indexs) && this.stateManager.updateProjectTaskTimes(indexs);
479
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
480
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
481
+ Array.isArray(recordIndex) && this.stateManager.updateProjectTaskTimes(recordIndex),
482
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index);
467
483
  }
468
484
  }
469
485
  _updateProgressToTaskRecord(progress, index, sub_task_index) {
470
486
  const taskRecord = this.getRecordByIndex(index, sub_task_index), progressField = this.parsedOptions.progressField;
471
487
  if (progressField) {
472
488
  taskRecord[progressField] = progress;
473
- const indexs = this.getRecordIndexByTaskShowIndex(index);
474
- this._updateRecordToListTable(taskRecord, indexs), this._refreshTaskBar(index, sub_task_index);
489
+ const recordIndex = this.getRecordIndexByTaskShowIndex(index);
490
+ this._updateRecordToListTable(taskRecord, Array.isArray(recordIndex) ? recordIndex : index),
491
+ this._refreshSortedTaskBarsAfterRecordUpdate(recordIndex, index) || this._refreshTaskBar(index, sub_task_index);
475
492
  }
476
493
  }
477
494
  _dragOrderTaskRecord(source_index, source_sub_task_index, target_index, target_sub_task_index) {