1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

enum filters and org accept state

This commit is contained in:
Kyle Spearrin 2017-03-30 22:06:01 -04:00
parent 2692bbaa63
commit 11002c2881
10 changed files with 102 additions and 35 deletions

View File

@ -3,6 +3,7 @@ angular
.controller('accountsLoginController', function ($scope, $rootScope, $cookies, apiService, cryptoService, authService,
$state, appSettings, $analytics) {
$scope.state = $state;
var returnState = $state.params.returnState;
var rememberedEmail = $cookies.get(appSettings.rememberedEmailCookieName);
if (rememberedEmail || $state.params.email) {

View File

@ -35,7 +35,15 @@
</div>
<hr />
<ul>
<li><a ui-sref="frontend.register">Create a new account</a></li>
<li><a ui-sref="frontend.passwordHint">Get master password hint</a></li>
<li>
<a ui-sref="frontend.register({returnState: state.params.returnState, email: state.params.email})">
Create a new account
</a>
</li>
<li>
<a ui-sref="frontend.passwordHint">
Get master password hint
</a>
</li>
</ul>
</form>

View File

@ -9,7 +9,7 @@
<h4>Account Created!</h4>
<p>You may now log in to your new account.</p>
</div>
<a ui-sref="frontend.login.info({returnState: returnState})">Ready to log in?</a>
<a ui-sref="frontend.login.info({returnState: returnState, email: model.email})">Ready to log in?</a>
</div>
<form name="registerForm" ng-submit="registerForm.$valid && register(registerForm)" ng-show="!success"
api-form="registerPromise">

View File

@ -10,6 +10,7 @@
'angulartics.google.analytics',
'bit.directives',
'bit.filters',
'bit.services',
'bit.global',

View File

@ -0,0 +1,32 @@
angular
.module('bit.filters')
.filter('enumLabelClass', function () {
return function (input, name) {
if (typeof input !== 'number') {
return input.toString();
}
var output;
switch (name) {
case 'OrgUserStatus':
switch (input) {
case 0:
output = 'label-default';
break;
case 1:
output = 'label-warning';
break;
case 2:
/* falls through */
default:
output = 'label-success';
}
break;
default:
output = 'label-default';
}
return output;
};
});

View File

@ -0,0 +1,46 @@
angular
.module('bit.filters')
.filter('enumName', function () {
return function (input, name) {
if (typeof input !== 'number') {
return input.toString();
}
var output;
switch (name) {
case 'OrgUserStatus':
switch (input) {
case 0:
output = 'Invited';
break;
case 1:
output = 'Accepted';
break;
case 2:
/* falls through */
default:
output = 'Confirmed';
}
break;
case 'OrgUserType':
switch (input) {
case 0:
output = 'Owner';
break;
case 1:
output = 'Admin';
break;
case 2:
/* falls through */
default:
output = 'User';
}
break;
default:
output = input.toString();
}
return output;
};
});

View File

@ -0,0 +1,2 @@
angular
.module('bit.filters', []);

View File

@ -92,35 +92,6 @@
type: list.Data[i].Type
};
switch (user.type) {
case 0:
user.typeName = 'Owner';
break;
case 1:
user.typeName = 'Admin';
break;
case 2:
/* falls through */
default:
user.typeName = 'User';
}
switch (user.status) {
case 0:
user.statusName = 'Invited';
user.statusClass = { 'label-default': true };
break;
case 1:
user.statusName = 'Accepted';
user.statusClass = { 'label-warning': true };
break;
case 2:
/* falls through */
default:
user.statusName = 'Confirmed';
user.statusClass = { 'label-success': true };
}
users.push(user);
}

View File

@ -32,7 +32,7 @@
<table class="table table-striped table-hover table-vmiddle">
<tbody>
<tr ng-repeat="user in filteredUsers = (users | filter: (filterSearch || '') |
orderBy: ['name', 'email'])">
orderBy: ['type', 'name', 'email'])">
<td style="width: 70px;">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
@ -66,10 +66,12 @@
<div ng-if="user.name"><small class="text-muted">{{user.name}}</small></div>
</td>
<td style="width: 100px;">
{{user.typeName}}
{{user.type | enumName: 'OrgUserType'}}
</td>
<td style="width: 120px;">
<span class="label" ng-class="{{user.statusClass}}">{{user.statusName}}</span>
<span class="label {{user.status | enumLabelClass: 'OrgUserStatus'}}">
{{user.status | enumName: 'OrgUserStatus'}}
</span>
</td>
</tr>
</tbody>

View File

@ -87,6 +87,10 @@
<script src="app/directives/passwordMeterDirective.js"></script>
<script src="app/directives/passwordViewerDirective.js"></script>
<script src="app/filters/filtersModule.js"></script>
<script src="app/filters/enumNameFilter.js"></script>
<script src="app/filters/enumLabelClassFilter.js"></script>
<script src="app/services/servicesModule.js"></script>
<script src="app/services/tokenService.js"></script>
<script src="app/services/apiService.js"></script>