Our pure JavaScript Scheduler component


Post by tsarmf »

Is there a easy way to create assignment for both resources.

Resource store would have our worker dto. And Event Store have Work Objects/Items that would be assigned to multiple worker.
On init all that is connected in assignment store.

My question would be if there is something out of the box, On drag and drop, to just create assignment for worker(resource) on where work object is droped on (in this case assignment).
dragHelperConfig: {
                mode: 'translateXY',
                constrain: false,
                cloneTarget: true,
                hideOriginalElement: false
}
I have set it to remain in original position.

Post by mats »

On drag and drop, to just create assignment for worker(resource) on where work object is droped on (in this case assignment).
Sorry it's not quite clear what you need. Can you please explain a bit further what should happen, when you drag drop (what do you drag drop?)?

Post by tsarmf »

simple copy paste of assignment for both resources. When event is dragged from one person to another. to keep original assignment but to create one for new resource with same event ref.

Post by sergey.maltsev »

Hi!

Unfortunately we have no this build-in feature yet.
I've created this issue for implementing it
https://github.com/bryntum/support/issues/311

You could try this simple workaround which you could improve on your needs.
new Scheduler({
...
    listeners : {
        beforeeventdropfinalize : async({ context }) => {
            // Set your own method to enable/disable copy mode
            const
                enableCopy = true;

            const
                { draggedRecords, resourceRecord, newResource } = context;
            let
                isEventCopied = false;

            draggedRecords.forEach((assignment) => {
                const
                    event = assignment.event;
                // if we dragged the event to a different resource
                if (resourceRecord !== newResource) {
                    if (enableCopy) {
                        isEventCopied = true;
                        event.assign(newResource);
                    }
                }
            });
            // `true` to accept the changes or `false` to reject them on copy
            context.finalize(!isEventCopied);
        }
    }
You could check it in this demo by adding listeners config there
https://www.bryntum.com/examples/scheduler/multiassign/

Also check beforeEventDropFinalize event
https://www.bryntum.com/docs/scheduler/#Scheduler/feature/EventDrag#event-beforeEventDropFinalize

And this demo for using different validators
https://www.bryntum.com/examples/scheduler/validation/

Post by tsarmf »

Thank you.

Post Reply