From 0313170921a3391754d451cc5b3e40de97e0016e Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Tue, 21 Jul 2015 15:25:34 -0500 Subject: [PATCH] feat(quests): Invite party button --- website/public/js/controllers/groupsCtrl.js | 6 ++++-- website/public/js/controllers/inventoryCtrl.js | 9 +-------- .../public/js/controllers/notificationCtrl.js | 6 ++++-- website/public/js/services/questServices.js | 17 ++++++++++++++--- website/views/shared/modals/quests.jade | 3 ++- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/website/public/js/controllers/groupsCtrl.js b/website/public/js/controllers/groupsCtrl.js index 2cd61ad518..f42811b9b1 100644 --- a/website/public/js/controllers/groupsCtrl.js +++ b/website/public/js/controllers/groupsCtrl.js @@ -512,12 +512,14 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } ]) - .controller("PartyCtrl", ['$rootScope','$scope', 'Groups', 'Chat', 'User', 'Challenges', '$state', '$compile', 'Analytics', - function($rootScope,$scope, Groups, Chat, User, Challenges, $state, $compile, Analytics) { + .controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','Challenges','$state','$compile','Analytics','Quests', + function($rootScope,$scope,Groups,Chat,User,Challenges,$state,$compile,Analytics,Quests) { $scope.type = 'party'; $scope.text = window.env.t('party'); $scope.group = $rootScope.party = Groups.party(); $scope.newGroup = new Groups.Group({type:'party'}); + $scope.inviteOrStartParty = Groups.inviteOrStartParty; + $scope.questInit = Quests.questInit; if ($state.is('options.social.party')) { $scope.group.$syncParty(); // Sync party automatically when navigating to party page diff --git a/website/public/js/controllers/inventoryCtrl.js b/website/public/js/controllers/inventoryCtrl.js index 4bc97cbc42..e7e9aba457 100644 --- a/website/public/js/controllers/inventoryCtrl.js +++ b/website/public/js/controllers/inventoryCtrl.js @@ -17,6 +17,7 @@ habitrpg.controller("InventoryCtrl", $scope.questPopover = Quests.questPopover; $scope.showQuest = Quests.showQuest; $scope.closeQuest = Quests.closeQuest; + $scope.questInit = Quests.questInit; // count egg, food, hatchingPotion stack totals var countStacks = function(items) { return _.reduce(items,function(m,v){return m+v;},0);} @@ -146,14 +147,6 @@ habitrpg.controller("InventoryCtrl", User.user.ops.equip({params:{type: 'mount', key: egg + '-' + potion}}); } - $scope.questInit = function(){ - Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'quest','owner':true,'response':'accept','questName':$scope.selectedQuest.key}); - $rootScope.party.$questAccept({key:$scope.selectedQuest.key}, function(){ - $rootScope.party.$get(); - }); - $scope.closeQuest(); - } - $scope.getSeasonalShopArray = function(set){ var flatGearArray = _.toArray(Content.gear.flat); diff --git a/website/public/js/controllers/notificationCtrl.js b/website/public/js/controllers/notificationCtrl.js index 16214127bb..6a4f41df88 100644 --- a/website/public/js/controllers/notificationCtrl.js +++ b/website/public/js/controllers/notificationCtrl.js @@ -67,7 +67,9 @@ habitrpg.controller('NotificationCtrl', type = 'food'; } else if (after.type === 'HatchingPotion') { type = 'hatchingPotions'; - } else type = after.type.toLowerCase() + 's'; + } else { + type = after.type.toLowerCase() + 's'; + } if(!User.user.items[type][after.key]){ User.user.items[type][after.key] = 0; } @@ -88,7 +90,7 @@ habitrpg.controller('NotificationCtrl', Notification.drop(env.t('messageDropFood', {dropArticle: after.article, dropText: text, dropNotes: notes}), after); } else if (after.type === 'Quest') { $rootScope.selectedQuest = Content.quests[after.key]; - $rootScope.openModal('questDrop'); + $rootScope.openModal('questDrop', {controller:'PartyCtrl'}); } else { // Keep support for another type of drops that might be added Notification.drop(User.user._tmp.drop.dialog); diff --git a/website/public/js/services/questServices.js b/website/public/js/services/questServices.js index 1ca6995c38..fc6c241f5a 100644 --- a/website/public/js/services/questServices.js +++ b/website/public/js/services/questServices.js @@ -10,10 +10,11 @@ '$rootScope', 'Content', 'Groups', - 'User' + 'User', + 'Analytics' ]; - function questsFactory($rootScope,Content,Groups,User) { + function questsFactory($rootScope,Content,Groups,User,Analytics) { var user = User.user; @@ -84,12 +85,22 @@ $rootScope.selectedQuest = undefined; } + function questInit(){ + Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'quest','owner':true,'response':'accept','questName':$rootScope.selectedQuest.key}); + $rootScope.party.$questAccept({key:$rootScope.selectedQuest.key}, function(){ + $rootScope.party.$get(); + }); + $rootScope.$state.go('options.social.party'); + closeQuest(); + } + return { lockQuest: lockQuest, buyQuest: buyQuest, questPopover: questPopover, showQuest: showQuest, - closeQuest: closeQuest + closeQuest: closeQuest, + questInit: questInit } } }()); diff --git a/website/views/shared/modals/quests.jade b/website/views/shared/modals/quests.jade index be769625bd..165e0187e1 100644 --- a/website/views/shared/modals/quests.jade +++ b/website/views/shared/modals/quests.jade @@ -90,4 +90,5 @@ script(type='text/ng-template', id='modals/questDrop.html') p=env.t('dropQuestCongrats') .modal-footer button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater') - button.btn.btn-primary(ng-click='questInit(); $close()')=env.t('inviteParty') + button.btn.btn-primary(ng-click='inviteOrStartParty(group); $close()', ng-if='!party.members')=env.t('startAParty') + button.btn.btn-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty')