Hi,
I am trying to write an NG component and have a question regarding pushing values to the server.
In my .spec file I have the following property definition:
{
"name": "ewscomponents-testcomponent",
"displayName": "EWS Test",
"version": 1,
"definition": "ewscomponents/testcomponent/testcomponent.js",
"libraries": [ ],
"model":
{
"settings":
{
"type": "settingsObject",
"pushToServer": "shallow",
"tags": {
"doc": "The settings for this element"
},
"default": { }
},
"visible": "visible"
},
"types":
{
"settingsObject":
{
"options":
{
"type": "optionsObject",
"tags": {
"doc": "The options for the component"
},
"default": { }
}
},
"optionsObject":
{
"sizes":
{
"type": "float[]",
"tags": {
"doc": "The relative size of each of the options. Specified as an array of numbers"
},
},
"default": { }
}
}
}
In the .js file I have a watch on the property using:
// Watch the sizes
$scope.$watch('model.settings.options.sizes', function(newValue, oldValue) {
if ($scope.optionsContainer) $scope.optionsContainer.setSizes(newValue);
}, true);
Also in the .js file I have a callback from my client component that is triggered when they end a drag on one of the options:
onDragEnd: function() {
if ($scope.split) {
$scope.model.settings.options.sizes.length = 0;
$scope.$apply();
$scope.optionsContainer.getSizes().forEach(function(element, index) {
$scope.model.settings.options.sizes.push(element);
});
$scope.$apply();
}
}
My issue is that the array of sizes can be changed on the client and I want these changes pushed back to the server. The problem I am getting is that this all works fine as log as the sizes array is empty when the component is initialised but if it already contains values then when the client tries to update the array I get errors on the server:
ERROR org.sablo.specification.property.CustomJSONPropertyType - Cannot correctly parse custom array property updates/values from browser. Update JSON: {"vEr":2,"u":[{"i":"0"}]} org.json.JSONException: JSONObject["v"] not found.
Can anyone see what I am doing wrong?
Thanks
Steve