Discuss anything related to web development but no technical support questions


Post by lxxrxns »

Hi there!

I have a TimeRangeStore and a ResourceTimeRange Store, both with recurring events.

They look something like this:

const resourceTimeRangeStore = new MyResourceTimeRangeStore({
  readUrl        : 'php/schedule/resourcetimerange/read.php',
  autoLoad       : true,
  autoCommit     : true,
  sendAsFormData : true,
  listeners : {
    beforeCommit : () => {
      scheduler.readOnly = true;
    },
    commit : () => {
      scheduler.readOnly = false;
    },
    exception : (timerange) => {
      processException(timerange);
      scheduler.readOnly = false;
    }
  }
});

const timeRangeStore = new MyTimeRangeStore({
  readUrl        : 'php/schedule/timerange/read.php',
  autoLoad       : true,
  autoCommit     : true,
  sendAsFormData : true,
  listeners : {
    beforeCommit : () => {
      scheduler.readOnly = true;
    },
    commit : () => {
      scheduler.readOnly = false;
    },
    exception : (timerange) => {
      processException(timerange);
      scheduler.readOnly = false;
    }
  }
});

My features section has

timeRanges  : {
  showCurrentTimeLine : true,
  showHeaderElements  : false
},
resourceTimeRanges : true,

And my read.php's look something like this (the resourceTimeRangeStore's read.php is the same, but with a resourceId attached to the ranges)

function sendData($data) {
  die(json_encode(
    [
      "success" => true,
      "data"    => $data
    ]));
}

array_push($_SESSION["timeranges"], [ "id" => 'weekendstest', "name" => 'Weekend', "startDate" => '2024-01-01 00:00:00', "endDate" => '2024-01-02 23:59:00', "recurrenceRule" => 'FREQ=WEEKLY;INTERVAL=1;BYDAY=SA', "timeRangeColor" => "red" ]);

sendData($_SESSION["timeranges"]);

How can it be that only the RESOURCE time ranges show up? What am I not seeing?
Or is it not possible to have regular timeRanges AND resourceTimeRanges in one scheduler??

Any help would be greatly appreciated.


Post by tasnim »

Hi,

The code looks correct to me. Please check in your network tab if the data is correct or not.
Or could you please send the data (from the network tab) here so we can check what's wrong?


Post by lxxrxns »

Hi Tasnim,

Thanks for helping!

It seems that the read.php for the timeRangeStore is not being loaded...
It loads 3 different read.php's (events, resources, resourceTimeRanges), but not the timeRanges one, even though all FOUR stores are loaded:

resourceStore : {
  (...)
},

eventStore : {
  (...)
},

resourceTimeRangeStore,
timeRangeStore,

I don't understand why the php/schedule/timerange/read.php is not being loaded.

By "data" do you mean the SESSION data (i.e. the timeranges and events themselves)? Is there any way to show that in the Network tab?

Kind regards,

Laurens


Post by lxxrxns »

When I call the read.php directly, it DOES return the JSON, so it must be something in the javascript that is not calling/loading the timeRangeStore...

{"success":true,"data":[{"id":"weekendstest","name":"Weekend","startDate":"2024-01-01 00:00:00","endDate":"2024-01-02 23:59:00","recurrenceRule":"FREQ=WEEKLY;INTERVAL=1;BYDAY=SA","timeRangeColor":"red"}]}

Is there some additional module I need to load to make timeRanges work? (I tried "TimeRangeStore" and "TimeRangeModel" -because there is also a ResourceTimeRangeModel and a ResourceTimeRangeStore- but these don't exist):

import { DateHelper, StringHelper, Scheduler, Toast, ResourceTimeRangeModel, TimeRanges, RecurringTimeSpan, TimeSpan, RecurringTimeSpansMixin, Store, ResourceTimeRangeStore, LocaleManager, Localizable, PresetManager, EventModel, AjaxHelper } from './build/scheduler.module.js';

Post by tasnim »

Are you setting this timeRangeStore to scheduler?

I'm not able to reproduce the issue! Could you please provide a runnable test case so we can reproduce and debug it?


Post by lxxrxns »

lxxrxns wrote: Tue Dec 12, 2023 10:54 am
resourceStore : {
  (...)
},

eventStore : {
  (...)
},

resourceTimeRangeStore,
timeRangeStore,

Yes I am... It's really strange...


Post by tasnim »

Hi,

Could you please provide a runnable test case so we can reproduce and debug the issue?

Note: Please ensure you're not using any older version, see if you can reproduce it with the latest version.


Post Reply