Page 1 of 1

Sync request Comes with duration, but without duration unit

Posted: Fri Nov 25, 2022 12:40 pm
by tornikezhizh

Hello, I have weird scenario there, when I update endTime or StartTime, sync request acts very weird, sometimes it passes both start and end date/time, sometimes only one of them and + automatically calculated duration, but duration unit never passed to request, and as far as I understand, sometimes it comes in hours, like when difference between start time and end time is 30 minutes, duration is 0.5, but if difference is 38 minutes, duration is 0.02638888888888889M, which is not in hours, but in days and I can't apply correct logic, since I don't receive duration unit. What will be best solution in case like this?


Re: Sync request Comes with duration, but without duration unit

Posted: Fri Nov 25, 2022 2:57 pm
by johan.isaksson

Hello,

On sync, only the changes are sent by default. Duration will be in the unit it was loaded in, if the unit had changed too it would be part of the sync. So the duration you received is in the unit that was sent in the load, or in the default duration unit if it is a new event record.

If you prefer, you can configure it to send all fields in the sync. See https://bryntum.com/products/calendar/docs/api/Scheduler/data/CrudManager#config-writeAllFields


Re: Sync request Comes with duration, but without duration unit

Posted: Fri Nov 25, 2022 4:35 pm
by tornikezhizh

thanks, I found alwaysWrite and changes js script like this, but still I don't get all those fields in request

 startDateField: {
            weight: 180,
            label: 'Start',
            type: 'dateField',
            name: 'startDate',
            format: 'DD/MM/YYYY',
            alwaysWrite : true,
            listeners: {
                change: editorHelper.onStartDateChange
            }
        },

    startTimeField: {
        weight: 190,
        type: 'timeField',
        name: 'startDate',
        alwaysWrite: true,
        step: '30min',
        picker: {
            items: {
                minute: {
                    step: 15
                }
            }
        },
    },

    endDateField: {
        type: 'dateField',
        weight: 193,
        name: 'endDate',
        format: 'DD/MM/YYYY',
        readOnly: true,
        alwaysWrite: true,
    },

    endTimeField: {
        weight: 195,
        type: 'timeField',
        name: 'endDate',
        step: '30min',
        alwaysWrite: true,
        picker: {
            items: {
                minute: {
                    step: 15
                }
            }
        },
    },

Re: Sync request Comes with duration, but without duration unit

Posted: Sun Nov 27, 2022 10:50 am
by alex.l

https://bryntum.com/products/calendar/docs/api/Core/data/field/DataField#config-alwaysWrite is a config for data field and not for form field. You need to define this in your Model or Store configuration, depends on the code you use.
https://bryntum.com/products/calendar/docs/api/Core/data/AjaxStore#config-fields
https://bryntum.com/products/calendar/docs/api/Core/data/Model

class Person extends Model {
    static get fields() {
        return [
            'name',
            { name : 'birthday', type : 'date', format : 'YYYY-MM-DD', alwaysWrite : true },
            { name : 'shoeSize', type : 'number', defaultValue : 11 },
            { name : 'age', readOnly : true }
        ];
    }
}

Re: Sync request Comes with duration, but without duration unit

Posted: Sun Nov 27, 2022 11:20 am
by tornikezhizh

I got it, thank you