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

Adding to resourceStore and resourceTimeRangeStore doesnt update reference #2900

Closed
jsakalos opened this issue May 20, 2021 · 3 comments
Closed
Assignees
Labels
bug Something isn't working forum Issues from forum resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@jsakalos
Copy link

When a record is added to resourceStore with the same id as an already existing record, the existing record is replaced by the new one which breaks its relation to resourceTimeRangeStore record.

Steps to reproduce:

  1. https://bryntum.com/examples/scheduler/resourcetimeranges/
  2. in console:
scheduler.resourceStore.add( { id : 'r1', name : 'Mock' });
  1. drag the first event

The existing resource time range disappears. The situation should be handled, either by removing resource time range record or updating behind the scenes.

Forum post

Hey!

Im running a useEffect hook where im dynamically updating resourceData (1 to many fields) using the resourceStore.addAsync() function it removes that resources resourceTimeRange.

Ive tried a few workArounds, and the only one that seems to work is the very bruteforcy way of doing a setAsync(); func on the Resource itself, which seems wrong to me.

I have recreated this issue in https://bryntum.com/examples/scheduler/resourcetimeranges/

where Ive changed the "add resource" btn onclick to this:

onAction : () => {
                scheduler.resourceStore.add( { id : 'r1', name : 'Mock' });
scheduler.resourceStore.add( { id : 'r2', name : 'Mock' });
            }
            

It looks fine when u click it (the name changes of the resource) but when u interact with the scheduler (either moving timeRanges to lunch or just simply moving an event) the resources timeRanges disapear.

-----OurImplementation-----
the project is set up like this:

    project: {
      eventStore: new EventStore(),
      resourceStore: new ResourceStore(),
      resourceTimeRangeStore: new ResourceTimeRangeStore(),
    },

the "this should work" tries

  useEffect(() => {
    if (updatedWorkShift) {
      const addToResourceStore = async () => {
        await props.planningSchedulerRef.current.resourceStore.addAsync(updatedWorkShift);
      };
      
  addToResourceStore();
}
  }, [updatedWorkShift]);

  useEffect(() => {
    if (updatedWorkShift) {
      const addToResourceStore = async () => {
        props.planningSchedulerRef.current.resourceStore.add(updatedWorkShift);
        await props.planningSchedulerRef.current.project.commitAsync();
      };
      
  addToResourceStore();
}
  }, [updatedWorkShift]);

  useEffect(() => {
    if (updatedWorkShift) {
      const addToResourceStore = async () => {
        props.planningSchedulerRef.current.resourceStore.add(updatedWorkShift);
        const updatedTimeRanges = updatedWorkShift.map((workShift) => ({
          resourceId: workShift.id,
          startDate: dateUtils.addHours(workShift.workShiftStart, -2),
          endDate: dateUtils.addHours(workShift.workShiftEnd, 2),
        }));
        props.planningSchedulerRef.current.resourceTimeRangeStore.add(
          updatedTimeRanges,
        );
        await props.planningSchedulerRef.current.project.commitAsync();
      };
      
  addToResourceStore();
}
  }, [updatedWorkShift]);

  useEffect(() => {
    if (updatedWorkShift) {
      const addToResourceStore = async () => {
        props.planningSchedulerRef.current.resourceStore.add(updatedWorkShift);
        const updatedTimeRanges = updatedWorkShift.map((workShift) => ({
          resourceId: workShift.id,
          startDate: dateUtils.addHours(workShift.workShiftStart, -2),
          endDate: dateUtils.addHours(workShift.workShiftEnd, 2),
        }));
        await props.planningSchedulerRef.current.project.commitAsync();
        
    props.planningSchedulerRef.current.resourceTimeRangeStore.add(
      updatedTimeRanges,
    );
    await props.planningSchedulerRef.current.project.commitAsync();
  };
  
  addToResourceStore();
}
  }, [updatedWorkShift]);

@jsakalos jsakalos added bug Something isn't working forum Issues from forum labels May 20, 2021
@jsakalos jsakalos changed the title [REACT] adding to resourceStore and resourceTimeRangeStore doesnt update reference adding to resourceStore and resourceTimeRangeStore doesnt update reference May 20, 2021
@acpanackal
Copy link

Is this bug fixed?

I was trying with 'loadDataAsync' and 'addAsync' to update ResourceStore.

When I use 'loadDataAsync' there is a flicker after polling
When I use 'addAsync' flicker is gone but ResourceTimeranges disappear on polling. any idea?

@matsbryntse
Copy link
Member

Not yet fixed but we'll try to get this sorted out shortly!

@matsbryntse matsbryntse self-assigned this Aug 15, 2023
@matsbryntse matsbryntse added the ready for review Issue is fixed, the pull request is being reviewed label Aug 15, 2023
@matsbryntse matsbryntse changed the title adding to resourceStore and resourceTimeRangeStore doesnt update reference Adding to resourceStore and resourceTimeRangeStore doesnt update reference Aug 15, 2023
@acpanackal
Copy link

acpanackal commented Aug 16, 2023

Wow so happy to see that it's ready for review. Would really appreciate it if it's online and available. Because the scenario is very irritating for our customers.

We do have a Premium Account but I messaged here since I think my Issue is well explained here.

Thanks :)

@isglass isglass added resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed labels Aug 21, 2023
@isglass isglass added this to the 5.5.2 milestone Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

4 participants