diff --git a/web/app/assets/javascripts/bandProfile.js b/web/app/assets/javascripts/bandProfile.js index 0e0282dac..3066efe85 100644 --- a/web/app/assets/javascripts/bandProfile.js +++ b/web/app/assets/javascripts/bandProfile.js @@ -434,7 +434,11 @@ $("#btn-edit-band-profile").unbind('click').click(function() { //$('div[layout-id="band/setup"] .hdn-band-id').val(bandId); - context.location = "/client#/band/setup/" + bandId; + context.location = "/client#/band/setup/" + bandId + '/step1'; + return false; + }); + $("#btn-edit-band-members").unbind('click').click(function() { + context.location = "/client#/band/setup/" + bandId + '/step2'; return false; }); } diff --git a/web/app/assets/javascripts/band_setup.js b/web/app/assets/javascripts/band_setup.js index dccd67937..e3a7c0436 100644 --- a/web/app/assets/javascripts/band_setup.js +++ b/web/app/assets/javascripts/band_setup.js @@ -22,7 +22,8 @@ var nilOptionText = 'n/a'; var bandId = ''; var friendInput=null; - var isSaving = false; + var step1, step2; + var isSaving = false; function is_new_record() { return bandId.length == 0; @@ -135,30 +136,48 @@ if (is_new_record()) { rest.createBand(band) .done(function (response) { - isSaving = false; + isSaving = false; createBandInvitations(response.id, function () { context.location = "/client#/bandProfile/" + response.id; }); }) .fail(function (jqXHR) { - isSaving = false; + isSaving = false; app.notifyServerError(jqXHR, "Unable to create band") }); ; } else { band.id = bandId; - rest.updateBand(band) - .done(function (response) { + if (!step1 && !step2){ + rest.updateBand(band) + .done(function (response) { isSaving = false; - createBandInvitations(band.id, function () { - context.location = "/client#/bandProfile/" + band.id; + createBandInvitations(band.id, function () { + context.location = "/client#/bandProfile/" + band.id; + }); + }).fail(function (jqXHR) { + isSaving = false; + app.notifyServerError(jqXHR, "Unable to create band") }); - }) - .fail(function (jqXHR) { - isSaving = false; - app.notifyServerError(jqXHR, "Unable to create band") - }); + } else { + if (step1) { + rest.updateBand(band) + .done(function (response) { + isSaving = false; + app.notifyAlert('Band Information', 'Your changes have been saved'); + }).fail(function (jqXHR) { + isSaving = false; + app.notifyServerError(jqXHR, "Unable to update band") + }); + } else if (step2) { + isSaving = false; + createBandInvitations(bandId, function () { + app.notifyAlert('Band Members', 'Your invitations have been sent'); + context.location = "/client#/bandProfile/" + bandId; + }); + } + } } } @@ -190,6 +209,15 @@ function beforeShow(data) { inviteMusiciansUtil.clearSelections(); bandId = data.id == 'new' ? '' : data.id; + + step1 = step2 = false; + if ('step2'==data['d']) { + step2 = true; + delete data['d']; + } else if ('step1'==data['d']){ + step1 = true; + delete data['d']; + } resetForm(); } @@ -204,6 +232,27 @@ // retrieve and initialize band profile data points loadBandDetails(); + + if (step2) { + $("#band-setup-step-2").show(); + $("#band-setup-step-1").hide(); + $('.band-setup-text-step2').each(function(idx) { $(this).hide(); }); + $('#btn-band-setup-back').text('CANCEL'); + $('#btn-band-setup-save').text('SEND INVITATIONS'); + + } else if (step1) { + $("#band-setup-step-1").show(); + $("#band-setup-step-2").hide(); + $('.band-setup-text-step1').each(function(idx) { $(this).hide(); }); + $('#btn-band-setup-next').text('SAVE'); + } + if (! step1 && ! step2) { + $('#btn-band-setup-next').text('NEXT'); + $('#btn-band-setup-back').text('CANCEL'); + $('#btn-band-setup-save').text('CREATE BAND'); + $('.band-setup-text-step1').each(function(idx) { $(this).show(); }); + $('.band-setup-text-step2').each(function(idx) { $(this).show(); }); + } } else { loadGenres(); @@ -417,8 +466,12 @@ $('#btn-band-setup-next').click(function () { validateGeneralInfo() .done(function (response) { - $("#band-setup-step-2").show(); - $("#band-setup-step-1").hide(); + if (!step1 && !step2) { + $("#band-setup-step-2").show(); + $("#band-setup-step-1").hide(); + } else if (step1) { + saveBand(); + } }) .fail(function (jqXHR) { if(jqXHR.status == 422) { @@ -431,8 +484,14 @@ }); $('#btn-band-setup-back').click(function () { - $("#band-setup-step-1").show(); - $("#band-setup-step-2").hide(); + if (!step2) { + $("#band-setup-step-1").show(); + $("#band-setup-step-2").hide(); + } else { + resetForm(); + window.history.go(-1); + return false; + } }); $('#btn-band-setup-save').click(saveBand); diff --git a/web/app/assets/javascripts/dialog/invitationDialog.js.erb b/web/app/assets/javascripts/dialog/invitationDialog.js.erb index 324d3b96d..b7887d9b4 100644 --- a/web/app/assets/javascripts/dialog/invitationDialog.js.erb +++ b/web/app/assets/javascripts/dialog/invitationDialog.js.erb @@ -19,7 +19,7 @@ function createFbInvite() { - if(deferredFbInvite == null || deferredFbInvite.isRejected()) { + if(deferredFbInvite == null || (typeof(deferredFbInvite.isRejected)!=='undefined' && deferredFbInvite.isRejected())) { deferredFbInvite = rest.createFbInviteUrl(); } diff --git a/web/app/assets/javascripts/findBand.js b/web/app/assets/javascripts/findBand.js index df498dca7..e7c30f315 100644 --- a/web/app/assets/javascripts/findBand.js +++ b/web/app/assets/javascripts/findBand.js @@ -84,15 +84,17 @@ var mTemplate = $('#template-find-band-row').html(); var pTemplate = $('#template-band-player-info').html(); var aTemplate = $('#template-band-action-btns').html(); + var eTemplate = $('#template-band-edit-btns').html(); var bVals, bb, renderings=''; var instr_logos, instr; - var players, playerVals, aPlayer; + var players, playerVals, aPlayer, isMember; for (ii=0, len=bands.length; ii < len; ii++) { bb = bands[ii]; instr_logos = ''; players = ''; playerVals = {}; + isMember = false; for (var jj=0, ilen=bb['players'].length; jj'; } - + if (!isMember) { + isMember = aPlayer.user_id == context.JK.currentUserId; + } playerVals = { user_id: aPlayer.user_id, player_name: aPlayer.name, @@ -119,14 +123,24 @@ players += context.JK.fillTemplate(pTemplate, playerVals); } - var actionVals = { - profile_url: "/client#/bandProfile/" + bb.id, - button_follow: bb['is_following'] ? '' : 'button-orange', - button_message: 'button-orange' - }; - var band_actions = context.JK.fillTemplate(aTemplate, actionVals); - var bgenres = ''; + var actionVals, band_actions; + if (isMember) { + actionVals = { + profile_url: "/client#/bandProfile/" + bb.id, + band_edit_url: "/client#/band/setup/" + bb.id + '/step1', + band_member_url: "/client#/band/setup/" + bb.id + '/step2' + }; + band_actions = context.JK.fillTemplate(eTemplate, actionVals); + } else { + actionVals = { + profile_url: "/client#/bandProfile/" + bb.id, + button_follow: bb['is_following'] ? '' : 'button-orange', + button_message: 'button-orange' + }; + band_actions = context.JK.fillTemplate(aTemplate, actionVals); + } + var bgenres = ''; for (jj=0, ilen=bb['genres'].length; jj'; } diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index a7b27526b..6f76d65f8 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -14,6 +14,7 @@ var profileScreen = null; var textMessageDialog = null; var feed = null; + var isBandMember = false; var instrument_logo_map = context.JK.getInstrumentIconMap24(); diff --git a/web/app/views/clients/_bandProfile.html.erb b/web/app/views/clients/_bandProfile.html.erb index b98ee672f..12baf47fa 100644 --- a/web/app/views/clients/_bandProfile.html.erb +++ b/web/app/views/clients/_bandProfile.html.erb @@ -19,7 +19,9 @@

@@ -104,7 +106,7 @@
- {friend_count} + {friend_count} {follower_count} {recording_count} {session_count} @@ -128,4 +130,4 @@
{userName}
{location}
- \ No newline at end of file + diff --git a/web/app/views/clients/_band_setup.html.erb b/web/app/views/clients/_band_setup.html.erb index ab1edc76e..7d56273f5 100644 --- a/web/app/views/clients/_band_setup.html.erb +++ b/web/app/views/clients/_band_setup.html.erb @@ -18,7 +18,7 @@
-

Step 1: General Information

+

Step 1: General Information

@@ -92,8 +92,9 @@