From 4e456bce41c1f1c0fcab07c94d2c5b2b69e93c46 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 13 Mar 2015 02:26:09 -0400 Subject: [PATCH] VRFS-2701 wip current interests editing --- .../accounts_profile_experience.js | 6 +- .../javascripts/accounts_profile_interests.js | 116 +++++++++ .../client/accountProfileInterests.css.scss | 43 ++++ .../_account_profile_experience.html.erb | 7 - .../_account_profile_interests.html.erb | 222 ++++++++++++++++++ web/app/views/clients/index.html.erb | 4 +- 6 files changed, 386 insertions(+), 12 deletions(-) diff --git a/web/app/assets/javascripts/accounts_profile_experience.js b/web/app/assets/javascripts/accounts_profile_experience.js index a85888b9f..826cf09aa 100644 --- a/web/app/assets/javascripts/accounts_profile_experience.js +++ b/web/app/assets/javascripts/accounts_profile_experience.js @@ -48,7 +48,7 @@ description : instrument.description, id : instrument.id }); - $instrumentSelector.append(template) + $instrumentSelector.append(template); }); // and fill in the proficiency for the instruments that the user can play @@ -137,7 +137,7 @@ function navigateTo(targetLocation) { resetForm(); - window.location = targetLocation; + context.location = targetLocation; } function handleUpdateProfile() { @@ -152,7 +152,7 @@ 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(), + studio_session_count: $scroller.find('select[name=studio_session_count]').val() }) .done(postUpdateProfileSuccess) .fail(postUpdateProfileFailure); diff --git a/web/app/assets/javascripts/accounts_profile_interests.js b/web/app/assets/javascripts/accounts_profile_interests.js index e69de29bb..a79fb5e1a 100644 --- a/web/app/assets/javascripts/accounts_profile_interests.js +++ b/web/app/assets/javascripts/accounts_profile_interests.js @@ -0,0 +1,116 @@ +(function(context,$) { + + "use strict"; + + context.JK = context.JK || {}; + context.JK.AccountProfileInterests= function(app) { + var $document = $(document); + var logger = context.JK.logger; + var EVENTS = context.JK.EVENTS; + var api = context.JK.Rest(); + var userId; + var user = {}; + var profileUtils = context.JK.ProfileUtils; + + var $screen = $('#account-profile-interests'); + var $scroller = $screen.find('#account-profile-content-scroller'); + var $btnCancel = $scroller.find('#account-edit-profile-cancel'); + var $btnBack = $scroller.find('#account-edit-profile-back'); + var $btnSubmit = $scroller.find('#account-edit-profile-submit'); + + function beforeShow(data) { + userId = data.id; + } + + function afterShow(data) { + renderInterests(); + } + + function resetForm() { + $scroller.find('form .error-text').remove(); + $scroller.find('form .error').removeClass("error"); + } + + function populateAccountProfile(userDetail) { + + + context.JK.dropdown($('select', $scroller)); + } + + function events() { + console.log("HERE2"); + $btnCancel.on('click', function(evt) { evt.stopPropagation(); navigateTo('/client#/account'); return false; } ); + $btnBack.on('click', function(evt) { evt.stopPropagation(); navigateTo('/client#/account/profile/experience'); return false; } ); + $btnSubmit.on('click', function(evt) { evt.stopPropagation(); handleUpdateProfile(); return false; } ); + } + + function renderInterests() { + $.when(api.getUserProfile()) + .done(function(userDetailResponse) { + var userDetail = userDetailResponse[0]; + populateAccountProfile(userDetail); + }); + + context.JK.dropdown($('select')); + } + + function navigateTo(targetLocation) { + console.log("HERE"); + context.location = targetLocation; + } + + function handleUpdateProfile() { + resetForm(); + + 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() + }) + .done(postUpdateProfileSuccess) + .fail(postUpdateProfileFailure); + } + + function postUpdateProfileSuccess(response) { + $document.triggerHandler(EVENTS.USER_UPDATED, response); + context.location = "/client#/account/profile/samples"; + } + + function postUpdateProfileFailure(xhr, textStatus, errorMessage) { + + var errors = JSON.parse(xhr.responseText) + + if(xhr.status == 422) { + + } + else { + app.ajaxError(xhr, textStatus, errorMessage) + } + } + + function initialize() { + var screenBindings = { + 'beforeShow': beforeShow, + 'afterShow': afterShow + }; + + app.bindScreen('account/profile/interests', screenBindings); + + events(); + + $screen.iCheck({ + checkboxClass: 'icheckbox_minimal', + radioClass: 'iradio_minimal', + inheritClass: true + }); + } + + this.initialize = initialize; + this.beforeShow = beforeShow; + this.afterShow = afterShow; + return this; + }; + +})(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/stylesheets/client/accountProfileInterests.css.scss b/web/app/assets/stylesheets/client/accountProfileInterests.css.scss index e69de29bb..0ae312516 100644 --- a/web/app/assets/stylesheets/client/accountProfileInterests.css.scss +++ b/web/app/assets/stylesheets/client/accountProfileInterests.css.scss @@ -0,0 +1,43 @@ +@import "client/common.css.scss"; + + +#account-profile-interests { + .interest { + font-weight: 600; + font-size: 16px; + } + + a.help { + font-weight: normal; + font-size: 14px; + } + + div.genres { + width: 20%; + margin-bottom: 15px; + } + + a.select-genre { + text-decoration: underline; + font-size: 12px; + font-weight: normal !important; + } + + span.genre-list { + font-style: italic; + font-size: 12px; + } + + .interest-options { + width: 30%; + margin-bottom: 15px; + + label { + margin-bottom: 10px; + } + } + + input[type=text].rate { + width: 100px; + } +} \ No newline at end of file diff --git a/web/app/views/clients/_account_profile_experience.html.erb b/web/app/views/clients/_account_profile_experience.html.erb index d4091e602..a371bd594 100644 --- a/web/app/views/clients/_account_profile_experience.html.erb +++ b/web/app/views/clients/_account_profile_experience.html.erb @@ -1,24 +1,17 @@ -
-
-
<%= image_tag "content/icon_account.png", {:width => 27, :height => 20} %>
-

my account

<%= render "screen_navigation" %>
- -
-