Skip to content

Commit

Permalink
Fixes #10569: Adding a json node property by UI make it a string
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Apr 13, 2017
1 parent 220b179 commit c914240
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,24 @@ app.controller('nodePropertiesCtrl', function ($scope, $http, $compile) {
function checkNameUnicity(property, index, array) {
return property.name == $scope.newProperty.name;
}
var propertyToSave = angular.copy($scope.newProperty)
var newValue = propertyToSave.value
try {
newValue = JSON.parse(propertyToSave.value)
} catch(e) {
// Do nothing if error we keep the current value
}
propertyToSave.value = newValue
var data = {
"properties": [ $scope.newProperty ]
"properties": [ propertyToSave ]
, 'reason' : "Add property '"+$scope.newProperty.name+"' to Node '"+currentNodeId+"'"
};
$http.post($scope.urlAPI, data).then(function successCallback(response) {
$scope.errorSaving = false;
//Check if new property's name is already used or not.
$scope.alreadyUsed = $scope.properties.some(checkNameUnicity);
if(!$scope.alreadyUsed){
$scope.properties.push(angular.copy($scope.newProperty));
$scope.properties.push(propertyToSave);
$scope.resetNewProperty();
$('#newPropPopup').bsModal('hide');
$scope.newPropForm.$setPristine();
Expand Down Expand Up @@ -186,4 +194,4 @@ app.config(function($locationProvider) {
enabled: true,
requireBase: false
});
})
})

0 comments on commit c914240

Please sign in to comment.