fix bug introduced in create session friend selector
This commit is contained in:
parent
743048e95b
commit
2cd70405e0
|
|
@ -24,35 +24,36 @@ module JamRuby
|
|||
|
||||
# used for persisted notifications
|
||||
def formatted_msg
|
||||
target_user, source_user, band, session, recording, invitation, join_request = nil
|
||||
# target_user, band, session, recording, invitation, join_request = nil
|
||||
source_user = nil
|
||||
|
||||
unless self.target_user_id.nil?
|
||||
target_user = User.find(self.target_user_id)
|
||||
end
|
||||
# unless self.target_user_id.nil?
|
||||
# target_user = User.find(self.target_user_id)
|
||||
# end
|
||||
|
||||
unless self.source_user_id.nil?
|
||||
source_user = User.find(self.source_user_id)
|
||||
end
|
||||
|
||||
unless self.band_id.nil?
|
||||
band = Band.find(self.band_id)
|
||||
end
|
||||
# unless self.band_id.nil?
|
||||
# band = Band.find(self.band_id)
|
||||
# end
|
||||
|
||||
unless self.session_id.nil?
|
||||
session = MusicSession.find(self.session_id)
|
||||
end
|
||||
# unless self.session_id.nil?
|
||||
# session = MusicSession.find(self.session_id)
|
||||
# end
|
||||
|
||||
unless self.recording_id.nil?
|
||||
recording = Recording.find(self.recording_id)
|
||||
end
|
||||
# unless self.recording_id.nil?
|
||||
# recording = Recording.find(self.recording_id)
|
||||
# end
|
||||
|
||||
unless self.invitation_id.nil?
|
||||
invitation = Invitation.find(self.invitation_id)
|
||||
end
|
||||
# unless self.invitation_id.nil?
|
||||
# invitation = Invitation.find(self.invitation_id)
|
||||
# end
|
||||
|
||||
unless self.join_request_id.nil?
|
||||
join_request = JoinRequest.find(self.join_request_id)
|
||||
end
|
||||
# unless self.join_request_id.nil?
|
||||
# join_request = JoinRequest.find(self.join_request_id)
|
||||
# end
|
||||
|
||||
return self.class.format_msg(self.description, source_user)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
var genre = $(this).val();
|
||||
genres.push(genre);
|
||||
});
|
||||
|
||||
|
||||
return genres;
|
||||
}
|
||||
|
||||
|
|
@ -101,33 +101,33 @@
|
|||
}
|
||||
|
||||
function afterShow(data) {
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
loadFriends();
|
||||
loadGenres();
|
||||
loadCountries();
|
||||
}
|
||||
|
||||
// TODO: this
|
||||
function loadFriends() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/api/users/" + context.JK.currentUserId + "/friends",
|
||||
async: false
|
||||
}).done(function(response) {
|
||||
$.each(response, function() {
|
||||
userNames.push(this.name);
|
||||
userIds.push(this.id);
|
||||
userPhotoUrls.push(this.photo_url);
|
||||
});
|
||||
logger.debug("Loading friends...");
|
||||
rest.getFriends({ id: context.JK.currentUserId })
|
||||
.done(function(response) {
|
||||
$.each(response, function() {
|
||||
userNames.push(this.name);
|
||||
userIds.push(this.id);
|
||||
userPhotoUrls.push(this.photo_url);
|
||||
});
|
||||
|
||||
var autoCompleteOptions = {
|
||||
lookup: { suggestions: userNames, data: userIds },
|
||||
onSelect: addInvitation
|
||||
};
|
||||
if (!autoComplete) {
|
||||
autoComplete = $('#band-invitee-input').autocomplete(autoCompleteOptions);
|
||||
}
|
||||
else {
|
||||
autoComplete.setOptions(autoCompleteOptions);
|
||||
}
|
||||
var autoCompleteOptions = {
|
||||
lookup: { suggestions: userNames, data: userIds },
|
||||
onSelect: addInvitation
|
||||
};
|
||||
if (!autoComplete) {
|
||||
autoComplete = $('#band-invitee-input').autocomplete(autoCompleteOptions);
|
||||
}
|
||||
else {
|
||||
autoComplete.setOptions(autoCompleteOptions);
|
||||
}
|
||||
});
|
||||
|
||||
$(".autocomplete").width("150px");
|
||||
|
|
@ -167,6 +167,7 @@
|
|||
}
|
||||
|
||||
function addInvitation(value, data) {
|
||||
logger.debug("executing band addInvitation");
|
||||
if ($('#selected-band-invitees div[user-id=' + data + ']').length === 0) {
|
||||
var template = $('#template-band-invitation').html();
|
||||
var invitationHtml = context.JK.fillTemplate(template, {userId: data, userName: value});
|
||||
|
|
@ -233,7 +234,6 @@
|
|||
|
||||
function initialize(friendSelectorDialogInstance) {
|
||||
friendSelectorDialog = friendSelectorDialogInstance;
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
events();
|
||||
|
||||
var screenBindings = {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
context.JK = context.JK || {};
|
||||
context.JK.CreateSessionScreen = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var realtimeMessaging = context.JK.JamServer;
|
||||
var friendSelectorDialog = null;
|
||||
var invitationDialog = null;
|
||||
|
|
@ -25,52 +26,30 @@
|
|||
}
|
||||
|
||||
function afterShow(data) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/api/users/" + context.JK.currentUserId + "/friends",
|
||||
async: false
|
||||
}).done(function(response) {
|
||||
$.each(response, function() {
|
||||
userNames.push(this.name);
|
||||
userIds.push(this.id);
|
||||
userPhotoUrls.push(this.photo_url);
|
||||
});
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
|
||||
// var autoCompleteOptions = {
|
||||
// lookup: { suggestions: userNames, data: userIds },
|
||||
// onSelect: addInvitation
|
||||
// };
|
||||
// if (!autoComplete) {
|
||||
// autoComplete = $('#friend-input').autocomplete(autoCompleteOptions);
|
||||
// }
|
||||
// else {
|
||||
// autoComplete.setOptions(autoCompleteOptions);
|
||||
// }
|
||||
rest.getFriends({ id: context.JK.currentUserId })
|
||||
.done(function(response) {
|
||||
$.each(response, function() {
|
||||
userNames.push(this.name);
|
||||
userIds.push(this.id);
|
||||
userPhotoUrls.push(this.photo_url);
|
||||
});
|
||||
|
||||
var autoCompleteOptions = {
|
||||
lookup: { suggestions: userNames, data: userIds },
|
||||
onSelect: addInvitation
|
||||
};
|
||||
|
||||
if (!autoComplete) {
|
||||
autoComplete = $('#friend-input').autocomplete(autoCompleteOptions);
|
||||
}
|
||||
else {
|
||||
autoComplete.setOptions(autoCompleteOptions);
|
||||
}
|
||||
});
|
||||
|
||||
// var autoCompleteOptions = {
|
||||
// serviceUrl: "/api/users/" + context.JK.currentUserId + "/friends",
|
||||
// minChars: 3,
|
||||
// dataType: 'jsonp',
|
||||
// transformResult: function(response) {
|
||||
// logger.debug("transforming...");
|
||||
// logger.debug("response.length=" + response.length);
|
||||
// return {
|
||||
// suggestions: $.map(response, function(dataItem) {
|
||||
// return { value: dataItem.id, data: dataItem.name };
|
||||
// })
|
||||
// };
|
||||
// },
|
||||
// onSelect: addInvitation
|
||||
// };
|
||||
|
||||
// if (!autoComplete) {
|
||||
// autoComplete = $('#friend-input').autocomplete(autoCompleteOptions);
|
||||
// }
|
||||
// else {
|
||||
// logger.debug("here2");
|
||||
// autoComplete.setOptions(autoCompleteOptions);
|
||||
// }
|
||||
$(".autocomplete").width("150px");
|
||||
}
|
||||
|
||||
function friendSelectorCallback(newSelections) {
|
||||
|
|
@ -81,6 +60,7 @@
|
|||
}
|
||||
|
||||
function addInvitation(value, data) {
|
||||
logger.debug("executing session addInvitation");
|
||||
if ($('#selected-friends div[user-id=' + data + ']').length === 0) {
|
||||
var template = $('#template-added-invitation').html();
|
||||
var invitationHtml = context.JK.fillTemplate(template, {userId: data, userName: value});
|
||||
|
|
@ -421,7 +401,6 @@
|
|||
|
||||
function initialize(invitationDialogInstance, friendSelectorDialogInstance) {
|
||||
friendSelectorDialog = friendSelectorDialogInstance;
|
||||
friendSelectorDialog.setCallback(friendSelectorCallback);
|
||||
invitationDialog = invitationDialogInstance;
|
||||
events();
|
||||
loadBands();
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@
|
|||
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
async: false,
|
||||
url: '/api/users/' + id + '/friends',
|
||||
dataType: 'json'
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue