find session fixes / set avatar and user name in header

This commit is contained in:
Brian Smith 2013-02-09 11:45:11 -05:00
parent 1fa4f97867
commit 9dbe1a51c7
8 changed files with 93 additions and 43 deletions

View File

@ -132,12 +132,10 @@
// top instrument in the user's profile.
// 2. Otherwise, use the tracks from the last created session.
data.tracks = [
{ instrument_id: "electric guitar", sound: "mono" },
{ instrument_id: "keyboard", sound: "mono" }
{ instrument_id: "electric guitar", sound: "mono" }
];
var jsonData = JSON.stringify(data);
alert(jsonData);
var url = "/api/sessions";
$.ajax({

View File

@ -73,6 +73,7 @@
$.ajax({
type: "GET",
url: "/api/sessions?" + queryString,
async: false,
success: startSessionLatencyChecks
});
}
@ -89,7 +90,6 @@
var OTHER = 'div#sessions-other';
// INVITATION
//alert(sessionCounts[CATEGORY.INVITATION.index]);
if (sessionCounts[CATEGORY.INVITATION.index] == 0) {
priorVisible = false;
$(INVITATION).hide();
@ -104,7 +104,6 @@
$(FRIEND).removeClass('mt35');
}
//alert(sessionCounts[CATEGORY.FRIEND.index]);
if (sessionCounts[CATEGORY.FRIEND.index] == 0) {
priorVisible = false;
$(FRIEND).hide();
@ -119,7 +118,6 @@
$(OTHER).removeClass('mt35');
}
//alert(sessionCounts[CATEGORY.OTHER.index]);
if (sessionCounts[CATEGORY.OTHER.index] == 0) {
$(OTHER).hide();
}
@ -130,9 +128,14 @@
function getSelectedMusicians() {
var selectedMusicians = [];
$('#musician-list-items :checked').each(function() {
selectedMusicians.push($(this).val());
});
// $('#musician-list-items :checked').each(function() {
// selectedMusicians.push($(this).val());
// });
var selectedVal = $('#musician-list').val();
if (selectedVal != '') {
selectedMusicians.push(selectedVal);
}
return selectedMusicians;
}
@ -205,53 +208,69 @@
*/
function renderSession(sessionId) {
var session = null;
// hack to prevent duplicate rows from being rendered when filtering
var sessionExists = false;
var $tbGroup;
if (invitationSessionGroup[sessionId] != null) {
session = invitationSessionGroup[sessionId];
$tbGroup = $(CATEGORY.INVITATION.id);
if ($("table#sessions-invitations tr[id='" + sessionId + "']").length > 0) {
sessionExists = true;
}
}
else if (friendSessionGroup[sessionId] != null) {
session = friendSessionGroup[sessionId];
$tbGroup = $(CATEGORY.FRIEND.id);
if ($("table#sessions-friends tr[id='" + sessionId + "']").length > 0) {
sessionExists = true;
}
}
else if (otherSessionGroup[sessionId] != null) {
session = otherSessionGroup[sessionId];
$tbGroup = $(CATEGORY.OTHER.id);
if ($("table#sessions-other tr[id='" + sessionId + "']").length > 0) {
sessionExists = true;
}
}
else {
//alert('ERROR: No session with ID = ' + sessionId + ' found.');
return;
}
var row = sessionList.renderSession(session, sessionLatency, $tbGroup, $('#template-session-row').html(), $('#template-musician-info').html(),
// populate the musician filter with musicians that haven't already been added
function(musicianArray) {
var template = $('#template-musician-filter').html();
$.each(musicianArray, function(index, val) {
// check if this musician is already in the filter
if ( $('#musician-list-items input[value=' + val.id + ']').length == 0 ) {
var musicianOptionHtml = context.JK.fillTemplate(template, {value: val.id, label: val.name});
$('#musician-list-items').append(musicianOptionHtml);
}
if (!sessionExists) {
var row = sessionList.renderSession(session, sessionLatency, $tbGroup, $('#template-session-row').html(), $('#template-musician-info').html(),
// populate the musician filter with musicians that haven't already been added
function(musicianArray) {
var template = $('#template-musician-option').html();
$.each(musicianArray, function(index, val) {
// check if this musician is already in the filter
if ( $('#musician-list option[value=' + val.id + ']').length == 0 ) {
var musicianOptionHtml = context.JK.fillTemplate(template, {value: val.id, label: val.name});
$('#musician-list').append(musicianOptionHtml);
}
});
});
});
}
}
// TODO: refactor this and GenreSelector into common code
function toggleMusicianBox() {
var boxHeight = $('#musician-list').css("height");
// TODO: clean this up (check class name of arrow to determine current state)
if (boxHeight == "20px") {
$('#musician-list').css({height: "auto"});
$('#musician-list-arrow').removeClass("arrow-down").addClass("arrow-up");
// function toggleMusicianBox() {
// var boxHeight = $('#musician-list').css("height");
// // TODO: clean this up (check class name of arrow to determine current state)
// if (boxHeight == "20px") {
// $('#musician-list').css({height: "auto"});
// $('#musician-list-arrow').removeClass("arrow-down").addClass("arrow-up");
}
else {
$('#musician-list').css({height: "20px"});
$('#musician-list-arrow').removeClass("arrow-up").addClass("arrow-down");
}
}
// }
// else {
// $('#musician-list').css({height: "20px"});
// $('#musician-list-arrow').removeClass("arrow-up").addClass("arrow-down");
// }
// }
function afterShow(data) {
clearResults();
@ -264,6 +283,18 @@
$('table#sessions-friends').children(':not(:first-child)').remove();
$('table#sessions-other').children(':not(:first-child)').remove();
// sessions = null;
// sessions = {};
// invitationSessionGroup = null;
// invitationSessionGroup = {};
// friendSessionGroup = null;
// friendSessionGroup = {};
// otherSessionGroup = null;
// otherSessionGroup = {};
sessionCounts = [0, 0, 0];
}
@ -279,8 +310,8 @@
function events() {
//$('#findSession-tableBody').on("click", '[action="delete"]', deleteSession);
$('#musician-list-header').on("click", toggleMusicianBox);
$('#musician-list-arrow').on("click", toggleMusicianBox);
// $('#musician-list-header').on("click", toggleMusicianBox);
// $('#musician-list-arrow').on("click", toggleMusicianBox);
$('#session-keyword-srch').focus(function() {
$(this).val('');

View File

@ -149,9 +149,16 @@
}).done(function(r) {
userMe = r;
updateAccountForms();
updateHeader();
}).fail(app.ajaxError);
}
function updateHeader() {
$('#user').html(userMe.name);
$('#header-avatar').attr('src', userMe.photo_url);
}
function updateAccountForms() {
var idTemplate = $('#template-identity-summary').html();
var idHtml = context.JK.fillTemplate(idTemplate, userMe);
@ -173,6 +180,7 @@
}
this.initialize = function() {
events();
loadInstruments();
loadMe();

View File

@ -9,6 +9,10 @@
width:145px;
}
#find-session-genre select, #find-session-musician select {
width:145px;
}
.session-right {
width:50%;
float:right;

View File

@ -1,4 +1,4 @@
collection @users
# do not retrieve all child collections when showing a list of users
attributes :id, :first_name, :last_name, :city, :state, :country, :email, :online, :musician, :photo_url
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :email, :online, :musician, :photo_url

View File

@ -1,6 +1,6 @@
object @user
attributes :id, :first_name, :last_name, :city, :state, :country, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :favorite_count, :recording_count, :session_count
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :favorite_count, :recording_count, :session_count
unless @user.friends.nil? || @user.friends.size == 0
child :friends => :friends do

View File

@ -16,19 +16,23 @@
<div class="left ml35">Filter Session List:</div>
<!-- musician filter -->
<div class="ml10 left">
<div id="musician-list" class="multiselect-dropdown">
<div id="find-session-musician" class="ml10 left">
<select id="musician-list">
<option value="">All Musicians</option>
</select>
<!-- <div id="musician-list" class="multiselect-dropdown">
<div class="list-item-text">
<a id="musician-list-header">All musicians</a>
</div>
<a class="arrow-down" id="musician-list-arrow"></a>
<div id="musician-list-items" class="list-items">
</div>
</div>
</div> -->
</div>
<!-- genre filter -->
<div class="left ml10">
<div id="find-session-genre" class="left ml10">
<%= render "genreSelector" %>
</div>
@ -104,7 +108,12 @@
</tr>
</script>
<!-- Genre option template -->
<!-- Musician option template
<script type="text/template" id="template-musician-filter">
<div class="list-item-text"><input type="checkbox" value="{value}"> {label}</div>
</script> -->
<!-- Musician option template -->
<script type="text/template" id="template-musician-option">
<option value="{value}">{label}</option>
</script>

View File

@ -13,11 +13,11 @@
<div id="profile" class="userinfo">
<!-- avatar -->
<div class="avatar_large">
<%= image_tag "header/avatar_jonathon.png", {:height => 246, :width => 246} %>
<img id="header-avatar" height="246px" width:"246px" />
</div>
<!-- user name -->
<div id="user">Jonathon Wilson</div>
<div id="user"></div>
<div class="arrow-down"></div>
<ul>