From 92a47474c5ef9cf51ae18fc7ae52b9980dc00355 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Fri, 10 Jul 2015 13:40:15 -0500 Subject: [PATCH] * VRFS-3323 - band setup page 3 styling --- .../javascripts/accounts_profile_interests.js | 27 +++----------- web/app/assets/javascripts/band_setup.js | 19 ++++++---- web/app/assets/javascripts/profile_utils.js | 25 +++++++++++++ .../assets/stylesheets/client/band.css.scss | 36 +++++++++++-------- web/app/views/clients/_band_setup.html.slim | 22 ++++++------ 5 files changed, 74 insertions(+), 55 deletions(-) diff --git a/web/app/assets/javascripts/accounts_profile_interests.js b/web/app/assets/javascripts/accounts_profile_interests.js index ec5f34868..d4ad601db 100644 --- a/web/app/assets/javascripts/accounts_profile_interests.js +++ b/web/app/assets/javascripts/accounts_profile_interests.js @@ -146,8 +146,8 @@ context.JK.dropdown($traditionalTouringOption) // convert the value to cents - $hourlyRate.val(userDetail.paid_sessions_hourly_rate || userDetail.paid_sessions_hourly_rate == 0 ? (new Number(userDetail.paid_sessions_hourly_rate) / 100).toFixed(2) : '') - $dailyRate.val(userDetail.paid_sessions_daily_rate || userDetail.paid_sessions_daily_rate == 0 ? (new Number(userDetail.paid_sessions_daily_rate) / 100).toFixed(2) : '') + $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) @@ -227,25 +227,6 @@ disableSubmits() resetForm() - // convert from dollars to cents - var hourlyRate = new Number($hourlyRate.val()) - var dailyRate = new Number($dailyRate.val()) - - if(!context._.isNaN(hourlyRate)) { - hourlyRate = Math.round(hourlyRate * 100) - } - else { - // restore original value to allow server to reject with validation error - hourlyRate = $hourlyRate.val() - } - if(!context._.isNaN(dailyRate)) { - dailyRate = Math.round(dailyRate * 100) - } - else { - // restore original value to allow server to reject with validation error - dailyRate = $dailyRate.val() - } - api.updateUser({ virtual_band: $screen.find('input[name=virtual_band]:checked').val(), virtual_band_genres: $virtualBandGenreList.html() === NONE_SPECIFIED ? [] : $virtualBandGenreList.html().split(GENRE_LIST_DELIMITER), @@ -258,8 +239,8 @@ paid_sessions: $screen.find('input[name=paid_sessions]:checked').val(), paid_session_genres: $paidSessionsGenreList.html() === NONE_SPECIFIED ? [] : $paidSessionsGenreList.html().split(GENRE_LIST_DELIMITER), - paid_sessions_hourly_rate: hourlyRate, - paid_sessions_daily_rate: dailyRate, + paid_sessions_hourly_rate: profileUtils.normalizeMoneyForSubmit($hourlyRate.val()), + paid_sessions_daily_rate: profileUtils.normalizeMoneyForSubmit($dailyRate.val()), free_sessions: $screen.find('input[name=free_sessions]:checked').val(), free_session_genres: $freeSessionsGenreList.html() === NONE_SPECIFIED ? [] : $freeSessionsGenreList.html().split(GENRE_LIST_DELIMITER), diff --git a/web/app/assets/javascripts/band_setup.js b/web/app/assets/javascripts/band_setup.js index 4e09a8e47..50f41bdf9 100644 --- a/web/app/assets/javascripts/band_setup.js +++ b/web/app/assets/javascripts/band_setup.js @@ -151,8 +151,8 @@ $("#play-commitment").val('1') - $("#hourly-rate").val("0.0") - $("#gig-minimum").val("0.0") + $screen.find("#hourly-rate").val("0") + $screen.find("#gig-minimum").val("0") resetGenres(); renderDesiredExperienceLabel([]) @@ -225,9 +225,14 @@ band.free_gigs=$('input[name="free_gigs"]:checked').val()=="yes" band.touring_option=$('#touring-option').val()=="yes" - band.play_commitment=$("#play-commitment").val() - band.hourly_rate=$("#hourly-rate").val() - band.gig_minimum=$("#gig-minimum").val() + + if ($screen.find("#play-commitment").length == 0) { + logger.error("MISSING PLAY MOTIMMENT") + } + + band.play_commitment = $screen.find("#play-commitment").val() + band.hourly_rate = profileUtils.normalizeMoneyForSubmit($screen.find("#hourly-rate").val()) + band.gig_minimum = profileUtils.normalizeMoneyForSubmit($("#gig-minimum").val()) if (currentStep==GENRE_STEP) { band.genres = getSelectedGenres(); @@ -424,8 +429,8 @@ $('#touring-option').val(band.touring_option ? 'yes' : 'no') $("#play-commitment").val(band.play_commitment) - $("#hourly-rate").val(band.hourly_rate) - $("#gig-minimum").val(band.gig_minimum) + $("#hourly-rate").val(profileUtils.normalizeMoneyForDisplay(band.hourly_rate)) + $("#gig-minimum").val(profileUtils.normalizeMoneyForDisplay(band.gig_minimum)) // Initialize avatar if (band.photo_url) { diff --git a/web/app/assets/javascripts/profile_utils.js b/web/app/assets/javascripts/profile_utils.js index 6b46d97c9..139d4155e 100644 --- a/web/app/assets/javascripts/profile_utils.js +++ b/web/app/assets/javascripts/profile_utils.js @@ -99,6 +99,31 @@ return list; } + // the server stores money in cents; display it as such + profileUtils.normalizeMoneyForDisplay = function(serverValue) { + if(serverValue || serverValue == 0) { + return (new Number(serverValue) / 100).toFixed(2) + } + else { + return 0; + } + } + + // the server stores money in cents; normalize it from what user entered + profileUtils.normalizeMoneyForSubmit = function(clientValue) { + var money = new Number(clientValue); + + if(!context._.isNaN(money)) { + money = Math.round(money * 100) + } + else { + // restore original value to allow server to reject with validation error + money = clientValue; + } + return money; + } + + // Initialize standard profile help bubbles (topics stored as attributes on element): profileUtils.initializeHelpBubbles = function(parentElement) { $(".help", parentElement).each(function( index ) { diff --git a/web/app/assets/stylesheets/client/band.css.scss b/web/app/assets/stylesheets/client/band.css.scss index 60260afb4..e3b33b7a3 100644 --- a/web/app/assets/stylesheets/client/band.css.scss +++ b/web/app/assets/stylesheets/client/band.css.scss @@ -40,10 +40,10 @@ } .radio-field { - display: inline; + display: inline-block; padding: 2px; - margin: 0.5em 2em 0.5em 0.25em; - label { + margin:5px 40px 0 0; + label { display: inline; padding: 2px; } @@ -413,33 +413,41 @@ } #band-setup-step-0 { - .band-name { width:36%; } } + #band-setup-step-1 { - - .band-name { - width:36%; - } - - .easydropdown-wrapper { width:100% !important; } } + #band-setup-step-2 { + .band-form-table { + margin:20px 0 0 10px; + } + + .iradio_minimal { + float:left; + } + label.radio-label { + float:left; + margin-left:5px; + } + + tr:nth-child(even) td { + padding-bottom:20px; + } + } + #band-setup-form { margin: 0.25em 0.5em 1.25em 0.25em; table.band-form-table { width: 100%; @include border_box_sizing; - /** tr:nth-child(even) td { - padding-bottom: 1em; - }*/ - td.band-biography, td.tdBandGenres { height:100%; vertical-align: top; diff --git a/web/app/views/clients/_band_setup.html.slim b/web/app/views/clients/_band_setup.html.slim index 895dda9ca..e1b2740f0 100644 --- a/web/app/views/clients/_band_setup.html.slim +++ b/web/app/views/clients/_band_setup.html.slim @@ -100,7 +100,7 @@ table.band-form-table tr td - label.strong-label for="new-member" + label for="new-member" | We want to add a new member   a.help help-topic="band-profile-add-new-member" [?] td.new-member-dependent @@ -115,10 +115,10 @@ td .radio-field input#new-member-yes.iradio-inline.dependent-master type="radio" name="add_new_members" value='yes' - label for='new-member-yes' Yes + label.radio-label for='new-member-yes' Yes .radio-field input#new-member-no.iradio-inline.dependent-master type="radio" name="add_new_members" value='no' - label for='new-member-no' No + label.radio-label for='new-member-no' No td.new-member-dependent #desired-experience-label None specified td.new-member-dependent @@ -133,7 +133,7 @@ option value="no" No tr td - label.strong-label for="paid-gigs" + label for="paid-gigs" | We want to play paid gigs   a.help help-topic="band-profile-play-paid-gigs" [?] td.paid-gigs-dependent @@ -144,27 +144,27 @@ td .radio-field input#paid-gigs-yes.iradio-inline.dependent-master type="radio" name="paid_gigs" value='yes' - label for="paid-gigs-yes" Yes + label.radio-label for="paid-gigs-yes" Yes .radio-field input#paid-gigs-no.iradio-inline.dependent-master type="radio" name="paid_gigs" value='no' - label for="paid-gigs-no" No + label.radio-label for="paid-gigs-no" No td.paid-gigs-dependent - input#hourly-rate type="number" name="hourly_rate" + input#hourly-rate name="hourly_rate" td.paid-gigs-dependent - input#gig-minimum type="number" name="gig_minimum" + input#gig-minimum name="gig_minimum" tr td - label.strong-label for="free-gigs" + label for="free-gigs" | We want to play free gigs   a.help help-topic="band-profile-play-free-gigs" [?] tr td .radio-field input#free-gigs-yes.iradio-inline type="radio" name="free_gigs" value='yes' - label for="free-gigs-yes" Yes + label.radio-label for="free-gigs-yes" Yes .radio-field input#free-gigs-no.iradio-inline type="radio" name="free_gigs" value='no' - label for="free-gigs-no" No + label.radio-label for="free-gigs-no" No #band-setup-step-3.band-step.content-wrapper h2 set up band: online presence & performance samples