Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

devexpress-gantt

Package Overview
Dependencies
Maintainers
7
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devexpress-gantt - npm Package Compare versions

Comparing version 4.1.31 to 4.1.32

dist/lib/src/Model/History/IInsertedKeyKeeper.ts

2

dist/lib/package.json
{
"name": "devexpress-gantt",
"version": "4.1.31",
"version": "4.1.32",
"description": "DevExpress Gantt Control",

@@ -5,0 +5,0 @@ "main": "dist/dx-gantt.min.js",

@@ -11,3 +11,3 @@ import { ConfirmationType } from "../../Dialogs/DialogEnums";

export class RemoveTaskCommand extends TaskCommandBase {
public execute(id: string, confirmRequired: boolean = true, isApiCall: boolean = false, isUpdateParentTaskRequired: boolean = true, historyItem?: RemoveTaskHistoryItem): boolean {
public execute(id: string, confirmRequired: boolean = true, isApiCall: boolean = false, isUpdateParentTaskRequired: boolean = true, historyItem?: RemoveTaskHistoryItem, pendingDependencyIds?: string[]): boolean {
this.isApiCall = isApiCall;

@@ -17,8 +17,9 @@ this.isUpdateParentTaskRequired = isUpdateParentTaskRequired;

this.control.commandManager.showConfirmationDialog.execute(new ConfirmationDialogParameters(ConfirmationType.TaskDelete,
() => { this.executeInternal(id, historyItem); }));
() => { this.executeInternal(id, historyItem, pendingDependencyIds); }));
return false;
}
return super.execute(id, historyItem);
return super.execute(id, historyItem, pendingDependencyIds);
}
protected executeInternal(id: string, historyItem?: RemoveTaskHistoryItem): boolean {
protected executeInternal(id: string, historyItem?: RemoveTaskHistoryItem, pendingDependencyIds?: string[]): boolean {
const pendingDependencyKeys = pendingDependencyIds || [];
id = id || this.control.currentSelectedTaskID;

@@ -31,19 +32,23 @@ const item = this.control.viewModel.findItem(id);

return false;
this.control.history.beginTransaction();
this.control.viewModel.beginUpdate();
const removeTaskHistoryItem = historyItem || new RemoveTaskHistoryItem(this.modelManipulator);
removeTaskHistoryItem.addTask(id);
const childTasks = this.control.viewModel.tasks.items.filter(t => t.parentId === id);
childTasks.forEach(t => new RemoveTaskCommand(this.control).execute(t.internalId, false, true, false, removeTaskHistoryItem));
let dependencies = this.control.viewModel.dependencies.items.filter(d => d.predecessorId === id || d.successorId === id);
if(dependencies.length)
if(this.control.settings.editing.allowDependencyDelete) {
dependencies = dependencies.filter(d => childTasks.filter(c => c.internalId === d.predecessorId || c.internalId === d.successorId).length === 0);
dependencies.forEach(d => removeTaskHistoryItem.add(new RemoveDependencyHistoryItem(this.modelManipulator, d.internalId)));
}
else
return false;
const history = this.history;
const viewModel = this.control.viewModel;
const assignments = this.control.viewModel.assignments.items.filter(a => a.taskId === id);
history.beginTransaction();
viewModel.beginUpdate();
const isRecursiveCall = !!historyItem;
const removeTaskHistoryItem = new RemoveTaskHistoryItem(this.modelManipulator, id);
const childTasks = viewModel.tasks.items.filter(t => t.parentId === id);
const childIds = childTasks.map(t => t.internalId);
const dependencies = viewModel.dependencies.items.filter(d => {
return pendingDependencyKeys.indexOf(d.internalId) === -1 && (d.predecessorId === id || d.successorId === id) && !childIds.some(k => d.predecessorId === k || d.successorId === k);
});
if(dependencies.length) {
if(!this.control.settings.editing.allowDependencyDelete) return false;
dependencies.forEach(d => {
removeTaskHistoryItem.add(new RemoveDependencyHistoryItem(this.modelManipulator, d.internalId));
pendingDependencyKeys.push(d.internalId);
});
}
const assignments = viewModel.assignments.items.filter(a => a.taskId === id);
assignments.forEach(a => {

@@ -53,11 +58,18 @@ if(this.modelManipulator.dispatcher.fireResourceUnassigning(a))

});
if(!historyItem)
this.history.addAndRedo(removeTaskHistoryItem);
const parent = this.control.viewModel.findItem(task.parentId);
if(this.isUpdateParentTaskRequired)
childTasks.reverse().forEach(t => new RemoveTaskCommand(this.control).execute(t.internalId, false, true, false, removeTaskHistoryItem, pendingDependencyKeys));
if(!isRecursiveCall)
history.addAndRedo(removeTaskHistoryItem);
else
historyItem.add(removeTaskHistoryItem);
if(this.isUpdateParentTaskRequired) {
const parent = this.control.viewModel.findItem(task.parentId);
super.updateParent(parent);
this.control.history.endTransaction();
this.control.viewModel.endUpdate();
}
history.endTransaction();
viewModel.endUpdate();
return true;
}
isEnabled(): boolean {

@@ -64,0 +76,0 @@ const gantt = this.control;

@@ -33,2 +33,5 @@ import { DataObject } from "../Entities/DataObject";

}
invalidate(): void {
delete this._invertedItems;
}
private _addItem(element: T): void {

@@ -35,0 +38,0 @@ this._items.push(element);

@@ -16,7 +16,17 @@ import { isDefined } from "@devexpress/utils/lib/utils/common";

if(isDefined(sourceObj.id)) {
this.id = sourceObj.id;
this.internalId = String(sourceObj.id);
}
if(isDefined(sourceObj.id))
this.updateId(sourceObj.id);
}
public updateId(newKey: any): void {
this.id = newKey;
this.internalId = String(newKey);
}
}
export const GanttDataObjectNames = {
task: "task",
dependency: "dependency",
resource: "resource",
resourceAssignment: "assignment"
};

