From 4329338fa86c43246ba72880f7b739b5997c9e2a Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Tue, 17 Dec 2013 10:58:35 -0600 Subject: [PATCH 1/2] vrfs-884: added check for client_id==undefined in participant_delete method --- web/app/controllers/api_music_sessions_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/app/controllers/api_music_sessions_controller.rb b/web/app/controllers/api_music_sessions_controller.rb index 1d1028a8b..9809d49d0 100644 --- a/web/app/controllers/api_music_sessions_controller.rb +++ b/web/app/controllers/api_music_sessions_controller.rb @@ -101,11 +101,11 @@ class ApiMusicSessionsController < ApiController def participant_delete client_id = params[:id] - @connection = Connection.find_by_client_id!(client_id) - music_session = MusicSession.find(@connection.music_session_id) - - MusicSessionManager.new.participant_delete(current_user, @connection, music_session) - + if client_id.present? && client_id != 'undefined' + @connection = Connection.find_by_client_id!(client_id) + music_session = MusicSession.find(@connection.music_session_id) + MusicSessionManager.new.participant_delete(current_user, @connection, music_session) + end respond_with @connection, responder: ApiResponder end From 020f9d544eb3b863b5bcda6f5532a3aec797a861 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Tue, 17 Dec 2013 10:59:16 -0600 Subject: [PATCH 2/2] vrfs-884: tweaking layout --- web/app/assets/javascripts/findBand.js | 29 ++++---- .../assets/stylesheets/client/band.css.scss | 19 +++++ .../stylesheets/client/web_filter.css.scss | 70 +++++++++++++++++++ web/app/views/api_search/index.rabl | 2 +- web/app/views/clients/_bands.html.erb | 20 +++--- web/lib/tasks/sample_data.rake | 13 ++++ 6 files changed, 126 insertions(+), 27 deletions(-) create mode 100644 web/app/assets/stylesheets/client/web_filter.css.scss diff --git a/web/app/assets/javascripts/findBand.js b/web/app/assets/javascripts/findBand.js index a8a9714db..2475521d6 100644 --- a/web/app/assets/javascripts/findBand.js +++ b/web/app/assets/javascripts/findBand.js @@ -91,24 +91,19 @@ for (ii=0, len=bands.length; ii < len; ii++) { bb = bands[ii]; instr_logos = ''; - /*for (var jj=0, ilen=bb['instruments'].length; jj '; - }*/ players = ''; playerVals = {}; for (var jj=0, ilen=bb['players'].length; jj '; - }*/ + } playerVals = { player_name: aPlayer.name, @@ -124,19 +119,25 @@ button_message: 'button-orange' }; var band_actions = context.JK.fillTemplate(aTemplate, actionVals); + var bgenres = ''; + for (jj=0, ilen=bb['genres'].length; jj'; + } + bgenres += '
'; bVals = { avatar_url: context.JK.resolveAvatarUrl(bb.photo_url), profile_url: "/#/profile/" + bb.id, band_name: bb.name, band_location: bb.city + ', ' + bb.state, + genres: bgenres, instruments: instr_logos, biography: bb['biography'], follow_count: bb['follow_count'], recording_count: bb['recording_count'], session_count: bb['session_count'], band_id: bb['id'], - band_follow_template: players, + band_player_template: players, band_action_template: band_actions }; var band_row = context.JK.fillTemplate(mTemplate, bVals); @@ -171,7 +172,7 @@ evt.stopPropagation(); var newFollowing = {}; - newFollowing.user_id = $(this).parent().data('band-id'); + newFollowing.band_id = $(this).parent().data('band-id'); var url = "/api/users/" + context.JK.currentUserId + "/followings"; $.ajax({ type: "POST", @@ -182,7 +183,7 @@ processData: false, success: function(response) { // remove the orange look to indicate it's not selectable - $('div[data-band-id='+newFollowing.user_id+'] .search-m-follow').removeClass('button-orange'); + $('div[data-band-id='+newFollowing.band_id+'] .search-m-follow').removeClass('button-orange'); }, error: app.ajaxError }); diff --git a/web/app/assets/stylesheets/client/band.css.scss b/web/app/assets/stylesheets/client/band.css.scss index 18f505eb1..63152401a 100644 --- a/web/app/assets/stylesheets/client/band.css.scss +++ b/web/app/assets/stylesheets/client/band.css.scss @@ -270,3 +270,22 @@ .band-profile-block-city { font-size:12px; } + +#band-filter-results { + margin: 0 10px 5px 10px; + overflow: auto; + height: 100%; + width: 100%; +} + +.band-list-result { + padding-top: 5px; + padding-right: 5px; + padding-left: 5px; +} + +.band-wrapper { + overflow: auto; + height: 480px; + width: 100%; +} diff --git a/web/app/assets/stylesheets/client/web_filter.css.scss b/web/app/assets/stylesheets/client/web_filter.css.scss new file mode 100644 index 000000000..b84bc97ce --- /dev/null +++ b/web/app/assets/stylesheets/client/web_filter.css.scss @@ -0,0 +1,70 @@ +@import "client/common.css.scss"; +@charset "UTF-8"; + +.filter-results { + + li { + position: relative; + border-bottom:solid 1px shade($ColorElementPrimary, 20); + clear:both; + } + + li strong { + font-weight:bold; + } + + li.offline { + background-color: shade($ColorElementPrimary, 20); + color: shade($text, 10); + opacity:0.5; + ms-filter: "alpha(opacity=50)"; + } + + .avatar-small { + float:left; + padding:1px; + width:36px; + height:36px; + background-color:#ed3618; + margin:10px; + -webkit-border-radius:18px; + -moz-border-radius:18px; + border-radius:18px; + } + + .avatar-small img { + width: 36px; + height: 36px; + -webkit-border-radius:18px; + -moz-border-radius:18px; + border-radius:18px; + } + + li a { + color:#B3DD15; + } + + li a:hover { + color:#FFF; + } + + .result-name { + float:left; + font-size:12px; + margin-top:12px; + font-weight:bold; + } + + .result-location { + font-size:11px; + color:#D5E2E4; + font-weight:200; + } + + .results-wrapper { + width: 300px; + overflow-y:auto; + overflow-x:hidden; + } +} + diff --git a/web/app/views/api_search/index.rabl b/web/app/views/api_search/index.rabl index 581566cd8..e7102cee9 100644 --- a/web/app/views/api_search/index.rabl +++ b/web/app/views/api_search/index.rabl @@ -71,7 +71,7 @@ if @search.bands_filter.present? @search.is_follower?(band) end - child :genres => :genre do + child :genres => :genres do attributes :genre_id, :description end diff --git a/web/app/views/clients/_bands.html.erb b/web/app/views/clients/_bands.html.erb index 091244ff5..473ecf9bf 100644 --- a/web/app/views/clients/_bands.html.erb +++ b/web/app/views/clients/_bands.html.erb @@ -9,7 +9,7 @@ <%= form_tag('', :id => 'find-band-form') do -%> <%= content_tag(:div, render(:partial => "web_filter", :locals => {:search_type => Search::PARAM_BAND}), :class => 'band-filter', :id => 'session-controls') %> <%= content_tag(:div, :class => 'content-scroller') do -%> - <%= content_tag(:div, content_tag(:div, '', :id => 'band-filter-results'), :class => 'content-wrapper band-wrapper') %> + <%= content_tag(:div, content_tag(:div, '', :id => 'band-filter-results', :class => 'filter-results'), :class => 'content-wrapper band-wrapper') %> <% end -%> <% end -%> <% end -%> @@ -24,24 +24,20 @@
{band_name}
- {band_location} + {band_location}

-
{instruments}
-

- {follow_count}    {recording_count}    {session_count}


+
{genres}
+

+ {follow_count}    {recording_count}    {session_count}

-

+

{biography}

-
- {band_action_template} -
+
{band_action_template}
-
- FOLLOWING: - {band_follow_template}
+ {band_player_template}

diff --git a/web/lib/tasks/sample_data.rake b/web/lib/tasks/sample_data.rake index dee36061d..f2c63850c 100644 --- a/web/lib/tasks/sample_data.rake +++ b/web/lib/tasks/sample_data.rake @@ -22,6 +22,10 @@ namespace :db do make_band_members end + task populate_band_genres: :environment do + make_band_genres + end + desc "Fill database with music session sample data" task populate_music_sessions: :environment do make_users(10) if 14 > User.count @@ -72,6 +76,15 @@ def make_band_members end end +def make_band_genres + Band.find_each do |bb| + next if bb.genres.present? + Genre.order('RANDOM()').limit(rand(3)+1).each do |gg| + bb.genres << gg + end + end +end + def make_bands 10.times do |nn| name = Faker::Name.name