diff --git a/src/app/views/customers/create-step-1/create-step-1.controller.coffee b/src/app/views/customers/create-step-1/create-step-1.controller.coffee index 4364d6dd..8fdc4b88 100644 --- a/src/app/views/customers/create-step-1/create-step-1.controller.coffee +++ b/src/app/views/customers/create-step-1/create-step-1.controller.coffee @@ -1,9 +1,13 @@ -@App.controller 'CreateStep1Controller', ($scope, $document, $state, toastr, MnoeAdminConfig, MnoeOrganizations, MnoeMarketplace, MnoErrorsHandler) -> +@App.controller 'CreateStep1Controller', ($scope, $document, $state, toastr, MnoeAdminConfig, MnoeOrganizations, MnoeMarketplace, MnoErrorsHandler, MnoeCurrentUser, MnoeSubTenants) -> 'ngInject' vm = this vm.organization = {} vm.appSearch = "" + vm.subTenantLoading = true + vm.isAdmin = false + vm.selectedSubTenants = {} + vm.sub_tenants = [] vm.toggleApp = (app) -> app.checked = !app.checked @@ -26,6 +30,8 @@ # List of checked apps vm.organization.app_nids = _.map(_.filter(vm.marketplace.apps, {checked: true}), 'nid') if MnoeAdminConfig.isAppManagementEnabled() + vm.organization.sub_tenant_ids = Object.keys vm.selectedSubTenants + MnoeOrganizations.create(vm.organization).then( (response) -> toastr.success('mnoe_admin_panel.dashboard.customers.create_customer.toastr_success', {extraData: {organization_name: vm.organization.name}}) @@ -49,4 +55,21 @@ vm.marketplace = angular.copy(response.data) ) if MnoeAdminConfig.isAppManagementEnabled() + loadSubTenants = -> + MnoeSubTenants.list(null, null, 'name.desc').then( + (response) -> + vm.sub_tenants = response.data + ).finally(-> vm.subTenantLoading = false) + + MnoeCurrentUser.getUser().then( + # Display the layout + vm.user = MnoeCurrentUser.user + vm.isAdmin = vm.user.admin_role == 'admin' + if vm.isAdmin + loadSubTenants() + else + vm.selectedSubTenants[vm.user.mnoe_sub_tenant_id] = true + vm.subTenantLoading = false + ) + return diff --git a/src/app/views/customers/create-step-1/create-step-1.html b/src/app/views/customers/create-step-1/create-step-1.html index 212762b2..f2a439c3 100644 --- a/src/app/views/customers/create-step-1/create-step-1.html +++ b/src/app/views/customers/create-step-1/create-step-1.html @@ -41,7 +41,37 @@

mnoe_admin_panel.dashboard.customers.create_customer.create_custom -