Merge branch 'develop' into blade-Finish_weeklies_pr

This commit is contained in:
Blade Barringer
2015-06-04 12:45:23 -05:00
9 changed files with 95 additions and 9 deletions

View File

@@ -116,5 +116,8 @@
"sendGiftFromBalance": "From Balance",
"sendGiftPurchase": "Purchase",
"sendGiftMessagePlaceholder": "Personal message (optional)",
"sendGiftSubscription": "<%= months %> Month(s): $<%= price %>"
"sendGiftSubscription": "<%= months %> Month(s): $<%= price %>",
"inviteFriends": "Invite Friends",
"startAParty": "Start a Party",
"addToParty": "Add someone to your party"
}

View File

@@ -118,5 +118,7 @@
"resubscribe": "Resubscribe",
"promoCode": "Promo Code",
"promoCodeApplied": "Promo Code Applied! Check your inventory",
"promoPlaceholder": "Enter Promotion Code"
"promoPlaceholder": "Enter Promotion Code",
"couponText": "We sometimes have events and give out coupon codes for special gear. (eg, those who stop by our Wondercon booth)",
"displayInviteToPartyWhenPartyIs1": "Display Invite To Party button when party has 1 member."
}

View File

@@ -0,0 +1,56 @@
'use strict';
describe('Header Controller', function() {
var scope, ctrl, user, $location, $rootScope;
beforeEach(function() {
module(function($provide) {
$provide.value('User', {});
});
inject(function(_$rootScope_, _$controller_, _$location_){
user = specHelper.newUser();
user._id = "unique-user-id"
scope = _$rootScope_.$new();
$rootScope = _$rootScope_;
$location = _$location_;
// Load RootCtrl to ensure shared behaviors are loaded
_$controller_('RootCtrl', {$scope: scope, User: {user: user}});
ctrl = _$controller_('HeaderCtrl', {$scope: scope, User: {user: user}});
});
});
context('inviteOrStartParty', function(){
beforeEach(function(){
sinon.stub($location, 'path');
sinon.stub($rootScope, 'openModal');
});
afterEach(function(){
$location.path.restore();
$rootScope.openModal.restore();
});
it('redirects to party page if user does not have a party', function(){
var group = {};
scope.inviteOrStartParty(group);
expect($location.path).to.be.calledWith("/options/groups/party");
expect($rootScope.openModal).to.not.be.called;
});
it('Opens invite-friends modal if user has a party', function(){
var group = {
type: 'party'
};
scope.inviteOrStartParty(group);
expect($rootScope.openModal).to.be.calledOnce;
expect($location.path).to.not.be.called;
});
});
});

View File

@@ -173,3 +173,7 @@ header .hero-stats
background-color: darken($color-herobox, 4%)
border-right: 1px solid darken($color-herobox, 12%)
button.party-invite
right: 10px;
position: absolute;
top: 55px;

View File

@@ -1,7 +1,7 @@
"use strict";
habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User',
function($scope, Groups, User) {
habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User', '$location', '$rootScope',
function($scope, Groups, User, $location, $rootScope) {
$scope.Math = window.Math;
$scope.user = User.user;
@@ -16,6 +16,19 @@ habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User',
$scope.$watch('user.party.orderAscending', triggerResort);
});
$scope.inviteOrStartParty = function(group) {
if (group.type === "party") {
$rootScope.openModal('invite-friends', {
controller:'InviteToGroupCtrl',
resolve: {
injectedGroup: function(){ return group; }
}
});
} else {
$location.path("/options/groups/party");
}
}
function resortParty() {
var result = _.sortBy(
_.filter($scope.party.members, function(member){

View File

@@ -321,6 +321,7 @@ var UserSchema = new Schema({
advancedCollapsed: {type: Boolean, 'default': false},
toolbarCollapsed: {type:Boolean, 'default':false},
background: String,
displayInviteToPartyWhenPartyIs1: { type:Boolean, 'default':true},
webhooks: {type: Schema.Types.Mixed, 'default': {}},
// For this fields make sure to use strict comparison when searching for falsey values (=== false)
// As users who didn't login after these were introduced may have them undefined/null

View File

@@ -66,6 +66,10 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
label
input(type='checkbox', ng-model='user.preferences.dailyDueDefaultView', ng-change='set({"preferences.dailyDueDefaultView": user.preferences.dailyDueDefaultView?true: false})')
span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('dailyDueDefaultViewPop'))=env.t('dailyDueDefaultView')
.checkbox(ng-if='party.memberCount === 1')
label
input(type='checkbox', ng-model='user.preferences.displayInviteToPartyWhenPartyIs1', ng-change='set({"preferences.displayInviteToPartyWhenPartyIs1": user.preferences.displayInviteToPartyWhenPartyIs1 ? true : false})')
span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('displayInviteToPartyWhenPartyIs1'))=env.t('displayInviteToPartyWhenPartyIs1')
// button.btn.btn-default(ng-click='showTour()', popover-placement='right', popover-trigger='mouseenter', popover=env.t('restartTour'))= env.t('showTour')
button.btn.btn-default(ng-click='showBailey()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('showBaileyPop'))= env.t('showBailey')
button.btn.btn-default(ng-click='openRestoreModal()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('fixValPop'))= env.t('fixVal')

View File

@@ -60,7 +60,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter
.panel-heading
h3.panel-title
=env.t('members')
button.pull-right.btn.btn-primary(ng-click="openInviteModal(group)")=env.t('inviteFriends')
button.pull-right.btn.btn-primary(ng-click="openInviteModal(group)")=env.t("inviteFriends")
.panel-body.modal-fixed-height
div.form-group(ng-if='::group.type=="party"')
p=env.t('partyList')

View File

@@ -32,5 +32,8 @@
// party
span(ng-controller='PartyCtrl')
button.party-invite.pull-right.btn.btn-primary(ng-click="inviteOrStartParty(group)",
ng-if="(!party.members || party.memberCount === 1) && user.preferences.displayInviteToPartyWhenPartyIs1",
popover="{{!party.members ? env.t('startAParty') : env.t('addToParty')}}", popover-placement="left", popover-trigger="mouseenter")=env.t("inviteFriends")
.herobox-wrap(ng-repeat='profile in partyMinusSelf')
+herobox()