# HG changeset patch # User ymh # Date 1379235662 -7200 # Node ID 1753fcef095ad52afc676509f0e6be698a439ae3 # Parent 9f456eb416022cdc432b95e44a1d1bca081ce7fa Improve object list behaviour in edit form diff -r 9f456eb41602 -r 1753fcef095a src/p4l/static/p4l/css/p4l.css --- a/src/p4l/static/p4l/css/p4l.css Fri Sep 13 18:33:41 2013 +0200 +++ b/src/p4l/static/p4l/css/p4l.css Sun Sep 15 11:01:02 2013 +0200 @@ -31,6 +31,10 @@ .after-plus { margin-top: 5px; } +.after-plus button { + margin-right: 5px; +} + .rotate{ transform:rotate(90deg); -ms-transform:rotate(90deg); diff -r 9f456eb41602 -r 1753fcef095a src/p4l/static/p4l/js/p4l.js --- a/src/p4l/static/p4l/js/p4l.js Fri Sep 13 18:33:41 2013 +0200 +++ b/src/p4l/static/p4l/js/p4l.js Sun Sep 15 11:01:02 2013 +0200 @@ -72,20 +72,6 @@ table: "@table" }, controller: function($scope, $element, $attrs, $transclude) { - // Setup divs table parameters - $scope.headFields = angular.fromJson($scope.objectFields); - $scope.headLabels = angular.fromJson($scope.labelFields); - $scope.headSizes = angular.fromJson($scope.sizeFields); - if($scope.headSizes==undefined){ - $scope.headSizes = []; - var n = $scope.headFields.length; - for(var i=0;i=0) { + newObj = angular.copy(obj); + } + $scope.editedObj = newObj; + $scope.editedIndex = index; } $scope.newEditedObject = function() { var newObj = $scope.getEmptyObject(); - $scope.list.push(newObj); - $scope.setEditedObject(newObj); + $scope.setEditedObject(newObj, -1); }; - $scope.removeFromList = function(obj) { - var i = $scope.list.indexOf(obj); - if(i>=0){ - $scope.list.splice(i, 1); + $scope.removeFromList = function(index) { + if(index>=0){ + $scope.list.splice(index, 1); } - $scope.setEditedObject(null); + $scope.setEditedObject(null, -1); } $scope.onOk = function() { - $scope.setEditedObject(null); + + if($scope.editedIndex >= 0) { + $scope.list[$scope.editedIndex] = $scope.editedObj; + } + else { + $scope.list.push($scope.editedObj); + } + + $scope.setEditedObject(null, -1); + } + $scope.onCancel = function() { + $scope.setEditedObject(null, -1); + } } }; }); diff -r 9f456eb41602 -r 1753fcef095a src/p4l/static/p4l/templates/objectList.html --- a/src/p4l/static/p4l/templates/objectList.html Fri Sep 13 18:33:41 2013 +0200 +++ b/src/p4l/static/p4l/templates/objectList.html Sun Sep 15 11:01:02 2013 +0200 @@ -3,13 +3,13 @@
  • - - + +
  • - +
    \ No newline at end of file diff -r 9f456eb41602 -r 1753fcef095a src/p4l/static/p4l/templates/objectListTable.html --- a/src/p4l/static/p4l/templates/objectListTable.html Fri Sep 13 18:33:41 2013 +0200 +++ b/src/p4l/static/p4l/templates/objectListTable.html Sun Sep 15 11:01:02 2013 +0200 @@ -9,14 +9,14 @@
    - - + +
    - +
    \ No newline at end of file