mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Merge branch 'origin-paglias-fix-guilds' into develop
Conflicts: public/css/index.styl
This commit is contained in:
@@ -128,6 +128,13 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
||||
}
|
||||
|
||||
$scope.join = function(group){
|
||||
// If we're accepting an invitation, we don't have the actual group object, but a faux group object (for performance
|
||||
// purposes) {id, name}. Let's trick ngResource into thinking we have a group, so we can call the same $join
|
||||
// function (server calls .attachGroup(), which finds group by _id and handles this properly)
|
||||
if (group.id && !group._id) {
|
||||
group = new Groups.Group({_id:group.id});
|
||||
}
|
||||
|
||||
group.$join(function(saved){
|
||||
//$scope.groups.guilds.push(saved);
|
||||
alert('Joined guild, refresh page to see changes')
|
||||
@@ -140,6 +147,14 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
||||
// if (~i) $scope.groups.guilds.splice(i, 1);
|
||||
alert('Left guild, refresh page to see changes')
|
||||
}
|
||||
|
||||
$scope.reject = function(guild){
|
||||
var i = _.findIndex(User.user.invitations.guilds, {id:guild.id});
|
||||
if (~i){
|
||||
User.user.invitations.guilds.splice(i, 1);
|
||||
User.set('invitations.guilds', User.user.invitations.guilds);
|
||||
}
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
@@ -272,8 +272,13 @@ api.invite = function(req, res, next) {
|
||||
}
|
||||
|
||||
function sendInvite (){
|
||||
if(group.type === 'guild'){
|
||||
invite.invitations.guilds.push({id: group._id, name: group.name});
|
||||
}else{
|
||||
//req.body.type in 'guild', 'party'
|
||||
invite.invitations.party = {id: group._id, name: group.name}
|
||||
}
|
||||
|
||||
invite.save();
|
||||
Group.findById(group._id)
|
||||
.populate('members', partyFields).exec(function(err, saved){
|
||||
|
||||
@@ -87,7 +87,7 @@ var UserSchema = new Schema({
|
||||
/* FIXME remove?*/
|
||||
|
||||
invitations: {
|
||||
guilds: Array,
|
||||
guilds: {type: Array, 'default': []},
|
||||
party: Schema.Types.Mixed
|
||||
},
|
||||
items: {
|
||||
|
||||
@@ -17,7 +17,7 @@ ul.nav.nav-tabs
|
||||
// {#with _user.invitations.party as :party}
|
||||
h2 You're Invited To {{user.invitations.party.name}}
|
||||
a.btn.btn-success(data-type='party', ng-click='join(user.invitations.party)') Accept
|
||||
a.btn.btn-danger(ng-click='reject(group)') Reject
|
||||
a.btn.btn-danger(ng-click='reject()') Reject
|
||||
// {/}
|
||||
div(ng-hide='user.invitations.party', ng-controller='PartyCtrl')
|
||||
h2 Create A Party
|
||||
@@ -39,8 +39,8 @@ ul.nav.nav-tabs
|
||||
.tab-pane.active#groups-public-guilds
|
||||
div(ng-repeat='invitation in user.invitations.guilds')
|
||||
h3 You're Invited To {{invitation.name}}
|
||||
a.btn.btn-success(data-type='guild', ng-click='join(group)') Accept
|
||||
a.btn.btn-danger(x-bind='click:rejectInvitation') Reject
|
||||
a.btn.btn-success(data-type='guild', ng-click='join(invitation)') Accept
|
||||
a.btn.btn-danger(ng-click='reject(invitation)') Reject
|
||||
// Public Groups
|
||||
.options-group.option-large.whatever-options
|
||||
input.option-content(type='text',ng-model='guildSearch', placeholder='Search')
|
||||
|
||||
Reference in New Issue
Block a user