Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('cbuControllers').controller 'AccountViewCtrl',
- [
- '$scope'
- '$state'
- '$stateParams'
- '$i18next'
- 'AccountService'
- 'cbServices'
- ($scope, $state, $stateParams, $i18n, accountService, services) ->
- Auth = services.get 'Auth'
- $scope.title = $i18n 'account.list_accounts'
- $scope.account = {}
- $scope.isInvoiceEdit = false
- $scope.subscription = null;
- $scope.invoices = null;
- $scope.billingData = null
- $scope.billingDataBackup = null
- # Check if we have the appropriate mask to edit.
- if Auth.authorize 'account', Auth.masks.EDIT
- $scope.editAccount = () ->
- $state.go 'root.account.edit.general',
- us_hash: $scope.account.hash
- else
- $scope.editAccount = false
- accountService.ensureLoaded () ->
- _.assign $scope.account, accountService.getByHash($stateParams.us_hash)
- $scope.title = $scope.account.name
- $scope.subscription = null;
- accountService.getBillingInfo($scope.account).then (billingInfo) =>
- if billingInfo
- $scope.billingData = billingInfo
- accountService.getSubscription($scope.account).then (sub) =>
- $scope.subscription = sub;
- accountService.getInvoices($scope.account)
- .then (invoices) =>
- $scope.invoices = invoices.plain()
- .catch (error) =>
- $scope.invoices = []
- $scope.editInvoiceDetails = () ->
- console.log 'trigger edit'
- $scope.billingDataBackup = angular.copy $scope.billingData;
- $scope.isInvoiceEdit = true
- $scope.saveInvoiceDetails = (billingData) ->
- accountService.setBillingInfo($scope.account, billingData);
- $scope.isInvoiceEdit = false
- $scope.cancelInvoiceDetailsEdit = () ->
- $scope.billingData = angular.copy $scope.billingDataBackup;
- $scope.billingDataBackup = null;
- $scope.isInvoiceEdit = false
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement