VRFS-2701 remove use of template on experience screen

This commit is contained in:
Brian Smith 2015-03-23 22:26:36 -04:00
parent 9face3b3f9
commit d3cf83db85
2 changed files with 85 additions and 96 deletions

View File

@ -9,14 +9,14 @@
var EVENTS = context.JK.EVENTS;
var api = context.JK.Rest();
var $screen = $('#account-profile-experience');
var $scroller = $screen.find('#account-profile-content-scroller');
var $instrumentSelector = null;
var $userGenres = null;
var profileUtils = context.JK.ProfileUtils;
var $btnCancel = $screen.find('#account-edit-profile-cancel');
var $btnBack = $screen.find('#account-edit-profile-back');
var $btnSubmit = $screen.find('#account-edit-profile-submit');
var $instrumentSelector = $screen.find('.instrument_selector');
var $userGenres = $screen.find('#user-genres');
function beforeShow(data) {
}
@ -26,23 +26,15 @@
}
function resetForm() {
$scroller.find('form .error-text').remove();
$scroller.find('form .error').removeClass("error");
$screen.find('form .error-text').remove();
$screen.find('form .error').removeClass("error");
}
function populateAccountProfile(userDetail, instruments) {
var template = context.JK.fillTemplate($('#template-account-profile-experience').html(), {
user_instruments: userDetail.instruments
});
$scroller.html(template);
$instrumentSelector = $screen.find('.instrument_selector');
$userGenres = $screen.find('#user-genres');
events();
loadGenres(profileUtils.profileGenres(userDetail.genres));
$instrumentSelector.empty();
$.each(instruments, function(index, instrument) {
var template = context.JK.fillTemplate($('#account-profile-instrument').html(), {
checked : isUserInstrument(instrument, userDetail.instruments) ? "checked=\"checked\"" :"",
@ -55,15 +47,15 @@
// and fill in the proficiency for the instruments that the user can play
if(userDetail.instruments) {
$.each(userDetail.instruments, function(index, userInstrument) {
$('tr[data-instrument-id="' + userInstrument.instrument_id + '"] select.proficiency_selector', $scroller).val(userInstrument.proficiency_level);
$('tr[data-instrument-id="' + userInstrument.instrument_id + '"] select.proficiency_selector', $screen).val(userInstrument.proficiency_level);
});
}
$scroller.find('select[name=skill_level]').val(userDetail.skill_level);
$scroller.find('select[name=concert_count]').val(userDetail.concert_count);
$scroller.find('select[name=studio_session_count]').val(userDetail.studio_session_count);
$screen.find('select[name=skill_level]').val(userDetail.skill_level);
$screen.find('select[name=concert_count]').val(userDetail.concert_count);
$screen.find('select[name=studio_session_count]').val(userDetail.studio_session_count);
context.JK.dropdown($('select', $scroller));
context.JK.dropdown($('select', $screen));
}
function isUserInstrument(instrument, userInstruments) {
@ -122,6 +114,7 @@
function events() {
$btnCancel.click(function(evt) {
console.log("HERE");
evt.stopPropagation();
navigateTo('/client#/profile/' + context.JK.currentUserId);
return false;
@ -158,16 +151,15 @@
function handleUpdateProfile() {
resetForm();
var instruments = getInstrumentsValue();
var instruments = getSelectedInstruments();
var genres = getSelectedGenres();
var status =
api.updateUser({
instruments: instruments,
genres: genres,
skill_level: $scroller.find('select[name=skill_level]').val(),
concert_count: $scroller.find('select[name=concert_count]').val(),
studio_session_count: $scroller.find('select[name=studio_session_count]').val()
skill_level: $screen.find('select[name=skill_level]').val(),
concert_count: $screen.find('select[name=concert_count]').val(),
studio_session_count: $screen.find('select[name=studio_session_count]').val()
})
.done(postUpdateProfileSuccess)
.fail(postUpdateProfileFailure);
@ -186,7 +178,7 @@
var instruments = context.JK.format_errors("musician_instruments", errors);
if(instruments != null) {
instrumentSelector.closest('div.field').addClass('error').append(instruments);
$instrumentSelector.closest('div.field').addClass('error').append(instruments);
}
}
else {
@ -194,7 +186,7 @@
}
}
function getInstrumentsValue() {
function getSelectedInstruments() {
var instruments = [];
$('input[type=checkbox]:checked', $instrumentSelector).each(function(i) {
@ -217,7 +209,10 @@
'beforeShow': beforeShow,
'afterShow': afterShow
};
app.bindScreen('account/profile/experience', screenBindings);
events();
}
this.initialize = initialize;

View File

@ -9,81 +9,75 @@
<div class="content-body">
<div id="account-profile-content-scroller" class="content-body-scroller account-content-scroller">
<div class="content-wrapper account-profile">
<form id="account-edit-profile-experience-form">
<h2>edit profile: musical experience</h2>
<div class="field left">
<label for="user-genres">What genres do you play?</label>
<div class="genres">
<table id="user-genres" width="100%" cellpadding="10" cellspacing="6"></table>
</div>
</div>
<div class="field right w65">
What instruments do you play?
<div class="instruments">
<table class="instrument_selector" width="100%" cellpadding="0" cellspacing="6">
</table>
</div>
</div>
<div class="clearall"></div>
<div>
<div class="field left w35">
<label>Status</label>
<select name="skill_level">
<option value='1'>Amateur</option>
<option value='2'>Professional</option>
</select>
</div>
<div class="field left w25">
<label>Concert Gigs Played</label>
<select name="concert_count">
<option value='0'>zero</option>
<option value='1'>under 10</option>
<option value='2'>10 to 50</option>
<option value='3'>50 to 100</option>
<option value='4'>over 100</option>
</select>
</div>
<div class="field left w25">
<label>Studio Sessions Played</label>
<select name="studio_session_count">
<option value='0'>zero</option>
<option value='1'>under 10</option>
<option value='2'>10 to 50</option>
<option value='3'>50 to 100</option>
<option value='4'>over 100</option>
</select>
</div>
</div>
<br/><br/>
<div class="right field actions">
<a id="account-edit-profile-cancel" class="button-grey">CANCEL</a>&nbsp;&nbsp;
<a id="account-edit-profile-back" class="button-grey">BACK</a>&nbsp;&nbsp;
<a id="account-edit-profile-submit" class="button-orange">SAVE &amp; NEXT</a>
</div>
<div class="clearall"></div>
</form>
</div>
</div>
</div>
</div>
<script type="text/template" id="template-account-profile-experience">
<div class="content-wrapper account-profile">
<form id="account-edit-profile-experience-form">
<h2>edit profile: musical experience</h2>
<div class="field left">
<label for="user-genres">What genres do you play?</label>
<div class="genres">
<table id="user-genres" width="100%" cellpadding="10" cellspacing="6"></table>
</div>
</div>
<div class="field right w65">
What instruments do you play?
<div class="instruments">
<table class="instrument_selector" width="100%" cellpadding="0" cellspacing="6">
</table>
</div>
</div>
<div class="clearall"></div>
<div>
<div class="field left w35">
<label>Status</label>
<select name="skill_level">
<option value='1'>Amateur</option>
<option value='2'>Professional</option>
</select>
</div>
<div class="field left w25">
<label>Concert Gigs Played</label>
<select name="concert_count">
<option value='0'>zero</option>
<option value='1'>under 10</option>
<option value='2'>10 to 50</option>
<option value='3'>50 to 100</option>
<option value='4'>over 100</option>
</select>
</div>
<div class="field left w25">
<label>Studio Sessions Played</label>
<select name="studio_session_count">
<option value='0'>zero</option>
<option value='1'>under 10</option>
<option value='2'>10 to 50</option>
<option value='3'>50 to 100</option>
<option value='4'>over 100</option>
</select>
</div>
</div>
<br/><br/>
<div class="right field actions">
<a id="account-edit-profile-cancel" class="button-grey">CANCEL</a>&nbsp;&nbsp;
<a id="account-edit-profile-back" class="button-grey">BACK</a>&nbsp;&nbsp;
<a id="account-edit-profile-submit" class="button-orange">SAVE &amp; NEXT</a>
</div>
<div class="clearall"></div>
</form>
</div>
</script>
<script type="text/template" id="account-profile-instrument">
<tr data-instrument-id='{id}'>