@@ -22,3 +22,2 @@ import { isDefined } from "@devexpress/utils/lib/utils/common";

super.assignFromObject(sourceObj);
this.internalId = String(sourceObj.id);
this.predecessorId = String(sourceObj.predecessorId);

@@ -25,0 +24,0 @@ this.successorId = String(sourceObj.successorId);

@@ -6,3 +6,2 @@ import { isDefined } from "@devexpress/utils/lib/utils/common";

export class Task extends DataObject {
internalId: string;
start: Date;

@@ -9,0 +8,0 @@ end: Date;

@@ -34,5 +34,6 @@ import { IHistory } from "./IHistory";

this.transactionLevel++;
if(this.transactionLevel == 0)
if(this.transactionLevel == 0) {
this.transaction = new CompositionHistoryItem();
this._listener?.onTransactionStart();
this._listener?.onTransactionStart();
}
}

@@ -122,2 +123,17 @@ public endTransaction(): void {

}
public updateObsoleteInsertedKey(oldKey: string, newKey: string, type: string): void {
if(this.transaction)
this.updateItemsObsoleteInsertedKey(oldKey, newKey, type, [ this.transaction ]);
this.updateItemsObsoleteInsertedKey(oldKey, newKey, type, this.historyItems);
}
updateItemsObsoleteInsertedKey(oldKey: string, newKey: string, type: string, historyItems: HistoryItem[]): void {
if(historyItems)
for(let i = 0; i < historyItems.length; i++) {
const item = historyItems[i];
const keyUpdaters = item.keyUpdaters.filter(k => k.getKey() === oldKey && k.objectType === type);
keyUpdaters.forEach(k => k.updateKey(newKey));
if(item instanceof CompositionHistoryItem)
this.updateItemsObsoleteInsertedKey(oldKey, newKey, type, item.historyItems);
}
}
}

@@ -28,6 +28,7 @@ import { ModelManipulator } from "../../Manipulators/ModelManipulator";

