| .. | .. |
|---|
| 40 | 40 | |
|---|
| 41 | 41 | var packResource = $resource('pack/:packId/:action', |
|---|
| 42 | 42 | { |
|---|
| 43 | | - packId : '@id', |
|---|
| 44 | | - action : '@action' |
|---|
| 43 | + packId : '@id', |
|---|
| 44 | + action : '@action' |
|---|
| 45 | 45 | }, |
|---|
| 46 | 46 | { |
|---|
| 47 | 47 | activate: { |
|---|
| .. | .. |
|---|
| 103 | 103 | } |
|---|
| 104 | 104 | } |
|---|
| 105 | 105 | 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; |
|---|
| 107 | 109 | } |
|---|
| 108 | 110 | this.activate = function(pack, _onsuccess, _onerror) { |
|---|
| 109 | 111 | console.log('Activation on pack: ' + pack.id); |
|---|
| .. | .. |
|---|
| 266 | 268 | } |
|---|
| 267 | 269 | |
|---|
| 268 | 270 | 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; |
|---|
| 270 | 274 | } |
|---|
| 271 | 275 | this.activate = function(license, _onsuccess, _onerror) { |
|---|
| 272 | 276 | console.log('Activation on license: ' + license.id); |
|---|
| .. | .. |
|---|
| 390 | 394 | return txt.substring(0, len) + '...'; |
|---|
| 391 | 395 | } |
|---|
| 392 | 396 | $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 | + } |
|---|
| 396 | 403 | |
|---|
| 397 | 404 | }]); |
|---|
| 398 | 405 | |
|---|
| .. | .. |
|---|
| 445 | 452 | $scope.pack = null; |
|---|
| 446 | 453 | |
|---|
| 447 | 454 | $scope.packs = Packs.getPacksList(function(list) { |
|---|
| 455 | + console.log('The packs were got: ' + list); |
|---|
| 448 | 456 | angular.forEach(list, function(elem) { |
|---|
| 449 | 457 | elem.organization_code = $scope.getOrganizationCode(elem.organization_id); |
|---|
| 450 | 458 | elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id); |
|---|
| .. | .. |
|---|
| 543 | 551 | status: 'CR', |
|---|
| 544 | 552 | num_licenses: 1, |
|---|
| 545 | 553 | init_valid_date: new Date(), |
|---|
| 546 | | - default_valid_period: 30, |
|---|
| 554 | + preactivation_valid_period: 7, |
|---|
| 555 | + renew_valid_period: 30, |
|---|
| 547 | 556 | license_type_id: null, |
|---|
| 548 | 557 | organization_id: null // !$scope.refs.organization_id |
|---|
| 549 | 558 | // || |
|---|
| .. | .. |
|---|
| 603 | 612 | } |
|---|
| 604 | 613 | |
|---|
| 605 | 614 | $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); |
|---|
| 609 | 621 | } |
|---|
| 610 | 622 | |
|---|
| 611 | 623 | $scope.getLabelFromId = function(field, myid) { |
|---|