1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

org create form on it's own page instead of modal

This commit is contained in:
Kyle Spearrin 2017-04-07 12:32:15 -04:00
parent d39d49fb8f
commit 71adf31f7b
7 changed files with 547 additions and 498 deletions

View File

@ -111,6 +111,12 @@ angular
controller: 'settingsDomainsController',
data: { pageTitle: 'Domain Settings' }
})
.state('backend.user.settingsCreateOrg', {
url: '^/settings/create-organization',
templateUrl: 'app/settings/views/settingsCreateOrganization.html',
controller: 'settingsCreateOrganizationController',
data: { pageTitle: 'Create Organization' }
})
.state('backend.user.tools', {
url: '^/tools',
templateUrl: 'app/tools/views/tools.html',

View File

@ -73,14 +73,6 @@
});
};
$scope.createOrganization = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/settings/views/settingsCreateOrganization.html',
controller: 'settingsCreateOrganizationController'
});
};
$scope.viewOrganization = function (id) {
$state.go('backend.org.dashboard', { orgId: id });
};

View File

@ -1,10 +1,8 @@
angular
.module('bit.settings')
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, $uibModalInstance, cryptoService,
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, cryptoService,
toastr, $analytics, authService, stripe) {
$analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' });
$scope.plans = {
free: {
basePrice: 0
@ -30,7 +28,24 @@
$scope.model = {
plan: 'personal',
additionalUsers: 0,
interval: 'annually'
interval: 'year'
};
$scope.totalPrice = function () {
if ($scope.model.interval === 'month') {
return ($scope.model.additionalUsers || 0) * $scope.plans[$scope.model.plan].monthlyUserPrice +
$scope.plans[$scope.model.plan].monthlyBasePrice;
}
else {
return ($scope.model.additionalUsers || 0) * $scope.plans[$scope.model.plan].annualUserPrice +
$scope.plans[$scope.model.plan].annualBasePrice;
}
};
$scope.changedPlan = function () {
if ($scope.model.plan !== 'teams') {
$scope.model.interval = 'year';
}
};
$scope.submit = function (model) {
@ -45,14 +60,13 @@
additionalUsers: model.additionalUsers,
billingEmail: model.billingEmail,
businessName: model.ownedBusiness ? model.businessName : null,
monthly: model.interval === 'monthly'
monthly: model.interval === 'month'
};
return apiService.organizations.post(request).$promise;
}).then(function (result) {
$scope.model.card = null;
$uibModalInstance.dismiss('cancel');
$analytics.eventTrack('Created Organization');
authService.addProfileOrganizationOwner(result, shareKey);
$state.go('backend.org.dashboard', { orgId: result.Id }).then(function () {
@ -60,8 +74,4 @@
});
});
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -122,9 +122,9 @@
</a>
</div>
<div class="box-footer">
<button type="button" ng-click="createOrganization()" class="btn btn-default btn-flat">
<a ui-sref="backend.user.settingsCreateOrg" class="btn btn-default btn-flat">
Create an Organization
</button>
</a>
</div>
</div>
<div class="box box-danger">

View File

@ -1,9 +1,13 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><i class="fa fa-sitemap"></i> Create Organization</h4>
</div>
<form name="createOrgForm" ng-submit="createOrgForm.$valid && submit(model)" api-form="submitPromise">
<div class="modal-body">
<section class="content-header">
<h1>Create Organization</h1>
</section>
<section class="content">
<form name="createOrgForm" ng-submit="createOrgForm.$valid && submit(model)" api-form="submitPromise">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">General Information</h3>
</div>
<div class="box-body">
<div class="callout callout-danger validation-errors" ng-show="createOrgForm.$errors">
<h4>Errors have occured</h4>
<ul>
@ -40,18 +44,22 @@
</div>
</div>
</div>
<hr />
<h4>Choose Your Plan</h4>
<div class="form-group">
<div class="radio" ng-show="!model.ownedBusiness">
<label class="label-block">
</div>
</div>
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Choose Your Plan</h3>
</div>
<div class="box-body">
<div class="radio radio-block" ng-show="!model.ownedBusiness" ng-click="changedPlan()">
<label>
<input type="radio" ng-model="model.plan" name="PlanType" value="free">
Free
<span>Share with 1 other user.</span>
<span>For personal users to share with 1 other user.</span>
</label>
</div>
<div class="radio" ng-show="!model.ownedBusiness">
<label class="label-block">
<div class="radio radio-block" ng-show="!model.ownedBusiness" ng-click="changedPlan()">
<label>
<input type="radio" ng-model="model.plan" name="PlanType" value="personal">
Personal
<span>For personal users such as families &amp; friends.</span>
@ -61,11 +69,11 @@
</span>
</label>
</div>
<div class="radio">
<label class="label-block">
<div class="radio radio-block" ng-click="changedPlan()">
<label>
<input type="radio" ng-model="model.plan" name="PlanType" value="teams">
Teams
<span>For businesses and other large teams.</span>
<span>For businesses and other team organizations.</span>
<span>
{{plans.teams.basePrice | currency:'$'}} /month for {{plans.teams.baseUsers}} users,
additional users {{plans.teams.userPrice | currency:'$'}} /month
@ -73,29 +81,40 @@
</label>
</div>
</div>
<div ng-show="model.plan !== 'free'">
<hr />
<h4>Additional Users</h4>
<div class="box-footer" ng-show="model.plan === 'free'">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="createOrgForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="createOrgForm.$loading"></i>Submit
</button>
</div>
</div>
<div class="box box-default" ng-show="model.plan !== 'free'">
<div class="box-header with-border">
<h3 class="box-title">Additional Users</h3>
</div>
<div class="box-body">
<p>
Your plan comes with <b>{{plans[model.plan].baseUsers}}</b> users. You can add additional users
for {{plans[model.plan].userPrice | currency:'$'}} /month.
for {{plans[model.plan].userPrice | currency:'$'}} per user /month.
</p>
<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<div class="form-group" show-errors style="margin: 0;">
<label for="additionalUsers" class="sr-only">Additional Users</label>
<input type="number" id="additionalUsers" name="AdditionalUsers" ng-model="model.additionalUsers" min="0"
class="form-control" api-field />
class="form-control" placeholder="# of users" api-field />
</div>
</div>
</div>
</div>
<div ng-show="model.plan !== 'free'">
<hr />
<h4>Billing Totals</h4>
<div class="radio">
<label class="label-block">
<input type="radio" ng-model="model.interval" name="BillingInterval" value="annually">
</div>
<div class="box box-default" ng-show="model.plan !== 'free'">
<div class="box-header with-border">
<h3 class="box-title">Billing Summary</h3>
</div>
<div class="box-body">
<div class="radio radio-block">
<label>
<input type="radio" ng-model="model.interval" name="BillingInterval" value="year">
Bill me annually
<span>
Base price:
@ -107,15 +126,11 @@
{{model.additionalUsers || 0}} &times;{{plans[model.plan].userPrice | currency:"$":2}}
&times;12 mo. = {{(model.additionalUsers * plans[model.plan].annualUserPrice) | currency:"$":2}} /year
</span>
<span>
<b>Total:</b>
{{((model.additionalUsers || 0) * plans[model.plan].annualUserPrice + plans[model.plan].annualBasePrice) | currency:"USD $":2}} /year
</span>
</label>
</div>
<div class="radio" ng-show="model.plan !== 'personal'">
<label class="label-block">
<input type="radio" ng-model="model.interval" name="BillingInterval" value="monthly">
<div class="radio radio-block" ng-if="model.plan !== 'personal'">
<label>
<input type="radio" ng-model="model.interval" name="BillingInterval" value="month">
Bill me monthly
<span>
Base price:
@ -126,26 +141,30 @@
{{model.additionalUsers || 0}} &times;{{plans[model.plan].monthlyUserPrice | currency:"$":2}} =
{{(model.additionalUsers * plans[model.plan].monthlyUserPrice) | currency:"$":2}} /month
</span>
<span>
<b>Total:</b>
{{((model.additionalUsers || 0) * plans[model.plan].monthlyUserPrice + plans[model.plan].monthlyBasePrice) | currency:"USD $":2}} /month
</span>
</label>
</div>
</div>
<div ng-show="model.plan !== 'free'">
<hr />
<h4>Payment Information</h4>
<div class="box-footer">
<b>Total:</b>
{{totalPrice() | currency:"USD $":2}} /{{model.interval}}
</div>
</div>
<div class="box box-default" ng-show="model.plan !== 'free'">
<div class="box-header with-border">
<h3 class="box-title">Payment Information</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-sm-6">
<div class="col-md-5">
<div class="form-group">
<label for="card_number">Card Number</label>
<input type="text" id="card_number" name="card_number" ng-model="model.card.number" class="form-control"
cc-number cc-eager-type required />
</div>
</div>
</div>
<ul class="list-inline">
<div class="col-md-7">
<br />
<ul class="list-inline" style="margin: 0;">
<li><div class="cc visa"></div></li>
<li><div class="cc mastercard"></div></li>
<li><div class="cc amex"></div></li>
@ -153,6 +172,8 @@
<li><div class="cc diners"></div></li>
<li><div class="cc jcb"></div></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group">
@ -464,11 +485,11 @@
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="createOrgForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="createOrgForm.$loading"></i>Submit
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>
</div>
</form>
</section>

View File

@ -61,10 +61,16 @@
<a ui-sref="backend.user.tools"><i class="fa fa-wrench fa-fw"></i> <span>Tools</span></a>
</li>
<li class="treeview"
ng-class="{active: $state.is('backend.user.settings') || $state.is('backend.user.settingsDomains')}">
ng-class="{active: $state.is('backend.user.settings') || $state.is('backend.user.settingsDomains') ||
$state.is('backend.user.settingsCreateOrg')}">
<a ui-sref="backend.user.settings"><i class="fa fa-cogs fa-fw"></i> <span>Settings</span></a>
<ul class="treeview-menu" ng-class="{'menu-open': $state.is('backend.user.settings')
|| $state.is('backend.user.settingsDomains')}">
<ul class="treeview-menu" ng-class="{'menu-open': $state.is('backend.user.settings') ||
$state.is('backend.user.settingsDomains') || $state.is('backend.user.settingsCreateOrg')}">
<li ng-class="{active: $state.is('backend.user.settingsCreateOrg')}">
<a ui-sref="backend.user.settingsCreateOrg">
<i class="fa fa-plus-circle fa-fw"></i> New Organization
</a>
</li>
<li ng-class="{active: $state.is('backend.user.settingsDomains')}">
<a ui-sref="backend.user.settingsDomains">
<i class="fa fa-fw fa-circle-o"></i> Domain Rules

View File

@ -171,9 +171,22 @@ form .btn .loading-icon {
}
}
.radio .label-block {
.radio.radio-block {
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
label {
border-bottom: 0;
}
}
label {
display: block;
border: 1px solid @table-border-color;
border-bottom: 1px solid @table-border-color;
border-radius: 3px;
padding: 10px 10px 10px 30px;
font-weight: bold;
@ -192,6 +205,7 @@ form .btn .loading-icon {
margin-bottom: 0;
}
}
}
}
/* Modals */