Our pure JavaScript Scheduler component


Post by Aniket »

Team,
I am using crudmanager and after first load request, I want to send an id as a parameter to sync request of crudmanager that comes as a response from the crudmanagers load request.

But I can see load and sync getting fired simultaneously.

Do you see anything incorrct here?

    this.crudManager = {
      listeners: {
        load({ response }) {
          console.log(response);
          const
            start = new Date(response.calendar.startDate);
          const end = new Date(response.calendar.endDate);
          var childId = (response.details.childId);
          var parentId = response.details.parentId;
            console.log(childId);
          console.log(parentId);
          this.scheduler.setTimeSpan(start, end);      // set calendar startdate and enddate
        },
        beforeResponseApply: ({ response }) => {
          response.resources.rows = response.resources.vehicles;
          response.events.rows = response.events.tests;
          response.timeRanges.rows = response.timeRanges.dueDates;
          localStorage.setItem('CurrentSelectedScheduleChildId', response.details.childId);
          console.log(localStorage.getItem('CurrentSelectedScheduleChildId'));
        },
        //beforeSend: ({ params }) => {
        //  // can be used to dynamically add arbitrary parameters to data load/sync requests
        //  const queryString = JSON.parse(
        //    localStorage.getItem('CurrentSelectedScheduleChildId')
        //  );
        //  params.outputScheduleId = queryString;
        //  console.log(params.outputScheduleId);
        //  // params.config = queryString;
        //}
      },
      autoLoad: true,
      autoSync: true,
      transport: {
        load: {
          url: 'https://localhost:5000/api/Schedule',
          params: {
            outputScheduleId: JSON.parse(
              localStorage.getItem('CurrentSelectedSchedule')
            ),

     }
      method: 'GET',
      credentials: 'omit',
    },
    sync: {
      url: 'https://localhost:5000/api/ReScheduling',
      params: {
        outputScheduleChildId: JSON.parse(
          localStorage.getItem('CurrentSelectedScheduleChildId')

        )
      },
      headers: {
        'Content-Type': 'application/json'
      },
      method: 'POST',
      credentials: 'omit'

    }
   }
    };

Post by Maxim Gorkovsky »

Hello.
It looks like a duplicate of your own thread: viewtopic.php?f=44&t=14743&start=20
This code snippet doesn't show any issues which might lead to sync being called right after load. Have you tried debugging sync method call?


Post by Aniket »

maxim, when i set autoSync to false, the sync does not happen. But in this case, the changes aso dont get posted automatically.

I get this error message

:4200/polyfills.js:3982 Unhandled Promise rejection: Sync failed ; Zone: <root> ; Task: Promise.then ; Value: Error: Sync failed

Post by Maxim Gorkovsky »

I'm afraid this error message doesn't help us. We will need a runnable test case to help you.


Post Reply