I'm trying to do a control for Rooms reservations for Meetings and here are my scenarios
I have 3 users "Admin" , "Secretary" , "Assistant"
# 1:
1.- User Admin Creates an appointment/Event For room #1 from 12:30 to 14:30
2.- User Assistant Wants to create also an appointment/Event For room #1 but the time is from 14:00 to 15:30 (this part i need to generate error on serverside and get it with JS in order to alert users about the error)
# 2:
1.- User Admin Creates an appointment/Event For room #1 from 12:30 to 14:30
2.- User Assistant Wants to create also an appointment/Event For room #1 but the time is from 14:30 to 15:30
3.- User Admin notice he made a mistake and tries to EDIT his event so now the time is going to be 12:30 to 15:30 (this part i need to generate error on serverside and get it with JS in order to alert users about the error)
#3 (After scenario 1 & 2)
1.- User secretary want to create a recurrent event from 11:30 to 13:30 every 2 days for Room # 1 but it collides with appointments created with scenario#1 and #2 so i need to generate an error alert
First of all i dont want to control everything on JS i want to get the errors from the serverside. I am generating JSON responses for the scheduler. NOW Obviously for this issue the server must return an error in the response but no luck finding on docs how to create an error response for the data manager. So my problem is HOW CAN I: intercept errors in all operations ???
I have tried to make according the documentation https://help.syncfusion.com/js/datamanager/how-to#how-do-i-control-communication-errors-with-the-web-service
but for me this works only the first time the DataManager makes a request
Also another problem i see its that for promises i need to execute the query before create the Scheduler so that leads me to that the URL is called before scheduler its created and then its called again after its created. Looking At detail it seems that Scheduler always expects a success response but how can i interact with Users when there is an error about data conflicts which is the case of the Scenarios. Also documentation for Datamanager of Scheduler examples really doesnt help at all in this case.
This is so far an example CODE i have made to check how to solve this.
var myOtherAdaptorBase = new ej.UrlAdaptor().extend({
beforeSend: function (request, settings){
console.log('myAdaptor-beforeSend');
}
});
var myOtherAdaptor = new myOtherAdaptorBase();
var dataManager = new ej.DataManager({
url:"/data/calendar_sample.php",
batchUrl:"/data/calendar_sample.php?batch=1",
insertUrl:"/data/calendar_sample.php?add=1",
updateUrl:"/data/calendar_sample.php?edit=1",
removeUrl:"/data/calendar_sample.php?remove=1",
adaptor: myOtherAdaptor
});
var myquery = ej.Query().from("events");
var dataSource = dataManager.executeQuery(myquery).done(
function(args){
console.log('myquery-done');
}
).fail(
function(args){
console.log('myquery-fail');
}
).always(
function(args){
console.log('myquery-always');
}
);
var calx= $("#schedule").ejSchedule({
locale: "es-ES",
views:['Day','Week','Month','Agenda'],
currentView: ej.Schedule.CurrentView.Week,
isDST:false,
allowDragAndDrop: false,
showWeekend: true,
showQuickWindow: false,
showDeleteConfirmationDialog: false,
enableRecurrenceValidation: false,
enableLoadOnDemand: true,
startHour:7,
endHour:21,
timeZone:"UTC -06:00",
timeMode: ej.Schedule.TimeMode.Hour24,
currentDate: new Date(),
appointmentSettings: {
dataSource: dataManager,
query: myquery,
id: "Id",
subject: "Subject",
startTime: "StartTime",
endTime: "EndTime",
allDay: "AllDay",
recurrence: "Recurrence",
recurrenceRule: "RecurrenceRule",
editFutureEventsOnly: true
},
create:"doOnCreate",
actionBegin:'doActionBegin',
//cellClick: "cellClickx",
//cellDoubleClick:'cellDobleclickx',
//cellHover:"mycellHover",
overflowButtonHover:"MyoverflowButtonHover",
overflowButtonClick:"myoverflowButtonClick",
appointmentHover: "myAppointmentHover",
appointmentClick: "OnAppointmentClick",
appointmentWindowOpen:'onAppointmentWindowOpen',
beforeAppointmentCreate: "onAppointmentSave",
beforeAppointmentChange: "onAppointmentEdit",
beforeAppointmentRemove: "onAppointmentDelete"
});
Hope some other users have face similar issues or needs and may share solution.
Thanks in advance.