Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. angular.module('cbuControllers').controller 'AccountViewCtrl',
  2. [
  3. '$scope'
  4. '$state'
  5. '$stateParams'
  6. '$i18next'
  7. 'AccountService'
  8. 'cbServices'
  9. ($scope, $state, $stateParams, $i18n, accountService, services) ->
  10.  
  11. Auth = services.get 'Auth'
  12. $scope.title = $i18n 'account.list_accounts'
  13. $scope.account = {}
  14. $scope.isInvoiceEdit = false
  15. $scope.subscription = null;
  16. $scope.invoices = null;
  17. $scope.billingData = null
  18. $scope.billingDataBackup = null
  19.  
  20.  
  21. # Check if we have the appropriate mask to edit.
  22. if Auth.authorize 'account', Auth.masks.EDIT
  23. $scope.editAccount = () ->
  24. $state.go 'root.account.edit.general',
  25. us_hash: $scope.account.hash
  26. else
  27. $scope.editAccount = false
  28.  
  29. accountService.ensureLoaded () ->
  30. _.assign $scope.account, accountService.getByHash($stateParams.us_hash)
  31. $scope.title = $scope.account.name
  32. $scope.subscription = null;
  33. accountService.getBillingInfo($scope.account).then (billingInfo) =>
  34. if billingInfo
  35. $scope.billingData = billingInfo
  36. accountService.getSubscription($scope.account).then (sub) =>
  37. $scope.subscription = sub;
  38.  
  39. accountService.getInvoices($scope.account)
  40. .then (invoices) =>
  41. $scope.invoices = invoices.plain()
  42. .catch (error) =>
  43. $scope.invoices = []
  44.  
  45. $scope.editInvoiceDetails = () ->
  46. console.log 'trigger edit'
  47. $scope.billingDataBackup = angular.copy $scope.billingData;
  48. $scope.isInvoiceEdit = true
  49.  
  50. $scope.saveInvoiceDetails = (billingData) ->
  51. accountService.setBillingInfo($scope.account, billingData);
  52. $scope.isInvoiceEdit = false
  53.  
  54. $scope.cancelInvoiceDetailsEdit = () ->
  55. $scope.billingData = angular.copy $scope.billingDataBackup;
  56. $scope.billingDataBackup = null;
  57. $scope.isInvoiceEdit = false
  58. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement