From 0f0b1f523520fab2ceaaf1a86197a731b9c943fd Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 11 Apr 2012 17:26:03 +0530 Subject: [PATCH] added app frame --- build.json | 1 + css/all-app.css | 20 +++++++++++------- css/all-web.css | 2 +- js/all-app.js | 55 ++++++++++++++++++++++++------------------------- js/all-web.js | 7 ++----- version.num | 2 +- 6 files changed, 44 insertions(+), 43 deletions(-) diff --git a/build.json b/build.json index 3c72277887..9c977b7f5c 100644 --- a/build.json +++ b/build.json @@ -131,6 +131,7 @@ "lib/js/legacy/utils/msgprint.js", "lib/js/legacy/utils/printElement.js", "lib/js/legacy/widgets/form/fields.js", + "lib/js/wn/views/appframe.js", "lib/js/wn/ui/dialog.js", "lib/js/wn/ui/button.js", "lib/js/legacy/widgets/dialog.js", diff --git a/css/all-app.css b/css/all-app.css index b64db5c122..2f1d36d030 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -169,7 +169,7 @@ div.loading_div { } div.std-footer { - margin: 13px 0px; + margin: 13px -15px; border-top: 1px solid #AAA; padding: 13px; } @@ -328,6 +328,13 @@ div.notice { */ /* FORMS */ +div.form-title { + /*background-color: #e0eeff;*/ + padding: 5px 11px 15px 11px; + margin: -15px -15px 0px -15px; + border-bottom: 1px solid #eee; +} + div.form-section-head { margin: 11px -15px 3px -15px; border-top: 1px solid #ccc; @@ -337,7 +344,7 @@ div.form-section-head { div.form-layout-row:first-child .form-section-head { border-top: 0px solid #ccc !important; margin-top: 0px; - padding-top: 0px; + padding-top: 15px; } div.form-section-head h3 { @@ -1712,10 +1719,6 @@ div.stat-bar { /* * lib/css/ui/views.css */ -.breadcrumbs-area { - margin-bottom: 8px; -} - .breadcrumbs { color: #000000; } @@ -1724,7 +1727,7 @@ div.stat-bar { color: #000000; } -div.page-app-bar { +div.appframe-titlebar { padding: 6px; background: #eeeeee; /* Old browsers */ background: -moz-linear-gradient(top, #eeeeee 0%, #cccccc 100%); /* FF3.6+ */ @@ -1736,7 +1739,8 @@ div.page-app-bar { filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#cccccc',GradientType=0 ); /* IE6-9 */ border-bottom: 1px solid #ccc; } -div.page-app-toolbar { + +div.appframe-toolbar { padding: 4px; background: #eeeeee; border-top: 1px solid #f8f8f8; diff --git a/css/all-web.css b/css/all-web.css index ee59bd2920..b788d2025a 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -169,7 +169,7 @@ div.loading_div { } div.std-footer { - margin: 13px 0px; + margin: 13px -15px; border-top: 1px solid #AAA; padding: 13px; } diff --git a/js/all-app.js b/js/all-app.js index 78deffe029..096a18e69f 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -359,10 +359,7 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('\ -
\ - \ - ×\ -
\ +
\
\

%(label)s

\
\ @@ -377,7 +374,7 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype,page){this.doct
\ \
\ - ',{label:this.label}));wn.views.breadcrumbs(this.$page.find('.breadcrumbs-area').get(0),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.add_delete_option();},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 + ',{label:this.label}));this.appframe=new wn.views.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.add_delete_option();},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);} this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('

No %(doctype_label)s found

\ %(description)s\ @@ -915,6 +912,15 @@ if(hide_label){f.with_label=0;} if(frm){f.frm=frm;if(parent) f.layout_cell=parent.parentNode;} if(f.init)f.init();f.make_body();return f;} +/* + * lib/js/wn/views/appframe.js + */ +wn.views.AppFrame=Class.extend({init:function(parent){this.buttons={};this.$w=$('
').appendTo(parent);this.$titlebar=$('
\ + ×\ +
').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})},add_button:function(label,click,icon){if(!this.$w.find('.appframe-toolbar').length) +this.$w.append('
');args={label:label,icon:''};if(icon){args.icon='';} +this.buttons[label]=$(repl('',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));},clear_buttons:function(){this.$w.find('.appframe-toolbar').empty();}}) /* * lib/js/wn/ui/dialog.js */ @@ -1173,7 +1179,7 @@ function upload_callback(id,fid){uploaders[id].callback(fid);} * lib/js/legacy/wn/page_layout.js */ wn.PageLayout=function(args){$.extend(this,args) -this.wrapper=$a(this.parent,'div','layout-wrapper layout-wrapper-background');this.head=$a(this.wrapper,'div');this.main=$a(this.wrapper,'div','layout-main-section');this.sidebar_area=$a(this.wrapper,'div','layout-side-section');$a(this.wrapper,'div','',{clear:'both'});this.toolbar_area=$a(this.main,'div');this.body=$a(this.main,'div');this.footer=$a(this.main,'div');if(this.heading){this.page_head=new PageHeader(this.head,this.heading);}} +this.wrapper=$a(this.parent,'div','layout-wrapper layout-wrapper-background');this.head=$a(this.wrapper,'div');this.main=$a(this.wrapper,'div','layout-main-section');this.sidebar_area=$a(this.wrapper,'div','layout-side-section');$a(this.wrapper,'div','',{clear:'both'});this.main_head=$a(this.main,'div','form-title');this.body=$a(this.main,'div');this.footer=$a(this.main,'div');if(this.heading){this.page_head=new PageHeader(this.head,this.heading);}} /* * lib/js/legacy/wn/widgets/page_sidebar.js */ @@ -1606,27 +1612,19 @@ d.cur_frm=f;d.dn=dn;d.table_form=f.meta.istable;f.refresh(dn);d.dialog.show();}) /* * lib/js/legacy/widgets/form/form_header.js */ -_f.FrmHeader=Class.extend({init:function(parent,frm){this.buttons={};this.$w=$('
\ -
\ - \ - \ - ×\ -
\ -
\ -
\ -
').appendTo(parent);this.$w.find('.close').click(function(){window.history.back();})},refresh:function(){wn.views.breadcrumbs($(this.$w.find('.breadcrumb-area')),cur_frm.meta.module,cur_frm.meta.name,cur_frm.docname);this.refresh_labels();this.refresh_toolbar();},refresh_labels:function(){var labinfo={0:['Draft',''],1:['Submitted','label-info'],2:['Cancelled','label-important']}[cint(cur_frm.doc.docstatus)];if(cur_frm.doc.__unsaved){labinfo[1]='label-warning'} +_f.FrmHeader=Class.extend({init:function(parent,frm){this.appframe=new wn.views.AppFrame(parent) +this.appframe.$titlebar.append('\ + ');this.$w=this.appframe.$w;},refresh:function(){wn.views.breadcrumbs($(this.$w.find('.breadcrumb-area')),cur_frm.meta.module,cur_frm.meta.name,cur_frm.docname);this.refresh_labels();this.refresh_toolbar();},refresh_labels:function(){var labinfo={0:['Draft',''],1:['Submitted','label-info'],2:['Cancelled','label-important']}[cint(cur_frm.doc.docstatus)];if(cur_frm.doc.__unsaved){labinfo[1]='label-warning'} this.$w.find('.label-area').html(repl('\ - %(lab_status)s',{lab_status:labinfo[0],lab_class:labinfo[1]}));},refresh_toolbar:function(){this.$w.find('.page-app-toolbar').empty();var p=cur_frm.get_doc_perms();if(cur_frm.meta.read_only_onload&&!cur_frm.doc.__islocal){if(!cur_frm.editable) -this.add_button('Edit',function(){cur_frm.edit_doc();},'icon-pencil');else -this.add_button('Print View',function(){cur_frm.is_editable[cur_frm.docname]=0;cur_frm.refresh();},'icon-print');} -var docstatus=cint(cur_frm.doc.docstatus);if(docstatus==0&&p[WRITE]){this.add_button('Save',function(){cur_frm.save('Save');},'');this.buttons['Save'].addClass('btn-info');} + %(lab_status)s',{lab_status:labinfo[0],lab_class:labinfo[1]}));},refresh_toolbar:function(){this.appframe.clear_buttons();var p=cur_frm.get_doc_perms();if(cur_frm.meta.read_only_onload&&!cur_frm.doc.__islocal){if(!cur_frm.editable) +this.appframe.add_button('Edit',function(){cur_frm.edit_doc();},'icon-pencil');else +this.appframe.add_button('Print View',function(){cur_frm.is_editable[cur_frm.docname]=0;cur_frm.refresh();},'icon-print');} +var docstatus=cint(cur_frm.doc.docstatus);if(docstatus==0&&p[WRITE]){this.appframe.add_button('Save',function(){cur_frm.save('Save');},'');this.appframe.buttons['Save'].addClass('btn-info');} if(docstatus==0&&p[SUBMIT]&&(!cur_frm.doc.__islocal)) -this.add_button('Submit',function(){cur_frm.savesubmit();},'icon-lock');if(docstatus==1&&p[SUBMIT]){this.add_button('Update',function(){cur_frm.savesubmit();},'');if(!cur_frm.doc.__unsaved)this.buttons['Update'].toggle(false);} +this.appframe.add_button('Submit',function(){cur_frm.savesubmit();},'icon-lock');if(docstatus==1&&p[SUBMIT]){this.appframe.add_button('Update',function(){cur_frm.savesubmit();},'');if(!cur_frm.doc.__unsaved)this.appframe.buttons['Update'].toggle(false);} if(docstatus==1&&p[CANCEL]) -this.add_button('Cancel',function(){cur_frm.savecancel()},'icon-remove');if(docstatus==2&&p[AMEND]) -this.add_button('Amend',function(){cur_frm.amend_doc()},'icon-pencil');},add_button:function(label,click,icon){args={label:label,icon:''};if(icon){args.icon='';} -this.buttons[label]=$(repl('',args)).click(click).appendTo(this.$w.find('.page-app-toolbar'));},show:function(){},hide:function(){},hide_close:function(){this.$w.find('.close').toggle(false);}}) +this.appframe.add_button('Cancel',function(){cur_frm.savecancel()},'icon-remove');if(docstatus==2&&p[AMEND]) +this.appframe.add_button('Amend',function(){cur_frm.amend_doc()},'icon-pencil');},show:function(){},hide:function(){},hide_close:function(){this.$w.find('.close').toggle(false);}}) /* * lib/js/legacy/widgets/form/form.js */ @@ -1640,8 +1638,8 @@ _f.Frm.prototype.setup_print_layout=function(){this.print_wrapper=$a(this.wrappe _f.Frm.prototype.onhide=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.grid.cell_deselect();} _f.Frm.prototype.setup_std_layout=function(){this.page_layout=new wn.PageLayout({parent:this.wrapper,main_width:this.meta.in_dialog?'100%':'75%',sidebar_width:this.meta.in_dialog?'0%':'25%'}) this.meta.section_style='Simple';this.layout=new Layout(this.page_layout.body,'100%');if(this.meta.in_dialog){$(this.page_layout.wrapper).removeClass('layout-wrapper-background');$(this.page_layout.main).removeClass('layout-main-section');$(this.page_layout.sidebar_area).toggle(false);}else{this.setup_sidebar();} -this.setup_footer();if(!(this.meta.istable||user=='Guest')) -this.frm_head=new _f.FrmHeader(this.page_layout.head,this);if(this.frm_head&&this.meta.in_dialog)this.frm_head.hide_close();if(this.meta.colour) +this.setup_footer();if(!(this.meta.istable||user=='Guest'||this.meta.in_dialog)) +this.frm_head=new _f.FrmHeader(this.page_layout.head,this);if(this.meta.colour) this.layout.wrapper.style.backgroundColor='#'+this.meta.colour.split(':')[1];this.setup_fields_std();} _f.Frm.prototype.setup_print=function(){var l=[] this.default_format='Standard';for(var key in locals['Print Format']){if(locals['Print Format'][key].doc_type==this.meta.name){l.push(locals['Print Format'][key].name);}} @@ -1682,7 +1680,8 @@ _f.Frm.prototype.defocus_rest=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.gr _f.Frm.prototype.get_doc_perms=function(){var p=[0,0,0,0,0,0];for(var i=0;i';if(this.frm_head)this.frm_head.refresh();if(wn.ui.toolbar.recent) +wn.ui.toolbar.recent.add(this.doctype,this.docname,1);} _f.Frm.prototype.check_doc_perm=function(){var dt=this.parent_doctype?this.parent_doctype:this.doctype;var dn=this.parent_docname?this.parent_docname:this.docname;this.perm=get_perm(dt,dn);this.orig_perm=get_perm(dt,dn,1);if(!this.perm[0][READ]){if(user=='Guest'){if(_f.temp_access[dt]&&_f.temp_access[dt][dn]){this.perm=[[1,0,0]] return 1;}} window.back();return 0;} @@ -1774,7 +1773,7 @@ _f.SectionBreak=function(){this.fields=[];this.set_input=function(){};this.make_ _f.SectionBreak.prototype.make_body=function(){var me=this;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;} this.make_row();if(this.df.label){if(!this.df.description) this.df.description='';$(this.row.main_head).html(repl('
\ -

%(label)s

\ +

%(label)s

\
%(description)s
\
',this.df));}else{$(this.wrapper).html('
');} diff --git a/js/all-web.js b/js/all-web.js index d3dfc99b74..8508b10b92 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -246,10 +246,7 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('\ -
\ - \ - ×\ -
\ +
\
\

%(label)s

\
\ @@ -264,7 +261,7 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype,page){this.doct
\
\
\ - ',{label:this.label}));wn.views.breadcrumbs(this.$page.find('.breadcrumbs-area').get(0),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.add_delete_option();},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 + ',{label:this.label}));this.appframe=new wn.views.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.add_delete_option();},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);} this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('

No %(doctype_label)s found

\ %(description)s\ diff --git a/version.num b/version.num index 50b710d816..bcf484964b 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -1610 \ No newline at end of file +1644 \ No newline at end of file