rsanchez
2014-12-11 36edce38f6b17f73322fa38404d6e01818a44fd2
securis/src/main/webapp/js/licenses.js
....@@ -40,8 +40,8 @@
4040
4141 var packResource = $resource('pack/:packId/:action',
4242 {
43
- packId : '@id',
44
- action : '@action'
43
+ packId : '@id',
44
+ action : '@action'
4545 },
4646 {
4747 activate: {
....@@ -103,7 +103,9 @@
103103 }
104104 }
105105 this.getPacksList = function(_onsuccess, _onerror) {
106
- return packResource.query(_onsuccess, _onerror);
106
+ var query = packResource.query();
107
+ query.$promise.then(_onsuccess, _onerror);
108
+ return query;
107109 }
108110 this.activate = function(pack, _onsuccess, _onerror) {
109111 console.log('Activation on pack: ' + pack.id);
....@@ -266,7 +268,9 @@
266268 }
267269
268270 this.getLicensesList = function(pack, _onsuccess, _onerror) {
269
- return licenseResource.query({packId: pack.id}, _onsuccess, _onerror);
271
+ var query = licenseResource.query({packId: pack.id});
272
+ query.$promise.then(_onsuccess, _onerror);
273
+ return query;
270274 }
271275 this.activate = function(license, _onsuccess, _onerror) {
272276 console.log('Activation on license: ' + license.id);
....@@ -390,9 +394,12 @@
390394 return txt.substring(0, len) + '...';
391395 }
392396 $scope.currentPack = $store.get('currentPack');
393
- setTimeout(function() {
394
- $scope.$broadcast('pack_changed', $scope.currentPack);
395
- }, 0);
397
+ if ($scope.currentPack) {
398
+ $scope.currentPack._selected = true;
399
+ setTimeout(function() {
400
+ $scope.$broadcast('pack_changed', $scope.currentPack);
401
+ }, 0);
402
+ }
396403
397404 }]);
398405
....@@ -445,6 +452,7 @@
445452 $scope.pack = null;
446453
447454 $scope.packs = Packs.getPacksList(function(list) {
455
+ console.log('The packs were got: ' + list);
448456 angular.forEach(list, function(elem) {
449457 elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
450458 elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
....@@ -543,7 +551,8 @@
543551 status: 'CR',
544552 num_licenses: 1,
545553 init_valid_date: new Date(),
546
- default_valid_period: 30,
554
+ preactivation_valid_period: 7,
555
+ renew_valid_period: 30,
547556 license_type_id: null,
548557 organization_id: null // !$scope.refs.organization_id
549558 // ||
....@@ -603,9 +612,12 @@
603612 }
604613
605614 $scope.selectPack = function(pack) {
606
- $scope.$parent.currentPack = pack;
607
- $store.put('currentPack', pack);
608
- $scope.$parent.$broadcast('pack_changed', pack);
615
+ if ($scope.$parent.currentPack) {
616
+ $scope.$parent.currentPack._selected = false;
617
+ }
618
+ $scope.$parent.currentPack = pack._selected ? pack : null;
619
+ $store.put('currentPack', $scope.$parent.currentPack);
620
+ $scope.$parent.$broadcast('pack_changed', $scope.$parent.currentPack);
609621 }
610622
611623 $scope.getLabelFromId = function(field, myid) {