Fixed quest drop modal (#7377)

* Fixed quest drop modal

* Fixed broken party test
This commit is contained in:
Keith Holliday
2016-05-21 11:21:39 +01:00
committed by Matteo Pagliazzi
parent d36c514c06
commit f4ca97ffc3
4 changed files with 23 additions and 13 deletions

View File

@@ -51,7 +51,9 @@ describe("Party Controller", function() {
var syncParty = sinon.stub(groups.Group, 'syncParty')
syncParty.returns(Promise.resolve(groupResponse));
$controller('PartyCtrl', { $scope: scope, $state: state, User: User });
expect(state.is).to.be.calledOnce; // ensure initialization worked as desired
// @TODO: I have update the party ctrl to sync the user whenever it is called rather than only on the party page
// Since I have cached the promise, this should not be a performance issue, but let's keep this test here in case anything breaks.
// expect(state.is).to.be.calledOnce; // ensure initialization worked as desired
});
};

View File

@@ -127,7 +127,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', {controller:'PartyCtrl',size:'sm'});
$rootScope.openModal('questDrop', {controller:'PartyCtrl', size:'sm'});
} else if (after.notificationType === 'Mystery') {
text = Content.gear.flat[after.key].text();
Notification.drop(env.t('messageDropMysteryItem', {dropText: text}), after);

View File

@@ -11,7 +11,6 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
$scope.loadWidgets = Social.loadWidgets;
if ($state.is('options.social.party')) {
Groups.Group.syncParty()
.then(function successCallback(group) {
$rootScope.party = $scope.group = group;
@@ -19,7 +18,6 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
}, function errorCallback(response) {
$rootScope.party = $scope.group = $scope.newGroup = { type: 'party' };
});
}
function checkForNotifications () {
// Checks if user's party has reached 2 players for the first time.
@@ -148,6 +146,15 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
User.set({'invitations.party':{}});
}
$scope.questInit = function() {
var key = $rootScope.selectedQuest.key;
Quests.initQuest(key).then(function() {
$rootScope.selectedQuest = undefined;
$scope.$close();
});
};
$scope.questCancel = function(){
if (!confirm(window.env.t('sureCancel'))) return;

View File

@@ -104,7 +104,8 @@ script(type='text/ng-template', id='modals/questDrop.html')
.quest-icon(class='inventory_quest_scroll_{{::selectedQuest.key}}')
h4!=env.t('leveledUpReceivedQuest', {level:'{{user.stats.lvl}}'})
.row(style='margin-top:2em')
button.btn.btn-primary(ng-click='inviteOrStartParty(group); $close()', ng-if='!party.members')=env.t('startAParty')
button.btn.btn-primary(ng-click='inviteOrStartParty(party); $close()', ng-if='!User.user.party._id')=env.t('startAParty')
button.btn.btn-primary(ng-click='inviteOrStartParty(party); $close()', ng-if='!User.user.party._id && !party.members')=env.t('battleWithFriends')
button.btn.btn-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty')
button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater')
.modal-footer(style='margin-top:0', ng-init='loadWidgets()')