use ngif so that form elements are not on page

This commit is contained in:
Kyle Spearrin 2017-04-07 14:15:11 -04:00
parent 60f62b2b50
commit 2b880d322a
2 changed files with 41 additions and 27 deletions

View File

@ -57,27 +57,41 @@
$scope.submit = function (model) { $scope.submit = function (model) {
var shareKey = cryptoService.makeShareKey(); var shareKey = cryptoService.makeShareKey();
$scope.submitPromise = stripe.card.createToken(model.card).then(function (response) { if (model.plan === 'free') {
var request = { var freeRequest = {
name: model.name, name: model.name,
planType: model.plan, planType: model.plan,
key: shareKey, key: shareKey,
cardToken: response.id, billingEmail: model.billingEmail
additionalUsers: model.additionalUsers,
billingEmail: model.billingEmail,
businessName: model.ownedBusiness ? model.businessName : null,
monthly: model.interval === 'month'
}; };
return apiService.organizations.post(request).$promise; $scope.submitPromise = apiService.organizations.post(freeRequest).$promise.then(finalizeCreate);
}).then(function (result) { }
$scope.model.card = null; else {
$scope.submitPromise = stripe.card.createToken(model.card).then(function (response) {
var paidRequest = {
name: model.name,
planType: model.plan,
key: shareKey,
cardToken: response.id,
additionalUsers: model.additionalUsers,
billingEmail: model.billingEmail,
businessName: model.ownedBusiness ? model.businessName : null,
monthly: model.interval === 'month'
};
$analytics.eventTrack('Created Organization'); return apiService.organizations.post(paidRequest).$promise;
authService.addProfileOrganizationOwner(result, shareKey); }).then(finalizeCreate);
$state.go('backend.org.dashboard', { orgId: result.Id }).then(function () { }
toastr.success('Your new organization is ready to go!', 'Organization Created');
});
});
}; };
function finalizeCreate(result) {
$scope.model.card = null;
$analytics.eventTrack('Created Organization');
authService.addProfileOrganizationOwner(result, shareKey);
$state.go('backend.org.dashboard', { orgId: result.Id }).then(function () {
toastr.success('Your new organization is ready to go!', 'Organization Created');
});
}
}); });

View File

@ -29,8 +29,8 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group" show-errors> <div class="form-group" show-errors>
<label for="billingEmail">Billing Email</label> <label for="billingEmail">Billing Email</label>
<input type="email" id="billingEmail" name="BillingEmail" ng-model="model.billingEmail" class="form-control" <input type="email" id="billingEmail" name="BillingEmail" ng-model="model.billingEmail"
required api-field /> class="form-control" required api-field />
</div> </div>
</div> </div>
</div> </div>
@ -44,8 +44,8 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group" show-errors> <div class="form-group" show-errors>
<label for="businessName">Business Name</label> <label for="businessName">Business Name</label>
<input type="text" id="businessName" name="BusinessName" ng-model="model.businessName" class="form-control" <input type="text" id="businessName" name="BusinessName" ng-model="model.businessName"
api-field /> class="form-control" api-field />
</div> </div>
</div> </div>
</div> </div>
@ -56,7 +56,7 @@
<h3 class="box-title">Choose Your Plan</h3> <h3 class="box-title">Choose Your Plan</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="radio radio-block" ng-show="!model.ownedBusiness" ng-click="changedPlan()"> <div class="radio radio-block" ng-if="!model.ownedBusiness" ng-click="changedPlan()">
<label> <label>
<input type="radio" ng-model="model.plan" name="PlanType" value="free"> <input type="radio" ng-model="model.plan" name="PlanType" value="free">
Free Free
@ -65,7 +65,7 @@
<span>- Limit 2 subvaults</span> <span>- Limit 2 subvaults</span>
</label> </label>
</div> </div>
<div class="radio radio-block" ng-show="!model.ownedBusiness" ng-click="changedPlan()"> <div class="radio radio-block" ng-if="!model.ownedBusiness" ng-click="changedPlan()">
<label> <label>
<input type="radio" ng-model="model.plan" name="PlanType" value="personal"> <input type="radio" ng-model="model.plan" name="PlanType" value="personal">
Personal Personal
@ -102,7 +102,7 @@
</button> </button>
</div> </div>
</div> </div>
<div class="box box-default" ng-show="model.plan !== 'free'"> <div class="box box-default" ng-if="model.plan !== 'free'">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Additional Users</h3> <h3 class="box-title">Additional Users</h3>
</div> </div>
@ -115,14 +115,14 @@
<div class="col-md-4"> <div class="col-md-4">
<div class="form-group" show-errors style="margin: 0;"> <div class="form-group" show-errors style="margin: 0;">
<label for="additionalUsers" class="sr-only">Additional Users</label> <label for="additionalUsers" class="sr-only">Additional Users</label>
<input type="number" id="additionalUsers" name="AdditionalUsers" ng-model="model.additionalUsers" min="0" <input type="number" id="additionalUsers" name="AdditionalUsers" ng-model="model.additionalUsers"
class="form-control" placeholder="# of users" api-field /> min="0" class="form-control" placeholder="# of users" api-field />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="box box-default" ng-show="model.plan !== 'free'"> <div class="box box-default" ng-if="model.plan !== 'free'">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Billing Summary</h3> <h3 class="box-title">Billing Summary</h3>
</div> </div>
@ -164,7 +164,7 @@
{{totalPrice() | currency:"USD $":2}} /{{model.interval}} {{totalPrice() | currency:"USD $":2}} /{{model.interval}}
</div> </div>
</div> </div>
<div class="box box-default" ng-show="model.plan !== 'free'"> <div class="box box-default" ng-if="model.plan !== 'free'">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Payment Information</h3> <h3 class="box-title">Payment Information</h3>
</div> </div>