Add missing text to buttons on the party / guild invite modal - Fixes #8391 (#8402)

* Fix missing text in party / guild invite modal

* add tests and abstract logic

* use translation lib for test
This commit is contained in:
ean
2017-01-19 13:17:38 -06:00
committed by Keith Holliday
parent ffa561473c
commit 74c9a1b02d
5 changed files with 55 additions and 38 deletions

View File

@@ -240,6 +240,5 @@ describe('Groups Controller', function() {
describe.skip("clickMember", function() { }); describe.skip("clickMember", function() { });
describe.skip("removeMember", function() { }); describe.skip("removeMember", function() { });
describe.skip("confirmRemoveMember", function() { }); describe.skip("confirmRemoveMember", function() { });
describe.skip("openInviteModal", function() { });
describe.skip("quickReply", function() { }); describe.skip("quickReply", function() { });
}); });

View File

@@ -1,7 +1,7 @@
'use strict'; 'use strict';
describe('groupServices', function() { describe('groupServices', function() {
var $httpBackend, $http, groups, user; var $httpBackend, $http, groups, user, $rootScope;
var groupApiUrlPrefix = '/api/v3/groups'; var groupApiUrlPrefix = '/api/v3/groups';
beforeEach(function() { beforeEach(function() {
@@ -13,8 +13,10 @@ describe('groupServices', function() {
$provide.value('User', {user: user}); $provide.value('User', {user: user});
}); });
inject(function(_$httpBackend_, Groups, User) { inject(function(_$httpBackend_, _$rootScope_, Groups, User) {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
$rootScope.openModal = function() {}
groups = Groups; groups = Groups;
}); });
}); });
@@ -166,4 +168,33 @@ describe('groupServices', function() {
$httpBackend.flush() $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'));
});
}); });

View File

@@ -2,6 +2,7 @@
habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', '$q', 'User', 'Members', '$state', 'Notification', habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', '$q', 'User', 'Members', '$state', 'Notification',
function($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) { $scope.isMemberOfPendingQuest = function (userid, group) {
if (!group.quest || !group.quest.members) return false; if (!group.quest || !group.quest.members) return false;
if (group.quest.active) return false; // quest is started, not pending 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) { $scope.quickReply = function (uid) {
Members.selectMember(uid) Members.selectMember(uid)
.then(function (response) { .then(function (response) {

View File

@@ -221,18 +221,24 @@ angular.module('habitrpg')
function inviteOrStartParty (group) { function inviteOrStartParty (group) {
Analytics.track({'hitType':'event','eventCategory':'button','eventAction':'click','eventLabel':'Invite Friends'}); Analytics.track({'hitType':'event','eventCategory':'button','eventAction':'click','eventLabel':'Invite Friends'});
if (group && group.type === "party" || $location.$$path === "/options/groups/party") { var sendInviteText = window.env.t('sendInvitations');
group.type = 'party'; if (group.type !== 'party' && group.type !== 'guild') {
$location.path("/options/groups/party");
$rootScope.openModal('invite-party', { return console.log('Invalid group type.')
controller:'InviteToGroupCtrl',
resolve: {
injectedGroup: function(){ return group; }
}
});
} else {
$location.path("/options/groups/party");
} }
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 { return {

View File

@@ -87,7 +87,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter
h3.panel-title h3.panel-title
=env.t('members') =env.t('members')
span(ng-if='group.type=="party" && (group.onlineUsers || group.onlineUsers == 0)')= ' (' + env.t('onlineCount', {count: "{{group.onlineUsers}}"}) + ')' 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 .panel-body.modal-fixed-height
h4(ng-show='::group.memberCount === 1 && group.type === "party"')=env.t('partyEmpty') h4(ng-show='::group.memberCount === 1 && group.type === "party"')=env.t('partyEmpty')
@@ -179,4 +179,3 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter
group-approvals(ng-show="groupPanel == 'approvals'", ng-if="group.leader._id === user._id", group="group") group-approvals(ng-show="groupPanel == 'approvals'", ng-if="group.leader._id === user._id", group="group")
+groupSubscription +groupSubscription