Skip to content

Commit

Permalink
Merge pull request #532 from RidaAhmad/mnoe-1263-update-local-product…
Browse files Browse the repository at this point in the history
…s-provision-button

[MNOE-1263] [OPAL-497] Updated local products provision button
  • Loading branch information
Adam Abdelaziz authored Jul 25, 2018
2 parents 938658c + 87621f9 commit 2152bca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/app/components/mno-local-products/mno-local-product.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module 'mnoEnterpriseAngular'

vm.isProvisioningEnabled = !vm.isPublic && MnoeConfig.isProvisioningEnabled()
vm.canProvision = false
vm.buttonDisabledTooltip = ''

vm.isLoading = true

Expand All @@ -23,6 +24,15 @@ angular.module 'mnoEnterpriseAngular'
vm.hideNoPricingFound = (plan) ->
vm.isPublic || vm.planAvailableForCurrency(plan) || !vm.pricedPlan(plan)

vm.buttonDisabled = () ->
!vm.canProvision || !vm.orderPossible

vm.updateButtonDisabledTooltip = () ->
if !vm.canProvision
'mno_enterprise.templates.components.app_install_btn.insufficient_privilege'
else if !vm.orderPossible
'mno_enterprise.templates.dashboard.marketplace.show.no_pricing_plans_found_tooltip'

# Retrieve the products
vm.initialize = ->
MnoeMarketplace.getApps().then(
Expand All @@ -42,6 +52,13 @@ angular.module 'mnoEnterpriseAngular'
productId = $stateParams.productId
vm.product = _.findWhere(vm.products, { nid: productId })
vm.product ||= _.findWhere(vm.products, { id: productId })
# Is currency selection enabled
currencySelection = MnoeConfig.isCurrencySelectionEnabled()
# Are there any available plans
availablePlans = ProvisioningHelper.plansForCurrency(vm.product.pricing_plans, vm.orgCurrency)

vm.orderPossible = !_.isEmpty(availablePlans) || (vm.product.pricing_plans?[0].default?[0] && currencySelection)
vm.buttonDisabledTooltip = vm.updateButtonDisabledTooltip()

$state.go(vm.parentState) unless vm.product?
).finally(-> vm.isLoading = false)
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/mno-local-products/mno-local-product.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ <h2 class="media-heading">{{vm.product.name}}</h2>
<!-- Key benefits -->
<div class="col-md-4">
<div class="well text-center well-details">
<a class="btn btn-warning btn-lg top-buffer-1" ng-if="vm.isProvisioningEnabled && vm.canProvision" ui-sref="home.provisioning.order({productId: vm.product.id, editAction: 'provision'})" translate>
<a class="btn btn-warning btn-lg top-buffer-1" ng-if="vm.isProvisioningEnabled && !vm.buttonDisabled()" ui-sref="home.provisioning.order({productId: vm.product.id, editAction: 'provision'})" translate>
mno_enterprise.templates.dashboard.marketplace.show.provision
</a>

<div ng-if="vm.isProvisioningEnabled && !vm.canProvision" disabled=true class="btn btn-warning btn-promo btn-lg" uib-tooltip="{{ 'mno_enterprise.templates.components.app_install_btn.insufficient_privilege' | translate }}" translate>
<div ng-if="vm.isProvisioningEnabled && vm.buttonDisabled()" disabled=true class="btn btn-warning btn-promo btn-lg" uib-tooltip="{{ vm.buttonDisabledTooltip | translate }}" translate>
mno_enterprise.templates.dashboard.marketplace.show.provision
</div>

Expand Down Expand Up @@ -68,7 +68,7 @@ <h2 class="media-heading">{{vm.product.name}}</h2>
<div class="col-md-12">
<div class="well">
<h2>{{ 'mno_enterprise.templates.dashboard.marketplace.show.price' | translate }}</h2>
<ul>
<ul ng-if="vm.orderPossible">
<li ng-if="vm.product.free_trial_duration > 0">
<b>{{ 'mno_enterprise.templates.dashboard.marketplace.show.free_trial_duration' | translate }}</b>: {{vm.product.free_trial_duration}} {{vm.product.free_trial_unit}}
</li>
Expand All @@ -85,6 +85,7 @@ <h2>{{ 'mno_enterprise.templates.dashboard.marketplace.show.price' | translate }
<span ng-show="plan.pricing_type == 'payg'">{{'mno_enterprise.templates.dashboard.marketplace.show.pricing.payg' | translate}}</span>
</li>
</ul>
<div ng-if="!vm.orderPossible">{{'mno_enterprise.templates.dashboard.marketplace.show.no_pricing_plans_found' | translate}}</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 2152bca

Please sign in to comment.