public setModelManipulator(modelManipulator: ModelManipulator): void {
super.setModelManipulator(modelManipulator);
if(this.historyItems)
for(let i = 0; i < this.historyItems.length - 1; i++)
for(let i = 0; i < this.historyItems.length; i++)
this.historyItems[i].setModelManipulator(modelManipulator);
}
}

@@ -1,8 +0,9 @@

import { Dependency } from "../../../Entities/Dependency";
import { MathUtils } from "@devexpress/utils/lib/utils/math";
import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { DependencyType } from "../../../Entities/Enums";
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { HistoryItem } from "../HistoryItem";
export class InsertDependencyHistoryItem extends HistoryItem {
dependency: Dependency;
predecessorId: string;

@@ -12,2 +13,5 @@ successorId: string;

public insertedKey: string;
constructor(modelManipulator: ModelManipulator, predecessorId: string, successorId: string, type: DependencyType) {

@@ -20,8 +24,29 @@ super(modelManipulator);

public redo(): void {
this.dependency = this.modelManipulator.dependency.insertDependency(this.predecessorId, this.successorId, this.type,
this.dependency ? this.dependency.internalId : null);
this.insertedKey ??= MathUtils.generateGuid();
this.modelManipulator.dependency.insertDependency(this.predecessorId, this.successorId, this.type, this.insertedKey);
}
public undo(): void {
this.modelManipulator.dependency.removeDependency(this.dependency.internalId);
this.modelManipulator.dependency.removeDependency(this.insertedKey);
}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.dependency,
getKey: () => this.insertedKey,
updateKey: value => this.insertedKey = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.predecessorId,
updateKey: value => this.predecessorId = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.successorId,
updateKey: value => this.successorId = value
}
];
}
}

@@ -0,3 +1,5 @@

import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { Dependency } from "../../../Entities/Dependency";
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { HistoryItem } from "../HistoryItem";

@@ -19,2 +21,22 @@

}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.dependency,
getKey: () => this.dependencyId,
updateKey: value => this.dependencyId = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.dependency?.predecessorId,
updateKey: value => this.dependency.predecessorId = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.dependency?.successorId,
updateKey: value => this.dependency.successorId = value
}
];
}
}
import { ModelManipulator } from "../../Manipulators/ModelManipulator";
import { IDataObjectKeyUpdater } from "../IInsertedKeyKeeper";

@@ -15,2 +16,4 @@ export abstract class HistoryItem {

}
public get keyUpdaters(): IDataObjectKeyUpdater[] { return [ ]; }
}
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { Resource } from "../../../Entities/Resource";
import { HistoryItem } from "../HistoryItem";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { MathUtils } from "@devexpress/utils/lib/utils/math";
export class CreateResourceHistoryItem extends HistoryItem {
resource: Resource;
text: string;
color: string;
createCallback: (id: any) => void;
public insertedKey: string;

@@ -18,7 +20,18 @@ constructor(modelManipulator: ModelManipulator, text: string, color: string = "", callback?: (id: any) => void) {

public redo(): void {
this.resource = this.modelManipulator.resource.create(this.text, this.color, this.resource ? this.resource.internalId : null, this.createCallback);
this.insertedKey ??= MathUtils.generateGuid();
this.modelManipulator.resource.create(this.text, this.color, this.insertedKey, this.createCallback);
}
public undo(): void {
this.modelManipulator.resource.remove(this.resource.internalId);
this.modelManipulator.resource.remove(this.insertedKey);
}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.resource,
getKey: () => this.insertedKey,
updateKey: value => this.insertedKey = value
}
];
}
}

@@ -0,3 +1,5 @@

import { GanttDataObjectNames } from "../../../../Entities/DataObject";
import { ModelManipulator } from "../../../../Manipulators/ModelManipulator";
import { ResourcePropertyManipulator } from "../../../../Manipulators/Resource/Properties/ResourcePropertyManipulator";
import { IDataObjectKeyUpdater } from "../../../IInsertedKeyKeeper";
import { HistoryItem } from "../../HistoryItem";

