* VRFS-3188 - sort instrument appropriately

This commit is contained in:
Seth Call 2015-05-05 09:22:15 -05:00
parent 48c2b9a2b2
commit 5970fae4fa
3 changed files with 20 additions and 2 deletions

View File

@ -99,6 +99,7 @@ group :development, :test do
gem 'factory_girl_rails', '4.1.0' # in dev because in use by rake task
gem 'database_cleaner', '1.3.0' #in dev because in use by rake task
gem 'teaspoon'
gem 'teaspoon-jasmine'
end
group :unix do
gem 'therubyracer' #, '0.11.0beta8'

View File

@ -222,14 +222,31 @@ context.JK.JamTrackScreen=class JamTrackScreen
@renderJamtracks(@currentData)
false
computeWeight: (jam_track_track, instrument) =>
weight = switch
when jam_track_track.track_type == 'Master' then 0
when jam_track_track.instrument?.id == instrument then 1 + jam_track_track.position
else 10000 + jam_track_track.position
renderJamtracks:(data) =>
@currentData = data
that = this
for jamtrack in data.jamtracks
jamtrackExpanded = this.expanded==jamtrack.id
trackRow = _.clone(jamtrack)
trackRow.track_cnt = jamtrack.tracks.length
trackRow.tracks = []
trackRow.tracks = []
# if an instrument is selected by the user, then re-order any jam tracks with a matching instrument to the top
instrument = @instrument.val()
if instrument?
jamtrack.tracks.sort((a, b) =>
aWeight = @computeWeight(a, instrument)
bWeight = @computeWeight(b, instrument)
return aWeight - bWeight
)
for track in jamtrack.tracks
trackRow.tracks.push(track)
if track.track_type=='Master'

View File

@ -15,7 +15,7 @@ node :purchased do |item|
end
child(:jam_track_tracks => :tracks) {
attributes :id, :part, :instrument, :track_type
attributes :id, :part, :instrument, :track_type, :position
node do |track|
{