mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
quests: add abort feature
This commit is contained in:
@@ -300,6 +300,12 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
||||
//User.user.invitations.party = undefined;
|
||||
User.set({'invitations.party':{}});
|
||||
}
|
||||
|
||||
$scope.questAbort = function(){
|
||||
if (!confirm("Are you sure you want to abort this mission? It will abort it for everyone in your party.")) return;
|
||||
if (!confirm("Are you double sure? Make sure they won't hate you forever!")) return;
|
||||
$rootScope.party.$questAbort();
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ angular.module('groupServices', ['ngResource']).
|
||||
leave: {method: "POST", url: API_URL + '/api/v2/groups/:gid/leave'},
|
||||
invite: {method: "POST", url: API_URL + '/api/v2/groups/:gid/invite'},
|
||||
questAccept: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questAccept'},
|
||||
questReject: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questReject'}
|
||||
questReject: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questReject'},
|
||||
questAbort: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questAbort'}
|
||||
});
|
||||
|
||||
// Defer loading everything until they're requested
|
||||
|
||||
@@ -491,5 +491,21 @@ api.questReject = function(req, res, next) {
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
function questAbort(){}
|
||||
api.questAbort = function(req, res, next){
|
||||
var group = res.locals.group;
|
||||
var parallel = _.transform(group.members, function(m,v){
|
||||
m.push(function(cb){
|
||||
v.party.quest = {};
|
||||
v.party.quest.tally.collection = {};v.markModified('party.quest');
|
||||
v._v++;
|
||||
v.save(cb);
|
||||
})
|
||||
});
|
||||
group.quest = {};
|
||||
parallel.push(function(cb){group.save(cb);});
|
||||
async.parallel(parallel,function(err){
|
||||
if (err) return res.json(500,{err:err});
|
||||
res.json(group);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ router.post('/groups/:gid/invite', auth.auth, groups.attachGroup, groups.invite)
|
||||
router.post('/groups/:gid/removeMember', auth.auth, groups.attachGroup, groups.removeMember);
|
||||
router.post('/groups/:gid/questAccept', auth.auth, groups.attachGroupPopulated, groups.questAccept); // query={key} (optional. if provided, trigger new invite, if not, accept existing invite)
|
||||
router.post('/groups/:gid/questReject', auth.auth, groups.attachGroupPopulated, groups.questReject);
|
||||
router.post('/groups/:gid/questAbort', auth.auth, groups.attachGroupPopulated, groups.questAbort);
|
||||
|
||||
//GET /groups/:gid/chat
|
||||
router.post('/groups/:gid/chat', auth.auth, groups.attachGroup, groups.postChat);
|
||||
|
||||
@@ -36,6 +36,7 @@ a.pull-right.gem-wallet(popover-trigger='mouseenter', popover-title='Guild Bank'
|
||||
i.icon-heart
|
||||
| {{group.quest.progress.hp | number:0}} / {{Content.quests[group.quest.key].stats.hp}}
|
||||
p {{Content.quests[group.quest.key].notes}}
|
||||
button.btn.btn-mini.btn-danger(ng-click='questAbort()') Abort
|
||||
|
||||
// ------ Information -------
|
||||
.modal.inline-modal
|
||||
|
||||
Reference in New Issue
Block a user