contracts, index, rootGBPcontroller
[groupbasedpolicy.git] / groupbasedpolicy-ui / module / src / main / resources / gbp / contract / contract.controller.js
index 2f77133d06272d265efb92178e246e90d5016338..d19c9156daced470f98afb9b1fb90d96643045d2 100644 (file)
@@ -6,20 +6,36 @@ define([
 
     angular.module('app.gbp').controller('ContractController', ContractController);
 
-    ContractController.$inject = ['$scope', 'TenantService', 'ContractService', 'ContractListService'];
+    ContractController.$inject = ['$scope', 'TenantListService', 'TenantService', 'ContractService', 'ContractListService', '$stateParams'];
 
-    function ContractController($scope, TenantService, ContractService, ContractListService) {
-        $scope.tenant = TenantService.createObject();
-        $scope.tenant.get('tenant1');
-        console.log('tenant from CONTRACT CTRL:', $scope.tenant);
+    function ContractController($scope, TenantListService, TenantService, ContractService, ContractListService, $stateParams) {
+        $scope.contracts = ContractListService.createList();
+        $scope.contractsTableQuery = {
+            order: 'data.id',
+            limit: 25,
+            page: 1,
+            options: [25, 50, 100],
+            filter: '',
+        };
 
-        $scope.contract = ContractService.createObject();
-        $scope.contract.get('contract1');
-        console.log('contract from CONTRACT CTRL', $scope.contract);
+        getContracts();
+
+        /* if ($stateParams.contractId) {
+            $scope.contractId = $stateParams.contractId;
+            console.log('contract.ctrl.if.$scope.contractId', $scope.contractId);
+            $scope.contract.get($scope.contractId);
+        }
+        else {
+            console.log('contract.ctrl.else.$scope.contractId', $scope.contractId);
+            $scope.contract.get($scope.$parent.tenantId);
+        }*/
+
+        function getContracts() {
+            $scope.contracts.data = [];
+            $scope.contracts.get($scope.rootTenant.data.id);
+        }
 
-        $scope.contracts = ContractListService.createList();
-        $scope.contracts.get('config');
-        console.log('contracts from CONTRACT CTRL', $scope.contracts);
 
+        $scope.$on('ROOT_TENANT_CHANGED', getContracts);
     }
 });