Our state of the art Gantt chart


Post by cf_Simon »

Hi,
is there a way to create an override for an override?

When applying a second override to the same class and function, the app crashes.

So I tried to create an override for the overwritten function of an override.
Something like that:

class CustomerTextFieldOverride extends Override {
  static get target() {
    return {
      class: TextFieldOverride,
    };
  }

  construct(config: TextFieldConfig) {
    if (this.type === TextField.type) {
      config.cls= 'custom-class';
    }
  }
}
Override.apply(CustomerTextFieldOverride);

But that function is being ignored. So now I'm wondering if that is even possible/intended


Post by marcio »

Hey cf_Simon,

That's intended, as you'll see here https://bryntum.com/products/gantt/docs/api/Core/mixin/Override

Simplifies overriding class methods by allowing methods from another class to be used as overrides. Overrides are defined as own classes. They must at a minimum contain a static getter named targetClass, which should return the class to override.

So you don't need that extends Override in the class definition.

Best regards,
Márcio


Post by cf_Simon »

Yes you're right, I don't need the extends.
I tried it without the extends Override - I still cannot create an Override for a function of another override.

Here is the setup I tried for the advanced example:

class TextFieldOverride {

  static get target(){
    return {
      class: TextField,
    };
  }

  construct(config) {
    if (this.type === TextField.type) {
      config.clearable = true;
    }

this._overridden.construct.call(this, config);
  }
}
class CustomerTextFieldOverride {
  static get target(){
    return {
      class: TextFieldOverride,
    };
  }

  construct(config) {
    if (this.type === TextField.type) {
      config.cls = 'custom-cls';
    }

this._overridden.construct.call(this, config);
  }
}

Override.apply(TextFieldOverride);
Override.apply(CustomerTextFieldOverride);

I can get either one to apply, but not both


Post by alex.l »

Could you please post full code you used for that for both files, also show how and where did you import those overrides in the order as in your app.

I can get either one to apply, but not both

Why then don't combine all in one and use one instead of two?

All the best,
Alex


Post by cf_Simon »

You can use the code posted above in the advanced example - just add TextField and Override to the import and it should work.

My expectation in that case would be, that every textfield has the clearable enabled by default as well as the defined class in the DOM.

Why then don't combine all in one and use one instead of two?

We use Override to customize the default behavior. So far (with the ExtJS Version) we also use it to deploy patches (hotfixes) on systems until the app can be redeployed.
By definition we cannot put both in the same file - if we'd known before rollout, we wouldn't have to deploy a fix :)


Post by alex.l »

Reproduced, we'll check what's wrong, here is the link to track a status https://github.com/bryntum/support/issues/6364

All the best,
Alex


Post Reply