* teacher profile musician profile QA'ed some

This commit is contained in:
Seth Call 2016-01-15 11:59:55 -06:00
parent 88afc1c272
commit 0d49744a7a
19 changed files with 173 additions and 68 deletions

View File

@ -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)

View File

@ -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

View File

@ -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;
@ -36,6 +36,12 @@
}
function afterShow(data) {
if (window.ProfileStore.solo) {
$btnSubmit.text('SAVE & RETURN TO PROFILE');
}
else {
$btnSubmit.text('SAVE & NEXT');
}
resetForm();
renderAccountProfile();
}
@ -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];
@ -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,20 +224,25 @@
/****************** 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);
@ -283,13 +294,17 @@
}
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-profile-content-scroller').on('submit', '#account-edit-email-form', function (evt) {
evt.stopPropagation();
handleUpdateProfile();
return false;
});
$("#account-edit-email-form").removeClass("disabled");
}
@ -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,35 +335,35 @@
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);
}
}
@ -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,9 +419,9 @@
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) {
.error(function (err) {
cityElement.children().remove();
cityElement.append($(nilOptionStr).text(nilOptionText));
})
@ -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);
})(window, jQuery);

View File

@ -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();

View File

@ -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()

View File

@ -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("<span class='error-text'>Invalid username</span>").show();
}
function websiteSuccessCallback($inputDiv) {
$inputDiv.addClass('error');
$inputDiv.find('.error-text').remove();
$inputDiv.append("<span class='error-text'>Invalid URL</span>").show();
}
function soundCloudSuccessCallback($inputDiv) {
siteSuccessCallback($inputDiv, soundCloudRecordingValidator, $soundCloudSampleList, 'soundcloud');
}

View File

@ -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
});
}

View File

@ -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)

View File

@ -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(`<div className="profile-tile"><a className={classes}

View File

@ -62,12 +62,12 @@ rest = window.JK.Rest()
<div className="teacher-field" name="years_teaching">
<label htmlFor="years-teaching-experience">Years Teaching Experience:</label>
<input className="years-teaching-experience" name="years_teaching" ref ="years_teaching_experience" type="number" min="0" max="99" value={this.state.years_teaching} onChange={this.handleTextChange} placeholder="Select" />
<input className="years-teaching-experience" name="years_teaching" ref ="years_teaching_experience" type="number" min="0" max="99" value={this.state.years_teaching} onChange={this.handleTextChange} />
</div>
<div className="teacher-field" name="years_playing">
<label htmlFor="teacher-playing-experience">Years Playing Experience:</label>
<input className="years-playing-experience" name="years_playing" ref="years_playing_experience" type="number" min="0" max="99" value={this.state.years_playing} onChange={this.handleTextChange} placeholder="Select" />
<input className="years-playing-experience" name="years_playing" ref="years_playing_experience" type="number" min="0" max="99" value={this.state.years_playing} onChange={this.handleTextChange} />
</div>
</div>
<TeacherSetupNav hideBack={true} handleNav={this.handleNav}/>

View File

@ -20,7 +20,10 @@ ProfileActions = @ProfileActions
render: () ->
if window.ProfileStore.solo
saveText = 'SAVE'
saveText = 'SAVE & RETURN TO PROFILE'
else
if @props.last
saveText = 'SAVE & FINISH'
else
saveText = 'SAVE & NEXT'

View File

@ -276,7 +276,7 @@ rest = window.JK.Rest()
{priceRows}
<br className="clearall"/>
<TeacherSetupNav handleNav={this.handleNav}></TeacherSetupNav>
<TeacherSetupNav handleNav={this.handleNav} last={true}></TeacherSetupNav>
</div>`

View File

@ -492,9 +492,6 @@
}
}
label {
font-size: 1.05em;
}
}
#bands-screen {

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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

View File

@ -31,3 +31,9 @@ end
child :musician_instruments => :instruments do
attributes :description, :proficiency_level, :priority, :instrument_id
end
if @show_teacher_profile && @profile && @profile.teacher
node :teacher do
partial("api_teachers/detail", :object => @profile.teacher)
end
end

View File

@ -16,6 +16,8 @@
<div class="user-header">
<h2 id="username"></h2>
<%= 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") %>
</div>
<!-- action buttons -->