diff --git a/app/assets/javascripts/findSession.js b/app/assets/javascripts/findSession.js
index 868a22a67..627df03f5 100644
--- a/app/assets/javascripts/findSession.js
+++ b/app/assets/javascripts/findSession.js
@@ -6,7 +6,7 @@
context.JK.FindSessionScreen = function(app) {
var CATEGORY = {
INVITATION : {index: 0, id: "table#sessions-invitations"},
- FRIENDS : {index: 1, id: "table#sessions-friends"},
+ FRIEND : {index: 1, id: "table#sessions-friends"},
OTHER : {index: 2, id: "table#sessions-other"}
};
@@ -17,6 +17,7 @@
var invitationSessionGroup = {};
var friendSessionGroup = {};
var otherSessionGroup = {};
+ var sessionCounts = [0, 0, 0];
var sessionList;
// for unit tests
@@ -33,6 +34,7 @@
$.ajax({
type: "GET",
url: "/api/sessions",
+ async: false,
success: startSessionLatencyChecks
});
}
@@ -79,6 +81,53 @@
}
}
+ function initializeDisplay() {
+ var priorVisible;
+
+ var INVITATION = 'div#sessions-invitations';
+ var FRIEND = 'div#sessions-friends';
+ var OTHER = 'div#sessions-other';
+
+ // INVITATION
+ //alert(sessionCounts[CATEGORY.INVITATION.index]);
+ if (sessionCounts[CATEGORY.INVITATION.index] == 0) {
+ priorVisible = false;
+ $(INVITATION).hide();
+ }
+ else {
+ priorVisible = true;
+ $(INVITATION).show();
+ }
+
+ // FRIEND
+ if (!priorVisible) {
+ $(FRIEND).removeClass('mt35');
+ }
+
+ //alert(sessionCounts[CATEGORY.FRIEND.index]);
+ if (sessionCounts[CATEGORY.FRIEND.index] == 0) {
+ priorVisible = false;
+ $(FRIEND).hide();
+ }
+ else {
+ priorVisible = true;
+ $(FRIEND).show();
+ }
+
+ // OTHER
+ if (!priorVisible) {
+ $(OTHER).removeClass('mt35');
+ }
+
+ //alert(sessionCounts[CATEGORY.OTHER.index]);
+ if (sessionCounts[CATEGORY.OTHER.index] == 0) {
+ $(OTHER).hide();
+ }
+ else {
+ $(OTHER).show();
+ }
+ }
+
function getSelectedMusicians() {
var selectedMusicians = [];
$('#musician-list-items :checked').each(function() {
@@ -95,12 +144,15 @@
// store session in the appropriate bucket
if (containsInvitation(session)) {
invitationSessionGroup[session.id] = session;
+ sessionCounts[CATEGORY.INVITATION.index]++;
}
else if (containsFriend(session)) {
friendSessionGroup[session.id] = session;
+ sessionCounts[CATEGORY.FRIEND.index]++;
}
else {
otherSessionGroup[session.id] = session;
+ sessionCounts[CATEGORY.OTHER.index]++;
}
sessionLatency.sessionPings(session);
});
@@ -161,7 +213,7 @@
}
else if (friendSessionGroup[sessionId] != null) {
session = friendSessionGroup[sessionId];
- $tbGroup = $(CATEGORY.FRIENDS.id);
+ $tbGroup = $(CATEGORY.FRIEND.id);
}
else if (otherSessionGroup[sessionId] != null) {
session = otherSessionGroup[sessionId];
@@ -204,53 +256,12 @@
function afterShow(data) {
clearResults();
loadSessions();
-
- var priorVisible;
-
- var INVITATIONS = 'div#sessions-invitations';
- var FRIENDS = 'div#sessions-friends';
- var OTHER = 'div#sessions-other';
-
- // INVITATIONS
- if (invitationSessionGroup.length === undefined) {
- priorVisible = false;
- $(INVITATIONS).hide();
- }
- else {
- priorVisible = true;
- $(INVITATIONS).show();
- }
-
- // FRIENDS
- if (!priorVisible) {
- $(FRIENDS).removeClass('mt35');
- }
-
- if (friendSessionGroup.length === undefined) {
- priorVisible = false;
- $(FRIENDS).hide();
- }
- else {
- priorVisible = true;
- $(FRIENDS).show();
- }
-
- // OTHER
- if (!priorVisible) {
- $(OTHER).removeClass('mt35');
- }
-
- if (otherSessionGroup.length === undefined) {
- $(OTHER).hide();
- }
- else {
- $(OTHER).show();
- }
+ initializeDisplay();
}
function clearResults() {
$(CATEGORY.INVITATION).children(':not(:first-child)').remove();
- $(CATEGORY.FRIENDS).children(':not(:first-child)').remove();
+ $(CATEGORY.FRIEND).children(':not(:first-child)').remove();
$(CATEGORY.OTHER).children(':not(:first-child)').remove();
}
@@ -262,7 +273,7 @@
url: "/api/sessions/" + sessionId
}).done(loadSessions);
}
- }
+ }renderSession
function events() {
//$('#findSession-tableBody').on("click", '[action="delete"]', deleteSession);
diff --git a/app/assets/stylesheets/client/createSession.css.scss b/app/assets/stylesheets/client/createSession.css.scss
index 3e09ea58e..b3c4540bf 100644
--- a/app/assets/stylesheets/client/createSession.css.scss
+++ b/app/assets/stylesheets/client/createSession.css.scss
@@ -19,10 +19,6 @@
height:80px;
}
-.input-title {
- padding-bottom:5px;
-}
-
.radio-text {
font-size:13px;
}
diff --git a/app/assets/stylesheets/client/screen_common.css.scss b/app/assets/stylesheets/client/screen_common.css.scss
index ca33ea7e0..8e8590f0e 100644
--- a/app/assets/stylesheets/client/screen_common.css.scss
+++ b/app/assets/stylesheets/client/screen_common.css.scss
@@ -292,6 +292,10 @@ a img {
margin-top:40px;
}
+.mb5 {
+ margin-bottom:5px;
+}
+
.mb15 {
margin-bottom:15px;
}
diff --git a/app/views/clients/_createSession.html.erb b/app/views/clients/_createSession.html.erb
index 98a1026b5..1118299a0 100644
--- a/app/views/clients/_createSession.html.erb
+++ b/app/views/clients/_createSession.html.erb
@@ -21,7 +21,7 @@