Page 1 of 1

[INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Mon Dec 11, 2023 5:56 pm
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.


Re: [INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Tue Dec 12, 2023 6:45 am
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?


Re: [INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Tue Dec 12, 2023 10:54 am
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


Re: [INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Tue Dec 12, 2023 11:00 am
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';

Re: [INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Wed Dec 13, 2023 2:04 pm
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?


Re: [INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Wed Dec 13, 2023 6:13 pm
by lxxrxns
lxxrxns wrote: Tue Dec 12, 2023 10:54 am
resourceStore : {
  (...)
},

eventStore : {
  (...)
},

resourceTimeRangeStore,
timeRangeStore,

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


Re: [INFO REQ] resourceTimeRanges are shown, but normal timeRanges not, what am I doing wrong?

Posted: Thu Dec 14, 2023 6:51 am
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.