diff --git a/web/app/assets/javascripts/accounts_profile.js b/web/app/assets/javascripts/accounts_profile.js index 5c7cb6123..d904f5f0e 100644 --- a/web/app/assets/javascripts/accounts_profile.js +++ b/web/app/assets/javascripts/accounts_profile.js @@ -4,7 +4,9 @@ context.JK = context.JK || {}; context.JK.AccountProfileScreen = function(app) { + var $document = $(document); var logger = context.JK.logger; + var EVENTS = context.JK.EVENTS; var api = context.JK.Rest(); var userId; var user = {}; @@ -63,6 +65,7 @@ $('select#user_birth_date_1i', content_root).val(parseInt(birthDateYear)); $('select#user_birth_date_2i', content_root).val(parseInt(birthDateMonth)); $('select#user_birth_date_3i', content_root).val(parseInt(birthDateDay)); + } // update instruments @@ -87,6 +90,7 @@ } context.JK.dropdown($('select', content_root)); + } function isUserInstrument(instrument, userInstruments) { @@ -317,7 +321,9 @@ .always(function() { loadingCitiesData = false;}) } } + }) + context.JK.dropdown($('select')); } function navToAccount() { @@ -366,6 +372,9 @@ }, null, true); + + $document.triggerHandler(EVENTS.USER_UPDATED, response); + } function postUpdateProfileFailure(xhr, textStatus, errorMessage) { diff --git a/web/app/assets/javascripts/accounts_profile_avatar.js b/web/app/assets/javascripts/accounts_profile_avatar.js index 388bed37c..c89039d97 100644 --- a/web/app/assets/javascripts/accounts_profile_avatar.js +++ b/web/app/assets/javascripts/accounts_profile_avatar.js @@ -6,6 +6,7 @@ context.JK.AccountProfileAvatarScreen = function(app) { var self = this; var logger = context.JK.logger; + var EVENTS = context.JK.EVENTS; var rest = context.JK.Rest(); var user = {}; var tmpUploadPath = null; @@ -381,9 +382,9 @@ self.userDetail = response; // notify any listeners that the avatar changed - userDropdown.loadMe(); + // userDropdown.loadMe(); // $('.avatar_large img').trigger('avatar_changed', [self.userDetail.photo_url]); - + $(document).triggerHandler(EVENTS.USER_UPDATED, response); app.notify( { title: "Avatar Changed", text: "You have updated your avatar successfully." diff --git a/web/app/assets/javascripts/globals.js b/web/app/assets/javascripts/globals.js index 087e0213d..309c40509 100644 --- a/web/app/assets/javascripts/globals.js +++ b/web/app/assets/javascripts/globals.js @@ -32,8 +32,9 @@ SHOW_SIGNUP : 'show_signup', SHOW_SIGNIN : 'show_signin', RSVP_SUBMITTED: 'rsvp_submitted', - RSVP_CANCELED : 'rsvp_canceled' - } + RSVP_CANCELED : 'rsvp_canceled', + USER_UPDATED : 'user_updated' + }; context.JK.ALERT_NAMES = { NO_EVENT : 0, diff --git a/web/app/assets/javascripts/user_dropdown.js b/web/app/assets/javascripts/user_dropdown.js index 656ce71ab..3242ec824 100644 --- a/web/app/assets/javascripts/user_dropdown.js +++ b/web/app/assets/javascripts/user_dropdown.js @@ -6,7 +6,7 @@ context.JK = context.JK || {}; context.JK.UserDropdown = function (app) { - + var EVENTS = context.JK.EVENTS; var logger = context.JK.logger; var rest = new JK.Rest(); var userMe = null; @@ -53,12 +53,16 @@ $('.shortcuts .test-network').on('click', function(e) { app.layout.showDialog('network-test'); return false; - }) + }); $('#header-avatar').on('avatar_changed', function (event, newAvatarUrl) { updateAvatar(newAvatarUrl); event.preventDefault(); return false; + }); + $(document).on(EVENTS.USER_UPDATED, function(e, data) { + userMe = data; + updateHeader(); }) } @@ -115,5 +119,8 @@ loadMe(); } this.loadMe = loadMe; + } -})(window, jQuery); \ No newline at end of file +})(window, jQuery); + + diff --git a/web/app/views/clients/_account_profile.html.erb b/web/app/views/clients/_account_profile.html.erb index bf1ec484f..c297b0f7b 100644 --- a/web/app/views/clients/_account_profile.html.erb +++ b/web/app/views/clients/_account_profile.html.erb @@ -79,7 +79,7 @@
- <%= date_select("user", "birth_date", :use_short_month => true, :start_year => 1900, :end_year => Time.now.year - 18, :order => [:month, :day, :year], :default => -25.years.from_now) %> + <%= date_select("user", "birth_date", :use_short_month => true, :start_year => 1900, :end_year => Time.now.year - 18, :order => [:month, :day, :year], :default => -25.years.from_now, :html=>{:class => "account-profile-birthdate"} ) %>

diff --git a/web/spec/features/account_spec.rb b/web/spec/features/account_spec.rb index 64fa2baf5..80c2ab1b0 100644 --- a/web/spec/features/account_spec.rb +++ b/web/spec/features/account_spec.rb @@ -11,7 +11,7 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do emulate_client sign_in_poltergeist user visit "/client#/account" - + find('div.account-mid.identity') end @@ -99,7 +99,25 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do user.subscribe_email.should be_false user.first_name.should == "Bobby" user.last_name.should == "Toes" + should have_selector('#profile #user', text: 'Bobby Toes') + + + # Update birth date and check updated birth date + + jk_select("Jan", '#account-edit-profile-form #user_birth_date_2i') + jk_select("12", '#account-edit-profile-form #user_birth_date_3i') + jk_select("1960", '#account-edit-profile-form #user_birth_date_1i') + find("#account-edit-profile-submit").trigger(:click) + + user.reload + user.birth_date == "1960-01-12" + + should have_selector('#account-edit-profile-form .birth_date li.active', text: "Jan") + should have_selector('#account-edit-profile-form .birth_date li.active', text: "12") + should have_selector('#account-edit-profile-form .birth_date li.active', text: "1960") + } + end describe "unsuccessfully" do diff --git a/web/spec/features/avatar_spec.rb b/web/spec/features/avatar_spec.rb index 18aab6609..1e9c6521f 100644 --- a/web/spec/features/avatar_spec.rb +++ b/web/spec/features/avatar_spec.rb @@ -18,6 +18,9 @@ describe "Avatar", :js => true, :type => :feature, :capybara_feature => true do visit "/client#/account/profile/avatar" find('#account-edit-avatar-upload') + # within_frame 'filepicker_dialog' do + # attach_file '#fileUploadInput', Rails.root.join('spec', 'files', 'avatar.jpg') + # end end it { diff --git a/web/spec/files/avatar.jpeg b/web/spec/files/avatar.jpeg new file mode 100644 index 000000000..799e5cbba Binary files /dev/null and b/web/spec/files/avatar.jpeg differ