added fullnames in boot, cleanup of pages

This commit is contained in:
Rushabh Mehta 2012-02-27 18:06:32 +05:30
parent 337fc930ba
commit d7d8d12299
16 changed files with 49 additions and 45 deletions

View file

@ -183,6 +183,9 @@ div.std-footer-item {
padding: 15px;
background-color: #FFF;
min-height: 450px;
-moz-box-shadow: 7px 0px 6px -2px #ddd;
-webkit-box-shadow: 7px 0px 6px -2px #ddd;
box-shadow: 7px 0px 6px -2px #ddd;
}
.layout-side-section {

View file

@ -19,7 +19,7 @@ function startup() {
profile = r.profile;
user = r.profile.name;
user_fullname = profile.first_name + (r.profile.last_name ? (' ' + r.profile.last_name) : '');
user_fullname = wn.boot.user_fullnames ? wn.boot.user_fullnames[user] : 'Guest';
user_defaults = profile.defaults;
user_roles = profile.roles;
user_email = profile.email;

View file

@ -93,9 +93,6 @@ function save_doclist(dt, dn, save_action, onsave, onerr) {
}
var _save = function() {
//if(user=='Administrator')errprint(out);
page_body.set_status('Saving...')
$c('webnotes.widgets.form.save.savedocs', {'docs':compress_doclist(doclist), 'docname':dn, 'action': save_action, 'user':user },
function(r, rtxt) {
if(f){ f.savingflag = false;}

View file

@ -186,7 +186,7 @@ return;if(_r.rb_con.cur_rb){if(_r.rb_con.cur_rb.large_report==1){msgprint("This
_r.rb_con.cur_rb.mytabs.items['Result'].expand();}
var me=this;this._get_query();if(this.set_data){this.show_result(this.set_data);this.set_data=null;return;}
$ds(this.fetching_tag);if(isFF)this.clear_all();var args={'query':me.query,'report_name':'_r.DataTable','show_deleted':1,'sc_id':me.search_criteria?me.search_criteria.name:'','filter_values':me.filter_vals?docstring(me.filter_vals):'','roles':'["'+user_roles.join('","')+'"]'}
if(this.is_simple)args.is_simple=1;page_body.set_status('Running Query...');$c('webnotes.widgets.query_builder.runquery',args,function(r,rt){$dh(me.fetching_tag);page_body.set_status('Done');me.show_result(r,rt);});}
if(this.is_simple)args.is_simple=1;$c('webnotes.widgets.query_builder.runquery',args,function(r,rt){$dh(me.fetching_tag);me.show_result(r,rt);});}
_r.DataTable.prototype.clear_all=function(){if(this.htab&&this.htab.parentNode){this.htab.parentNode.removeChild(this.htab);delete this.htab;}
if(this.tab&&this.tab.parentNode){this.tab.parentNode.removeChild(this.tab);delete this.tab;}
$dh(this.no_data_tag);}

View file

@ -31,6 +31,8 @@
**/
wn.provide('wn.pages');
function Body() {
this.left_sidebar = null;
this.right_sidebar = null;
@ -89,15 +91,14 @@ function Body() {
// - Item List
// - [Pages by their names]
this.pages = {};
this.cur_page = null;
this.add_page = function(label, onshow, onhide) {
var c = $a(this.center.body, 'div');
if(onshow)
c.onshow = onshow;
c.page_show = onshow;
if(onhide)
c.onhide = onhide;
this.pages[label] = c;
c.page_hide = onhide;
wn.pages[label] = c;
$dh(c);
return c;
}
@ -105,24 +106,19 @@ function Body() {
this.change_to = function(label) {
// hide existing
$dh(this.center.loading);
if(me.cur_page && me.pages[label]!=me.cur_page) {
if(me.cur_page.onhide)
me.cur_page.onhide();
if(me.cur_page && wn.pages[label]!=me.cur_page) {
if(me.cur_page.page_hide)
me.cur_page.page_hide();
$dh(me.cur_page);
}
// show
me.cur_page = me.pages[label];
me.cur_page = wn.pages[label];
me.cur_page_label = label;
$(me.cur_page).fadeIn();
// on show
if(me.cur_page.onshow)
me.cur_page.onshow(me.cur_page);
}
this.set_status = function(txt) {
if(this.status_area)
this.status_area.innerHTML = txt;
if(me.cur_page.page_show)
me.cur_page.page_show(me.cur_page);
}
this.set_session_changed = function() {

View file

@ -106,7 +106,6 @@ function loaddoc(doctype, name, onload, menuitem, from_archive) {
var show_doc = function(r,rt) {
if(locals[doctype] && locals[doctype][name]) {
page_body.set_status('Done');
var frm = frms[doctype];
// show
@ -205,10 +204,9 @@ function loadpage(page_name, call_back, no_history) {
if(page_name=='_home')
page_name = home_page;
var fn = function(r,rt) {
page_body.set_status('Done');
if(page_body.pages[page_name]) {
if(wn.pages[page_name]) {
// loaded
var p = page_body.pages[page_name]
var p = wn.pages[page_name]
// show
page_body.change_to(page_name);
@ -237,7 +235,7 @@ function loadpage(page_name, call_back, no_history) {
}
}
if(get_local('Page', page_name) || page_body.pages[page_name])
if(get_local('Page', page_name) || wn.pages[page_name])
fn();
else {
args = get_url_dict(); // send everything to the page

View file

@ -22,7 +22,6 @@
// PAGE
var pages=[];
var stylesheets = [];
function Page(page_name, content) {
@ -32,13 +31,16 @@ function Page(page_name, content) {
this.trigger = function(event) {
try {
if(pscript[event+'_'+this.name])
pscript[event+'_'+this.name](this.wrapper);
pscript[event+'_'+this.name](me.wrapper);
if(me.wrapper[event]) {
me.wrapper[event](me.wrapper);
}
} catch(e) {
console.log(e);
}
}
this.onshow = function() {
this.page_show = function() {
// default set_title
set_title(me.doc.title ? me.doc.title : me.name);
@ -52,14 +54,11 @@ function Page(page_name, content) {
cur_frm = null;
}
this.wrapper = page_body.add_page(page_name, this.onshow);
this.wrapper = page_body.add_page(page_name, this.page_show);
this.cont = this.wrapper // bc
if(content)
this.wrapper.innerHTML = content;
if(page_name == home_page)
pages['_home'] = this;
return this;
}
@ -103,5 +102,6 @@ function refresh_page(page_name) {
var fn = function(r, rt) {
render_page(page_name)
}
$c('webnotes.widgets.page.getpage', {'name':page_name, stylesheets:JSON.stringify(stylesheets)}, fn);
$c('webnotes.widgets.page.getpage', {'name':page_name,
stylesheets:JSON.stringify(stylesheets)}, fn);
}

View file

@ -204,7 +204,7 @@ Field.prototype.refresh_mandatory = function() {
Field.prototype.refresh_display = function() {
// from permission
if(!this.set_status || this.set_status!=this.disp_status) { // status changed
if(!this.current_status || this.current_status!=this.disp_status) { // status changed
if(this.disp_status=='Write') { // write
if(this.make_input&&(!this.input)) { // make input if reqd
this.make_input();
@ -238,7 +238,7 @@ Field.prototype.refresh_display = function() {
if(this.hide) this.hide();
else $dh(this.wrapper);
}
this.set_status = this.disp_status;
this.current_status = this.disp_status;
}
}

View file

@ -1076,14 +1076,12 @@ _f.Frm.prototype.reload_doc = function() {
}
var ret_fn = function(r, rtxt) {
page_body.set_status('Done')
// n tweets and last comment
me.runclientscript('setup', me.doctype, me.docname);
me.refresh();
}
page_body.set_status('Reloading...')
if(me.doc.__islocal) {
// reload only doctype
$c('webnotes.widgets.form.load.getdoctype', {'doctype':me.doctype }, ret_fn, null, null, 'Refreshing ' + me.doctype + '...');

View file

@ -119,7 +119,6 @@ _f.add_frm = function(doctype, onload, opt_name, from_archive) {
// Load Doctype from server
var callback = function(r,rt) {
page_body.set_status('Done')
if(!locals['DocType'][doctype]) {
if(r.exc) { msgprint("Did not load " + doctype, 1); }

View file

@ -317,10 +317,8 @@ _r.DataTable.prototype.run = function() {
if(this.is_simple) args.is_simple = 1;
page_body.set_status('Running Query...');
$c('webnotes.widgets.query_builder.runquery', args, function(r,rt) {
$dh(me.fetching_tag);
page_body.set_status('Done');
me.show_result(r,rt);
});

View file

@ -148,7 +148,6 @@ wn.body.List = function(list_page, parent, doctype) {
},
reload: function() {
list_page.page_head.set_status('Checking for updates...');
wn.list.diff(doctype, (me.list.length ? me.list[0].modified : null),
me.render_reload);
},
@ -164,7 +163,6 @@ wn.body.List = function(list_page, parent, doctype) {
me.render(me.list);
// update heading
list_page.page_head.set_status('');
},
refresh: function() {

View file

@ -49,6 +49,8 @@ wn.widgets.Listing = function(opts) {
// create place holders for all the elements
this.make = function(opts) {
if(this.opts.parent.jquery)
this.opts.parent = this.opts.parent.get(0);
this.wrapper = $a(this.opts.parent, 'div');
this.filters_area = $a(this.wrapper, 'div', 'listing-filters');
this.toolbar_area = $a(this.wrapper, 'div', 'listing-toolbar');
@ -134,6 +136,7 @@ wn.widgets.Listing = function(opts) {
$dh(this.more_button_area);
if(this.loading_img) $dh(this.loading_img)
if(r.message) r.values = r.message;
if(r.values && r.values.length) {
this.values = r.values;

View file

@ -51,6 +51,7 @@ def get_bootinfo():
if webnotes.session['user'] != 'Guest':
import webnotes.widgets.menus
bootinfo['dt_labels'] = get_dt_labels()
bootinfo['user_fullnames'] = get_fullnames()
# home page
get_home_page(bootinfo, doclist)
@ -71,6 +72,19 @@ def get_bootinfo():
return bootinfo
def get_fullnames():
"""map of user fullnames"""
import webnotes
ret = dict(webnotes.conn.sql("""select name,
concat(ifnull(first_name, ''),
if(ifnull(first_name, '')!='', ' ', ''), ifnull(last_name, ''))
from tabProfile where ifnull(enabled, 0)=1"""))
for key in ret:
if not ret[key]:
ret[key] = key
return ret
def get_profile(bootinfo):
"""get profile info"""
import webnotes

View file

@ -44,7 +44,7 @@ def getCSVelement(v):
return '"'+v+'"'
else: return v or ''
def get_full_name(profile):
def get_fullname(profile):
"""get the full name (first name + last name) of the user from Profile"""
p = webnotes.conn.sql("""select first_name, last_name from tabProfile
where name=%s""", profile, as_dict=1)

View file

@ -59,9 +59,9 @@ def add():
# update feeed
try:
import home
from webnotes.utils import get_full_name
from webnotes.utils import get_fullname
home.make_feed('Assignment', d.reference_type, d.reference_name, webnotes.session['user'],
'[%s] Assigned to %s' % (d.priority, get_full_name(d.owner)), '#C78F58')
'[%s] Assigned to %s' % (d.priority, get_fullname(d.owner)), '#C78F58')
except ImportError, e:
pass