upate for editing with fields that need not be saved when empty.

This commit is contained in:
Admin
2017-03-16 14:57:21 -05:00
parent fb24e9d1a3
commit c13b9bd8f4
2 changed files with 23 additions and 6 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId> <groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId> <artifactId>ha-bridge</artifactId>
<version>4.2.1b</version> <version>4.2.1c</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>

View File

@@ -147,7 +147,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
this.clearDevice = function () { this.clearDevice = function () {
self.state.device = {}; self.state.device = {};
self.state.olddevicename = ""; self.state.olddevicename = null;
}; };
this.getHABridgeVersion = function () { this.getHABridgeVersion = function () {
@@ -525,6 +525,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
type = self.getMapType(s.type[0]) type = self.getMapType(s.type[0])
s.type = type[0] s.type = type[0]
} }
if(s.delay === "" || s.delay === null)
delete s.delay;
if(s.count === "" || s.count === null)
delete s.count;
if(s.filterIPs === "" || s.filterIPs === null)
delete s.filterIPs;
if(s.httpVerb === "" || s.httpVerb === null)
delete s.httpVerb;
if(s.httpBody === "" || s.httpBody === null)
delete s.httpBody;
if(s.httpHeaders === "" || s.httpHeaders === null)
delete s.httpHeaders;
if(s.contentType === "" || s.contentType === null)
delete s.contentType;
} }
} }
return theDevices return theDevices
@@ -2462,18 +2476,21 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if (copy) { if (copy) {
$scope.device.id = null; $scope.device.id = null;
$scope.device.uniqueid = null; $scope.device.uniqueid = null;
$scope.device.mapId = $scope.device.mapId + "-copy"; if($scope.bridge.olddevicename !== null && $scope.bridge.olddevicename !== "")
$scope.device.mapId = $scope.device.mapId + "-copy";
} }
if($scope.mapTypeSelected !== undefined && $scope.mapTypeSelected !== null) if($scope.mapTypeSelected !== undefined && $scope.mapTypeSelected !== null)
$scope.device.mapType = $scope.mapTypeSelected[0]; $scope.device.mapType = $scope.mapTypeSelected[0];
else else
$scope.device.mapType = null; $scope.device.mapType = null;
if ($scope.onDevices !== null) if ($scope.onDevices !== null)
$scope.device.onUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.onDevices)); $scope.device.onUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.onDevices));
if ($scope.dimDevices !== null) if ($scope.dimDevices !== null)
$scope.device.dimUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.dimDevices)); $scope.device.dimUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.dimDevices));
if ($scope.offDevices !== null) if ($scope.offDevices !== null)
$scope.device.offUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.offDevices)); $scope.device.offUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.offDevices));
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
$scope.clearDevice(); $scope.clearDevice();
@@ -2493,7 +2510,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if ($scope.onDevices === null) if ($scope.onDevices === null)
$scope.onDevices = []; $scope.onDevices = [];
$scope.onDevices.push(newitem); $scope.onDevices.push(newitem);
$scope.newOnItem = []; $scope.newOnItem = {};
}; };
$scope.removeItemOn = function (anItem) { $scope.removeItemOn = function (anItem) {
for(var i = $scope.onDevices.length - 1; i >= 0; i--) { for(var i = $scope.onDevices.length - 1; i >= 0; i--) {
@@ -2510,7 +2527,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if ($scope.dimDevices === null) if ($scope.dimDevices === null)
$scope.dimDevices = []; $scope.dimDevices = [];
$scope.dimDevices.push(newitem); $scope.dimDevices.push(newitem);
$scope.newDimItem = []; $scope.newDimItem = {};
}; };
$scope.removeItemDim = function (anItem) { $scope.removeItemDim = function (anItem) {
for(var i = $scope.dimDevices.length - 1; i >= 0; i--) { for(var i = $scope.dimDevices.length - 1; i >= 0; i--) {
@@ -2527,7 +2544,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if ($scope.offDevices === null) if ($scope.offDevices === null)
$scope.offDevices = []; $scope.offDevices = [];
$scope.offDevices.push(newitem); $scope.offDevices.push(newitem);
$scope.newOffItem = []; $scope.newOffItem = {};
}; };
$scope.removeItemOff = function (anItem) { $scope.removeItemOff = function (anItem) {
for(var i = $scope.offDevices.length - 1; i >= 0; i--) { for(var i = $scope.offDevices.length - 1; i >= 0; i--) {