Our state of the art Gantt chart


Post by Jerther »

Hi!

Here's how to replicate:

  • Open the basic demo
  • Add this configuration to the Gantt widget:
        features: {
            taskEdit: {
                autoClose: false
            }
        }
    
  • Right click any task, select edit. That opens the task editor.
  • Click anywhere outside the editor

Actual result:

  • The task editor closes.

Expected result:

  • The task editor stays open.

Additional info:


Post by mats »

The edit feature has an editor, so you want to configure the editor

features : {
        taskEdit : {
            editorConfig : {
                autoClose : false
            }
        }
    },

Post by Jerther »

Oh. Right. That was an oversight from my part.

Now if I want to set it in my custom class, I do it this way:

class MyTaskEditor extends TaskEditor {
    static get defaultConfig() {
        return {
            autoClose: false
        }
    }
}

new Gantt({
    appendTo : 'container',
    features : {
        taskEdit : {
            editorClass: MyTaskEditor
        }
    },
    // ...
});

And it does not work. Even defaultConfig() is not called. Did something change about https://www.bryntum.com/docs/gantt/#Gantt/feature/TaskEdit#config-editorClass since 2.x.x?


Post by Jerther »

The more I look into it, the more I think the extended class just cannot work the way I migrated it from 2.5.7. I only provided a snippit here and the full version had extraItems and tabsConfig which were migrated according to the guide but the guide is about the taskEdit feature, not a TaskEditor class.

I have no idea how to use the editorClass configuration in 4.x.x :(

The matter is quite different than originally intended so tell me if I should start a new thread.


Post by mats »

Looks like a bug we'll investigate! https://github.com/bryntum/support/issues/3030


Post by Jerther »

Alright!

Is there a workaround until 4.1.6 is released? I heavily depend on this.

EDIT: I came up with this:

class MyTaskEditor extends TaskEditor {
    static get type() {
        return 'mytaskeditor';  // ADD THIS
    }

static get defaultConfig() {
    return {
        autoClose: false,
    }
}
}

MyTaskEditor.initClass();  // ADD THIS

new Gantt({
    appendTo : 'container',
    features : {
        taskEdit : {
            editorClass: MyTaskEditor
        }
    },
    // ...
});

Now the autoClose config works. I still have problems with the tabs configuration but I'll start a new thread.


Post by saki »

Yeah, create a new thread please.


Post by Animal »

Simpler to use editorConfig with a type property.

So editorClass` is then not necessary and could be deprecated due to it being redundant.

class MyTaskEditor extends TaskEditor {
    static get type() {
        return 'mytaskeditor';
    }

    static get defaultConfig() {
        return {
            autoClose: false,
       }
    }
}
// Registers "mytaskeditor" as a known *type*
MyTaskEditor.initClass();

// The above should really go in its own module.
// Then here, we just need to ensure its imported so
// that the `mytaskeditor` type is registered

new Gantt({
    appendTo : 'container',
    features : {
        taskEdit : {
            editorConfig : {
                type : 'mytaskeditor',
                ...other configs...
            }
        }
    },
    // ...
});

Post by Jerther »

Hi Animal,

That would've been nice, but it does not work. I get this error when I edit a task:

TypeError: editor.showBy is not a function

Load the basic demo, and use this code:

import { Gantt, ProjectModel, TaskEditor } from '../../build/gantt.module.js?450897';
import shared from '../_shared/shared.module.js?450897';
/* eslint-disable no-unused-vars */

const project = new ProjectModel({
    transport : {
        load : {
            url : '../_datasets/launch-saas.json'
        }
    }
});

class MyTaskEditor extends TaskEditor {
    static get type() {
        return 'mytaskeditor';
    }

static get defaultConfig() {
    return {
        autoClose: false,
   }
}
}

MyTaskEditor.initClass();

new Gantt({
    appendTo : 'container',

project,

dependencyIdField : 'sequenceNumber',

columns : [
    { type : 'name', width : 250 }
],

features : {
    taskEdit : {
        editorConfig : {
            type : 'mytaskeditor',
        }
    }
},

// Custom task content, display task name on child tasks
taskRenderer({ taskRecord }) {
    if (taskRecord.isLeaf && !taskRecord.isMilestone) {
        return taskRecord.name;
    }
}
});

project.load();

Post by Animal »

OK, that's a bug. It should work. It is destroying the created editor on second time of calling getEditor because the type of the existing editor is not 'taskeditor'

I'll fix the issue. type in a widget configuration object should always work.


Post Reply