Code cleanup part #1: move all the services and directive JS code in the app.js file into its own files
This commit is contained in:
		
							parent
							
								
									3cae6609a7
								
							
						
					
					
						commit
						9b87999c1c
					
				
					 97 changed files with 7076 additions and 6870 deletions
				
			
		
							
								
								
									
										49
									
								
								static/js/directives/ui/billing-invoice.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								static/js/directives/ui/billing-invoice.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | |||
| /** | ||||
|  * Element for displaying the list of billing invoices for the user or organization. | ||||
|  */ | ||||
| angular.module('quay').directive('billingInvoices', function () { | ||||
|   var directiveDefinitionObject = { | ||||
|     priority: 0, | ||||
|     templateUrl: '/static/directives/billing-invoices.html', | ||||
|     replace: false, | ||||
|     transclude: false, | ||||
|     restrict: 'C', | ||||
|     scope: { | ||||
|       'organization': '=organization', | ||||
|       'user': '=user', | ||||
|       'makevisible': '=makevisible' | ||||
|     }, | ||||
|     controller: function($scope, $element, $sce, ApiService) { | ||||
|       $scope.loading = false; | ||||
|       $scope.invoiceExpanded = {}; | ||||
| 
 | ||||
|       $scope.toggleInvoice = function(id) { | ||||
|         $scope.invoiceExpanded[id] = !$scope.invoiceExpanded[id]; | ||||
|       }; | ||||
| 
 | ||||
|       var update = function() { | ||||
|         var hasValidUser = !!$scope.user; | ||||
|         var hasValidOrg = !!$scope.organization; | ||||
|         var isValid = hasValidUser || hasValidOrg; | ||||
| 
 | ||||
|         if (!$scope.makevisible || !isValid) { | ||||
|           return; | ||||
|         } | ||||
| 
 | ||||
|         $scope.loading = true; | ||||
| 
 | ||||
|         ApiService.listInvoices($scope.organization).then(function(resp) { | ||||
|           $scope.invoices = resp.invoices; | ||||
|           $scope.loading = false; | ||||
|         }); | ||||
|       }; | ||||
| 
 | ||||
|       $scope.$watch('organization', update); | ||||
|       $scope.$watch('user', update); | ||||
|       $scope.$watch('makevisible', update); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   return directiveDefinitionObject; | ||||
| }); | ||||
| 
 | ||||
		Reference in a new issue