diff --git a/test/client-old/spec/controllers/groupCtrlSpec.js b/test/client-old/spec/controllers/groupCtrlSpec.js index 6a5819ec67..f45513c124 100644 --- a/test/client-old/spec/controllers/groupCtrlSpec.js +++ b/test/client-old/spec/controllers/groupCtrlSpec.js @@ -240,6 +240,5 @@ describe('Groups Controller', function() { describe.skip("clickMember", function() { }); describe.skip("removeMember", function() { }); describe.skip("confirmRemoveMember", function() { }); - describe.skip("openInviteModal", function() { }); describe.skip("quickReply", function() { }); }); diff --git a/test/client-old/spec/services/groupServicesSpec.js b/test/client-old/spec/services/groupServicesSpec.js index 5b4a88c996..19da1b554b 100644 --- a/test/client-old/spec/services/groupServicesSpec.js +++ b/test/client-old/spec/services/groupServicesSpec.js @@ -1,7 +1,7 @@ 'use strict'; describe('groupServices', function() { - var $httpBackend, $http, groups, user; + var $httpBackend, $http, groups, user, $rootScope; var groupApiUrlPrefix = '/api/v3/groups'; beforeEach(function() { @@ -13,8 +13,10 @@ describe('groupServices', function() { $provide.value('User', {user: user}); }); - inject(function(_$httpBackend_, Groups, User) { + inject(function(_$httpBackend_, _$rootScope_, Groups, User) { $httpBackend = _$httpBackend_; + $rootScope = _$rootScope_; + $rootScope.openModal = function() {} groups = Groups; }); }); @@ -166,4 +168,33 @@ describe('groupServices', function() { $httpBackend.flush() }); + + it('sets a "sendInviteText" property on a party to "Send Invitations"', function() { + var sendInviteText = window.env.t('sendInvitations'); + var party = { + type: 'party', + data: { + _id: '1234', + }, + }; + groups.inviteOrStartParty(party); + expect(party.sendInviteText).to.eql(sendInviteText); + }); + + it('sets a "sendInviteText" proptery on a guild to "Send Invitations +$3.00/month/user"', function() { + var sendInviteText = window.env.t('sendInvitations'); + var guild = { + type: 'guild', + data: { + _id: '12345', + }, + purchased: { + plan: { + customerId: '123', + }, + }, + }; + groups.inviteOrStartParty(guild); + expect(guild.sendInviteText).to.eql(sendInviteText + window.env.t('groupAdditionalUserCost')); + }); }); diff --git a/website/client-old/js/controllers/groupsCtrl.js b/website/client-old/js/controllers/groupsCtrl.js index 0a02248932..9ffc00027b 100644 --- a/website/client-old/js/controllers/groupsCtrl.js +++ b/website/client-old/js/controllers/groupsCtrl.js @@ -2,6 +2,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', '$q', 'User', 'Members', '$state', 'Notification', function($scope, $rootScope, Shared, Groups, $http, $q, User, Members, $state, Notification) { + $scope.inviteOrStartParty = Groups.inviteOrStartParty; $scope.isMemberOfPendingQuest = function (userid, group) { if (!group.quest || !group.quest.members) return false; if (group.quest.active) return false; // quest is started, not pending @@ -120,25 +121,6 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } }; - $scope.openInviteModal = function (group) { - if (group.type !== 'party' && group.type !== 'guild') { - return console.log('Invalid group type.') - } - - var sendInviteText = window.env.t('sendInvitations'); - if(group.purchased && group.purchased.plan && group.purchased.plan.customerId) sendInviteText += window.env.t('groupAdditionalUserCost'); - group.sendInviteText = sendInviteText; - - $rootScope.openModal('invite-' + group.type, { - controller:'InviteToGroupCtrl', - resolve: { - injectedGroup: function(){ - return group; - }, - } - }); - }; - $scope.quickReply = function (uid) { Members.selectMember(uid) .then(function (response) { diff --git a/website/client-old/js/services/groupServices.js b/website/client-old/js/services/groupServices.js index 3294cdad11..65f24cf6c3 100644 --- a/website/client-old/js/services/groupServices.js +++ b/website/client-old/js/services/groupServices.js @@ -220,19 +220,25 @@ angular.module('habitrpg') function inviteOrStartParty (group) { Analytics.track({'hitType':'event','eventCategory':'button','eventAction':'click','eventLabel':'Invite Friends'}); - - if (group && group.type === "party" || $location.$$path === "/options/groups/party") { - group.type = 'party'; - - $rootScope.openModal('invite-party', { - controller:'InviteToGroupCtrl', - resolve: { - injectedGroup: function(){ return group; } - } - }); - } else { - $location.path("/options/groups/party"); + + var sendInviteText = window.env.t('sendInvitations'); + if (group.type !== 'party' && group.type !== 'guild') { + $location.path("/options/groups/party"); + return console.log('Invalid group type.') } + + if(group.purchased && group.purchased.plan && group.purchased.plan.customerId) sendInviteText += window.env.t('groupAdditionalUserCost'); + + group.sendInviteText = sendInviteText; + + $rootScope.openModal('invite-' + group.type, { + controller:'InviteToGroupCtrl', + resolve: { + injectedGroup: function() { + return group; + }, + }, + }); } return { diff --git a/website/views/options/social/group.jade b/website/views/options/social/group.jade index 1bdf77128c..0a39f2a8b2 100644 --- a/website/views/options/social/group.jade +++ b/website/views/options/social/group.jade @@ -19,7 +19,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter li a(ng-click="groupPanel = 'subscription'", ng-show='group.leader._id === user._id && group.purchased.plan.customerId')=env.t('subscription') a(ng-click="groupPanel = 'subscription'", ng-show='group.leader._id === user._id && !group.purchased.plan.customerId')=env.t('upgradeTitle') - + .tab-content .tab-pane.active @@ -87,7 +87,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter h3.panel-title =env.t('members') span(ng-if='group.type=="party" && (group.onlineUsers || group.onlineUsers == 0)')= ' (' + env.t('onlineCount', {count: "{{group.onlineUsers}}"}) + ')' - button.pull-right.btn.btn-primary(ng-click="openInviteModal(group)")=env.t("inviteFriends") + button.pull-right.btn.btn-primary(ng-click="inviteOrStartParty(group)")=env.t("inviteFriends") .panel-body.modal-fixed-height h4(ng-show='::group.memberCount === 1 && group.type === "party"')=env.t('partyEmpty') @@ -173,10 +173,9 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter +chatMessages() h4(ng-if='group.chat.length < 1 && group.type === "party"')=env.t('partyChatEmpty') h4(ng-if='group.chat.length < 1 && group.type === "guild"')=env.t('guildChatEmpty') - + group-tasks(ng-show="groupPanel == 'tasks'") group-approvals(ng-show="groupPanel == 'approvals'", ng-if="group.leader._id === user._id", group="group") +groupSubscription -