Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNOE-857] Setup divisions when creating a new organization based on … #209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
@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.isSubTenantEnabled = MnoeAdminConfig.isSubTenantEnabled()

vm.toggleApp = (app) ->
app.checked = !app.checked
Expand All @@ -26,6 +31,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) if vm.isSubTenantEnabled

MnoeOrganizations.create(vm.organization).then(
(response) ->
toastr.success('mnoe_admin_panel.dashboard.customers.create_customer.toastr_success', {extraData: {organization_name: vm.organization.name}})
Expand All @@ -49,4 +56,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(
vm.user = MnoeCurrentUser.user
vm.isAdmin = vm.user.admin_role == 'admin'
if vm.isSubTenantEnabled
if vm.isAdmin
loadSubTenants()
else
vm.selectedSubTenants[vm.user.mnoe_sub_tenant_id] = true
vm.subTenantLoading = false
)

return
32 changes: 31 additions & 1 deletion src/app/views/customers/create-step-1/create-step-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,37 @@ <h1 translate>mnoe_admin_panel.dashboard.customers.create_customer.create_custom
</mno-widget-body>
</mno-widget>

<button type="submit" class="btn btn-danger pull-right top-buffer-2" ng-click="vm.submitOrganisation()" ng-disabled="vm.isLoading">
<mno-widget ng-if="::vm.isSubTenantEnabled && vm.isAdmin" icon="fa-institution" heading="{{'mnoe_admin_panel.dashboard.customers.create_customer.division_details' | translate}}" class="top-buffer-2" is-loading="vm.subTenantLoading">
<mno-widget-header></mno-widget-header>
<mno-widget-body>
<div class='row'>
<div class='col-lg-6 col-md-offset-3'>
<table class='table table-striped table-centered'>
<thead>
<tr>
<th class='col-lg-3'>Division Name</th>
</tr>
</thead>
<tbody ng-show='vm.subTenantLoading'>
<tr>
<td colspan='6' class='text-center'>Loading ...</td>
</tr>
</tbody>
<tbody ng-show='!vm.subTenantLoading'>
<tr ng-repeat='sub_tenant in vm.sub_tenants'>
<td>{{sub_tenant.name}}</td>
<td class='text-center'>
<input type='checkbox' ng-model='vm.selectedSubTenants[sub_tenant.id]'>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</mno-widget-body>
</mno-widget>

<button type="submit" class="btn btn-danger pull-right top-buffer-2" ng-click="vm.submitOrganisation()" ng-disabled="vm.isLoading || vm.selectedSubTenants.length == 0">
<span ng-show="vm.isLoading">
<i class="fa fa-spinner fa-pulse fa-fw"></i>
</span>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-AU.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"mnoe_admin_panel.dashboard.customers.invite_user_modal.toastr_error": "An error occurred while sending an email to {email}. Please try again...",
"mnoe_admin_panel.dashboard.customers.create_customer.create_customer": "Create a new customer",
"mnoe_admin_panel.dashboard.customers.create_customer.organization_details": "Organisation details",
"mnoe_admin_panel.dashboard.customers.create_customer.division_details": "Division details",
"mnoe_admin_panel.dashboard.customers.create_customer.organization_name": "Organisation name",
"mnoe_admin_panel.dashboard.customers.create_customer.name": "Name",
"mnoe_admin_panel.dashboard.customers.create_customer.required.name": "Name is required",
Expand Down