@@ -25,2 +27,12 @@ import { HistoryItemState } from "../../HistoryItemState";

}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.resource,
getKey: () => this.resourceId,
updateKey: value => this.resourceId = value
}
];
}
}
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { Resource } from "../../../Entities/Resource";
import { CompositionHistoryItem } from "../CompositionHistoryItem";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { GanttDataObjectNames } from "../../../Entities/DataObject";

@@ -23,3 +25,3 @@ export class RemoveResourceHistoryItem extends CompositionHistoryItem {

this.modelManipulator.resource.properties.color.setValue(this.resource.internalId, this.resource.color);
super.undo();
window.setTimeout(() => super.undo(), 0);
});

@@ -33,2 +35,12 @@ }

}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.resource,
getKey: () => this.resourceId,
updateKey: value => this.resourceId = value
}
];
}
}
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { ResourceAssignment } from "../../../Entities/ResourceAssignment";
import { HistoryItem } from "../HistoryItem";
import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { MathUtils } from "@devexpress/utils/lib/utils/math";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
export class AssignResourceHistoryItem extends HistoryItem {
assignment: ResourceAssignment;
resourceId: string;
taskId: string;
public insertedKey: string;

@@ -16,7 +18,28 @@ constructor(modelManipulator: ModelManipulator, resourceId: string, taskId: string) {

public redo(): void {
this.assignment = this.modelManipulator.resource.assign(this.resourceId, this.taskId, this.assignment ? this.assignment.internalId : null);
this.insertedKey ??= MathUtils.generateGuid();
this.modelManipulator.resource.assign(this.resourceId, this.taskId, this.insertedKey);
}
public undo(): void {
this.modelManipulator.resource.deassig(this.assignment.internalId);
this.modelManipulator.resource.deassig(this.insertedKey);
}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.resourceAssignment,
getKey: () => this.insertedKey,
updateKey: value => this.insertedKey = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.taskId,
updateKey: value => this.taskId = value
},
{
objectType: GanttDataObjectNames.resource,
getKey: () => this.resourceId,
updateKey: value => this.resourceId = value
}
];
}
}
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { ResourceAssignment } from "../../../Entities/ResourceAssignment";
import { HistoryItem } from "../HistoryItem";
import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";

@@ -19,2 +21,22 @@ export class DeassignResourceHistoryItem extends HistoryItem {

}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.resourceAssignment,
getKey: () => this.assignmentId,
updateKey: value => this.assignmentId = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.assignment?.taskId,
updateKey: value => this.assignment.taskId = value
},
{
objectType: GanttDataObjectNames.resource,
getKey: () => this.assignment?.resourceId,
updateKey: value => this.assignment.resourceId = value
}
];
}
}

@@ -0,8 +1,12 @@

