Skip to content

Commit

Permalink
hella fixes and tweaks for teams
Browse files Browse the repository at this point in the history
  • Loading branch information
corytheboyd committed Oct 17, 2013
1 parent 84d14b5 commit 1964755
Show file tree
Hide file tree
Showing 27 changed files with 342 additions and 256 deletions.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<script src="pages/teams/account.js" type="text/javascript"></script>
<script src="pages/teams/activity.js" type="text/javascript"></script>
<script src="pages/teams/base.js" type="text/javascript"></script>
<script src="pages/teams/directives.js" type="text/javascript"></script>
<script src="pages/teams/index.js" type="text/javascript"></script>
<script src="pages/teams/join.js" type="text/javascript"></script>
<script src="pages/teams/manage_members.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion app/pages/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular.module('app', ['ui.bootstrap', 'api.bountysource', 'ngSanitize', 'ngCook
// HACK: angular 1.0 adds this bad header... not needed in 1.1 per https://github.com/angular/angular.js/pull/1454
delete $httpProvider.defaults.headers.common['X-Requested-With'];

}).run(function($api) {
}).run(function($api, $rootScope) {
// load person from initial cookies
$api.load_current_person_from_cookies();
});
10 changes: 5 additions & 5 deletions app/pages/issues/bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@

<!-- Team accounts -->
<div ng-show="teams.length > 0">
<label ng-repeat="team in teams | orderBy:['-is_spender', '-account_balance']" class="radio">
<input type="radio" ng-model="bounty.payment_method" value="team/{{team.id}}" ng-disabled="!team.is_spender || team.account_balance <= 0" ng-change="select_team(team)" />
<label ng-repeat="team in teams | orderBy:['-is_developer', '-account_balance']" class="radio">
<input type="radio" ng-model="bounty.payment_method" value="team/{{team.id}}" ng-disabled="!team.is_developer || team.account_balance <= 0" ng-change="select_team(team)" />
<img style="width: 16px; height: 16px;" ng-src="{{team.image_url}}">
<span ng-class="{ 'muted': (!team.is_spender || team.account_balance <= 0) }">
<span ng-class="{ 'muted': (!team.is_developer || team.account_balance <= 0) }">
{{team.name}}
<strong ng-show="team.is_spender">{{ team.account_balance | dollars }}</strong>
<strong ng-hide="team.is_spender">$0</strong>
<strong ng-show="team.is_developer">{{ team.account_balance | dollars }}</strong>
<strong ng-hide="team.is_developer">$0</strong>
<span ng-show="team.is_admin && team.account_balance < 100 && team.type != 'Team::Enterprise'">(<a ng-href="/teams/{{team.slug}}/account">add funds</a>)</span>
</span>
</label>
Expand Down
2 changes: 1 addition & 1 deletion app/pages/issues/controllers/bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ angular.module('app')

