[#1459] add profile-editing (note, it requires bluring the input fields for

changes to go through - this is a pretty assuming solution, but I doubt it
will cause problems)
This commit is contained in:
Tyler Renelle 2013-09-08 12:28:06 -04:00
parent 0b34b41bbe
commit aad034564e
9 changed files with 43 additions and 26 deletions

View file

@ -53,7 +53,7 @@ module.exports = function(grunt) {
'public/js/controllers/tasksCtrl.js',
'public/js/controllers/taskDetailsCtrl.js',
'public/js/controllers/filtersCtrl.js',
'public/js/controllers/userAvatarCtrl.js',
'public/js/controllers/userCtrl.js',
'public/js/controllers/groupsCtrl.js',
'public/js/controllers/petsCtrl.js',
'public/js/controllers/inventoryCtrl.js',

View file

@ -1,12 +0,0 @@
"use strict";
habitrpg.controller("UserAvatarCtrl", ['$scope', '$location', 'User',
function($scope, $location, User) {
$scope.profile = User.user;
$scope.hideUserAvatar = function() {
$(".userAvatar").hide();
};
$scope.toggleHelm = function(val){
User.log({op:'set', data:{'preferences.showHelm':val}});
}
}]);

View file

@ -0,0 +1,21 @@
"use strict";
habitrpg.controller("UserCtrl", ['$scope', '$location', 'User',
function($scope, $location, User) {
$scope.profile = User.user;
$scope.hideUserAvatar = function() {
$(".userAvatar").hide();
};
$scope.toggleHelm = function(val){
User.log({op:'set', data:{'preferences.showHelm':val}});
}
$scope.addWebsite = function(){
if (!User.user.profile.websites) User.user.profile.websites = [];
User.user.profile.websites.push($scope._newWebsite);
User.set('profile.websites', User.user.profile.websites);
$scope._newWebsite = '';
}
$scope.removeWebsite = function($index){
User.user.profile.websites.splice($index,1);
}
}]);

View file

@ -158,6 +158,16 @@ angular.module('userServices', []).
userServices.log(log);
},
setMultiple: function(obj){
var self = this;
var log = { op: 'set', data: {} };
_.each(obj, function(v,k){
window.habitrpgShared.helpers.dotSet(k, v, userServices.user);
log.data[k] = v;
})
userServices.log(log);
},
settings: settings
};

View file

@ -67,7 +67,7 @@ html
script(type='text/javascript', src='/js/controllers/tasksCtrl.js')
script(type='text/javascript', src='/js/controllers/taskDetailsCtrl.js')
script(type='text/javascript', src='/js/controllers/filtersCtrl.js')
script(type='text/javascript', src='/js/controllers/userAvatarCtrl.js')
script(type='text/javascript', src='/js/controllers/userCtrl.js')
script(type='text/javascript', src='/js/controllers/groupsCtrl.js')
script(type='text/javascript', src='/js/controllers/petsCtrl.js')
script(type='text/javascript', src='/js/controllers/inventoryCtrl.js')

View file

@ -1,4 +1,4 @@
.grid(ng-controller='UserAvatarCtrl')
.grid
.module.full-width
span.option-box.pull-right.wallet
include ../shared/gems

View file

@ -1,4 +1,4 @@
.row-fluid
.row-fluid(ng-controller='UserCtrl')
// ---- Customize -----
.span4.border-right
@ -38,30 +38,28 @@
// ------- Edit -------
.span4
// <profile-edit:>
// <a class='btn btn-success' x-bind="click:profileSave">Save</a>
// TODO use photo-upload instead: https://groups.google.com/forum/?fromgroups=#!topic/derbyjs/xMmADvxBOak
img.pull-right(ng-src='{{user.profile.imageUrl}}')
.control-group
label.control-label(for='profileImageUrl') Photo Url
.controls
input#profileImageUrl(type='url', value='{{user.profile.imageUrl}}', placeholder='Image Url')
input#profileImageUrl(type='url', ng-model='user.profile.imageUrl', placeholder='Image Url', ng-blur='set("profile.imageUrl", user.profile.imageUrl)')
.control-group
label.control-label(for='profileFullName') Full Name
.controls
input#profileFullName(type='text', placeholder='Full Name', value='{{user.profile.name}}')
input#profileFullName(type='text', placeholder='Full Name', ng-model='user.profile.name', ng-blur='set("profile.name", user.profile.name)', )
.control-group
label.control-label(for='profileBlurb') Blurb
.controls
textarea#profileBlurb(placeholder='Blurb') {{user.profile.blurb}}
textarea#profileBlurb(placeholder='Blurb', ng-model='user.profile.blurb', ng-blur='set("profile.blurb", user.profile.blurb)')
.control-group
label.control-label(for='profileWebsite') Websites
.controls
form(x-bind='submit:profileAddWebsite')
input#profileWebsite(type='url', value='{{_newProfileWebsite}}', placeholder='Add Website')
form(ng-submit='addWebsite()')
input#profileWebsite(type='url', ng-model='_newWebsite', placeholder='Add Website')
ul
// would prefer if there were and index in #each, instead using data-website to search with indexOf
li(ng-repeat='website in user.profile.websites')
| {{website}}
a(data-website='{{website}}', x-bind='click:profileRemoveWebsite')
a(data-website='{{website}}', ng-click='removeWebsite($index)')
i.icon-remove

View file

@ -6,7 +6,7 @@
header.site-header(ng-hide='user.preferences.hideHeader', role='banner', data-partysize='{{party.members.length>1 ? truarr(party.members.length) : 0}}')
// avatar
.herobox-wrap.main-herobox(ng-controller='UserAvatarCtrl')
.herobox-wrap.main-herobox(ng-controller='UserCtrl')
include avatar
// stat bars

View file

@ -1,4 +1,4 @@
.achievements-container
.achievements-container(ng-controller='UserCtrl')
// <div class='achievement achievement-sword'></div>
// <div class='achievement achievement-tree'></div>
// <div class='achievement achievement-comment'></div>