Page 1 of 1

[REACT] ResourceAllocationInfo override not working on production build

Posted: Fri Dec 09, 2022 10:22 pm
by tulioassis

Hey!
We are overriding the ResourceAllocationInfo class.
It's working good on a dev server but not on a production build.

On prod build we are able to get the resource histogram template but all the ticks are empty (no color).

Did someone face something similar?
Any ideas on what could be the issue?


Re: [REACT] ResourceAllocationInfo override not working on production build

Posted: Sat Dec 10, 2022 12:58 am
by tulioassis

I did some tests here and seems that generator function cannot be overridden.

Works:

export class ResourceAllocationInfoOverride {
	static get target() {
		return {
			class: ResourceAllocationInfo,
		};
	}

calculateAllocation() {
	alert('Test');
}
}

Does not work:

export class ResourceAllocationInfoOverride {
	static get target() {
		return {
			class: ResourceAllocationInfo,
		};
	}

*calculateAllocation() {
	alert('Test');
}
}

But we do need to keep it as a generator function...


Re: [REACT] ResourceAllocationInfo override not working on production build

Posted: Mon Dec 12, 2022 10:48 am
by arcady

You can extend ResourceAllocationInfo and provide the subclass to project:

class MyResourceAllocationInfo extend ResourceAllocationInfo {
    *calculateAllocation() {
        ...
    }
}

new ResourceHistogram({
    project : {
        resourceAllocationInfoClass : MyResourceAllocationInfo,
        ...
    },
    ...
})

Docs:
https://www.bryntum.com/products/gantt/docs/engine/classes/_lib_engine_quark_model_scheduler_pro_schedulerproprojectmixin_.schedulerproprojectmixin.html#resourceallocationinfoclass
https://www.bryntum.com/products/gantt/docs/engine/classes/_lib_engine_quark_model_scheduler_pro_schedulerproresourcemixin_.resourceallocationinfo.html


Re: [REACT] ResourceAllocationInfo override not working on production build

Posted: Mon Dec 12, 2022 3:29 pm
by tulioassis

Hey arcady,
That's weird, but this way you provided is not working for me when I use the * (generator function).

Working:

export class ResourceAllocationInfoOverride extends ResourceAllocationInfo {
	// @ts-expect-error
	calculateAllocation(): CalculationIterator<this['allocation']> {
		alert('calculateAllocation test');
	}
}

Not working:

export class ResourceAllocationInfoOverride extends ResourceAllocationInfo {
	// @ts-expect-error
	*calculateAllocation(): CalculationIterator<this['allocation']> {
		alert('calculateAllocation test');
	}
}

As project model:

	projectRef.current = new ProjectModel({
		...
		// @ts-expect-error
		resourceAllocationInfoClass: ResourceAllocationInfoOverride,
	});

Re: [REACT] ResourceAllocationInfo override not working on production build

Posted: Mon Dec 12, 2022 4:02 pm
by arcady

Please provide a test case demonstrating the problem and we'll investigate what happens.


Re: [REACT] ResourceAllocationInfo override not working on production build

Posted: Mon Dec 12, 2022 4:10 pm
by tulioassis

Do you know if is it possible to apply overrides on any available demo/example?


Re: [REACT] ResourceAllocationInfo override not working on production build

Posted: Mon Dec 12, 2022 4:38 pm
by arcady

Not sure. I haven't tried to override all of the demos. Why?