[REACT] beforeeventdropfinalize does not return the right data now
Hi Team,
We have upgraded Bryntum from 4.0.8 to 5.0.1 and ever since 'beforeeventdropfinalize' returns wrong data. I have raised another similar concern
viewtopic.php?p=113853#p113853.
Thanks for the prompt response.
These functionalities worked well and I came across now the context of the beforeeventdropfinalize does not update as it used to.
As you might already be aware we use the two scheduler view and React as the front-end development library. Please find the steps below.
- In this example we have a nested event and we have split functionality
- And then when you click we have an action that will create an event with a new event-id - '534535503rb21-21'. Deletes the one with the old ID - '534535503rb21'
case SPLIT_EVENT: const splitPayload = action.paramConfig; let eventId; return produce(state, (draft) => { // handle team view if (splitPayload.id.search(RESOURCE_TEAM_PATTERN) === -1) { eventId = splitPayload.id; } else { // e.g. 1756rb13:&&:TEAMCHS_01 ---> 1756rb13 eventId = splitPayload.id.split(`${RESOURCE_TEAM_CONCAT}`)[0]; } const schedulerEvent = getschedulerEventsFromEventId( state.schedulerEvents, eventId ); const splitedSchedulerEvents = []; if (schedulerEvent.nestedBookingEvents.length > 1) { // Making the scheduler event object for number of[nestedBookingEvents.length] with different eventIds schedulerEvent.nestedBookingEvents.forEach((nestedBookingEvent) => { const newSchedulerEvent = Object.assign({}, schedulerEvent); newSchedulerEvent['splittedEvent'] = true; newSchedulerEvent['originalId'] = schedulerEvent.id; // change the event id newSchedulerEvent[ 'id' ] = `${schedulerEvent.id}-${nestedBookingEvent.bookingID}`; newSchedulerEvent['startDate'] = nestedBookingEvent.start; newSchedulerEvent['endDate'] = nestedBookingEvent.end; newSchedulerEvent['bookingID'] = nestedBookingEvent.bookingID; newSchedulerEvent['bookings'] = []; newSchedulerEvent['bookings'].push(nestedBookingEvent); newSchedulerEvent['nestedBookingEvents'] = mapNestedBookingEvents( newSchedulerEvent ); // deleting bookings from newSchedulerEvent delete newSchedulerEvent.bookings; splitedSchedulerEvents.push(newSchedulerEvent); }); } else { splitedSchedulerEvents.push(schedulerEvent); } // Save splitted event in redux store draft.splittedEvent = schedulerEvent; // contcat newly created splitted into schedulerEvents draft.schedulerEvents = draft.schedulerEvents.concat( splitedSchedulerEvents ); // Delete splitted event from the schedulerEvents draft.schedulerEvents = draft.schedulerEvents.filter( (schedulerEvent) => { return schedulerEvent.id !== draft.splittedEvent.id; } ); });
- At this point we have two separate events in the scheduler now. This change of event object is detected in a useEffect and pushed through loadDataAsync. Please find one of the event objects we pass to loadDataAsync.
{ "description": "Cognos July Project Work - Cognos 2.0 Task 2 - Nett change", "start": "Date(2022-10-24) 13:00", "id": "534535503rb21-21", "resourceId": "res:534535503", "type": 11, "key1": "COGNOS_2", "key2": "200", "eventType": "Software Development", "eventTypeCode": "SD", "owner": "Melbourne Branch", "ownerCode": "MEL", "priority": "High Priority", "priorityCode": "0", "description1": "Cognos July Project Work", "description2": "Cognos 2.0 Task 2 - Nett change", "customerCode": "000000123", "customerName": "Gary Test Account 30", "customerDrillDown": "deb/m10mast -e 000000123", "customerRef": "", "addressName": "Shane Meredith", "address": "C/- Pronto Software 189 Coronation Drive Milton QLD 4064", "postcode": "4064", "latitude": -27.470518, "longitude": 153.008002, "locationStatus": "Valid", "phone": "", "email": "", "contactName": "", "parentKey1": "", "parentKeyDesc1": "", "startDate": "2022-10-24T02:00:00.000Z", "startTime": "13:00", "endDate": "2022-10-24T05:30:00.000Z", "endTime": "10:30", "bookingProjectLinkDate": "Date(2022-10-24)", "bookingProjectLinkTime": "13:00", "durationScale": "Hours", "durationText": "6 Hours", "durationTextHHMM": "6 Hours", "genericResource": "BM1", "attributes": [ { "group": "AIRCOND", "condition": "Equal To", "codes": [ { "code": "HVAC", "startDateFrom": "Date()", "startDateTo": "Date(2079-06-06)", "endDateFrom": "Date()", "endDateTo": "Date(2079-06-06)", "startNum1": 0, "endNum1": 99999999999999, "startNum2": 0, "endNum2": 99999999999999, "startText1": "", "endText1": "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ", "startText2": "", "endText2": "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" } ] } ], "suggestedResources": [ { "resourceNo": 111, "description": "Erica Low is a Electrician", "masterCode": "ERICA LOW" }, { "resourceNo": 469, "description": "numb nut", "masterCode": "DUMKOPF" }, { "resourceNo": 6667, "description": "Chef - and manager", "masterCode": "FLORA" } ], "generic1": "N", "genericDesc1": "Normal", "generic2": "", "genericDesc2": "none", "generic3": "", "genericDesc3": "Market Type not defined", "generic4": "Date(2022-07-20)", "genericDesc4": "", "generic5": "Date()", "genericDesc5": "", "notes": "", "holdReason": "", "holdReasonCode": "", "zoneCode": "", "zone": "", "eventRepCode": "DEB", "eventRep": "Debbie Green", "eventManagerCode": "andrewp", "eventManager": "Andrew Perera", "startDateType": "ASAP", "endDateType": "ASAP", "status": "Entered", "earliestStartDateTime": "Date(2022-07-20) 08:00", "earliestEndDateTime": "Date(2022-07-20) 13:00", "latestStartDateTime": "Date(2022-07-20) 08:00", "latestEndDateTime": "Date(2022-07-20) 13:00", "calcStartDateTime": "Date()", "calcEndDateTime": "Date()", "customAlpha1": "", "customAlpha2": "", "customAlpha3": "", "customAlpha4": "", "customAlpha5": "", "drillDown": "job/jimaint -maint COGNOS_2", "resizable": true, "draggable": true, "maskedEvent": 0, "eventColor": "#7457e4", "eventStyle": "border: 3px solid #ef0909; z-index: 40;", "icon": "", "overdueFlag": "0", "declineFlag": "0", "onHoldFlag": "0", "notifiedFlag": "0", "linkedGenericDate": "Date(2022-10-23)", "linkedGenericTime": "16:30", "end": "Date(2022-10-25) 10:30", "resourceNo": 534535503, "name": "Cognos July Project Work - Cognos 2.0 Task 2 - Nett change", "nestedBookingEvents": [ { "bookingID": 21, "bookingId": "rn534535503rb21", "start": "2022-10-24T02:00:00.000Z", "end": "2022-10-24T05:30:00.000Z", "startOffset": 0, "endOffset": 12600000, "description": "", "bookingProjectStart": "2022-10-24T02:00:00.000Z" } ], "Duration": 6, "splittedEvent": true, "originalId": "534535503rb21", "bookingID": 21 }
- Now if we try to move the event and try to capture the context through beforeeventdropfinalize
Looks like the event has the old event-id{ "description": "Cognos July Project Work - Cognos 2.0 Task 2 - Nett change", "start": "Date(2022-10-24) 13:00", "id": "534535503rb21", "resourceId": "res:534535503", "type": 11, "key1": "COGNOS_2", "key2": "200", "eventType": "Software Development", "eventTypeCode": "SD", "owner": "Melbourne Branch", "ownerCode": "MEL", "priority": "High Priority", "priorityCode": "0", "description1": "Cognos July Project Work", "description2": "Cognos 2.0 Task 2 - Nett change", "customerCode": "000000123", "customerName": "Gary Test Account 30", "customerDrillDown": "deb/m10mast -e 000000123", "customerRef": "", "addressName": "Shane Meredith", "address": "C/- Pronto Software 189 Coronation Drive Milton QLD 4064", "postcode": "4064", "latitude": -27.470518, "longitude": 153.008002, "locationStatus": "Valid", "phone": "", "email": "", "contactName": "", "parentKey1": "", "parentKeyDesc1": "", "startDate": "2022-10-24T02:00:00.000Z", "startTime": "13:00", "endDate": "2022-10-24T05:30:00.000Z", "endTime": "10:30", "bookingProjectLinkDate": "Date(2022-10-24)", "bookingProjectLinkTime": "13:00", "durationScale": "Hours", "durationText": "6 Hours", "durationTextHHMM": "6 Hours", "genericResource": "BM1", "attributes": [ { "group": "AIRCOND", "condition": "Equal To", "codes": [ { "code": "HVAC", "startDateFrom": "Date()", "startDateTo": "Date(2079-06-06)", "endDateFrom": "Date()", "endDateTo": "Date(2079-06-06)", "startNum1": 0, "endNum1": 99999999999999, "startNum2": 0, "endNum2": 99999999999999, "startText1": "", "endText1": "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ", "startText2": "", "endText2": "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" } ] } ], "suggestedResources": [ { "resourceNo": 111, "description": "Erica Low is a Electrician", "masterCode": "ERICA LOW" }, { "resourceNo": 469, "description": "numb nut", "masterCode": "DUMKOPF" }, { "resourceNo": 6667, "description": "Chef - and manager", "masterCode": "FLORA" } ], "generic1": "N", "genericDesc1": "Normal", "generic2": "", "genericDesc2": "none", "generic3": "", "genericDesc3": "Market Type not defined", "generic4": "Date(2022-07-20)", "genericDesc4": "", "generic5": "Date()", "genericDesc5": "", "notes": "", "holdReason": "", "holdReasonCode": "", "zoneCode": "", "zone": "", "eventRepCode": "DEB", "eventRep": "Debbie Green", "eventManagerCode": "andrewp", "eventManager": "Andrew Perera", "startDateType": "ASAP", "endDateType": "ASAP", "status": "Entered", "earliestStartDateTime": "Date(2022-07-20) 08:00", "earliestEndDateTime": "Date(2022-07-20) 13:00", "latestStartDateTime": "Date(2022-07-20) 08:00", "latestEndDateTime": "Date(2022-07-20) 13:00", "calcStartDateTime": "Date()", "calcEndDateTime": "Date()", "customAlpha1": "", "customAlpha2": "", "customAlpha3": "", "customAlpha4": "", "customAlpha5": "", "drillDown": "job/jimaint -maint COGNOS_2", "resizable": true, "draggable": true, "maskedEvent": 0, "eventColor": "#7457e4", "eventStyle": "border: 3px solid #ef0909; z-index: 40;", "icon": "", "overdueFlag": "0", "declineFlag": "0", "onHoldFlag": "0", "notifiedFlag": "0", "linkedGenericDate": "Date(2022-10-23)", "linkedGenericTime": "16:30", "end": "Date(2022-10-25) 10:30", "resourceNo": 534535503, "name": "Cognos July Project Work - Cognos 2.0 Task 2 - Nett change", "nestedBookingEvents": [ { "bookingID": 21, "bookingId": "rn534535503rb21", "start": "2022-10-24T02:00:00.000Z", "end": "2022-10-24T05:30:00.000Z", "startOffset": 0, "endOffset": 12600000, "description": "", "bookingProjectStart": "2022-10-24T02:00:00.000Z" } ], "Duration": 6, "splittedEvent": true, "originalId": "534535503rb21", "bookingID": 21, "durationUnit": "day", "cls": "", "allDay": false, "exceptionDates": {}, "duration": 0.14583333333333334, "parentIndex": 37 }
Please see the return value of contex.context.EventRecords[0]. data
Thanks in advance.