Skip to content

Commit

Permalink
[4.3] MACT-87: Ignore limits & credit at wizard if non master/reseller (
Browse files Browse the repository at this point in the history
  • Loading branch information
guillegr123 committed Oct 23, 2020
1 parent c26afe8 commit 9726165
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 71 deletions.
82 changes: 44 additions & 38 deletions submodules/wizard/views/step-creditBalanceAndFeatures.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,55 @@
</div>
<div class="step-body">
<form id="form_credit_balance_and_features">
<div class="section-title">
{{creditBalanceAndFeaturesI18n.accountCredit.title}}
</div>
<div class="section-body flex-row-container">
<div class="flex-item-3">
<label for="account_credit_initial_balance">
{{creditBalanceAndFeaturesI18n.accountCredit.labels.initialBalance}}
<span class="help-tip" title="{{creditBalanceAndFeaturesI18n.accountCredit.help.initialBalance}}" data-toggle="tooltip">
{{telicon "question--circle" class="iconography-small iconography-help"}}
</span>
</label>
<div class="input-append input-block-level">
<button type="button" class="monster-button-fit" disabled>
{{@root.currencySymbol}}
</button>
<input id="account_credit_initial_balance" name="accountCredit.initialBalance" type="text" class="input-block-level" pattern="\d+(\.\d{2})?" placeholder="{{creditBalanceAndFeaturesI18n.accountCredit.placeholders.initialBalance}}" value="{{@root.data.accountCredit.initialBalance}}"/>
{{#if @root.data.accountCredit}}
<div class="step-section">
<div class="section-title">
{{creditBalanceAndFeaturesI18n.accountCredit.title}}
</div>
<div class="section-body flex-row-container">
<div class="flex-item-3">
<label for="account_credit_initial_balance">
{{creditBalanceAndFeaturesI18n.accountCredit.labels.initialBalance}}
<span class="help-tip" title="{{creditBalanceAndFeaturesI18n.accountCredit.help.initialBalance}}" data-toggle="tooltip">
{{telicon "question--circle" class="iconography-small iconography-help"}}
</span>
</label>
<div class="input-append input-block-level">
<button type="button" class="monster-button-fit" disabled>
{{@root.currencySymbol}}
</button>
<input id="account_credit_initial_balance" name="accountCredit.initialBalance" type="text" class="input-block-level" pattern="\d+(\.\d{2})?" placeholder="{{creditBalanceAndFeaturesI18n.accountCredit.placeholders.initialBalance}}"{{#if @root.data.accountCredit.initialBalance}} value="{{@root.data.accountCredit.initialBalance}}"{{/if}}/>
</div>
</div>
</div>
</div>
<div class="section-title">
{{creditBalanceAndFeaturesI18n.controlCenterAccess.title}}
<span class="help-tip" title="{{creditBalanceAndFeaturesI18n.controlCenterAccess.help}}" data-toggle="tooltip">
{{telicon "question--circle" class="iconography-small iconography-help"}}
</span>
</div>
<div class="section-body">
<div class="flex-row-container">
<div class="flex-item-2">
{{creditBalanceAndFeaturesI18n.controlCenterAccess.description}}
</div>
{{/if}}
<div class="step-section">
<div class="section-title">
{{creditBalanceAndFeaturesI18n.controlCenterAccess.title}}
<span class="help-tip" title="{{creditBalanceAndFeaturesI18n.controlCenterAccess.help}}" data-toggle="tooltip">
{{telicon "question--circle" class="iconography-small iconography-help"}}
</span>
</div>
<div class="flex-row-container">
<div class="flex-item-3">
<ul class="features">
{{#each @root.controlCenter.featureTree}}
<li class="feature-category">
{{tryI18n creditBalanceAndFeaturesI18n.controlCenterAccess.featureCategories category}}
</li>
{{#each features}}
{{> featurePartial}}
<div class="section-body">
<div class="flex-row-container">
<div class="flex-item-2">
{{creditBalanceAndFeaturesI18n.controlCenterAccess.description}}
</div>
</div>
<div class="flex-row-container">
<div class="flex-item-3">
<ul class="features">
{{#each @root.controlCenter.featureTree}}
<li class="feature-category">
{{tryI18n creditBalanceAndFeaturesI18n.controlCenterAccess.featureCategories category}}
</li>
{{#each features}}
{{> featurePartial}}
{{/each}}
{{/each}}
{{/each}}
</ul>
</ul>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions submodules/wizard/views/step-review.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
{{> sectionTitle stepName="usageAndCallRestrictions"}}
<div class="section-body">
<div class="flex-row-container">
{{#if @root.usageAndCallRestrictions.trunkLimits}}
<div class="flex-item field-group-column">
<div class="flex-row-container">
<div class="flex-item-1 column-title">
Expand All @@ -215,6 +216,7 @@
{{> booleanLabel mode="Status"}}
{{/horizontalFieldPartial}}
</div>
{{/if}}
<div class="flex-item field-group-column">
<div class="flex-row-container">
<div class="flex-item-1 column-title">
Expand All @@ -241,6 +243,7 @@
{{> sectionTitle stepName="creditBalanceAndFeatures"}}
<div class="section-body">
<div class="flex-row-container">
{{#if @root.creditBalanceAndFeatures.accountCredit}}
<div class="flex-item field-group-column">
<div class="flex-row-container">
<div class="flex-item-1 column-title">
Expand All @@ -251,6 +254,7 @@
{{formatPrice value 2}}
{{/horizontalFieldPartial}}
</div>
{{/if}}
<div class="flex-item field-group-column">
<div class="flex-row-container">
<div class="flex-item-1 column-title">
Expand Down
2 changes: 2 additions & 0 deletions submodules/wizard/views/step-usageAndCallRestrictions.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</div>
<div class="step-body">
<form id="form_usage_and_call_restrictions">
{{#if @root.data.trunkLimits}}
<div class="step-section">
<div class="section-title">
{{usageAndCallRestrictionsI18n.trunkLimits.title}}
Expand All @@ -28,6 +29,7 @@
</div>
</div>
</div>
{{/if}}
<div class="step-section">
<div class="section-title">
{{usageAndCallRestrictionsI18n.callRestrictions.title}}
Expand Down
90 changes: 57 additions & 33 deletions submodules/wizard/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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: {
Expand All @@ -232,44 +237,55 @@ 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',
allowedAppIds: []
}
};

if (_.isEmpty(results.servicePlans)) {
if (noServicePlans) {
stepNames = _.without(stepNames, 'servicePlan');
}

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9726165

Please sign in to comment.