From 36edce38f6b17f73322fa38404d6e01818a44fd2 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Thu, 11 Dec 2014 19:08:16 +0000
Subject: [PATCH] #2140 fix - Added renew period to pack, change on DB schema, fixed pack selection in listing, upgrade angular to 1.3.6 and other minor issues

---
 securis/src/main/webapp/js/licenses.js |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/securis/src/main/webapp/js/licenses.js b/securis/src/main/webapp/js/licenses.js
index b27e52f..62bcb36 100644
--- a/securis/src/main/webapp/js/licenses.js
+++ b/securis/src/main/webapp/js/licenses.js
@@ -40,8 +40,8 @@
 
 		var packResource = $resource('pack/:packId/:action', 
 				{
-			packId : '@id',
-			action : '@action'
+					packId : '@id',
+					action : '@action'
 				},
 				{
 					activate: {
@@ -103,7 +103,9 @@
 			}
 		}
 		this.getPacksList = function(_onsuccess, _onerror) {
-			return packResource.query(_onsuccess, _onerror);
+			var query = packResource.query();
+			query.$promise.then(_onsuccess, _onerror);
+			return query;
 		}
 		this.activate = function(pack, _onsuccess, _onerror) {
 			console.log('Activation on pack: ' + pack.id);
@@ -266,7 +268,9 @@
 		}
 
 		this.getLicensesList = function(pack, _onsuccess, _onerror) {
-			return licenseResource.query({packId: pack.id}, _onsuccess, _onerror);
+			var query = licenseResource.query({packId: pack.id});
+			query.$promise.then(_onsuccess, _onerror);
+			return query;
 		}
 		this.activate = function(license, _onsuccess, _onerror) {
 			console.log('Activation on license: ' + license.id);
@@ -390,9 +394,12 @@
 	                                    		   return txt.substring(0, len) + '...';
 	                                    	   }
 	                                    	   $scope.currentPack = $store.get('currentPack');
-	                                    	   setTimeout(function() {
-	                                    		   $scope.$broadcast('pack_changed', $scope.currentPack);
-	                                    	   }, 0);
+	                                    	   if ($scope.currentPack) {
+	                                    		   $scope.currentPack._selected = true;
+		                                    	   setTimeout(function() {
+		                                    		   $scope.$broadcast('pack_changed', $scope.currentPack);
+		                                    	   }, 0);
+	                                    	   }
 
 	                                       }]);
 
@@ -445,6 +452,7 @@
 	                            	 $scope.pack = null;
 
 	                            	 $scope.packs = Packs.getPacksList(function(list) {
+	                            		 console.log('The packs were got: ' + list);
 	                            		 angular.forEach(list, function(elem) {
 	                            			 elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
 	                            			 elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
@@ -543,7 +551,8 @@
 	                            				 status: 'CR',
 	                            				 num_licenses: 1,
 	                            				 init_valid_date: new Date(),
-	                            				 default_valid_period: 30,
+	                            				 preactivation_valid_period: 7,
+	                            				 renew_valid_period: 30,
 	                            				 license_type_id: null,
 	                            				 organization_id: null  // !$scope.refs.organization_id
 	                            				 // ||
@@ -603,9 +612,12 @@
 	                            	 }
 
 	                            	 $scope.selectPack = function(pack) {
-	                            		 $scope.$parent.currentPack = pack;
-	                            		 $store.put('currentPack', pack);
-	                            		 $scope.$parent.$broadcast('pack_changed', pack);
+	                            		 if ($scope.$parent.currentPack) {
+	                            			 $scope.$parent.currentPack._selected = false;
+	                            		 }
+                            			 $scope.$parent.currentPack = pack._selected ? pack : null;
+	                            		 $store.put('currentPack', $scope.$parent.currentPack);
+	                            		 $scope.$parent.$broadcast('pack_changed', $scope.$parent.currentPack);
 	                            	 }
 
 	                            	 $scope.getLabelFromId = function(field, myid) {

--
Gitblit v1.3.2