bring client side changes and cleanup

This commit is contained in:
Matteo Pagliazzi 2015-02-09 20:35:41 +01:00
parent b069529fe8
commit fdf0c1d3ec
4 changed files with 33 additions and 29 deletions

View file

@ -65,15 +65,12 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
}
}
// ------ Invites ------
$scope.invite = function(group){
Groups.Group.invite({gid: group._id, uuid: group.invitee}, undefined, function(){
group.invitee = '';
}, function(){
group.invitee = '';
});
}
$scope.openInviteModal = function(group){
$rootScope.openModal('invite-friends', {controller:'InviteToGroupCtrl', resolve:
{injectedGroup: function(){
return group;
}}});
};
//var serializeQs = function(obj, prefix){
// var str = [];
@ -91,14 +88,6 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
//$scope.inviteLink = function(obj){
// return window.env.BASE_URL + '?' + serializeQs({partyInvite: obj});
//}
$scope.emails = [{name:"",email:""},{name:"",email:""}];
$scope.inviter = User.user.profile.name;
$scope.inviteEmails = function(inviter, emails){
$http.post('/api/v2/user/social/invite-friends', {inviter:inviter, emails:emails}).success(function(){
Notification.text("Invitations sent!");
$scope.emails = [{name:'',email:''},{name:'',email:''}];
});
}
$scope.quickReply = function(uid) {
Members.selectMember(uid, function(){
@ -108,6 +97,28 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
}
])
.controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedGroup', '$http', function($scope, User, Groups, injectedGroup, $http){ $scope.group = injectedGroup;
$scope.inviter = User.user.profile.name;
$scope.emails = [{name:"",email:""},{name:"",email:""}];
// todo use Groups.Group.invite for everything not raw $http
$scope.inviteEmails = function(){
$http.post('/api/v2/user/social/invite-friends/' + $scope.group._id, {inviter:$scope.inviter, emails:$scope.emails}).success(function(){
Notification.text("Invitations sent!");
$scope.emails = [{name:'',email:''},{name:'',email:''}];
});
};
$scope.invite = function(){
Groups.Group.invite({gid: $scope.group._id, uuid: $scope.invitee}, undefined, function(){
$scope.invitee = '';
}, function(){
$scope.invitee = '';
});
};
}])
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups',
function($scope, $rootScope, Members, Shared, $http, Notification, Groups) {
$scope.timestamp = function(timestamp){

View file

@ -114,6 +114,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
templateUrl: 'modals/' + template + '.html',
controller: options.controller, // optional
scope: options.scope, // optional
resolve: options.resolve, // optional
keyboard: (options.keyboard === undefined ? true : options.keyboard), // optional
backdrop: (options.backdrop === undefined ? true : options.backdrop), // optional
size: options.size, // optional, 'sm' or 'lg'

View file

@ -55,7 +55,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter
.panel-heading
h3.panel-title
=env.t('members')
button.pull-right.btn.btn-primary(ng-click="openModal('invite-friends', {controller:'GroupsCtrl'})", ng-if='::group.type=="party"') Invite Friends
button.pull-right.btn.btn-primary(ng-click="openInviteModal(group)") Invite Friends
.panel-body.modal-fixed-height
div.form-group(ng-if='::group.type=="party"')
p=env.t('partyList')
@ -99,14 +99,6 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter
a.media-body
span(ng-click='clickMember(invite._id, true)')
| {{invite.profile.name}}
.panel-footer(ng-if='::group.type!="party"')
form.form-inline(ng-submit='invite(group)')
//.alert.alert-danger(ng-show='_groupError') {{_groupError}}
.input-group
input.form-control(type='text', placeholder=env.t('userId'), ng-model='group.invitee')
span.input-group-btn
input.btn.btn-default(type='submit', value=env.t('invite'))
a.btn.btn-danger(data-id='{{group.id}}', ng-click='clickLeave(group, $event)')=env.t('leave')

View file

@ -4,10 +4,10 @@ script(type='text/ng-template', id='modals/invite-friends.html')
.modal-body
p.alert.alert-info Invite friends by <a href='http://habitrpg.wikia.com/wiki/API_Options' target='_blank'>User ID</a> here.
form.form-inline(ng-submit='invite(party)')
form.form-inline(ng-submit='invite()')
//-.alert.alert-danger(ng-show='_groupError') {{_groupError}}
.form-group
input.form-control(type='text', placeholder=env.t('userId'), ng-model='party.invitee')
input.form-control(type='text', placeholder=env.t('userId'), ng-model='invitee')
|&nbsp;
button.btn.btn-primary(type='submit') Invite Existing User
@ -15,7 +15,7 @@ script(type='text/ng-template', id='modals/invite-friends.html')
p.alert.alert-info Invite friends by email. If they join via your email, they'll automatically be invited to your party.
form.form-horizontal(ng-submit='inviteEmails(inviter, emails)')
form.form-horizontal(ng-submit='inviteEmails()')
table.table.table-striped
thead
tr