import { MathUtils } from "@devexpress/utils/lib/utils/math";
import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { HistoryItem } from "../HistoryItem";
export class CreateTaskHistoryItem extends HistoryItem {
taskId: string;
data: Record<string, any>
public insertedKey: string;
constructor(modelManipulator: ModelManipulator, data: Record<string, any>) {

@@ -13,7 +17,26 @@ super(modelManipulator);

public redo(): void {
this.taskId = this.modelManipulator.task.create(this.data, this.taskId ? this.taskId : null).internalId;
this.insertedKey ??= MathUtils.generateGuid();
this.modelManipulator.task.create(this.data, this.insertedKey);
}
public undo(): void {
this.modelManipulator.task.remove(this.taskId);
this.modelManipulator.task.remove(this.insertedKey);
}
public get keyUpdaters(): IDataObjectKeyUpdater[] {
const result = [
{
objectType: GanttDataObjectNames.task,
getKey: () => this.insertedKey,
updateKey: value => this.insertedKey = value
}
];
if(this.data?.parentId)
result.push({
objectType: GanttDataObjectNames.task,
getKey: () => this.data?.parentId,
updateKey: value => this.data.parentId = value
});
return result;
}
}
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { Task } from "../../../Entities/Task";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { CompositionHistoryItem } from "../CompositionHistoryItem";
import { RemoveDependencyHistoryItem } from "../Dependency/RemoveDependencyHistoryItem";
import { HistoryItem } from "../HistoryItem";
export class RemoveTaskHistoryItem extends CompositionHistoryItem {
taskIds: string[] = [];
tasks: Task[] = [];
private pendingCallbacks: number = 0;
taskId: string;
task: Task;
constructor(modelManipulator: ModelManipulator) {
constructor(modelManipulator: ModelManipulator, taskId: string) {
super();
this.modelManipulator = modelManipulator;
this.taskId = taskId;
}
public redo(): void {
super.redo();
this.taskIds.forEach(id => {
this.tasks.push(this.modelManipulator.task.remove(id));
});
this.task = this.modelManipulator.task.remove(this.taskId);
}
public undo(): void {
const viewModel = this.modelManipulator.task.viewModel;
viewModel.lockChangesProcessing = this.tasks.length > 0;
if(this.tasks.length) {
const task = this.tasks.shift();
this.pendingCallbacks++;
this.modelManipulator.task.create(task, task.internalId, () => {
const data = { progress: task.progress };
if(task.color)
data["color"] = task.color;
this.modelManipulator.task.update(task.internalId, data);
this.tasks.length ? this.undo() : super.undo();
this.pendingCallbacks--;
viewModel.lockChangesProcessing = this.pendingCallbacks > 0;
});
}
this.modelManipulator.task.create(this.task, this.taskId, () => {
window.setTimeout(() => super.undo(), 0);
});
}
public undoItemsQuery(): void {
while(this.tasks.length) {
const task = this.tasks.shift();
this.modelManipulator.task.create(task, task.internalId, () => { });
const data = { progress: task.progress };
if(task.color)
data["color"] = task.color;
this.modelManipulator.task.update(task.internalId, data);
}
this.modelManipulator.task.viewModel.lockChangesProcessing = false;
this.pendingCallbacks = 0;
super.undo();
this.modelManipulator.task.create(this.task, this.taskId);
let item: HistoryItem;
for(let i = this.historyItems.length - 1; item = this.historyItems[i]; i--)
if(item instanceof CompositionHistoryItem)
item.undoItemsQuery();
else
item.undo();
}
public addTask(taskId: string): void {
this.taskIds.push(taskId);
public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.task,
getKey: () => this.taskId,
updateKey: value => this.taskId = value
},
{
objectType: GanttDataObjectNames.task,
getKey: () => this.task?.parentId,
updateKey: value => this.task.parentId = value
}
];
}
public add(historyItem: HistoryItem): void {
if(historyItem instanceof RemoveDependencyHistoryItem) {
const item = <RemoveDependencyHistoryItem>historyItem;
if(!this.historyItems.filter(i => i instanceof RemoveDependencyHistoryItem && i.dependencyId == item.dependencyId).length)
this.historyItems.push(item);
}
else
super.add(historyItem);
}
}

@@ -0,3 +1,5 @@

import { GanttDataObjectNames } from "../../../Entities/DataObject";
import { ITaskUpdateValues } from "../../../Entities/ITaskUpdateValues";
import { ModelManipulator } from "../../../Manipulators/ModelManipulator";
import { IDataObjectKeyUpdater } from "../../IInsertedKeyKeeper";
import { HistoryItem } from "../HistoryItem";

@@ -25,2 +27,12 @@ import { HistoryItemState } from "../HistoryItemState";

public get keyUpdaters(): IDataObjectKeyUpdater[] {
return [
{
objectType: GanttDataObjectNames.task,
getKey: () => this.taskId,
updateKey: value => this.taskId = value
}
];
}
}

@@ -18,2 +18,3 @@ import { HistoryItem } from "./HistoryItems/HistoryItem";

