VRFS-2830 : Mesh out purchased jam tracks view and behavior.

This commit is contained in:
Steven Miers 2015-03-20 15:26:06 -05:00
parent abb31c4e40
commit e3d1a80a6f
7 changed files with 169 additions and 4 deletions

View File

@ -102,12 +102,16 @@
function events() {
// wire up main panel clicks
$('#account-content-scroller').on('click', '#account-scheduled-sessions-link', function(evt) { evt.stopPropagation(); navToScheduledSessions(); return false; } );
$('#account-content-scroller').on('click', '#account-my-jamtracks-link', function(evt) { evt.stopPropagation(); navToMyJamTracks(); return false; } );
$('#account-content-scroller').on('click', '#account-edit-identity-link', function(evt) { evt.stopPropagation(); navToEditIdentity(); return false; } );
$('#account-content-scroller').on('click', '#account-edit-profile-link', function(evt) { evt.stopPropagation(); navToEditProfile(); return false; } );
$('#account-content-scroller').on('click', '#account-edit-subscriptions-link', function(evt) { evt.stopPropagation(); navToEditSubscriptions(); return false; } );
$('#account-content-scroller').on('click', '#account-edit-payments-link', function(evt) { evt.stopPropagation(); navToEditPayments(); return false; } );
$('#account-content-scroller').on('click', '#account-edit-audio-link', function(evt) { evt.stopPropagation(); navToEditAudio(); return false; } );
$('#account-content-scroller').on('avatar_changed', '#profile-avatar', function(evt, newAvatarUrl) { evt.stopPropagation(); updateAvatar(newAvatarUrl); return false; })
$("#account-content-scroller").on('click', '.view-license', function(evt) { @app.layout.showDialog("jamtrack-license-dialog"); return false; } );
}
function renderAccount() {
@ -121,6 +125,11 @@
window.location = '/client#/account/sessions'
}
function navToMyJamTracks() {
resetForm();
window.location = '/client#/account/jamtracks'
}
function navToEditIdentity() {
resetForm()
window.location = '/client#/account/identity'

View File

@ -0,0 +1,103 @@
$ = jQuery
context = window
context.JK ||= {}
context.JK.AccountJamTracks = class AccountJamTracks
constructor: (@app) ->
@rest = context.JK.Rest()
@client = context.jamClient
@logger = context.JK.logger
@screen = null
@userId = context.JK.currentUserId;
initialize:() =>
screenBindings =
'beforeShow': @beforeShow
'afterShow': @afterShow
@app.bindScreen('account/jamtracks', screenBindings)
@screen = $('#account-jamtracks')
beforeShow:() =>
@logger.debug("beforeShow")
rest.getPurchasedJamTracks({})
.done(@populateJamTracks)
.fail(@app.ajaxError);
afterShow:() =>
@logger.debug("afterShow")
populateJamTracks:(data) =>
@logger.debug("populateJamTracks", data)
template = context._.template($('#template-account-jamtrack').html(), {jamtracks:data.jamtracks}, { variable: 'data' })
# template = context._.template($('#template-account-jamtrack').html(), {
# jamtracks: data.jamtracks
# current_user: @userId
# }, variable: 'data')
@logger.debug("TEMPLATE", template)
this.appendJamTracks template
@screen.find('.jamtrack-solo-session').on 'click', @soloSession
@screen.find('.jamtrack-group-session').on 'click', @groupSession
appendJamTracks:(template) =>
$('#account-my-jamtracks table tbody').replaceWith template
soloSession:(e) =>
#context.location="client#/createSession"
@logger.debug "BLEH", e
jamRow = $(e.target).parents("tr")
@logger.debug "BLEH2", e, jamRow.data()
@createSession(jamRow.data(), true)
#@logger.debug "BLEH", $(this), $(this).data()
groupSession:(e) =>
#context.location="client#/createSession"
jamRow = $(e.target).parents("tr")
@createSession(jamRow.data(), false)
createSession:(sessionData, solo) =>
tracks = context.JK.TrackHelpers.getUserTracks(context.jamClient)
if (context.JK.guardAgainstBrowser(@app))
@logger.debug("CRATING SESSION", sessionData.genre, solo)
data = {}
data.client_id = @app.clientId
#data.description = $('#description').val()
data.description = "Jam Track Session"
data.as_musician = true
data.legal_terms = true
data.intellectual_property = true
data.approval_required = false
data.musician_access = !solo
data.fan_access = false
data.fan_chat = false
data.genre = [sessionData.genre]
data.genres = [sessionData.genre]
# data.genres = context.JK.GenreSelectorHelper.getSelectedGenres('#create-session-genre')
# data.musician_access = if $('#musician-access option:selected').val() == 'true' then true else false
# data.approval_required = if $('input[name=\'musician-access-option\']:checked').val() == 'true' then true else false
# data.fan_access = if $('#fan-access option:selected').val() == 'true' then true else false
# data.fan_chat = if $('input[name=\'fan-chat-option\']:checked').val() == 'true' then true else false
# if $('#band-list option:selected').val() != ''
# data.band = $('#band-list option:selected').val()
data.audio_latency = context.jamClient.FTUEGetExpectedLatency().latency
data.tracks = tracks
rest.legacyCreateSession(data).done((response) =>
newSessionId = response.id
context.location = '/client#/session/' + newSessionId
# Re-loading the session settings will cause the form to reset with the right stuff in it.
# This is an extra xhr call, but it keeps things to a single codepath
loadSessionSettings()
context.JK.GA.trackSessionCount data.musician_access, data.fan_access, invitationCount
context.JK.GA.trackSessionMusicians context.JK.GA.SessionCreationTypes.create
).fail (jqXHR) =>
handled = false
if jqXHR.status = 422
response = JSON.parse(jqXHR.responseText)
if response['errors'] and response['errors']['tracks'] and response['errors']['tracks'][0] == 'Please select at least one track'
@app.notifyAlert 'No Inputs Configured', $('<span>You will need to reconfigure your audio device.</span>')
handled = true
if !handled
@app.notifyServerError jqXHR, 'Unable to Create Session'

View File

@ -474,8 +474,8 @@
}
/** account sessions */
.account-sessions {
div#account-scheduled-sessions {
.account-sessions, .account-jamtracks {
div#account-scheduled-sessions, #account-my-jamtracks {
position: relative;
display: block;
overflow: auto;

View File

@ -1,6 +1,10 @@
object @jam_track
attributes :id, :name, :description, :initial_play_silence, :original_artist, :version
attributes :id, :name, :description, :initial_play_silence, :original_artist, :version, :genre
node :genre do |jam_track|
jam_track.genre.present? ? jam_track.genre.id : nil
end
node :jmep do |jam_track|
jam_track.jmep_json ? JSON.parse(jam_track.jmep_json) : nil

View File

@ -106,7 +106,7 @@
</div>
<div class="right">
<a id="account-edit-subscriptions-link" href="#" class="button-orange">UPDATE</a>
<a id="account-my-jamtracks-link" href="#" class="button-orange">UPDATE</a>
</div>
<br clear="all" />

View File

@ -0,0 +1,39 @@
/! Account jamtracks Dialog
#account-jamtracks.screen.secondary layout='screen' layout-id='account/jamtracks'
.content-head
.content-icon
= image_tag "content/icon_account.png", :width => 27, :height => 20
h1 my account
= render "screen_navigation"
/! jamtracks scrolling area
.content-body
.content-body-scroller.account-content-scroller#account-jamtracks-content-scroller
.content-wrapper.account-jamtracks
.jamtracks-header
.left.jamtracks-caption
h2 my jamtracks:
.clearall
#account-my-jamtracks
table.generaltable
thead
th TITLE
th ORIGINAL ARTIST
th ACTIONS
tbody
.right
a.button-grey href="javascript:history.go(-1)" BACK
script#template-account-jamtrack type='text/template'
tbody
= "{% _.each(data.jamtracks, function(jamtrack) { %}"
tr data-id="{{jamtrack.id}}" data-genre="{{jamtrack.genre}}"
td
| {{jamtrack.name}}
td
| {{jamtrack.original_artist}}
td
.table-link: a.jamtrack-solo-session href= '#' jamtrack-id="{{jamtrack.id}}" Get into solo session
.table-link: a.jamtrack-group-session href= '#' jamtrack-id="{{jamtrack.id}}" Get into session others can join
= "{% }); %}"

View File

@ -52,6 +52,7 @@
<%= render "account_profile_avatar" %>
<%= render "account_audio_profile" %>
<%= render "account_sessions" %>
<%= render "account_jamtracks" %>
<%= render "account_session_detail" %>
<%= render "account_session_properties" %>
<%= render "inviteMusicians" %>
@ -168,6 +169,10 @@
var jamtrackAvailabilityDialog = new JK.JamtrackAvailabilityDialog(JK.app);
jamtrackAvailabilityDialog.initialize();
var jamtrackLicenseDialog = new JK.JamtrackLicenseDialog(JK.app);
jamtrackLicenseDialog.initialize();
var audioProfileInvalidDialog = new JK.AudioProfileInvalidDialog(JK.app);
audioProfileInvalidDialog.initialize();
@ -193,6 +198,9 @@
var accountSessionsScreen = new JK.AccountSessions(JK.app);
accountSessionsScreen.initialize();
var accountJamTracksScreen = new JK.AccountJamTracks(JK.app);
accountJamTracksScreen.initialize();
var accountSessionDetailScreen = new JK.AccountSessionDetail(JK.app);
accountSessionDetailScreen.initialize(JK.InvitationDialogInstance);
@ -246,6 +254,8 @@
var jamtrackScreen = new JK.JamTrackScreen(JK.app);
jamtrackScreen.initialize();
var jamtrackLanding = new JK.JamTrackLanding(JK.app);
jamtrackLanding.initialize();