Thanks for providing this useful tool. I have been trying to use it in the past few days and I encounter a specific issue.
Original db.json state:
"widgets": [
{
"dashboardId": 1,
"id": "WidgetA001",
"permissions": {
"canCollapse": true,
"canHide": true
},
"config": {
"isHidden": false,
"isCollapsed": true
}
}
]
Then call the following:
onSave(widget) {
let foundIndex = this.state.data.findIndex(function (item) {
return item.id === widget.id;
});
let modifiedWidget = this.state.data[foundIndex];
modifiedWidget.config.isCollapsed = false;
console.log('modify config collapse after', modifiedWidget)
$.ajax({
url: 'http://localhost:3000/widgets/' + widget.id,
dataType: 'json',
cache: false,
method: 'PUT',
data: modifiedWidget,
success: function(data) {
console.log('data loaded in succes update onSave', data)
}.bind(this),
error: function(xhr, status, err) {
console.error('loading in parent', status, err.toString());
}.bind(this)
});
}
Expected db.json state:
"widgets": [
{
"dashboardId": 1,
"id": "WidgetA001",
"permissions": {
"canCollapse": true,
"canHide": true
},
"config": {
"isHidden": false,
"isCollapsed": false //<--
}
}
]
Actual db.json state:
"widgets": [
{
"dashboardId": 1,
"id": "WidgetA001",
"permissions": {
"canCollapse": true,
"canHide": true
},
"config": {
"isHidden": false,
"isCollapsed": true //<--
},
"permissions[canCollapse]": true,
"permissions[canHide]": true,
"config[isHidden]": false,
"config[isCollapsed]": false
}
]
So instead of properly updating it in a nested object, I get a flattened object. Did I do something wrong? Any help would be greatly appreciated. Up until it hits thedb.json file it preserves the correct format (in the console.log)
Thanks for providing this useful tool. I have been trying to use it in the past few days and I encounter a specific issue.
Original db.json state:
Then call the following:
Expected db.json state:
Actual db.json state:
So instead of properly updating it in a nested object, I get a flattened object. Did I do something wrong? Any help would be greatly appreciated. Up until it hits the
db.jsonfile it preserves the correct format (in theconsole.log)