diff --git a/ruby/.gitignore b/ruby/.gitignore index a35fe92d7..be1654c09 100644 --- a/ruby/.gitignore +++ b/ruby/.gitignore @@ -15,7 +15,7 @@ spec/reports test/tmp test/version_tmp tmp - +vendor .idea *~ *.swp diff --git a/ruby/lib/jam_ruby/models/band.rb b/ruby/lib/jam_ruby/models/band.rb index d853050b7..50f18486c 100644 --- a/ruby/lib/jam_ruby/models/band.rb +++ b/ruby/lib/jam_ruby/models/band.rb @@ -131,34 +131,22 @@ module JamRuby end # name - unless name.nil? - band.name = name - end + band.name = name unless name.nil? # website - unless website.nil? - band.website = website - end + band.website = website unless website.nil? # biography - unless biography.nil? - band.biography = biography - end + band.biography = biography unless biography.nil? # city - unless city.nil? - band.city = city - end + band.city = city unless city.nil? # state - unless state.nil? - band.state = state - end + band.state = state unless state.nil? # country - unless country.nil? - band.country = country - end + band.country = country unless country.nil? # genres unless genres.nil? @@ -177,14 +165,10 @@ module JamRuby end # photo url - unless photo_url.nil? - band.photo_url = photo_url - end + band.photo_url = photo_url unless photo_url.nil? # logo url - unless logo_url.nil? - band.logo_url = logo_url - end + band.logo_url = logo_url unless logo_url.nil? band.updated_at = Time.now.getutc band.save diff --git a/web/app/assets/images/shared/avatar_generic_band.png b/web/app/assets/images/shared/avatar_generic_band.png new file mode 100644 index 000000000..4a883b004 Binary files /dev/null and b/web/app/assets/images/shared/avatar_generic_band.png differ diff --git a/web/app/assets/javascripts/band_setup.js b/web/app/assets/javascripts/band_setup.js new file mode 100644 index 000000000..e642dcb3c --- /dev/null +++ b/web/app/assets/javascripts/band_setup.js @@ -0,0 +1,156 @@ +(function(context,$) { + + "use strict"; + + context.JK = context.JK || {}; + // TODO: MUCH OF THIS CLASS IS REPEATED IN createSession.js - REFACTOR + context.JK.BandSetupScreen = function(app) { + var logger = context.JK.logger; + var rest = context.JK.Rest(); + var band = {}; + var friendSelectorDialog = null; + var autoComplete = null; + var userNames = []; + var userIds = []; + var userPhotoUrls = []; + var selectedFriendIds = {}; + + function resetForm() { + + } + + function formatGenres(genres) { + var formattedGenres = ''; + if (genres) { + for (var i=0; i < genres.length; i++) { + var genre = genres[i]; + formattedGenres += genre.description; + if (i < genres.length -1) { + formattedGenres += ', '; + } + } + } + return formattedGenres; + } + + function createBand() { + + } + + function createBandInvitation() { + + } + + function beforeShow(data) { + userNames = []; + userIds = []; + userPhotoUrls = []; + resetForm(); + } + + 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); + }); + + var autoCompleteOptions = { + lookup: { suggestions: userNames, data: userIds }, + onSelect: addInvitation + }; + if (!autoComplete) { + autoComplete = $('#band-invitee-input').autocomplete(autoCompleteOptions); + } + else { + autoComplete.setOptions(autoCompleteOptions); + } + }); + + $(".autocomplete").width("150px"); + } + + function friendSelectorCallback(newSelections) { + var keys = Object.keys(newSelections); + for (var i=0; i < keys.length; i++) { + addInvitation(newSelections[keys[i]].userName, newSelections[keys[i]].userId); + } + } + + function addInvitation(value, data) { + 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}); + $('#selected-band-invitees').append(invitationHtml); + $('#band-invitee-input').select(); + selectedFriendIds[data] = true; + } + else { + $('#band-invitee-input').select(); + context.alert('Invitation already exists for this musician.'); + } + } + + function removeInvitation(evt) { + delete selectedFriendIds[$(evt.currentTarget).parent().attr('user-id')]; + $(evt.currentTarget).closest('.invitation').remove(); + } + + function events() { + $('#selected-band-invitees').on("click", ".invitation a", removeInvitation); + + // friend input focus + $('#band-invitee-input').focus(function() { + $(this).val(''); + }); + + // friend input blur + $('#band-invitee-input').blur(function() { + $(this).val('Type a friend\'s name'); + }); + + $('#btn-band-setup-cancel').click(function() { + context.location = "#/"; + }); + + $('#btn-band-setup-next').click(function() { + $("#band-setup-step-2").show(); + $("#band-setup-step-1").hide(); + }); + + $('#btn-band-setup-back').click(function() { + $("#band-setup-step-1").show(); + $("#band-setup-step-2").hide(); + }); + + $('#btn-band-setup-create').click(createBand); + + $('#btn-band-choose-friends').click(function() { + friendSelectorDialog.showDialog(selectedFriendIds); + }); + } + + function initialize(friendSelectorDialogInstance) { + friendSelectorDialog = friendSelectorDialogInstance; + friendSelectorDialog.setCallback(friendSelectorCallback); + events(); + + var screenBindings = { + 'beforeShow': beforeShow, + 'afterShow': afterShow + }; + + app.bindScreen('band/setup', screenBindings); + } + + this.initialize = initialize; + this.afterShow = afterShow; + return this; + }; + + })(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/createSession.js b/web/app/assets/javascripts/createSession.js index 9f697366f..a5fd5101e 100644 --- a/web/app/assets/javascripts/createSession.js +++ b/web/app/assets/javascripts/createSession.js @@ -6,7 +6,7 @@ context.JK.CreateSessionScreen = function(app) { var logger = context.JK.logger; var realtimeMessaging = context.JK.JamServer; - var friendSelectorDialog = new context.JK.FriendSelectorDialog(app, friendSelectorCallback); + var friendSelectorDialog = null; var invitationDialog = null; var autoComplete = null; var userNames = []; @@ -36,16 +36,16 @@ 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 = { + // lookup: { suggestions: userNames, data: userIds }, + // onSelect: addInvitation + // }; + // if (!autoComplete) { + // autoComplete = $('#friend-input').autocomplete(autoCompleteOptions); + // } + // else { + // autoComplete.setOptions(autoCompleteOptions); + // } }); // var autoCompleteOptions = { @@ -419,8 +419,9 @@ }); } - function initialize(invitationDialogInstance) { - friendSelectorDialog.initialize(); + function initialize(invitationDialogInstance, friendSelectorDialogInstance) { + friendSelectorDialog = friendSelectorDialogInstance; + friendSelectorDialog.setCallback(friendSelectorCallback); invitationDialog = invitationDialogInstance; events(); loadBands(); diff --git a/web/app/assets/javascripts/friendSelector.js b/web/app/assets/javascripts/friendSelector.js index 4e76ea128..ae5bbeba5 100644 --- a/web/app/assets/javascripts/friendSelector.js +++ b/web/app/assets/javascripts/friendSelector.js @@ -3,11 +3,12 @@ "use strict"; context.JK = context.JK || {}; - context.JK.FriendSelectorDialog = function(app, saveCallback) { + context.JK.FriendSelectorDialog = function(app) { var logger = context.JK.logger; var rest = context.JK.Rest(); var selectedIds = {}; var newSelections = {}; + var mySaveCallback; function events() { $('#btn-save-friends').click(saveFriendInvitations); @@ -63,7 +64,7 @@ function saveFriendInvitations(evt) { evt.stopPropagation(); - saveCallback(newSelections); + mySaveCallback(newSelections); } function showDialog(ids) { @@ -78,6 +79,10 @@ events(); }; + this.setCallback = function(callback) { + mySaveCallback = callback; + } + this.showDialog = showDialog; return this; }; diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index d0dafc98d..0d698c4b6 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -44,6 +44,28 @@ }); } + function createBand(band) { + return $.ajax({ + type: "POST", + dataType: "json", + url: '/api/bands', + contentType: 'application/json', + processData: false, + data: JSON.stringify(band) + }); + } + + function updateBand(band) { + return $.ajax({ + type: "POST", + dataType: "json", + url: '/api/bands/' + band.id, + contentType: 'application/json', + processData: false, + data: JSON.stringify(band) + }); + } + function getSession(id) { var url = "/api/sessions/" + id; return $.ajax({ diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index d6ff1c289..8f676b221 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -85,6 +85,10 @@ return photo_url ? photo_url : "/assets/shared/avatar_generic.png"; }; + context.JK.resolveBandAvatarUrl = function(photo_url) { + return photo_url ? photo_url : "/assets/shared/avatar_generic_band.png"; + }; + context.JK.getInstrumentIconMap24 = function() { return instrumentIconMap24; }; diff --git a/web/app/assets/stylesheets/client/bandProfile.css.scss b/web/app/assets/stylesheets/client/band.css.scss similarity index 92% rename from web/app/assets/stylesheets/client/bandProfile.css.scss rename to web/app/assets/stylesheets/client/band.css.scss index d1ab30b9c..c907ef7d5 100644 --- a/web/app/assets/stylesheets/client/bandProfile.css.scss +++ b/web/app/assets/stylesheets/client/band.css.scss @@ -1,5 +1,22 @@ @import "client/common.css.scss"; +.band-setup-bio { + height:90px; + overflow:auto; +} + +.band-setup-genres { + width:100%; + height:90px; + background-color:#c5c5c5; + border:none; + -webkit-box-shadow: inset 2px 2px 3px 0px #888; + box-shadow: inset 2px 2px 3px 0px #888; + color:#666; + overflow:auto; + font-size:14px; +} + .band-profile-header { padding:20px; height:120px; diff --git a/web/app/assets/stylesheets/client/client.css b/web/app/assets/stylesheets/client/client.css index 54b1d6db8..05dcd7c9c 100644 --- a/web/app/assets/stylesheets/client/client.css +++ b/web/app/assets/stylesheets/client/client.css @@ -22,7 +22,7 @@ *= require ./sidebar *= require ./home *= require ./profile - *= require ./bandProfile + *= require ./band *= require ./findSession *= require ./session *= require ./account diff --git a/web/app/assets/stylesheets/client/content.css.scss b/web/app/assets/stylesheets/client/content.css.scss index 6a23a30a8..2c7d100e8 100644 --- a/web/app/assets/stylesheets/client/content.css.scss +++ b/web/app/assets/stylesheets/client/content.css.scss @@ -306,7 +306,7 @@ ul.shortcuts { padding:2px; } - .account-home, .audio, .get-help, .download-app, .invite-friends { + .account-home, .band-setup, .audio, .get-help, .download-app, .invite-friends { border-bottom:1px; border-style:solid; border-color:#ED3618; diff --git a/web/app/controllers/api_bands_controller.rb b/web/app/controllers/api_bands_controller.rb index baf88d43c..d01bff216 100644 --- a/web/app/controllers/api_bands_controller.rb +++ b/web/app/controllers/api_bands_controller.rb @@ -16,7 +16,7 @@ class ApiBandsController < ApiController end def create - @band = Band.save(params[:id], + @band = Band.save(nil, params[:name], params[:website], params[:biography], diff --git a/web/app/views/clients/_band_setup.html.erb b/web/app/views/clients/_band_setup.html.erb new file mode 100644 index 000000000..c29920c29 --- /dev/null +++ b/web/app/views/clients/_band_setup.html.erb @@ -0,0 +1,122 @@ + +
+
+
+ <%= image_tag "content/icon_bands.png", :size => "19x19" %> +
+ +

set up band

+ + <%= render "screen_navigation" %> +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
+

Step 1: General Information

+
+ + <%= image_tag "shared/avatar_generic_band.png", {:id => "band-avatar", :align=>"absmiddle", :height => 88, :width => 88 } %> + +

+ Upload Band Photo

+
Band Name:
+
+
Web Site:
+ +
Country:
+

+
State/Region:
+

+
City:
+

+
Genres:
+
+
+
+
Description / Bio:
+ +
+
+
+ CANCEL   + NEXT +
+
+ +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/web/app/views/clients/_createSession.html.erb b/web/app/views/clients/_createSession.html.erb index 6b508df6c..f4bf56b7b 100644 --- a/web/app/views/clients/_createSession.html.erb +++ b/web/app/views/clients/_createSession.html.erb @@ -169,8 +169,6 @@ -<%= render "friendSelector" %> -