$payment.process(payment_params, {
error: function(response) {
// if paying from team, but not a spender
// if paying from team, but not a developer
if ((/\Ateam\/(\d+)\Z/).test(payment_params.payment_method) && response.meta.status === 403) {
console.log("Forbidden:", response);
$scope.error = "You do not have permission to do that.";
Expand Down
10 changes: 5 additions & 5 deletions app/pages/pledges/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@

<!-- Team accounts -->
<div ng-show="teams.length > 0">
<label ng-repeat="team in teams | orderBy:['-is_spender', '-account_balance']" class="radio">
<input type="radio" ng-model="pledge.payment_method" value="team/{{team.id}}" ng-disabled="!team.is_spender || team.account_balance <= 0" />
<label ng-repeat="team in teams | orderBy:['-is_developer', '-account_balance']" class="radio">
<input type="radio" ng-model="pledge.payment_method" value="team/{{team.id}}" ng-disabled="!team.is_developer || team.account_balance <= 0" />
<img style="width: 16px; height: 16px;" ng-src="{{team.image_url}}">
<span ng-class="{ 'muted': (!team.is_spender || team.account_balance <= 0) }">
<span ng-class="{ 'muted': (!team.is_developer || team.account_balance <= 0) }">
{{team.name}}
<strong ng-show="team.is_spender">{{ team.account_balance | dollars }}</strong>
<strong ng-hide="team.is_spender">$0</strong>
<strong ng-show="team.is_developer">{{ team.account_balance | dollars }}</strong>
<strong ng-hide="team.is_developer">$0</strong>
<span ng-show="team.is_admin && team.account_balance < 100">(<a ng-href="/teams/{{team.slug}}/account">add funds</a>)</span>
</span>
</label>
Expand Down
6 changes: 1 addition & 5 deletions app/pages/teams/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
<ng-include src="'pages/teams/partials/header.html'"></ng-include>
<ng-include src="'pages/teams/partials/tabs.html'"></ng-include>

<div ng-show="funds_added">
<alert type="'success'" close="funds_added = null">Successfully added <strong>{{funds_added | dollars}}</strong> to <strong>{{team.name}}'s</strong> balance. Current balance of <strong>{{team.account_balance | dollars}}</strong> is available to spend immediately.</alert>
</div>

<div class="row-fluid">
<div class="span7">
<div ng-show="error">
Expand Down Expand Up @@ -70,7 +66,7 @@
<div class="span5">
<div class="well">
<h4 style="margin-top: 0;">Team Account</h4>
<p>This account is shared by the <strong>spenders</strong> of the team to create <strong>bounties</strong> and <strong>pledges</strong>.</p>
<p>This account is shared by the <strong>developers</strong> of the team to create <strong>bounties</strong> and <strong>pledges</strong>.</p>
</div>
</div>
</div>
Expand Down
11 changes: 2 additions & 9 deletions app/pages/teams/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ angular.module('app')
.when('/teams/:id/account', {
templateUrl: 'pages/teams/account.html',
controller: 'BaseTeamController',
resolve: $person,
reloadOnSearch: false
resolve: $person
});
})
.controller('TeamAccountController', function ($scope, $routeParams, $location, $api, $payment, $window) {
Expand All @@ -17,12 +16,6 @@ angular.module('app')
}
});

// pick off query string to show amount added to account
if ($location.search().funds_added) {
$scope.funds_added = parseInt($location.search().funds_added, 10) || undefined;
$location.search({}).replace();
}

$scope.pay_in = {
amount: 0,
item_number: "",
Expand All @@ -38,7 +31,7 @@ angular.module('app')
if ($scope.pay_in.amount && angular.isNumber($scope.pay_in.amount)) {
var payment_params = angular.copy($scope.pay_in);

payment_params.success_url = $window.location.href+"?funds_added="+$scope.pay_in.amount;
payment_params.success_url = $window.location.protocol + "//" + $window.location.host + "/teams/" + $routeParams.id + "?funds_added=" + $scope.pay_in.amount;
payment_params.cancel_url = $window.location.href;

$payment.process(payment_params, {
Expand Down
19 changes: 16 additions & 3 deletions app/pages/teams/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

angular.module('app')
.controller('BaseTeamController', function($scope, $location, $routeParams, $api) {
$scope.team = $api.team_get($routeParams.id);
$scope.team = $api.team_get($routeParams.id).then(function(team) {
team.owned_trackers = [];
team.unowned_trackers = [];

// set owned flag for all trackers
for (var i=0; i<team.trackers.length; i++) {
team.trackers[i].$owned = team.trackers[i].owner && (/^Team(?:::.*)*$/).test(team.trackers[i].owner.type) && team.trackers[i].owner.id === team.id;

// push to owned_trackers or unowned_trackers
(team.trackers[i].$owned ? team.owned_trackers : team.unowned_trackers).push(team.trackers[i]);
}

return team;
});

$scope.set_team = function(team) {
$scope.team = team;
Expand All @@ -25,7 +38,7 @@ angular.module('app')
if (members[i].id === $scope.current_person.id) {
$scope.is_member = true;
$scope.is_admin = members[i].is_admin;
$scope.is_spender = members[i].is_spender;
$scope.is_developer = members[i].is_developer;
$scope.is_public = members[i].is_public;
break;
}
Expand All @@ -35,7 +48,7 @@ angular.module('app')
// explicitly set to false if the logged in user is not part of the team
$scope.is_member = $scope.is_member || false;
$scope.is_admin = $scope.is_admin || false;
$scope.is_spender = $scope.is_spender || false;
$scope.is_developer = $scope.is_developer || false;
$scope.is_public = $scope.is_public || false;
});

Expand Down
12 changes: 12 additions & 0 deletions app/pages/teams/directives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

angular.module('app').
directive('teamTrackerThumbnails', function() {
return {
restrict: "E",
template: '<ul class="thumbnails team-tracker-thumbnails"><li ng-repeat="tracker in trackers" class="span2"><a class="thumbnail text-center" ng-href="/trackers/{{tracker.slug}}"><img ng-src="{{tracker.medium_image_url}}"/><span>{{tracker.name}}</span></a></li></ul>',
scope: {
trackers: "="
}
};
});
4 changes: 2 additions & 2 deletions app/pages/teams/join.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ <h1 style="margin-top: 0;">Join <a ng-href="teams/{{team.slug}}">{{team.name}}</
<p class="lead">You were invited to join this team with the following permissions:</p>

<div ng-class="{ muted: !permissions.public, 'text-success': permissions.public }"><strong>Public</strong>: displayed as a member of {{team.name}}</div>
<div ng-class="{ muted: !permissions.spender, 'text-success': permissions.spender }"><strong>Spender</strong>: use the team account to create bounties</div>
<div ng-class="{ muted: !permissions.admin, 'text-success': permissions.admin }"><strong>Administrative</strong>: add/remove team members, fund team account</div>
<div ng-class="{ muted: !permissions.developer, 'text-success': permissions.developer }"><strong>Developer</strong>: create bounties/pledges from team account, change team info, add/remove projects</div>
<div ng-class="{ muted: !permissions.admin, 'text-success': permissions.admin }"><strong>Administrative</strong>: add/remove team members, change team info, fund team account</div>
<br />

<form name="form" class="form-inline" ng-submit="accept()" style="margin-bottom: 0;">
Expand Down
4 changes: 2 additions & 2 deletions app/pages/teams/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ angular.module('app')

$scope.permissions = {
public: $routeParams.public === 'false' || true,
spender: $routeParams.spender === 'true' || false,
developer: $routeParams.developer === 'true' || false,
admin: $routeParams.admin === 'true' || false
};

$scope.accept = function() {
$api.team_invite_accept($routeParams.id, $routeParams.token).then(function() {
$location.url("/teams/"+$routeParams.id+"/members").replace();
$location.url("/teams/"+$routeParams.id).replace();
});
};
});
14 changes: 7 additions & 7 deletions app/pages/teams/manage_members.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3 style="margin-bottom: 0;">Members</h3>
<tr>
<th style="width: 30%;">Username</th>
<th style="width: 10%; text-align: center;">Public</th>
<th style="width: 10%; text-align: center;">Spender</th>
<th style="width: 10%; text-align: center;">Developer</th>
<th style="width: 10%; text-align: center;">Admin</th>
<th style="width: 10%; text-align: center;"></th>
</tr>
Expand All @@ -44,7 +44,7 @@ <h3 style="margin-bottom: 0;">Members</h3>
<input type="checkbox" ng-model="member.is_public" ng-change="member_changed(member)" ng-disabled="member.$saving" />
</td>
<td style="text-align: center;">
<input type="checkbox" ng-model="member.is_spender" ng-change="member_changed(member)" ng-disabled="member.$saving" />
<input type="checkbox" ng-model="member.is_developer" ng-change="member_changed(member)" ng-disabled="member.$saving" />
</td>
<td style="text-align: center;">
<input type="checkbox" ng-model="member.is_admin" ng-change="member_changed(member)" ng-disabled="member.$saving || (is_admin && current_person.id == member.id)" />
Expand Down Expand Up @@ -85,7 +85,7 @@ <h3 style="margin-bottom: 0;">Pending Members</h3>
</td>

<td style="text-align: center; cursor: default;"><input type="checkbox" ng-checked="invite.public" disabled /></td>
<td style="text-align: center; cursor: default;"><input type="checkbox" ng-checked="invite.spender" disabled /></td>
<td style="text-align: center; cursor: default;"><input type="checkbox" ng-checked="invite.developer" disabled /></td>
<td style="text-align: center; cursor: default;"><input type="checkbox" ng-checked="invite.admin" disabled /></td>

<td style="text-align: center;"><button ng-click="team_invite_reject(invite)" class="btn btn-mini btn-block" tooltip="Cancel Invite"><i class="icon-remove"></i></button></td>
Expand All @@ -101,7 +101,7 @@ <h3 style="margin-bottom: 0;">Add Member</h3>
<tr>
<th style="width: 30%;">Email</th>
<th style="width: 10%; text-align: center;">Public</th>
<th style="width: 10%; text-align: center;">Spender</th>
<th style="width: 10%; text-align: center;">Developer</th>
<th style="width: 10%; text-align: center;">Admin</th>
<th style="width: 10%; text-align: center;"></th>
</tr>
Expand All @@ -112,7 +112,7 @@ <h3 style="margin-bottom: 0;">Add Member</h3>
<td><input style="margin-bottom: 0;" type="email" name="email" class="span12" ng-model="new_member.email" ng-change="validate_new_member_email()" placeholder="Email address" /></td>

<td style="text-align: center;"><input type="checkbox" ng-model="new_member.public" /></td>
<td style="text-align: center;"><input type="checkbox" ng-model="new_member.spender" /></td>
<td style="text-align: center;"><input type="checkbox" ng-model="new_member.developer" /></td>
<td style="text-align: center;"><input type="checkbox" ng-model="new_member.admin" /></td>

<td style="text-align: center;">
Expand All @@ -132,8 +132,8 @@ <h3 style="margin-bottom: 0;">Add Member</h3>
<div class="well">
<h4>Public</h4>
<p>Publicly displayed as a member of {{team.name}} on the <a ng-href="/teams/{{team.slug}}/members">members</a> tab.</p>
<h4>Spender</h4>
<p>Authorized to <strong>spend money</strong> from the {{team.name}} account.</p>
<h4>Developer</h4>
<p>Authorized to <strong>spend money</strong> from the team's account and <strong>add/remove projects</strong> that the team maintains and/or uses.</p>
<h4>Admin</h4>
<p>Can <strong>add/remove projects and members</strong> to the team, as well as <strong>assign roles</strong> to members.</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/pages/teams/manage_members.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ angular.module('app')
$scope.update_member = function(member) {
var payload = {
admin: member.is_admin,
spender: member.is_spender,
developer: member.is_developer,
public: member.is_public
};

Expand All @@ -52,7 +52,7 @@ angular.module('app')

if (member.id === $scope.current_person.id) {
$scope.is_admin = member.is_admin;
$scope.is_spender = member.is_spender;
$scope.is_developer = member.is_developer;
$scope.is_public = member.is_public;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ angular.module('app')
email: "",
public: true,
admin: false,
spender: false,
developer: true,
registered: false
};

Expand Down
32 changes: 32 additions & 0 deletions app/pages/teams/partials/add_projects_box.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="well">
<h4>Add a Project</h4>
<p>Add a fucking project</p>

<form class="form-horizontal" style="margin: 30px 0 0 0;">
<div class="control-group">
<label class="control-label" style="width:inherit">URL:</label>

<div class="controls" style="margin-left:70px">
<input ng-model="search_query" type="text" class="span12" placeholder="https://github.com/.../issues/123" />
</div>
</div>

<div class="control-group">
<label class="control-label" style="width:inherit">Amount:</label>

<div class="controls" style="margin-left:70px">
<div class="input-prepend">
<span class="add-on">$</span>
<input ng-model="bounty_amount" type="number" class="span6" placeholder="30.00" />
</div>
</div>
</div>

<div class="control-group">
<div class="controls" style="margin-left:70px;">
<button ng-click="submit_search(search_query, bounty_amount)" class="btn btn-primary">Post Bounty
</button>
</div>
</div>
</form>
</div>
12 changes: 8 additions & 4 deletions app/pages/teams/partials/infobox.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ <h4 style="margin-top: 0;">Your Membership</h4>
<input type="checkbox" ng-checked="is_public" style="cursor: default;" disabled />
</label>
<label class="checkbox">
<span>can spend from team account</span>
<input type="checkbox" ng-checked="is_spender" style="cursor: default;" disabled />
<span>can modify team settings</span>
<input type="checkbox" ng-checked="is_admin || is_developer" style="cursor: default;" disabled />
</label>
<label class="checkbox">
<span>administrative privileges</span>
<span>can manage team projects</span>
<input type="checkbox" ng-checked="is_admin || is_developer" style="cursor: default;" disabled />
</label>
<label class="checkbox">
<span>can manage team members</span>
<input type="checkbox" ng-checked="is_admin" style="cursor: default;" disabled />
</label>
</div>

<!-- Account Balance -->
<div class="text-center" ng-show="is_spender || is_admin">
<div class="text-center" ng-show="is_developer || is_admin">
<h4>Team Account Balance</h4>
<strong>{{team.account_balance | currency}}</strong>
</div>
Expand Down
32 changes: 32 additions & 0 deletions app/pages/teams/partials/post_bounty_box.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="well">
<h4>Post a Bounty</h4>
<p>Paste the URL to an issue and enter an amount.</p>

<form class="form-horizontal" style="margin: 30px 0 0 0;">
<div class="control-group">
<label class="control-label" style="width:inherit">URL:</label>

<div class="controls" style="margin-left:70px">
<input ng-model="search_query" type="text" class="span12" placeholder="https://github.com/.../issues/123" />
</div>
</div>

<div class="control-group">
<label class="control-label" style="width:inherit">Amount:</label>

<div class="controls" style="margin-left:70px">
<div class="input-prepend">
<span class="add-on">$</span>
<input ng-model="bounty_amount" type="number" class="span6" placeholder="30.00" />
</div>
</div>
</div>

<div class="control-group">
<div class="controls" style="margin-left:70px;">
<button ng-click="submit_search(search_query, bounty_amount)" class="btn btn-primary">Post Bounty
</button>
</div>
</div>
</form>
</div>
Loading

0 comments on commit 1964755

Please sign in to comment.