rsanchez
2014-12-12 4c13c7324a920f5cca9601154e5224e5d7484fa9
securis/src/main/webapp/js/admin.js
....@@ -69,10 +69,7 @@
6969
7070 $scope.selectCatalog = _changeCatalog;
7171
72
- $scope.edit = function(data) {
73
- $scope.showForm = true;
74
- $scope.isNew = false;
75
- // Next line is a workaround due to some issues with values with ID == 0
72
+ $scope._loadFormu = function(elementData) {
7673 $('select').val(null);
7774 $scope.formu = {}
7875 var fields = Catalogs.getMetadata().fields;
....@@ -83,13 +80,23 @@
8380 // next lines are a workaround to avoid an issue where we try to show a form with "select" fields (if select field value doesn't change
8481 $scope.formu[field.name] = null;
8582 setTimeout(function() {
86
- $scope.formu[field.name] = data[field.name];
83
+ $scope.formu[field.name] = elementData[field.name];
8784 $scope.$apply();
8885 }, 0);
8986 } else {
90
- if (!field.listingOnly) $scope.formu[field.name] = data[field.name] || null;
87
+ if (!field.listingOnly) $scope.formu[field.name] = elementData[field.name] || null;
9188 }
9289 })
90
+ }
91
+
92
+ $scope.edit = function(data) {
93
+ $scope.showForm = true;
94
+ $scope.isNew = false;
95
+ $scope._loadFormu(data);
96
+ Catalogs.get(data[Catalogs.getPk()], function(eleData) {
97
+ $scope._loadFormu(eleData);
98
+ });
99
+ // Next line is a workaround due to some issues with values with ID == 0
93100 setTimeout(function() {
94101 $('#'+Catalogs.getFFF()).focus();
95102 }, 0);