VRFS-3246 : Cleanup code and style

This commit is contained in:
Steven Miers 2015-06-03 16:34:37 -05:00
parent bf14fa9926
commit 6c5ffd6644
4 changed files with 38 additions and 17 deletions

View File

@ -226,8 +226,7 @@ module JamRuby
end
# helper method for creating / updating a Band
def self.save(user, params)
puts "Band.save with #{user}, #{params}"
def self.save(user, params)
band = build_band(user, params)
if band.save

View File

@ -62,7 +62,9 @@ module JamRuby
private
def self.auth_player(target_player, options={})
raise JamPermissionError, PERMISSION_MSG if target_player.nil? || options[:player_id] != target_player.id
if target_player.nil? || options[:player_id] != target_player.id
raise JamPermissionError, PERMISSION_MSG
end
end
end
end

View File

@ -37,11 +37,9 @@
var $screen=$("#band-setup")
var $samples = $screen.find(".account-profile-samples")
var $selectedInstruments=[]
console.log("------------------------------------------")
var accountProfileSamples = new JK.AccountProfileSamples(app, $screen, loadBandCallback, rest.updateBand)
accountProfileSamples.initialize()
console.log("==========================================")
accountProfileSamples.initialize()
function navBack() {
if (currentStep>0) {
@ -245,9 +243,37 @@
band.instruments.push(h)
})
if(!isNewBand()) {
mergePerformanceSamples(band)
}
return band;
}
function mergePerformanceSamples(band) {
// Collect and merge data from this sub-widget:
var performanceSampleData = accountProfileSamples.buildPlayer()
band.website=performanceSampleData.website
band.online_presences=performanceSampleData.online_presences
band.performance_samples=performanceSampleData.performance_samples
// Change player id to that of band. Widget currently hardwires current user id:
if(band.online_presences) {
for (var i=0; i<band.online_presences.length; ++i) {
band.online_presences[i].player_id = band.id
}
}
// Change player id to that of band. Widget currently hardwires current user id:
if(band.performance_samples) {
for (var i=0; i<band.performance_samples.length; ++i) {
band.performance_samples[i].player_id = band.id
}
}
return band
}
function renderDesiredExperienceLabel(selectedInstruments) {
$selectedInstruments=selectedInstruments
var instrumentText=""
@ -273,18 +299,11 @@
function saveBand(saveBandSuccessFn) {
unbindNavButtons()
var band = buildBand()
// Collect and store data from this sub-widget:
var performanceSampleData = accountProfileSamples.buildPlayer()
band.website=performanceSampleData.website
band.online_presences=performanceSampleData.online_presences
band.performance_samples=performanceSampleData.performance_samples
var band = buildBand()
var saveBandFn = (isNewBand()) ? rest.createBand : rest.updateBand
saveBandFn(band)
.done(function (response) {
console.log("RESPONSESSSSS", response)
.done(function (response) {
bandId = response.id
saveInvitations()
if(saveBandSuccessFn) {

View File

@ -34,7 +34,8 @@
.site_validator {
a, .spinner-small {
margin: -7px 1px 2px 2px;
margin: 1px 1px 2px 2px;
vertical-align: top;
}
}
}