Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gantt.createDataProcessor((mode: 'task' | 'link', taskState: string, data: Task | Link, _rowId: unknown) => {
- switch (mode) {
- case 'link': {
- switch (taskState) {
- case 'create':
- this.api.linkCreate(data as Link)
- .then(result => {
- console.log('created link: ', result);
- gantt.changeLinkId(data.id as string, result.id as string);
- })
- .catch(error => {
- gantt.undo();
- this.displayError(error);
- });
- break;
- case 'delete':
- this.api.linkRemove(data.id as string)
- .then(_result => void 0)
- .catch(error => {
- gantt.undo();
- this.displayError(error);
- });
- break;
- case 'update':
- this.api.linkUpdate(data as Link)
- .then(result => {
- gantt.changeLinkId(data.id as string, result.id as string);
- })
- .catch(error => {
- gantt.undo();
- this.displayError(error);
- });
- break;
- }
- break;
- }
- case 'task': {
- switch (taskState) {
- case 'create':
- this.api.taskCreate(data as Task)
- .then(result => {
- console.log('created task: ', result);
- gantt.changeTaskId(data.id as string, result.id as string);
- })
- .catch(error => {
- gantt.undo();
- this.displayError(error);
- });
- break;
- case 'delete':
- this.api.taskRemove(data.id as string)
- .then(_result => void 0)
- .catch(error => {
- gantt.undo();
- this.displayError(error);
- });
- break;
- case 'update':
- this.api.taskUpdate(data as Task)
- .then(_result => void 0)
- .catch(error => {
- gantt.undo();
- this.displayError(error);
- });
- break;
- }
- break;
- }
- default: {
- throw new Error('Unsupported mode');
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement