mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-08 05:25:21 +00:00
Add challenges to groups. Fixed isMemberOfGuild check
This commit is contained in:
parent
12eba7bbe9
commit
eff2f04b45
5 changed files with 38 additions and 33 deletions
|
|
@ -150,8 +150,8 @@ window.habitrpg = angular.module('habitrpg',
|
|||
url: '/:gid',
|
||||
templateUrl: 'partials/options.social.guilds.detail.html',
|
||||
title: env.t('titleGuilds'),
|
||||
controller: ['$scope', 'Groups', 'Chat', '$stateParams', 'Members',
|
||||
function($scope, Groups, Chat, $stateParams, Members){
|
||||
controller: ['$scope', 'Groups', 'Chat', '$stateParams', 'Members', 'Challenges',
|
||||
function($scope, Groups, Chat, $stateParams, Members, Challenges){
|
||||
Groups.Group.get($stateParams.gid)
|
||||
.then(function (response) {
|
||||
$scope.group = response.data.data;
|
||||
|
|
@ -164,6 +164,10 @@ window.habitrpg = angular.module('habitrpg',
|
|||
.then(function (response) {
|
||||
$scope.group.invites = response.data.data;
|
||||
});
|
||||
Challenges.getGroupChallenges($scope.group._id)
|
||||
.then(function (response) {
|
||||
$scope.group.challenges = response.data.data;
|
||||
});
|
||||
});
|
||||
}]
|
||||
})
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
// If the group is a guild, just check for an intersection with the
|
||||
// current user's guilds, rather than checking the members of the group.
|
||||
if(group.type === 'guild') {
|
||||
var guilds = Groups.myGuilds();
|
||||
return _.detect(guilds, function(g) { return g._id === group._id });
|
||||
return _.detect(User.user.guilds, function(guildId) { return guildId === group._id });
|
||||
}
|
||||
|
||||
// Similarly, if we're dealing with the user's current party, return true.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$rootScope', '$state', '$location', '$compile', 'Analytics',
|
||||
function($scope, Groups, User, Challenges, $rootScope, $state, $location, $compile, Analytics) {
|
||||
$scope.groups = {
|
||||
guilds: Groups.myGuilds(),
|
||||
public: Groups.publicGuilds(),
|
||||
guilds: [],
|
||||
public: [],
|
||||
};
|
||||
|
||||
Groups.myGuilds()
|
||||
|
|
@ -88,8 +88,9 @@ habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$r
|
|||
|
||||
var html, title;
|
||||
|
||||
Challenges.Challenge.query(function(challenges) {
|
||||
challenges = _.pluck(_.filter(challenges, function(c) {
|
||||
Challenges.getGroupChallenges(group._id)
|
||||
.then(function(response) {
|
||||
var challenges = _.pluck(_.filter(response.data.data, function(c) {
|
||||
return c.group._id == group._id;
|
||||
}), '_id');
|
||||
|
||||
|
|
|
|||
|
|
@ -84,31 +84,32 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
|||
title = window.env.t('leavePartyCha');
|
||||
|
||||
//TODO: Move this to challenge service
|
||||
//@TODO: Implement this when we convert front-end challenge service
|
||||
// Challenges.Challenge.query(function(challenges) {
|
||||
// challenges = _.pluck(_.filter(challenges, function(c) {
|
||||
// return c.group._id == group._id;
|
||||
// }), '_id');
|
||||
// if (_.intersection(challenges, User.user.challenges).length > 0) {
|
||||
// html = $compile(
|
||||
// '<a ng-controller="GroupsCtrl" ng-click="leave(\'remove-all\')">' + window.env.t('removeTasks') + '</a><br/>\n<a ng-click="leave(\'keep-all\')">' + window.env.t('keepTasks') + '</a><br/>\n<a ng-click="leave(\'cancel\')">' + window.env.t('cancel') + '</a><br/>'
|
||||
// )($scope);
|
||||
// title = window.env.t('leavePartyCha');
|
||||
// } else {
|
||||
// html = $compile(
|
||||
// '<a ng-controller="GroupsCtrl" ng-click="leave(\'keep-all\')">' + window.env.t('confirm') + '</a><br/>\n<a ng-click="leave(\'cancel\')">' + window.env.t('cancel') + '</a><br/>'
|
||||
// )($scope);
|
||||
// title = window.env.t('leaveParty');
|
||||
// }
|
||||
Challenges.getGroupChallenges(group._id)
|
||||
.then(function(response) {
|
||||
var challenges = _.pluck(_.filter(response.data.data, function(c) {
|
||||
return c.group._id == group._id;
|
||||
}), '_id');
|
||||
|
||||
$scope.popoverEl.popover('destroy').popover({
|
||||
html: true,
|
||||
placement: 'top',
|
||||
trigger: 'manual',
|
||||
title: title,
|
||||
content: html
|
||||
}).popover('show');
|
||||
// });
|
||||
if (_.intersection(challenges, User.user.challenges).length > 0) {
|
||||
html = $compile(
|
||||
'<a ng-controller="GroupsCtrl" ng-click="leave(\'remove-all\')">' + window.env.t('removeTasks') + '</a><br/>\n<a ng-click="leave(\'keep-all\')">' + window.env.t('keepTasks') + '</a><br/>\n<a ng-click="leave(\'cancel\')">' + window.env.t('cancel') + '</a><br/>'
|
||||
)($scope);
|
||||
title = window.env.t('leavePartyCha');
|
||||
} else {
|
||||
html = $compile(
|
||||
'<a ng-controller="GroupsCtrl" ng-click="leave(\'keep-all\')">' + window.env.t('confirm') + '</a><br/>\n<a ng-click="leave(\'cancel\')">' + window.env.t('cancel') + '</a><br/>'
|
||||
)($scope);
|
||||
title = window.env.t('leaveParty');
|
||||
}
|
||||
|
||||
$scope.popoverEl.popover('destroy').popover({
|
||||
html: true,
|
||||
placement: 'top',
|
||||
trigger: 'manual',
|
||||
title: title,
|
||||
content: html
|
||||
}).popover('show');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.clickStartQuest = function () {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ angular.module('habitrpg')
|
|||
}
|
||||
|
||||
function markChatSeen (groupId) {
|
||||
if (User.user.newMessages) delete User.user.newMessages[gid];
|
||||
if (User.user.newMessages) delete User.user.newMessages[groupId];
|
||||
return $http({
|
||||
method: 'POST',
|
||||
url: apiV3Prefix + '/groups/' + groupId + '/chat/seen',
|
||||
|
|
|
|||
Loading…
Reference in a new issue