diff --git a/submodules/wizard/views/step-creditBalanceAndFeatures.html b/submodules/wizard/views/step-creditBalanceAndFeatures.html index 53fc3f3..0b739bd 100644 --- a/submodules/wizard/views/step-creditBalanceAndFeatures.html +++ b/submodules/wizard/views/step-creditBalanceAndFeatures.html @@ -28,49 +28,55 @@
-
- {{creditBalanceAndFeaturesI18n.accountCredit.title}} -
-
-
- -
- - + {{#if @root.data.accountCredit}} +
+
+ {{creditBalanceAndFeaturesI18n.accountCredit.title}} +
+
+
+ +
+ + +
-
- {{creditBalanceAndFeaturesI18n.controlCenterAccess.title}} - - {{telicon "question--circle" class="iconography-small iconography-help"}} - -
-
-
-
- {{creditBalanceAndFeaturesI18n.controlCenterAccess.description}} -
+ {{/if}} +
+
+ {{creditBalanceAndFeaturesI18n.controlCenterAccess.title}} + + {{telicon "question--circle" class="iconography-small iconography-help"}} +
-
-
-
    - {{#each @root.controlCenter.featureTree}} -
  • - {{tryI18n creditBalanceAndFeaturesI18n.controlCenterAccess.featureCategories category}} -
  • - {{#each features}} - {{> featurePartial}} +
    +
    +
    + {{creditBalanceAndFeaturesI18n.controlCenterAccess.description}} +
    +
    +
    +
    +
      + {{#each @root.controlCenter.featureTree}} +
    • + {{tryI18n creditBalanceAndFeaturesI18n.controlCenterAccess.featureCategories category}} +
    • + {{#each features}} + {{> featurePartial}} + {{/each}} {{/each}} - {{/each}} -
    +
+
diff --git a/submodules/wizard/views/step-review.html b/submodules/wizard/views/step-review.html index 17bc9bd..d43c08f 100644 --- a/submodules/wizard/views/step-review.html +++ b/submodules/wizard/views/step-review.html @@ -202,6 +202,7 @@ {{> sectionTitle stepName="usageAndCallRestrictions"}}
+ {{#if @root.usageAndCallRestrictions.trunkLimits}}
@@ -215,6 +216,7 @@ {{> booleanLabel mode="Status"}} {{/horizontalFieldPartial}}
+ {{/if}}
@@ -241,6 +243,7 @@ {{> sectionTitle stepName="creditBalanceAndFeatures"}}
+ {{#if @root.creditBalanceAndFeatures.accountCredit}}
@@ -251,6 +254,7 @@ {{formatPrice value 2}} {{/horizontalFieldPartial}}
+ {{/if}}
diff --git a/submodules/wizard/views/step-usageAndCallRestrictions.html b/submodules/wizard/views/step-usageAndCallRestrictions.html index b866bc7..a7bdcb6 100644 --- a/submodules/wizard/views/step-usageAndCallRestrictions.html +++ b/submodules/wizard/views/step-usageAndCallRestrictions.html @@ -5,6 +5,7 @@
+ {{#if @root.data.trunkLimits}}
{{usageAndCallRestrictionsI18n.trunkLimits.title}} @@ -28,6 +29,7 @@
+ {{/if}}
{{usageAndCallRestrictionsI18n.callRestrictions.title}} diff --git a/submodules/wizard/wizard.js b/submodules/wizard/wizard.js index 75a041f..2eef336 100644 --- a/submodules/wizard/wizard.js +++ b/submodules/wizard/wizard.js @@ -149,11 +149,12 @@ define(function(require) { }); }, function tryGetResellerAccount(parentAccount, waterfallCallback) { - var results = { + var resellerAccountId = self.wizardGetResellerAccountId(parentAccount), + results = { + resellerAccountId: resellerAccountId, parentAccount: parentAccount, servicePlans: [] - }, - resellerAccountId = self.wizardGetResellerAccountId(parentAccount); + }; if (resellerAccountId === parentAccountId) { self.wizardSetStore('resellerAccountId', parentAccountId); @@ -183,9 +184,9 @@ define(function(require) { }, function getServicePlans(results, waterfallCallback) { var isResellerUnavailable = results.isResellerUnavailable, - isCurrentAccountReseller = monster.util.isReseller(), - isCurrentAccountSuperDuperAdmin = monster.util.isSuperDuper(), - isElevatedAccount = isCurrentAccountReseller || isCurrentAccountSuperDuperAdmin, + isResellerAccount = monster.util.isReseller(), + isSuperDuperAccount = monster.util.isSuperDuper(), + isElevatedAccount = isResellerAccount || isSuperDuperAccount, skipServicePlans = isResellerUnavailable || !isElevatedAccount; if (skipServicePlans) { @@ -212,6 +213,10 @@ define(function(require) { defaultCountry = _.get(monster.config, 'whitelabel.countryCode'), parentAccount = results.parentAccount, isRealmSuffixDefined = !_.chain(monster.config).get('whitelabel.realm_suffix').isEmpty().value(), + noServicePlans = _.isEmpty(results.servicePlans), + isSuperDuperAccount = monster.util.isSuperDuper(), + isCurrentResellerAccount = monster.apps.auth.originalAccount.id === results.resellerAccountId, + masterOrResellerAccount = isSuperDuperAccount || isCurrentResellerAccount, defaultData = { // General Settings defaults generalSettings: { @@ -232,36 +237,47 @@ define(function(require) { } : {}) }, // Usage and Call Restrictions defaults - usageAndCallRestrictions: { - trunkLimits: { - inbound: 0, - outbound: 0, - twoway: 0 + usageAndCallRestrictions: _.merge( + { + callRestrictions: { + _all: true + } }, - allowPerMinuteCalls: false, - callRestrictions: { - _all: true + masterOrResellerAccount && { + trunkLimits: { + inbound: 0, + outbound: 0, + twoway: 0 + }, + allowPerMinuteCalls: false } - }, + ), // Credit Balance and Features defaults - creditBalanceAndFeatures: { - controlCenterAccess: { - features: { - user: true, - account: true, - billing: true, - balance: true, - credit: true, - minutes: true, - service_plan: true, - transactions: true, - inbound: true, - outbound: true, - twoway: true, - errorTracker: true + creditBalanceAndFeatures: _.merge( + { + controlCenterAccess: { + features: { + user: true, + account: true, + billing: true, + balance: true, + credit: true, + minutes: true, + service_plan: true, + transactions: true, + inbound: true, + outbound: true, + twoway: true, + errorTracker: true + } + } + }, + masterOrResellerAccount && { + accountCredit: { + initialBalance: 0 } } - }, + ), // App Restrictions defaults appRestrictions: { accessLevel: 'full', @@ -269,7 +285,7 @@ define(function(require) { } }; - if (_.isEmpty(results.servicePlans)) { + if (noServicePlans) { stepNames = _.without(stepNames, 'servicePlan'); } @@ -1706,6 +1722,10 @@ define(function(require) { }); }, limits: function(parallelCallback) { + if (!_.has(wizardData.usageAndCallRestrictions, 'trunkLimits')) { + return parallelCallback(null); + } + self.wizardRequestLimitsUpdate({ accountId: newAccountId, limits: self.wizardSubmitGetFormattedLimits(wizardData), @@ -1889,7 +1909,11 @@ define(function(require) { */ wizardSubmitGetFormattedLedgerCredit: function(wizardData) { var self = this, - amount = _.toNumber(wizardData.creditBalanceAndFeatures.accountCredit.initialBalance); + amount = _ + .chain(wizardData) + .get('creditBalanceAndFeatures.accountCredit.initialBalance', 0) + .toNumber() + .value(); if (amount === 0) { return null;