vrfs1008: fixing integration bugs
This commit is contained in:
parent
11074044a7
commit
33c64c2881
|
|
@ -13,13 +13,13 @@
|
|||
var sessionSettings = {};
|
||||
|
||||
function beforeShow(data) {
|
||||
inviteMusiciansDialog.afterShow(data);
|
||||
inviteMusiciansDialog.clearSelections();
|
||||
context.JK.GenreSelectorHelper.render('#create-session-genre');
|
||||
resetForm();
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
inviteMusiciansDialog.afterShow(data);
|
||||
inviteMusiciansDialog.loadFriends();
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
|
|
|
|||
|
|
@ -17,13 +17,17 @@
|
|||
var newSelections = {};
|
||||
var mySaveCallback;
|
||||
|
||||
this. beforeShow = function(data) {
|
||||
this.clearSelections = function() {
|
||||
userNames = [];
|
||||
userIds = [];
|
||||
userPhotoUrls = [];
|
||||
}
|
||||
selectedIds = {};
|
||||
selectedFriendIds = {};
|
||||
newSelections = {};
|
||||
$('.selected-friends').empty();
|
||||
};
|
||||
|
||||
this.afterShow = function(data) {
|
||||
this.loadFriends = function() {
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
|
||||
var friends = rest.getFriends({ id: context.JK.currentUserId })
|
||||
|
|
@ -144,16 +148,32 @@
|
|||
}
|
||||
|
||||
function events() {
|
||||
$('.selected-friends').on("click", ".invitation a", removeInvitation);
|
||||
$('.btn-choose-friends').click(function(){
|
||||
friendSelectorDialog.showDialog(selectedFriendIds);
|
||||
});
|
||||
if ($('.btn-choose-friends').data('events') === undefined) {
|
||||
$('.selected-friends').on("click", ".invitation a", removeInvitation);
|
||||
$('.btn-choose-friends').click(function(){
|
||||
friendSelectorDialog.showDialog(selectedFriendIds);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showDialog(ids) {
|
||||
function showDialog(sessionId) {
|
||||
if (0 == $('#join-session-invite-musicians .friendbox').length) {
|
||||
this.appendFriendSelector($('#join-session-invite-musicians'));
|
||||
}
|
||||
selectedFriendIds = {};
|
||||
$.ajax({
|
||||
ajax: false,
|
||||
url: "/api/invitations",
|
||||
data: {
|
||||
session_id: sessionId,
|
||||
sender: context.JK.currentUserId
|
||||
}
|
||||
}).done(function(response) {
|
||||
response.map(function(item) {
|
||||
selectedFriendIds[item['receiver']['id']] = true;
|
||||
});
|
||||
logger.debug(selectedFriendIds);
|
||||
}).fail(app.ajaxError);
|
||||
}
|
||||
|
||||
this.friendSelectorHTML = function() {
|
||||
|
|
|
|||
|
|
@ -1305,7 +1305,7 @@
|
|||
}
|
||||
|
||||
function inviteMusicians() {
|
||||
inviteMusiciansDialog.showDialog();
|
||||
inviteMusiciansDialog.showDialog(sessionId);
|
||||
}
|
||||
|
||||
function events() {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ class ApiInvitationsController < ApiController
|
|||
if current_user.id != sender_id
|
||||
raise PermissionError, "You can only ask for your own sent invitations"
|
||||
end
|
||||
|
||||
@invitations = Invitation.where(:sender_id => current_user.id)
|
||||
if session_id = params[:session_id]
|
||||
@invitations = Invitation.where(:sender_id => sender_id, :music_session_id => session_id)
|
||||
else
|
||||
@invitations = Invitation.where(:sender_id => current_user.id)
|
||||
end
|
||||
elsif !receiver_id.nil?
|
||||
if current_user.id != receiver_id
|
||||
raise PermissionError, "You can only ask for your own received invitations"
|
||||
|
|
|
|||
Loading…
Reference in New Issue