Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make extending TaskEditor easy and consistent. #3080

Open
jsakalos opened this issue Jun 21, 2021 · 0 comments
Open

Make extending TaskEditor easy and consistent. #3080

jsakalos opened this issue Jun 21, 2021 · 0 comments
Labels
feature request forum Issues from forum

Comments

@jsakalos
Copy link

The main problem is that extending Task Editor is not an easy and straightforward task but there are many humps on the road. See the forum thread. The user explains the problem(s) very clearly.

Forum post

Gantt.feature.TaskEdit#editorConfig is a configuration for Gantt.widget.TaskEditor. So that is covered.
Does not exactly apply here. The guide explains to move the extra widgets from features.taskEdit.editorConfig.extraItems to features.taskEdit.items. That means I must move the configuration from inside my custom TaskEditor class out to the taskEdit feature configuration. Right? If it is so, if it is really really so, it breaks my code but I'm fine with that.

defaultConfig was never public.
Does that mean I shouldn't use it? I can see it's "internal" but so is configurable() and the latter is demonstrated in Core/Advanced/Widgets: The-widget-class so I'm not sure what the quick tip "This member should not be used by non-framework code" means exactly. My understanding is that private stuff is just not shown in the documentation.

"defaultConfig" is getting replaced with "configurable".
Thanks for the heads up. I will stop using it.

Anyway, I carefully read Core.Base#configurable **. The example is clear, and works very well: the configurations of the Example and Example2 classes are merged, and this is what I expect. Unless you use let ex = new Example2(); then ex.config becomes { bar: {} }. Strange. let ex = new Example2({config: {}}); is the least that can be used to get any expected result. But I digress

So I did some more tests and here's where it gets interresting: it merges fine, UNLESS there's an array. Then that array gets completely replaced:

class Example extends Base {
     static get configurable() {
         return {
             config : {
                 foo : 1,
                 bar : [{
                     ref: 'first',
                     adjo: 'abc'
                 }, {
                     ref: 'second',
                     adjo: 'def'
                 }]
             }
         };
     }
 }


 class Example2 extends Example {
     static get configurable() {
         return {
             config : {
                 bar : [{
                     ref: 'second',
                     adjo: 'ghi'
                 }, {
                     ref: 'third',
                     adjo: 'jkl'
                 }],
                 zip : 'abc'
             }
         };
     }
 }

let ex = new Example2({config: { zip: 'xyz'}});
console.debug(ex.config);

// Expected result:
{
	"bar": [{
		"ref": "first",
		"adjo": "abc"
	}, {
		"ref": "second",
		"adjo": "ghi"  // This one is updated
	}, {
		"ref": "third",
		"adjo": "jkl"
	}],
	"foo": 1,
	"zip": "xyz"
}

// Expected result if ref was not to be handled:
{
	"bar": [{
		"ref": "first",
		"adjo": "abc"
	}, {
		"ref": "second",
		"adjo": "def"
	}, {
		"ref": "second",
		"adjo": "ghi"
	}, {
		"ref": "third",
		"adjo": "jkl"
	}],
	"foo": 1,
	"zip": "xyz"
}

// Actual result:
{
	"bar": [{  // MISSING ONE!
		"ref": "second",
		"adjo": "ghi"
	}, {
		"ref": "third",
		"adjo": "jkl"
	}],
	"foo": 1,
	"zip": "xyz"
}

And that is what I'm experiencing. Gantt.widget.TaskEditor#items has to be an array (see my original post) so it gets completely replaced. If I could refer to "tabs" with items: { tabs: {...} } instead of items: [ { ref: 'tabs', ...} ]then I believe the matter here would be over.

I'm sorry I don't mean to challenge you guys. What I did in 2.1.7 worked but maybe it was just wrong. I don't know The right strategy to use is a bit confusing and I just need to get it clear.

** There'a a typo: To support this, config options ca be declared like
** The result reads ex.foo = { but should be ex.config = {

@jsakalos jsakalos added feature request forum Issues from forum labels Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request forum Issues from forum
Projects
None yet
Development

No branches or pull requests

1 participant