Our powerful JS Calendar component


Post by skorer »

Hi,

I am trying to defining the correct response for adding event. Here is my response;

{
    "Success": true,
    "RequestId": 17018601833191,
    "Events": {
        "Rows": [
            {
                "PhantomId": "_generatedModelClass_c4ad953c-a6a0-4ac0-a458-a745121e02da",
                "CalendarId": 1000466,
                "AddedDt": "2023-12-06T13:56:23.4179866+03:00"
            }
        ]
    }
}

But when I check it with validateResponse: true the error message is;

validateresponse.png
validateresponse.png (24.38 KiB) Viewed 546 times

I am not getting any error from validateResponse for updating and deleting events which their responses are;

For the update;

{
    "Success": true,
    "RequestId": 17018606597091,
    "Events": {
        "Rows": [
            {
                "CalendarId": 1000465
            }
        ]
    }
}

For the delete;

{
    "Success": true,
    "RequestId": 17018607442562,
    "Events": {
        "Removed": [
            {
                "CalendarId": 1000404
            }
        ]
    }
}

I can not see any difference between what is expected and what is the response. Do you have any idea about what is the issue here?


Post by tasnim »

Hi,

Please use lowercase instead of uppercase for Rows -> rows, Events - events, Removed -> removed, CalendarId -> calendarId, etc.


Post by skorer »

Hi,

Last two responses of update and delete that I shared are working correctly, no validationResponse error for those. I am getting an error only with the adding. All of them are uppercases


Post by tasnim »

Hi,

I'm not able to replicate it.

This is the code I used to replicate the issue https://bryntum.com/products/calendar/examples/basic/

AjaxHelper.mockUrl('sync', () => {
    return {
        responseText : JSON.stringify({
            "Success": true,
            "RequestId": 17018601833191,
            "Events": {
                "Rows": [
                    {
                        "PhantomId": "_generatedModelClass_c4ad953c-a6a0-4ac0-a458-a745121e02da",
                        "CalendarId": 1000466,
                        "AddedDt": "2023-12-06T13:56:23.4179866+03:00"
                    }
                ]
            }
        })
    }
})

const calendar = new Calendar({
    // Start life looking at this date
    date : new Date(2020, 9, 12),

// CrudManager arranges loading and syncing of data in JSON form from/to a web service
crudManager : {
    autoLoad  : true,
    autoSync  : true,
    transport : {
        load : {
            url : 'data/data.json'
        },
        sync : {
            url : 'sync',
            method : 'GET'
        }
    }
},

appendTo : 'container',

// Features named by the properties are included.
// An object is used to configure the feature.
features : {
    eventTooltip : {
        // Configuration options are passed on to the tooltip instance
        // We want the tooltip's left edge aligned to the right edge of the event if possible.
        align : 'l-r'
    }
}
});

Could you please provide the steps to replicate this issue or a runnable test case where we can replicate/debug it?


Post by skorer »

Here is my sync request for adding an event;

{
    "type": "sync",
    "requestId": 17018725009641,
    "events": {
        "added": [
            {
                "startDate": "2023-12-06T00:00:00+03:00",
                "endDate": "2023-12-07T00:00:00+03:00",
                "durationUnit": "hour",
                "cls": "",
                "name": "Standart Altyapı Değişiklik",
                "exceptionDates": [],
                "resourceId": 1,
                "allDay": true,
                "isXLRoutage": false,
                "isXLRMFoutage": false,
                "PhantomId": "_generatedModelClass_87ab39a5-c1a1-44af-92f1-41371a7c1442",
                "resourceTypeName": "Özel Günler"
            }
        ]
    }
}

and here is the response for the sync request;

{
    "Success": true,
    "RequestId": 17018725009641,
    "Events": {
        "Rows": [
            {
                "PhantomId": "_generatedModelClass_87ab39a5-c1a1-44af-92f1-41371a7c1442",
                "CalendarId": 1685,
                "AddedDt": "2023-12-06T17:21:41.0554108+03:00"
            }
        ]
    }
}

Do you see any mistakes in the response? Response validate error is;

CrudManager sync response error(s):

  • "events" store "rows" section should mention added record(s) #generatedModelClass_87ab39a5-c1a1-44af-92f1-41371a7c1442 sent in the request. It should contain the added records identifiers (both phantom and "real" ones assigned by the backend).
    Please adjust your response to look like this:
    {
    "events": {
    "rows": [
    {
    "PhantomId": "
    generatedModelClass_87ab39a5-c1a1-44af-92f1-41371a7c1442",
    "calendarId": ...
    }
    ]
    }
    }
    Note: To disable this validation please set the "validateResponse" config to false

I know that there are uppercases in the response but it is same for the delete and update responses but those ones are not getting any errors from validate response. I dont get the error message from validate response.


Post by Animal »

This example uses CrudManager: https://bryntum.com/products/calendar/examples/load-on-demand/

It mocks the end point, but you can look at the object that it sends back. In this case, I added "New Event!", and stopped where its sending the response back.

Screenshot 2023-12-06 at 16.06.41.png
Screenshot 2023-12-06 at 16.06.41.png (967.32 KiB) Viewed 523 times

Post Reply