rollBackAndRemove: (info: HistoryItemInfo) => void;
updateObsoleteInsertedKey: (oldKey: string, newKey: string, type: string) => void;
}

@@ -0,1 +1,2 @@

import { GanttDataObjectNames } from "../../Entities/DataObject";
import { Dependency } from "../../Entities/Dependency";

@@ -7,3 +8,5 @@ import { DependencyType } from "../../Entities/Enums";

insertDependency(predecessorId: string, successorId: string, type: DependencyType, id?: string): Dependency {
const dependency = this.viewModel.dependencies.createItem();
const viewModel = this.viewModel;
viewModel.onBeginDataObjectCreate();
const dependency = viewModel.dependencies.createItem();
dependency.predecessorId = predecessorId;

@@ -15,6 +18,12 @@ dependency.successorId = successorId;

dependency.id = dependency.internalId;
this.viewModel.dependencies.add(dependency);
this.dispatcher.notifyDependencyInserted(this.getObjectForDataSource(dependency), id => dependency.id = id, this.getErrorCallback());
this.viewModel.updateVisibleItemDependencies();
viewModel.dependencies.add(dependency);
const callback = (newKey) => {
const oldKey = dependency.internalId;
dependency.updateId(newKey);
viewModel.processServerInsertedKey(oldKey, dependency.internalId, GanttDataObjectNames.dependency);
};
viewModel.updateVisibleItemDependencies();
this.renderHelper.recreateConnectorLineElement(dependency.internalId, true);
this.dispatcher.notifyDependencyInserted(this.getObjectForDataSource(dependency), callback, this.getErrorCallback());
viewModel.onEndDataObjectCreate();
return dependency;

@@ -21,0 +30,0 @@ }

import { ModelChangesDispatcher } from "../../Dispatchers/ModelChangesDispatcher";
import { GanttDataObjectNames } from "../../Entities/DataObject";
import { Resource } from "../../Entities/Resource";

@@ -16,3 +17,5 @@ import { ResourceAssignment } from "../../Entities/ResourceAssignment";

create(text: string, color?: string, id?: string, callback?: (id: any) => void): Resource {
const resource = this.viewModel.resources.createItem();
const viewModel = this.viewModel;
viewModel.onBeginDataObjectCreate();
const resource = viewModel.resources.createItem();
resource.text = text;

@@ -26,6 +29,9 @@ if(color)

this.dispatcher.notifyResourceCreated(this.getResourceObjectForDataSource(resource), id => {
resource.id = id;
const oldKey = resource.internalId;
resource.updateId(id);
viewModel.processServerInsertedKey(oldKey, resource.internalId, GanttDataObjectNames.resource);
if(callback)
callback(id);
}, this.getErrorCallback());
viewModel.onEndDataObjectCreate();
return resource;

@@ -45,3 +51,5 @@ }

