rsanchez
2014-12-12 fb1bbf788b8c2ec2cc292c66c851c7f0b9b19357
securis/src/main/webapp/js/licenses.js
....@@ -434,10 +434,7 @@
434434 var refFields = [{resource: 'organization', name: 'organization_id'},{resource: 'licensetype', name: 'license_type_id'}];
435435 Catalogs.loadRefs(function(refs) {
436436 $scope.refs = refs;
437
- angular.forEach($scope.packs, function(elem) {
438
- elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
439
- elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
440
- });
437
+ $scope._extendPackListing($scope.packs);
441438 }, refFields);
442439 });
443440
....@@ -452,13 +449,19 @@
452449 $scope.pack = null;
453450
454451 $scope.packs = Packs.getPacksList(function(list) {
455
- console.log('The packs were got: ' + list);
456
- angular.forEach(list, function(elem) {
452
+ $scope._extendPackListing(list);
453
+ });
454
+
455
+ /**
456
+ * Added calculated fields like org_code and lic_type_code to pack listing
457
+ */
458
+ $scope._extendPackListing = function(listing) {
459
+ angular.forEach(listing, function(elem) {
457460 elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
458461 elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
459462 });
460
- });
461
-
463
+ }
464
+
462465 $scope.save = function() {
463466 Packs.savePackData($scope.pack, $scope.isNew, function() {
464467 if (!$scope.isNew) {
....@@ -466,7 +469,9 @@
466469 } else {
467470 $scope.newPack();
468471 }
469
- $scope.packs = Packs.getPacksList();
472
+ $scope.packs = Packs.getPacksList(function(list) {
473
+ $scope._extendPackListing(list);
474
+ });
470475 });
471476 }
472477
....@@ -479,12 +484,16 @@
479484 if (extra_data) {
480485 Packs[action](pack || $scope.pack, extra_data, function() {
481486 if (!$scope.isNew) $scope.showForm = false;
482
- $scope.packs = Packs.getPacksList();
487
+ $scope.packs = Packs.getPacksList(function(list) {
488
+ $scope._extendPackListing(list);
489
+ });
483490 });
484491 } else {
485492 Packs[action](pack || $scope.pack, function() {
486493 if (!$scope.isNew) $scope.showForm = false;
487
- $scope.packs = Packs.getPacksList();
494
+ $scope.packs = Packs.getPacksList(function(list) {
495
+ $scope._extendPackListing(list);
496
+ });
488497 });
489498 }
490499 }