diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js index 8360a6ec..1d2909dd 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js @@ -2,6 +2,8 @@ { $scope.globals = globals; + $scope.descricao = null; + $scope.calculatedAge = 0; $scope.storeFichasClinicas = new globals.dataService.store({ @@ -91,25 +93,16 @@ { $scope.storeFichasClinicas.upsert($scope.selected, $scope.editing, function(response, selected, editing, isNewRecord){ - //TODO: id's de cada ficha - injectar no modelo em edição - - - //if(isNewRecord) - //{ - // //$scope.isNewRecord = isNewRecord; - //} - - //$scope.editing.ficha.id = editing.ficha.id; - - //if(response.success) - //{ - // $scope.edit($scope.selected); - //} + //TODO: check the need for other keys!!! + if(response.data) + { + $scope.editing.ficha.id = response.data.ficha.id; + } }); } }; - $scope.gridAddItem = function(item, array, arrayName){ + $scope.gridAddItem = function(item, array, arrayName, el){ if(!angular.isArray(array)) { @@ -118,12 +111,56 @@ } array.push(item); + + $timeout(function () { + + if(el != undefined) + { + var table = $(el.target).closest('table'); + if(table.length > 0) + { + var inputs = $(table[0]).find('input[data-required="true"]'); + + $.each(inputs, function(index, el) { + + var input = $(el); + + //activate field validation + $scope.editForm.$removeConstraints(input, false); + }); + } + } + }); }; - $scope.gridRemoveItem = function(index, array){ + $scope.gridRemoveItem = function(index, array, el){ if(angular.isArray(array)) { + if(el != undefined) + { + var table = $(el.target).closest('table'); + if(table.length > 0) + { + var trs = $(table[0]).find('tr[class="ng-scope"]'); + + if(trs.length > 0 && trs[index] != undefined) + { + var tr = $(trs[index]); + + var inputs = tr.find('input[data-required="true"]'); + + $.each(inputs, function(index, el) { + + var input = $(el); + + //disable field validation + $scope.editForm.$removeConstraints(input, true); + }); + } + } + } + array.splice(index, 1); } }; diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html index 78ba418f..6390b7b9 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html @@ -12,7 +12,7 @@