assign(resourceID: string, taskId: string, id?: string): ResourceAssignment {
const assignment = this.viewModel.assignments.createItem();
const viewModel = this.viewModel;
viewModel.onBeginDataObjectCreate();
const assignment = viewModel.assignments.createItem();
assignment.resourceId = resourceID;

@@ -53,4 +61,9 @@ assignment.taskId = taskId;

this.viewModel.assignments.add(assignment);
this.dispatcher.notifyResourceAssigned(this.getResourceAssignmentObjectForDataSource(assignment), id => assignment.id = id, this.getErrorCallback());
this.dispatcher.notifyResourceAssigned(this.getResourceAssignmentObjectForDataSource(assignment), id => {
const oldKey = assignment.internalId;
assignment.updateId(id);
viewModel.processServerInsertedKey(oldKey, assignment.internalId, GanttDataObjectNames.resourceAssignment);
}, this.getErrorCallback());
this.viewModel.updateModel();
viewModel.onEndDataObjectCreate();
this.viewModel.owner.resetAndUpdate();

@@ -57,0 +70,0 @@ return assignment;

import { isDefined } from "@devexpress/utils/lib/utils/common";
import { GanttDataObjectNames } from "../../Entities/DataObject";
import { ITaskUpdateValues } from "../../Entities/ITaskUpdateValues";

@@ -8,3 +9,5 @@ import { Task } from "../../Entities/Task";

create(data: Record<string, any>, id?: string, callback?: () => void): Task {
const task = this.viewModel.tasks.createItem();
const viewModel = this.viewModel;
viewModel.onBeginDataObjectCreate();
const task = viewModel.tasks.createItem();
task.start = data.start;

@@ -16,3 +19,3 @@ task.end = data.end;

task.color = data.color;
const parentItem = this.viewModel.tasks.getItemById(data.parentId);
const parentItem = viewModel.tasks.getItemById(data.parentId);
if(parentItem)

@@ -24,10 +27,12 @@ parentItem.expanded = true;

task.id = task.internalId;
this.viewModel.tasks.add(task);
this.viewModel.updateModel();
viewModel.tasks.add(task);
viewModel.updateModel();
this.dispatcher.notifyTaskCreated(this.getObjectForDataSource(task), id => {
task.id = id;
const oldKey = task.internalId;
task.updateId(id);
viewModel.processServerInsertedKey(oldKey, task.internalId, GanttDataObjectNames.task);
if(callback)
callback();
if(this.viewModel.requireFirstLoadParentAutoCalc) {
const data = this.viewModel.getCurrentTaskData().map(t => {
const data = viewModel.getCurrentTaskData().map(t => {
if(t.parentId === "")

@@ -40,3 +45,4 @@ t.parentId = null;

}, this.getErrorCallback());
this.viewModel.owner.resetAndUpdate();
viewModel.onEndDataObjectCreate();
viewModel.owner.resetAndUpdate();
return task;

@@ -43,0 +49,0 @@ }

@@ -11,3 +11,3 @@ import { Task } from "../Entities/Task";

import { isDefined } from "@devexpress/utils/lib/utils/common";
import { DataObject } from "../Entities/DataObject";
import { DataObject, GanttDataObjectNames } from "../Entities/DataObject";
import { Dependency } from "../Entities/Dependency";

@@ -532,2 +532,19 @@ import { Resource } from "../Entities/Resource";

}
public processServerInsertedKey(oldKey: string, newKey: string, type: string): void {
if(type === GanttDataObjectNames.task)
this.tasks.invalidate();
if(type === GanttDataObjectNames.dependency) {
this.dependencies.invalidate();
this.updateVisibleItemDependencies();
}
if(type === GanttDataObjectNames.resource)
this.resources.invalidate();
if(type === GanttDataObjectNames.resourceAssignment)
this.assignments.invalidate();
this.owner?.updateHistoryObsoleteInsertedKey(oldKey, newKey, type);
}
public onBeginDataObjectCreate(): void { this.owner.lockUpdateWithReload?.(); }
public onEndDataObjectCreate(): void { this.owner.unlockUpdateWithReload?.(); }
}
import { BarManager } from "../BarManager/BarManager";
import { Browser } from "@devexpress/utils/lib/browser";
import { CommandManager } from "../Commands/CommandManager";
import { CreateResourceHistoryItem } from "../Model/History/HistoryItems/Resource/CreateResourceHistoryItem";
import { CreateTaskHistoryItem } from "../Model/History/HistoryItems/Task/CreateTaskHistoryItem";

@@ -47,2 +46,3 @@ import { DateRange } from "../Model/WorkingTime/DateRange";

import { DialogBase } from "../Dialogs/DialogBase";
import { GanttDataObjectNames } from "../Model/Entities/DataObject";

@@ -77,3 +77,3 @@

isFocus: boolean = false;
private _updateWithModelReloadLocked: boolean = false;
private _updateWithModelReloadLockedCounter: number = 0;
private _pendingUpdateInfo: Record<string, any>;

@@ -126,6 +126,11 @@ scaleCount: number = 2;

}
protected onHistoryTransactionStart(): void { this._updateWithModelReloadLocked = true; }
protected onHistoryTransactionEnd(): void {
this._updateWithModelReloadLocked = false;
if(this._pendingUpdateInfo) {
protected onHistoryTransactionStart(): void { this.lockUpdateWithReload(); }
protected onHistoryTransactionEnd(): void { this.unlockUpdateWithReload(); }
public lockUpdateWithReload(): void {
this._updateWithModelReloadLockedCounter++;
}
public unlockUpdateWithReload(): void {
this._updateWithModelReloadLockedCounter--;
if(this._updateWithModelReloadLockedCounter === 0 && this._pendingUpdateInfo) {
this.updateWithDataReload(this._pendingUpdateInfo.keepExpandState);

@@ -496,2 +501,9 @@ this._pendingUpdateInfo = null;

}
updateHistoryObsoleteInsertedKey(oldKey: string, newKey: string, type: string): void {
this.history?.updateObsoleteInsertedKey(oldKey, newKey, type);
if(type === GanttDataObjectNames.dependency)
this.renderHelper.updateRenderedConnectorLinesId(oldKey, newKey);
}
updateRowHeights(height: number): void {

@@ -662,3 +674,3 @@ if(this.tickSize.height !== height) {

updateWithDataReload(keepExpandState: boolean): void {
if(this._updateWithModelReloadLocked) {
if(this._updateWithModelReloadLockedCounter > 0) {
this._pendingUpdateInfo = { keepExpandState: keepExpandState };

@@ -706,9 +718,4 @@ return;

const lastItem = createTaskItems[createTaskItems.length - 1] as CreateTaskHistoryItem;
return lastItem && lastItem.taskId;
return lastItem && lastItem.insertedKey;
}
getLastInsertedResource() : Resource {
const createTaskItems = this.history.historyItems.filter(i => i instanceof CreateResourceHistoryItem);
const lastItem = createTaskItems[createTaskItems.length - 1] as CreateResourceHistoryItem;
return lastItem && lastItem.resource;
}

@@ -724,8 +731,2 @@ getTaskByPublicId(id: string): Task {

}
updateCreatedTaskIdAfterServerUpdate(internalId: string, id: string): void {
const item = this.viewModel.findItem(internalId);
const task = item && item.task;
if(task)
task.id = id;
}
getTaskIdByInternalId(internalId : string): string {

@@ -732,0 +733,0 @@ const item = this.viewModel.findItem(internalId);

@@ -95,2 +95,18 @@ import { GridElementInfo } from "../Helpers/GridElementInfo";

}
updateRenderedConnectorLinesId(oldId: string, newKey : string): void {
this._renderedConnectorLines.forEach(line => {
if(line.attr["dependency-id"] === oldId)
line.attr["dependency-id"] = newKey;
});
for(const key in this.connectorLinesToElementsMap) {
if(!Object.prototype.hasOwnProperty.call(this.connectorLinesToElementsMap, key))
continue;
const element = this.connectorLinesToElementsMap[key];
if(element.getAttribute("dependency-id") === oldId)
element.setAttribute("dependency-id", newKey);
}
this.gridLayoutCalculator.updateTileToConnectorLinesMap(oldId);
this.gridLayoutCalculator.updateTileToConnectorLinesMap(newKey);
}
}

@@ -325,2 +325,5 @@ import { ConnectorLinesRender } from "./ConnectorLinesRender";

updateRenderedConnectorLinesId(oldId: string, newKey : string): void {
this._connectorLinesRender.updateRenderedConnectorLinesId(oldId, newKey);
}

@@ -327,0 +330,0 @@ recreateConnectorLineElement(dependencyId: string, forceRender: boolean = false): void {

{
"name": "devexpress-gantt",
"version": "4.1.31",
"version": "4.1.32",
"description": "DevExpress Gantt Control",

@@ -5,0 +5,0 @@ "main": "dist/dx-gantt.min.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc