How to properly create store that will subscribe to Bryntum app state changes, for example when user drags events or resizes them? We use bryntum with react redux and do not provide any CRUD manager for the bryntum.
We do have such demo, see the screenshot please. The demo initially loads data with CrudManager, but this is not the must, you can modify it to use axios. Axios is use for all subsequent loads (after you click the reload button). The demo demonstrates also error handling – one of 3 requests fails with error popup.
The demo uses also Redux-Saga for side-effects management but this is not a must; you can use your own way.
Screen Shot 2021-09-21 at 11.49.34.png (479.27 KiB) Viewed 1623 times
Thank you. Right now I am passing config to <BryntumScheduler /> with event listeners. But only "beforeEventEdit" works when edit popup dialog shows. I was expecting that other listeners, especially "onCatchAll" will be triggered if I for example move event or resize it. Can you tell me what I am doing wrong?
export const schedulerConfig: Partial<SchedulerConfig> = {
eventColor: '#000',
eventStyle: '',
features: {
timeRanges: {
showHeaderElements: true,
},
tree: true,
regionResize: true,
},
rowHeight: 45,
barMargin: 5,
columns: [
{
type: 'tree',
text: 'Name',
field: 'name',
width: 150,
},
],
startDate: new Date(2020, 11, 2), //'2020-12-02T15:00:00',
endDate: new Date(2023, 11, 2),
// zoomToFit: () => {},
viewPreset: 'year', // year
eventRenderer: (props: any) => {
const { eventRecord, resourceRecord, renderData } = props;
const { isLeaf } = resourceRecord;
// Add custom CSS classes to the template element data by setting property names
renderData.cls.leaf = isLeaf;
renderData.cls.group = !isLeaf;
return eventRecord.name;
},
listeners: {
beforeEventEdit: (source: any) => {
// TODO now we can show custom sidebar edit
console.log('beforeEventEdit', source);
// source.eventRecord.resourceId = source.resourceRecord.id;
// showEditor(source.eventRecord);
// return false;
},
onAfterEventSave: (source: any) => {
// TODO now we dispatch action to save event data
console.log('onAfterEventSave', source);
},
onDataChange: (source: any) => {
// TODO now we dispatch action to save event data
console.log('onDataChange', source);
},
onCatchAll: (source: any) => {
// TODO now we dispatch action to save event data
console.log('onCatchAll', source);
},
onAfterEventDrop: (source: any) => {
// TODO now we dispatch action to save event data
console.log('onAfterEventDrop', source);
}
},
};
Ok, I created DEMO with onDataChange method. With this demo when I try to drag/resize event - nothing happens. But the data was changed (start and end dates):