cleaned up profile settings

This commit is contained in:
Rushabh Mehta 2012-11-26 16:51:51 +05:30
parent 21df1479a7
commit 36b586cdfe
3 changed files with 57 additions and 33 deletions

View File

@ -25,11 +25,32 @@ MyProfile = function(wrapper) {
this.make = function() { this.make = function() {
this.wrapper.appframe = new wn.ui.AppFrame($(this.wrapper).find('.layout-appframe'), 'Profile Settings'); this.wrapper.appframe = new wn.ui.AppFrame($(this.wrapper).find('.layout-appframe'), 'Profile Settings');
this.wrapper.appframe.add_button('Update', this.update_profile);
this.wrapper.appframe.buttons["Update"].addClass("btn-info");
this.wrapper.appframe.add_button('Change Password', this.change_password); this.wrapper.appframe.add_button('Change Password', this.change_password);
this.wrapper.appframe.add_button('Change Background', this.change_background);
this.wrapper.appframe.add_label("Set Theme:"); $(this.wrapper).find('.layout-main').html("<h4>Personal</h4>\
this.wrapper.appframe.add_select("Theme", <div class='personal-settings' style='margin-left: 15px;'></div>\
keys(erpnext.themes).sort()) <hr>\
<!--<h4>Email</h4>\
<div class='email-settings' style='margin-left: 15px;'></div>\
<hr>-->\
<h4>Display</h4>\
<div class='display-settings' style='margin-left: 15px;'>\
<p>Change Background: <button class='btn btn-small change-background'>Upload</button></p>\
<br><p>Change Theme: <select class='change-theme'></select></p>\
</div>");
this.make_display();
this.make_personal();
}
this.make_display = function() {
$(this.wrapper).find(".change-background")
.click(me.change_background)
$(this.wrapper).find(".change-theme")
.add_options(keys(erpnext.themes).sort())
.change(function() { .change(function() {
erpnext.set_theme($(this).val()); erpnext.set_theme($(this).val());
}).val(wn.boot.profile.defaults.theme ? }).val(wn.boot.profile.defaults.theme ?
@ -42,16 +63,20 @@ MyProfile = function(wrapper) {
args: {theme: $(this).val() } args: {theme: $(this).val() }
}) })
}); });
}
this.make_personal = function() {
this.personal = $(this.wrapper).find('.personal-settings').html('<div \
class="pull-left" style="width: 300px;">\
<img style="max-width: 200px;" src='+wn.user_info(user).image+'><br><br>\
<button class="btn btn-small">Change Image</button><br><br>\
</div><div class="pull-left profile-form" style="width: 45%; margin-top: -11px;">\
<div class="clear"></div>\
</div>')
this.tab = make_table($a($(this.wrapper).find('.layout-main').get(0), 'div', '', {marginTop:'19px'}), this.personal.find("button").click(this.change_image);
1, 2, '90%', ['50%', '50%'], {padding:'11px'})
this.img = $a($td(this.tab, 0, 0), 'img', '', {width: '120px', maxHeight:'200px'});
this.img.src = wn.user_info(user).image;
$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image);
this.make_form(); this.make_form();
this.load_details(); this.load_details();
} }
this.load_details = function() { this.load_details = function() {
@ -64,34 +89,30 @@ MyProfile = function(wrapper) {
// form // form
// //
this.make_form = function() { this.make_form = function() {
var div = $a($td(this.tab, 0, 1), 'div'); var div = this.personal.find(".profile-form").get(0);
this.form = new wn.ui.FieldGroup({ this.form = new wn.ui.FieldGroup({
parent: div, parent: div,
fields: [ fields: [
{fieldname:'first_name', fieldtype:'Data',label:'First Name',reqd:1}, {fieldname:'first_name', fieldtype:'Data',label:'First Name',reqd:1},
{fieldname:'last_name', fieldtype:'Data',label:'Last Name'}, {fieldname:'last_name', fieldtype:'Data',label:'Last Name'},
{fieldname:'email_signature', fieldtype:'Text',label:'Email Signature', {fieldname:'email_signature', fieldtype:'Small Text',label:'Email Signature',
decription:'Will be appended to outgoing mail'}, decription:'Will be appended to outgoing mail'},
{fieldname:'bio', fieldtype:'Text',label:'Bio'},
{fieldname:'update', fieldtype:'Button',label:'Update'}
] ]
}); });
this.form.fields_dict.update.input.onclick = function() {
var v = me.form.get_values();
if(v) {
this.set_working();
var btn = this;
$c_page('home','profile_settings','set_user_details',v,function(r, rt) {
btn.done_working();
})
}
}
} }
// this.update_profile = function() {
// change password var v = me.form.get_values();
// if(v) {
$(this).set_working();
var btn = this;
$c_page('home','profile_settings','set_user_details',v,function(r, rt) {
$(btn).done_working();
})
}
}
this.change_password = function() { this.change_password = function() {
var d = new wn.ui.Dialog({ var d = new wn.ui.Dialog({
title:'Change Password', title:'Change Password',
@ -137,7 +158,7 @@ MyProfile = function(wrapper) {
if(fid) { if(fid) {
d.hide(); d.hide();
wn.boot.user_info[user].image = 'files/' + fid; wn.boot.user_info[user].image = 'files/' + fid;
pscript.myprofile.img.src = 'files/' + fid; me.personal.find("img").attr("src", 'files/' + fid);
} }
} }
}); });

View File

@ -49,7 +49,8 @@ def get_user_details(arg=None):
""" """
Returns user first name, last name and bio Returns user first name, last name and bio
""" """
return webnotes.conn.sql("select first_name, last_name, bio from tabProfile where name=%s", webnotes.user.name, as_dict=1)[0] return webnotes.conn.sql("""select first_name, last_name, bio, email_signature
from tabProfile where name=%s""", webnotes.user.name, as_dict=1)[0]
@webnotes.whitelist() @webnotes.whitelist()
def set_user_details(arg=None): def set_user_details(arg=None):

View File

@ -133,7 +133,9 @@ erpnext.CommunicationView = Class.extend({
this.comm_list[0].find('.comm-content').toggle(true); this.comm_list[0].find('.comm-content').toggle(true);
}, },
make_body: function() { make_body: function() {
this.body = $("<table class='table table-bordered table-hover table-striped'>").appendTo(this.parent); this.wrapper = $("<div><h4>Communication History</h4></div>").appendTo(this.parent);
this.body = $("<table class='table table-bordered table-hover table-striped'>")
.appendTo(this.body);
}, },
prepare: function(doc) { prepare: function(doc) {
//doc.when = comment_when(this.doc.modified); //doc.when = comment_when(this.doc.modified);