diff --git a/ruby/lib/jam_ruby/models/band.rb b/ruby/lib/jam_ruby/models/band.rb index e822df6a5..c3d4b471d 100644 --- a/ruby/lib/jam_ruby/models/band.rb +++ b/ruby/lib/jam_ruby/models/band.rb @@ -23,8 +23,8 @@ module JamRuby validate :validate_photo_info validate :require_at_least_one_genre, :unless => :skip_genre_validation validate :limit_max_genres - validates_numericality_of :hourly_rate, greater_than:0, less_than:100000, :allow_nil => true - validates_numericality_of :gig_minimum, greater_than:0, less_than:200000, :allow_nil => true + validates_numericality_of :hourly_rate, greater_than:0, less_than:100000, :if => :paid_gigs + validates_numericality_of :gig_minimum, greater_than:0, less_than:200000, :if => :paid_gigs before_save :check_lat_lng before_save :check_website_url diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 602d93570..217c73339 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -197,9 +197,9 @@ module JamRuby validates :last_jam_updated_reason, :inclusion => {:in => [nil, JAM_REASON_REGISTRATION, JAM_REASON_NETWORK_TEST, JAM_REASON_FTUE, JAM_REASON_JOIN, JAM_REASON_IMPORT, JAM_REASON_LOGIN] } # stored in cents - validates_numericality_of :paid_sessions_hourly_rate, greater_than:0, less_than:200000, :allow_nil => true + validates_numericality_of :paid_sessions_hourly_rate, greater_than:0, less_than:200000, :if => :paid_sessions # stored in cents - validates_numericality_of :paid_sessions_daily_rate, greater_than:0, less_than:5000000, :allow_nil => true + validates_numericality_of :paid_sessions_daily_rate, greater_than:0, less_than:5000000, :if => :paid_sessions # custom validators validate :validate_musician_instruments diff --git a/web/app/assets/javascripts/accounts_profile_interests.js b/web/app/assets/javascripts/accounts_profile_interests.js index d4ad601db..84b205777 100644 --- a/web/app/assets/javascripts/accounts_profile_interests.js +++ b/web/app/assets/javascripts/accounts_profile_interests.js @@ -148,13 +148,15 @@ // convert the value to cents $hourlyRate.val(profileUtils.normalizeMoneyForDisplay(userDetail.paid_sessions_hourly_rate)); $dailyRate.val(profileUtils.normalizeMoneyForDisplay(userDetail.paid_sessions_daily_rate)); - + $cowritingPurpose.val(userDetail.cowriting_purpose) context.JK.dropdown($cowritingPurpose) + + renderOptionalControls() } - function bindGenreSelector(type, $btnSelect, $genreList) { - $btnSelect.unbind('click').bind('click', function(e) { + function bindGenreSelector(type, $btnSelect, $genreList) { + $btnSelect.unbind('click').bind('click', function(e) { e.preventDefault() var genreText = $genreList.html() var genres = [] @@ -162,7 +164,7 @@ genres = genreText.split(GENRE_LIST_DELIMITER) } - ui.launchGenreSelectorDialog(type, genres, function(selectedGenres) { + ui.launchGenreSelectorDialog(type, genres, function(selectedGenres) { $genreList.html(selectedGenres && selectedGenres.length > 0 ? selectedGenres.join(GENRE_LIST_DELIMITER) : NONE_SPECIFIED) }) @@ -194,7 +196,8 @@ context.JK.dropdown($virtualBandCommitment) context.JK.dropdown($traditionalBandCommitment) - context.JK.dropdown($cowritingPurpose) + context.JK.dropdown($cowritingPurpose) + $screen.on('ifToggled', 'input[type="radio"].dependent-master', renderOptionalControls); } function enableSubmits() { @@ -219,6 +222,52 @@ }) } + function isChecked(val) { + return (val && val != "false"); + } + + function renderOptionalControls(e) { + if(e){e.stopPropagation()} + + + // Is virtual band selected? + if (isChecked($screen.find($('input[name="virtual_band"]:checked')).val())) { + $screen.find($(".virtual-band-dependent")).removeClass("hidden") + } else { + $screen.find($(".virtual-band-dependent")).addClass("hidden") + } + + // Is traditional band selected? + if (isChecked($screen.find($('input[name="traditional_band"]:checked')).val())) { + $screen.find($(".traditional-band-dependent")).removeClass("hidden") + } else { + $screen.find($(".traditional-band-dependent")).addClass("hidden") + } + + // Is paid sessions selected? + if (isChecked($screen.find($('input[name="paid_sessions"]:checked')).val())) { + $screen.find($(".paid-sessions-dependent")).removeClass("hidden") + } else { + $screen.find($(".paid-sessions-dependent")).addClass("hidden") + } + + // Is free sessions selected? + if (isChecked($screen.find($('input[name="free_sessions"]:checked')).val())) { + $screen.find($(".free-sessions-dependent")).removeClass("hidden") + } else { + $screen.find($(".free-sessions-dependent")).addClass("hidden") + } + + // Is cowriting selected? + if (isChecked($screen.find($('input[name="cowriting"]:checked')).val())) { + $screen.find($(".cowriting-dependent")).removeClass("hidden") + } else { + $screen.find($(".cowriting-dependent")).addClass("hidden") + } + + return false; + } + function navigateTo(targetLocation) { context.location = targetLocation } @@ -285,7 +334,7 @@ app.bindScreen('account/profile/interests', screenBindings) events() - + $screen.find('.interest-options').iCheck({ checkboxClass: 'icheckbox_minimal', radioClass: 'iradio_minimal', @@ -294,11 +343,11 @@ profileUtils.initializeHelpBubbles($screen) } - + this.initialize = initialize this.beforeShow = beforeShow - this.afterShow = afterShow + this.afterShow = afterShow return this } - + })(window,jQuery) \ No newline at end of file diff --git a/web/app/assets/javascripts/profile_utils.js b/web/app/assets/javascripts/profile_utils.js index 59065b289..c25035936 100644 --- a/web/app/assets/javascripts/profile_utils.js +++ b/web/app/assets/javascripts/profile_utils.js @@ -99,6 +99,10 @@ // the server stores money in cents; display it as such profileUtils.normalizeMoneyForDisplay = function(serverValue) { + if (!serverValue || serverValue==="") { + // Blank value is valid: + return "" + } if(serverValue || serverValue == 0) { return (new Number(serverValue) / 100).toFixed(2) } @@ -109,6 +113,10 @@ // the server stores money in cents; normalize it from what user entered profileUtils.normalizeMoneyForSubmit = function(clientValue) { + if (!clientValue || clientValue==="") { + // Blank value is valid: + return "" + } var money = new Number(clientValue); if(!context._.isNaN(money)) { diff --git a/web/app/views/clients/_account_profile_interests.html.erb b/web/app/views/clients/_account_profile_interests.html.erb index 1550905a2..a180d2da6 100644 --- a/web/app/views/clients/_account_profile_interests.html.erb +++ b/web/app/views/clients/_account_profile_interests.html.erb @@ -20,23 +20,24 @@
-