diff --git a/ruby/lib/jam_ruby/models/teacher.rb b/ruby/lib/jam_ruby/models/teacher.rb index 8146c0e26..8306c60ad 100644 --- a/ruby/lib/jam_ruby/models/teacher.rb +++ b/ruby/lib/jam_ruby/models/teacher.rb @@ -48,6 +48,7 @@ module JamRuby teacher = user.teacher teacher ||= user.build_teacher() + teacher.user = user teacher.website = params[:website] if params.key?(:website) teacher.biography = params[:biography] if params.key?(:biography) diff --git a/ruby/spec/jam_ruby/models/teacher_spec.rb b/ruby/spec/jam_ruby/models/teacher_spec.rb index 17a333270..061f7fe3a 100644 --- a/ruby/spec/jam_ruby/models/teacher_spec.rb +++ b/ruby/spec/jam_ruby/models/teacher_spec.rb @@ -28,7 +28,7 @@ describe Teacher do it "with instruments" do - teacher = user.build_teacher + teacher = Teacher.build_teacher(user, {}) teacher.instruments << instrument1 teacher.instruments << instrument2 teacher.save.should be_true diff --git a/web/app/assets/javascripts/accounts_profile.js b/web/app/assets/javascripts/accounts_profile.js index 44834b353..c00b03e60 100644 --- a/web/app/assets/javascripts/accounts_profile.js +++ b/web/app/assets/javascripts/accounts_profile.js @@ -1,9 +1,9 @@ -(function(context,$) { +(function (context, $) { "use strict"; context.JK = context.JK || {}; - context.JK.AccountProfileScreen = function(app) { + context.JK.AccountProfileScreen = function (app) { var $document = $(document); var logger = context.JK.logger; var EVENTS = context.JK.EVENTS; @@ -32,12 +32,18 @@ var $btnSubmit = $screen.find('.account-edit-profile-submit'); function beforeShow(data) { - userId = data.id; + userId = data.id; } function afterShow(data) { - resetForm(); - renderAccountProfile(); + if (window.ProfileStore.solo) { + $btnSubmit.text('SAVE & RETURN TO PROFILE'); + } + else { + $btnSubmit.text('SAVE & NEXT'); + } + resetForm(); + renderAccountProfile(); } function resetForm() { @@ -64,7 +70,7 @@ var content_root = $('#account-profile-content-scroller'); // set birth_date - if(userDetail.birth_date) { + if (userDetail.birth_date) { var birthDateFields = userDetail.birth_date.split('-') var birthDateYear = birthDateFields[0]; var birthDateMonth = birthDateFields[1]; @@ -79,8 +85,8 @@ } function populateAccountProfileLocation(userDetail, regions, cities) { - populateRegions(regions, userDetail.state); - populateCities(cities, userDetail.city); + populateRegions(regions, userDetail.state); + populateCities(cities, userDetail.city); } function populateCountries(countries, userCountry) { @@ -94,21 +100,21 @@ nilOption.text(nilOptionText); countrySelect.append(nilOption); - $.each(countries, function(index, country) { - if(!country) return; + $.each(countries, function (index, country) { + if (!country) return; var option = $(nilOptionStr); option.text(country); option.attr("value", country); - if(country == userCountry) { + if (country == userCountry) { foundCountry = true; } countrySelect.append(option); }); - if(!foundCountry) { + if (!foundCountry) { // in this case, the user has a country that is not in the database // this can happen in a development/test scenario, but let's assume it can // happen in production too. @@ -137,21 +143,21 @@ nilOption.text(nilOptionText); countrySelect.append(nilOption); - $.each(countriesx, function(index, countryx) { + $.each(countriesx, function (index, countryx) { if (!countryx.countrycode) return; var option = $(nilOptionStr); option.text(countryx.countryname); option.attr("value", countryx.countrycode); - if(countryx.countrycode == userCountry) { + if (countryx.countrycode == userCountry) { foundCountry = true; } countrySelect.append(option); }); - if(!foundCountry) { + if (!foundCountry) { // in this case, the user has a country that is not in the database // this can happen in a development/test scenario, but let's assume it can // happen in production too. @@ -175,8 +181,8 @@ nilOption.text(nilOptionText); regionSelect.append(nilOption); - $.each(regions, function(index, region) { - if(!region) return; + $.each(regions, function (index, region) { + if (!region) return; var option = $(nilOptionStr); option.text(region['name']); @@ -199,8 +205,8 @@ nilOption.text(nilOptionText); citySelect.append(nilOption); - $.each(cities, function(index, city) { - if(!city) return; + $.each(cities, function (index, city) { + if (!city) return; var option = $(nilOptionStr); option.text(city); @@ -218,27 +224,32 @@ /****************** MAIN PORTION OF SCREEN *****************/ // events for main screen function events() { - $btnCancel.click(function(evt) { + $btnCancel.click(function (evt) { evt.stopPropagation(); window.ProfileActions.cancelProfileEdit() return false; }); - - $('#account-profile-content-scroller').on('click', '#account-change-avatar', function(evt) { evt.stopPropagation(); navToAvatar(); return false; } ); + + $('#account-profile-content-scroller').on('click', '#account-change-avatar', function (evt) { + evt.stopPropagation(); + navToAvatar(); + return false; + }); enableSubmits(); } function renderAccountProfile() { + $.when(api.getUserProfile()) - .done(function(userDetail) { + .done(function (userDetail) { recentUserDetail = userDetail; populateAccountProfile(userDetail); selectLocation = new context.JK.SelectLocation(getCountryElement(), getRegionElement(), getCityElement(), app); selectLocation.load(userDetail.country, userDetail.state, userDetail.city) }); - + context.JK.dropdown($('select')); } @@ -277,20 +288,24 @@ biography: biography, subscribe_email: subscribeEmail }) - .done(postUpdateProfileSuccess) - .fail(postUpdateProfileFailure) - .always(enableSubmits) + .done(postUpdateProfileSuccess) + .fail(postUpdateProfileFailure) + .always(enableSubmits) } function enableSubmits() { - $btnSubmit.click(function(evt) { + $btnSubmit.click(function (evt) { evt.stopPropagation(); handleUpdateProfile(); return false; }); - $btnSubmit.removeClass("disabled"); - $('#account-profile-content-scroller').on('submit', '#account-edit-email-form', function(evt) { evt.stopPropagation(); handleUpdateProfile(); return false; } ); - $("#account-edit-email-form").removeClass("disabled"); + $btnSubmit.removeClass("disabled"); + $('#account-profile-content-scroller').on('submit', '#account-edit-email-form', function (evt) { + evt.stopPropagation(); + handleUpdateProfile(); + return false; + }); + $("#account-edit-email-form").removeClass("disabled"); } function disableSubmits() { @@ -309,7 +324,7 @@ var errors = JSON.parse(xhr.responseText) - if(xhr.status == 422) { + if (xhr.status == 422) { var first_name = context.JK.format_errors("first_name", errors); var last_name = context.JK.format_errors("last_name", errors); var country = context.JK.format_errors("country", errors); @@ -320,41 +335,41 @@ var subscribeEmail = context.JK.format_errors("subscribe_email", errors); var biography = context.JK.format_errors("biography", errors); - if(first_name != null) { + if (first_name != null) { getFirstNameElement().closest('div.field').addClass('error').end().after(first_name); } - if(last_name != null) { + if (last_name != null) { getLastNameElement().closest('div.field').addClass('error').end().after(last_name); } - if(country != null) { + if (country != null) { getCountryElement().closest('div.field').addClass('error').end().after(country); } - if(state != null) { + if (state != null) { getRegionElement().closest('div.field').addClass('error').end().after(state); } - if(city != null) { + if (city != null) { getCityElement().closest('div.field').addClass('error').end().after(city); } - if(birth_date != null) { + if (birth_date != null) { getYearElement().closest('div.field').addClass('error').end().after(birth_date); } - if(subscribeEmail != null) { + if (subscribeEmail != null) { getSubscribeEmail().closest('div.field').addClass('error').end().after(subscribeEmail); } - if(gender != null) { + if (gender != null) { getGenderElement().closest('div.field').addClass('error').end().after(gender); } } else { app.ajaxError(xhr, textStatus, errorMessage) - } + } } function handleCountryChanged() { @@ -376,9 +391,9 @@ regionElement.children().remove() regionElement.append($(nilOptionStr).text('loading...')) - api.getRegions({ country: selectedCountry }) + api.getRegions({country: selectedCountry}) .done(getRegionsDone) - .error(function(err) { + .error(function (err) { regionElement.children().remove() regionElement.append($(nilOptionStr).text(nilOptionText)) }) @@ -404,14 +419,14 @@ cityElement.children().remove(); cityElement.append($(nilOptionStr).text('loading...')); - api.getCities({ country: selectedCountry, region: selectedRegion }) + api.getCities({country: selectedCountry, region: selectedRegion}) .done(getCitiesDone) - .error(function(err) { - cityElement.children().remove(); - cityElement.append($(nilOptionStr).text(nilOptionText)); + .error(function (err) { + cityElement.children().remove(); + cityElement.append($(nilOptionStr).text(nilOptionText)); }) .always(function () { - loadingCitiesData = false; + loadingCitiesData = false; }); } else { @@ -483,7 +498,7 @@ var day = getDayElement().val() var year = getYearElement().val() - if(month != null && month.length > 0 && day != null && day.length > 0 && year != null && year.length > 0) { + if (month != null && month.length > 0 && day != null && day.length > 0 && year != null && year.length > 0) { return month + "-" + day + "-" + year; } else { @@ -506,4 +521,4 @@ return this; }; -})(window,jQuery); \ No newline at end of file +})(window, jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/accounts_profile_experience.js b/web/app/assets/javascripts/accounts_profile_experience.js index 46c44826a..d3d62ac60 100644 --- a/web/app/assets/javascripts/accounts_profile_experience.js +++ b/web/app/assets/javascripts/accounts_profile_experience.js @@ -21,11 +21,14 @@ } function afterShow(data) { + if (window.ProfileStore.solo) { $btnBack.hide() + $btnSubmit.text('SAVE & RETURN TO PROFILE'); } else { $btnBack.show() + $btnSubmit.text('SAVE & NEXT'); } resetForm(); diff --git a/web/app/assets/javascripts/accounts_profile_interests.js b/web/app/assets/javascripts/accounts_profile_interests.js index 768b62469..562b142dd 100644 --- a/web/app/assets/javascripts/accounts_profile_interests.js +++ b/web/app/assets/javascripts/accounts_profile_interests.js @@ -72,9 +72,11 @@ function afterShow(data) { if (window.ProfileStore.solo) { $btnBack.hide() + $btnSubmit.text('SAVE & RETURN TO PROFILE'); } else { $btnBack.show() + $btnSubmit.text('SAVE & NEXT'); } renderInterests() diff --git a/web/app/assets/javascripts/accounts_profile_samples.js b/web/app/assets/javascripts/accounts_profile_samples.js index 1b18a1062..60174c06d 100644 --- a/web/app/assets/javascripts/accounts_profile_samples.js +++ b/web/app/assets/javascripts/accounts_profile_samples.js @@ -60,9 +60,11 @@ function afterShow(data) { if (window.ProfileStore.solo) { $btnBack.hide() + $btnSubmit.text('SAVE & RETURN TO PROFILE'); } else { $btnBack.show() + $btnSubmit.text('SAVE & FINISH'); } $.when(loadFn()) @@ -167,6 +169,10 @@ } function buildNonJamKazamEntry($sampleList, type, source) { + + // remove anything that matches + $sampleList.find('[data-recording-id=' + source.recording_id + ']').remove(); + // TODO: this code is repeated in HTML file var recordingIdAttr = ' data-recording-id="' + source.recording_id + '" '; var recordingUrlAttr = ' data-recording-url="' + source.url + '" '; @@ -395,7 +401,7 @@ setTimeout(function() { - urlValidator = new JK.SiteValidator('url', userNameSuccessCallback, userNameFailCallback, parent) + urlValidator = new JK.SiteValidator('url', websiteSuccessCallback, userNameFailCallback, parent) urlValidator.init() soundCloudValidator = new JK.SiteValidator('soundcloud', userNameSuccessCallback, userNameFailCallback, parent) @@ -437,6 +443,13 @@ $inputDiv.append("Invalid username").show(); } + function websiteSuccessCallback($inputDiv) { + $inputDiv.addClass('error'); + $inputDiv.find('.error-text').remove(); + $inputDiv.append("Invalid URL").show(); + } + + function soundCloudSuccessCallback($inputDiv) { siteSuccessCallback($inputDiv, soundCloudRecordingValidator, $soundCloudSampleList, 'soundcloud'); } diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 56d3abd12..219df4f2c 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -591,7 +591,7 @@ detail = $.ajax({ type: "GET", dataType: "json", - url: "/api/users/" + id + '?'+ $.param(options), + url: "/api/users/" + id + '?' + $.param(options), processData: false }); } @@ -604,11 +604,14 @@ } function getUserProfile(options) { + if (!options) { + options = {} + } var id = getId(options); return $.ajax({ type: "GET", dataType: "json", - url: "/api/users/" + id + "/profile", + url: "/api/users/" + id + "/profile" + '?' + $.param(options), processData: false }); } diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index dd24f9aca..7b64fadeb 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -96,6 +96,8 @@ // buttons var $btnEdit = $screen.find('.edit-profile-btn'); + var $btnTeacherProfileEdit = $screen.find('.edit-teacher-profile-btn'); + var $btnTeacherProfileView = $screen.find('.view-teacher-profile-btn'); var $btnAddFriend = $screen.find('#btn-add-friend'); var $btnFollowUser = $screen.find('#btn-follow-user'); var $btnMessageUser = $screen.find('#btn-message-user'); @@ -145,7 +147,7 @@ user = null; decrementedFriendCountOnce = false; sentFriendRequest = false; - userDefer = rest.getUserProfile({id: userId}) + userDefer = rest.getUserProfile({id: userId, show_teacher:true}) .done(function (response) { user = response; configureUserType(); @@ -169,6 +171,10 @@ return user.musician; } + function isTeacher() { + return user.teacher; + } + function isCurrentUser() { return userId === context.JK.currentUserId; } @@ -200,6 +206,13 @@ if (isCurrentUser()) { $btnEdit.show(); + $btnTeacherProfileEdit.show(); + if(isTeacher()) { + $btnTeacherProfileView.show(); + } + else { + $btnTeacherProfileView.hide(); + } $btnAddFriend.hide(); $btnFollowUser.hide(); $btnMessageUser.hide(); @@ -207,6 +220,8 @@ configureFriendFollowersControls(); $btnEdit.hide(); + $btnTeacherProfileEdit.hide(); + $btnTeacherProfileView.show(); $btnAddFriend.show(); $btnFollowUser.show(); $btnMessageUser.show(); @@ -258,6 +273,16 @@ window.ProfileActions.startProfileEdit(null, false) return false; }) + $btnTeacherProfileEdit.click(function(e) { + e.preventDefault() + window.ProfileActions.startTeacherEdit(null, false) + return false; + }) + $btnTeacherProfileView.click(function(e) { + e.preventDefault() + context.location = '/client#/profile/teacher/' + context.JK.currentUserId; + return false; + }) $btnEditBio.click(function(e) { e.preventDefault() window.ProfileActions.startProfileEdit(null, true) diff --git a/web/app/assets/javascripts/react-components/TeacherProfile.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherProfile.js.jsx.coffee index 6caebaca9..d96ccd858 100644 --- a/web/app/assets/javascripts/react-components/TeacherProfile.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/TeacherProfile.js.jsx.coffee @@ -625,6 +625,7 @@ proficiencyDescriptionMap = { profileSelections = [] for tile, i in @TILES + console.log("@state.selected", @state.selected, @state.selected == tile) classes = classNames({last: i == @TILES.length - 1, active: @state.selected == tile}) profileSelections.push(`
- +
- +
diff --git a/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee index f39fabeab..998194321 100644 --- a/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee @@ -20,9 +20,12 @@ ProfileActions = @ProfileActions render: () -> if window.ProfileStore.solo - saveText = 'SAVE' + saveText = 'SAVE & RETURN TO PROFILE' else - saveText = 'SAVE & NEXT' + if @props.last + saveText = 'SAVE & FINISH' + else + saveText = 'SAVE & NEXT' if !this.props.hideBack && !window.ProfileStore.solo back = `
diff --git a/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee index a3d10018a..97aa11ce5 100644 --- a/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee @@ -276,7 +276,7 @@ rest = window.JK.Rest() {priceRows}
- + ` diff --git a/web/app/assets/stylesheets/client/band.css.scss b/web/app/assets/stylesheets/client/band.css.scss index 2cbdc6b26..6a24e48cd 100644 --- a/web/app/assets/stylesheets/client/band.css.scss +++ b/web/app/assets/stylesheets/client/band.css.scss @@ -492,9 +492,6 @@ } } - label { - font-size: 1.05em; - } } #bands-screen { diff --git a/web/app/assets/stylesheets/client/profile.css.scss b/web/app/assets/stylesheets/client/profile.css.scss index 932b7c797..6328c2cfc 100644 --- a/web/app/assets/stylesheets/client/profile.css.scss +++ b/web/app/assets/stylesheets/client/profile.css.scss @@ -27,6 +27,29 @@ &.no-online-presence { display:block; } + float:left; + margin-right:20px; + margin-top:20px; + + &.bandcamp-presence img { + + position:relative; + top:9px; + } + + &.user-website img { + position:relative; + top:-5px; + } + } + .performance-sample-option { + margin-right:40px; + a { + display:block; + } + img { + margin-bottom:5px; + } } .instruments-holder { margin-bottom:20px; @@ -78,6 +101,7 @@ font-weight:600; font-size:18px; margin: 0px 0px 10px 0px; + clear:both; } .section-content { diff --git a/web/app/assets/stylesheets/client/react-components/TeacherProfile.css.scss b/web/app/assets/stylesheets/client/react-components/TeacherProfile.css.scss index 9a14450be..59d767b3c 100644 --- a/web/app/assets/stylesheets/client/react-components/TeacherProfile.css.scss +++ b/web/app/assets/stylesheets/client/react-components/TeacherProfile.css.scss @@ -124,6 +124,17 @@ float:left; margin-right:20px; margin-top:20px; + + &.bandcamp-presence img { + + position:relative; + top:9px; + } + + &.user-website img { + position:relative; + top:-5px; + } } .performance-sample-option { diff --git a/web/app/assets/stylesheets/client/teachers.css.scss b/web/app/assets/stylesheets/client/teachers.css.scss index 5052ce623..94c0eb9db 100644 --- a/web/app/assets/stylesheets/client/teachers.css.scss +++ b/web/app/assets/stylesheets/client/teachers.css.scss @@ -250,7 +250,7 @@ } .add-experience-btn { width:80px; - font-size:16px; + font-size:12px; margin-right:0; } .teacher-third-column { @@ -338,9 +338,6 @@ } } - label { - font-size: 1.05em; - } label.strong-label { font-weight: bold; diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 553fda099..c271166ba 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -59,6 +59,8 @@ ApiUsersController < ApiController :online_presences, :performance_samples]) .find(params[:id]) + @show_teacher_profile = params[:show_teacher] + respond_with @profile, responder: ApiResponder, :status => 200 end diff --git a/web/app/views/api_users/profile_show.rabl b/web/app/views/api_users/profile_show.rabl index 56a822dfe..e0ca56d9c 100644 --- a/web/app/views/api_users/profile_show.rabl +++ b/web/app/views/api_users/profile_show.rabl @@ -30,4 +30,10 @@ end child :musician_instruments => :instruments do attributes :description, :proficiency_level, :priority, :instrument_id -end \ No newline at end of file +end + +if @show_teacher_profile && @profile && @profile.teacher + node :teacher do + partial("api_teachers/detail", :object => @profile.teacher) + end +end diff --git a/web/app/views/clients/_profile.html.erb b/web/app/views/clients/_profile.html.erb index 0d04a2c3e..a84cf42f7 100644 --- a/web/app/views/clients/_profile.html.erb +++ b/web/app/views/clients/_profile.html.erb @@ -16,6 +16,8 @@

<%= link_to("EDIT PROFILE", '/client#/account/profile', :class => "button-orange edit-profile-btn") %> + <%= link_to("EDIT TEACHER PROFILE", '/client#/profile/teachers/setup/introduction', :class => "button-orange edit-teacher-profile-btn") %> + <%= link_to("VIEW TEACHER PROFILE", '/client#/profile/profile/teacher/ID', :class => "button-orange view-teacher-profile-btn") %>