treat empty string as null

pull/2687/head
Mihail Maxacov 10 years ago
parent 270c0b29c0
commit 7bb234de84
  1. 28
      frontend/app/ui_components/inplace-editor-dispatcher.js

@ -126,7 +126,11 @@ module.exports = function($sce, $http, $timeout, AutoCompleteHelper, TextileServ
var hooks = {
_fallback: {
submit: function($scope, data) {
data[getAttribute($scope)] = $scope.dataObject.value;
var value = $scope.dataObject.value;
if ($scope.dataObject.value === '') {
value = null;
}
data[getAttribute($scope)] = value;
},
setWriteValue: function($scope) {
$scope.dataObject = {
@ -135,25 +139,9 @@ module.exports = function($sce, $http, $timeout, AutoCompleteHelper, TextileServ
},
setReadValue: function($scope) {
$scope.readValue = getReadAttributeValue($scope);
}
},
integer: {
submit: function($scope, data) {
var value = $scope.dataObject.value;
if ($scope.dataObject.value === '') {
value = null;
}
data[getAttribute($scope)] = value;
}
},
float: {
submit: function($scope, data) {
var value = $scope.dataObject.value;
if ($scope.dataObject.value === '') {
value = null;
if ($scope.readValue === '') {
$scope.readValue = null;
}
data[getAttribute($scope)] = value;
}
},
text: {
@ -279,7 +267,7 @@ module.exports = function($sce, $http, $timeout, AutoCompleteHelper, TextileServ
this._getReadAttributeValue = getReadAttributeValue;
this.dispatchHook = function($scope, action, data) {
var actionFunction = hooks[$scope.type][action] || hooks._fallback[action] || angular.noop;
var actionFunction = hooks[$scope.type] ? (hooks[$scope.type][action] || hooks._fallback[action] || angular.noop) : hooks._fallback[action] || angular.noop;
return actionFunction.call(this, $scope, data);
};
};

Loading…
Cancel
Save