listing with stats
This commit is contained in:
parent
38474e2db0
commit
08b670bddd
@ -728,6 +728,43 @@ div.srs_filter_area td {
|
||||
}
|
||||
|
||||
|
||||
/* stats */
|
||||
|
||||
div.stat-grid {
|
||||
border: 2px solid #bbb;
|
||||
background-color: white;
|
||||
margin-bottom: 19px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.stat-label {
|
||||
position: relative;
|
||||
padding: 3px;
|
||||
text-align: center;
|
||||
}
|
||||
div.stat-label, div.stat-label a {
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
div.stat-item {
|
||||
position: relative;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
div.stat-item:last-child {
|
||||
border-bottom: 0px solid #ddd;
|
||||
}
|
||||
|
||||
div.stat-bar {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
background-color: #def;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
13
erpnext/accounts/doctype/journal_voucher/listview.js
Normal file
13
erpnext/accounts/doctype/journal_voucher/listview.js
Normal file
@ -0,0 +1,13 @@
|
||||
wn.doclistviews['Journal Voucher'] = wn.pages.ListView.extend({
|
||||
init: function(doctype) {
|
||||
this._super(doctype);
|
||||
this.fields = this.fields.concat([
|
||||
'`tabJournal Voucher`.voucher_type'
|
||||
]);
|
||||
this.stats = this.stats.concat(['voucher_type']);
|
||||
},
|
||||
render: function(row, data) {
|
||||
this._super(row, data);
|
||||
this.$main.html(data.voucher_type);
|
||||
}
|
||||
});
|
@ -1,21 +1,16 @@
|
||||
// render
|
||||
wn.doclistviews['Sales Order'] = {
|
||||
fields: [
|
||||
{ field: "name", name: "ID"},
|
||||
{ field: "owner", name: "Created By"},
|
||||
{ field: "modified", name: "Last Updated"},
|
||||
{ field: "customer_name", name: "Customer", width:300},
|
||||
{ field: "per_delivered", name: "% Delivered",
|
||||
query: "ifnull(per_delivered,0) as per_delivered"},
|
||||
{ field: "per_billed", name: "% Billed",
|
||||
query: "ifnull(per_billed,0) as per_billed"},
|
||||
{ field: "currency", name: "Currency"},
|
||||
{ field: "grand_total_export", name: "Grand Total",
|
||||
query:"ifnull(grand_total_export,0) as grand_total_export"},
|
||||
{ field: "docstatus", name: "Status"}
|
||||
],
|
||||
wn.doclistviews['Sales Order'] = wn.pages.ListView.extend({
|
||||
init: function(doctype) {
|
||||
this._super(doctype)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabSales Order`.customer_name",
|
||||
"ifnull(`tabSales Order`.per_delivered,0) as per_delivered",
|
||||
"ifnull(`tabSales Order`.per_billed,0) as per_billed",
|
||||
"`tabSales Order`.currency",
|
||||
"ifnull(`tabSales Order`.grand_total_export,0) as grand_total_export"
|
||||
]);
|
||||
},
|
||||
render: function(row, data, listobj) {
|
||||
data.modified_date = dateutil.str_to_user(data.modified).split(' ')[0];
|
||||
|
||||
// bar color for billed
|
||||
data.bar_class_delivered = ''; data.bar_class_billed = '';
|
||||
@ -24,27 +19,30 @@ wn.doclistviews['Sales Order'] = {
|
||||
|
||||
// lock for docstatus
|
||||
data.icon = '';
|
||||
if(data.docstatus==1) {
|
||||
data.item_color = 'grey';
|
||||
if(data.docstatus==0) {
|
||||
data.customer_name = '[Draft] ' + data.customer_name;
|
||||
} else if(data.docstatus==1) {
|
||||
data.icon = ' <i class="icon-lock" title="Submitted"></i>';
|
||||
data.item_color = 'blue';
|
||||
} else if(data.docstatus==2) {
|
||||
data.icon = ' <i class="icon-remove" title="Cancelled"></i>';
|
||||
data.item_color = 'red';
|
||||
}
|
||||
|
||||
$(row).html(repl('<span class="avatar-small"><img src="%(avatar)s" /></span>\
|
||||
<a href="#!Form/%(doctype)s/%(name)s">%(name)s</a>\
|
||||
%(icon)s\
|
||||
<span style="color:#444">%(customer_name)s</span>\
|
||||
<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(per_delivered)s% Delivered">\
|
||||
<span class="bar-inner %(bar_class_delivered)s" \
|
||||
style="width: %(per_delivered)s%;"></span>\
|
||||
</span>\
|
||||
<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(per_billed)s% Billed">\
|
||||
<span class="bar-inner %(bar_class_billed)s" \
|
||||
style="width: %(per_billed)s%;"></span>\
|
||||
</span>\
|
||||
<span style="float:right; font-size: 11px; color: #888;\
|
||||
margin-left: 7px;">%(modified_date)s</span>\
|
||||
<span style="color:#444; float: right;">%(currency)s %(grand_total_export)s</span>\
|
||||
', data)).addClass('list-row');
|
||||
this._super(row, data);
|
||||
this.$main.html(repl('<span style="color:%(item_color)s">%(customer_name)s</span>\
|
||||
<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(per_delivered)s% Delivered">\
|
||||
<span class="bar-inner %(bar_class_delivered)s" \
|
||||
style="width: %(per_delivered)s%;"></span>\
|
||||
</span>\
|
||||
<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(per_billed)s% Billed">\
|
||||
<span class="bar-inner %(bar_class_billed)s" \
|
||||
style="width: %(per_billed)s%;"></span>\
|
||||
</span>\
|
||||
<span style="color:#444; float: right;">%(currency)s %(grand_total_export)s</span>\
|
||||
', data))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,242 +0,0 @@
|
||||
# Module Def, Stock
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-07-01 17:40:49',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-02-01 15:43:00',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'name': '__common__',
|
||||
'parent': 'Stock',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
|
||||
# These values are common for all Module Def Item
|
||||
{
|
||||
'doctype': 'Module Def Item',
|
||||
'name': '__common__',
|
||||
'parent': 'Stock',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
|
||||
# These values are common for all Module Def
|
||||
{
|
||||
'disabled': 'No',
|
||||
'doctype': u'Module Def',
|
||||
'doctype_list': 'DocType Label, QA Inspection Report',
|
||||
'is_hidden': 'No',
|
||||
'module_desc': 'Material Management',
|
||||
'module_icon': 'Stock.gif',
|
||||
'module_label': 'Stock',
|
||||
'module_name': 'Stock',
|
||||
'module_seq': 7,
|
||||
'name': '__common__'
|
||||
},
|
||||
|
||||
# Module Def, Stock
|
||||
{
|
||||
'doctype': u'Module Def',
|
||||
'name': 'Stock'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Item master',
|
||||
'display_name': 'Item',
|
||||
'doc_name': 'Item',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'name\nitem_group\ndescription'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'A unique number identifying each entity of an item',
|
||||
'display_name': 'Serial No',
|
||||
'doc_name': 'Serial No',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'item_code\nstatus\nwarehouse\npr_no\ndelivery_note_no\ncustomer'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Record of items added, removed or moved from one warehouse to another.',
|
||||
'display_name': 'Stock Entry',
|
||||
'doc_name': 'Stock Entry',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'transfer_date\npurpose\nfrom_warehouse\nto_warehouse\nremarks'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Record of items delivered to your customers along with the Printed Note',
|
||||
'display_name': 'Delivery Note',
|
||||
'doc_name': 'Delivery Note',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'status\ntransaction_date\ncustomer\nterritory\ngrand_total\nper_billed'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Generate Packing Slips based on a Delivery Note',
|
||||
'display_name': 'Packing Slip',
|
||||
'doc_name': 'Packing Slip',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'delivery_note\nfrom_case_no\nto_case_no\nnet_weight_pkg\ngross_weight_pkg'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Record of incoming material from your suppliers',
|
||||
'display_name': 'Purchase Receipt',
|
||||
'doc_name': 'Purchase Receipt',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'status\ntransaction_date\nsupplier\ngrand_total\nper_billed'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Details of Installation done after delivery',
|
||||
'display_name': 'Installation Note',
|
||||
'doc_name': 'Installation Note',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Create Quality Inspection Report for any item',
|
||||
'display_name': 'Inspection Report',
|
||||
'doc_name': 'QA Inspection Report',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'inspection_type\nitem_code\nreport_date\npurchase_receipt_no\ndelivery_note_no'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Reconcile your stock by uploading it form an excel file',
|
||||
'display_name': 'Stock Reconciliation',
|
||||
'doc_name': 'Stock Reconciliation',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'reconciliation_date\nreconciliation_time\nremark'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'This utility tool will update Stock UOM in Item and will respectively update Actual Qty in Stock Ledger as per Conversion Factor.',
|
||||
'display_name': 'Stock UOM Replace Utility',
|
||||
'doc_name': 'Stock UOM Replace Utility',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'This utility will help in tracking stock for Sales Return and Purchase Return.',
|
||||
'display_name': 'Sales and Purchase Return Wizard',
|
||||
'doc_name': 'Sales and Purchase Return Wizard',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'You can create master template for landed cost wizard',
|
||||
'display_name': 'Landed Cost Master',
|
||||
'doc_name': 'Landed Cost Master',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'icon': 'accept.gif'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Add extra expenses into Purchase Receipt which should be consider for item valuation. The cost will be added proportionately as per purchase receipt value.',
|
||||
'display_name': 'Landed Cost Wizard',
|
||||
'doc_name': 'Landed Cost Wizard',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'icon': 'accept.gif'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Stock Ledger',
|
||||
'doc_name': 'Stock Ledger Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Stock Level',
|
||||
'doc_name': 'Bin',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Shortage To Indent',
|
||||
'doc_name': 'Item',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Stock Value as per Item and Warehouse',
|
||||
'display_name': 'Stock Report',
|
||||
'doc_name': 'Stock Ledger Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Stock Aging Report',
|
||||
'doc_name': 'Serial No',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'role': 'Material User'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'role': 'Material Master Manager'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'role': 'Material Manager'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'role': 'Quality Manager'
|
||||
}
|
||||
]
|
@ -3,6 +3,7 @@
|
||||
border-bottom: 1px solid #DEB85F;
|
||||
margin-bottom: 5px;
|
||||
height: 14px;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.todoitem .label {
|
||||
|
@ -4,7 +4,7 @@
|
||||
<br>
|
||||
<div id="todo-list">
|
||||
</div>
|
||||
<div style="margin-top: 21px">
|
||||
<div style="margin-top: 21px; clear: both">
|
||||
<button id="add-todo" class="btn btn-small"><i class="icon-plus"></i> Add</button>
|
||||
</div>
|
||||
</div>
|
@ -200,7 +200,7 @@ wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==
|
||||
/*
|
||||
* lib/js/wn/model.js
|
||||
*/
|
||||
wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image'];
|
||||
wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image'];wn.model.can_delete=function(doctype){if(!doctype)return false;return locals.DocType[doctype].allow_trash&&wn.boot.profile.can_cancel.indexOf(doctype)!=-1;}
|
||||
/*
|
||||
* lib/js/wn/page.js
|
||||
*/
|
||||
@ -256,6 +256,7 @@ if(r.exc){errprint(r.exc);console.log(r.exc);};if(r.docs)LocalDB.sync(r.docs);}
|
||||
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});msgprint('Unable to complete request: '+textStatus)
|
||||
if(opts.error)opts.error(xhr)}})}
|
||||
wn.call=function(opts){var args=opts.args||{};if(opts.module&&opts.page){args.cmd=opts.module+'.page.'+opts.page+'.'+opts.page+'.'+opts.method}else if(opts.method){args.cmd=opts.method;}
|
||||
for(key in args){if(args[key]&&typeof args[key]!='string'){args[key]=JSON.stringify(args[key]);}}
|
||||
wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,freeze:opts.freeze,show_spinner:!opts.no_spinner});}
|
||||
/*
|
||||
* lib/js/core.js
|
||||
@ -538,7 +539,7 @@ if(this.onmake)this.onmake();}
|
||||
Field.prototype.set_max_width=function(){var no_max=['Code','Text Editor','Text','Table','HTML']
|
||||
if(this.wrapper&&this.layout_cell&&this.layout_cell.parentNode.cells&&this.layout_cell.parentNode.cells.length==1&&!in_list(no_max,this.df.fieldtype)){$y(this.wrapper,{paddingRight:'50%'});}}
|
||||
Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.label!=this.df.label){this.label_span.innerHTML=this.df.label;this.label=this.df.label;}}
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','field_description','',this.df.description)
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help','',this.df.description)
|
||||
if(in_list(['Text Editor','Code'],this.df.fieldtype))
|
||||
$(this.desc_area).addClass('field_description_top');}}
|
||||
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
|
||||
@ -934,7 +935,8 @@ this.show=function(){$ds(me.ldiv);}}
|
||||
var def_ph_style={wrapper:{marginBottom:'16px',backgroundColor:'#EEE'},main_heading:{},sub_heading:{marginBottom:'8px',color:'#555',display:'none'},separator:{borderTop:'3px solid #777'},toolbar_area:{padding:'3px 0px',display:'none',borderBottom:'1px solid #AAA'}}
|
||||
function PageHeader(parent,main_text,sub_text){this.wrapper=$a(parent,'div','page_header');this.t1=make_table($a(this.wrapper,'div','',def_ph_style.wrapper.backgroundColor),1,2,'100%',[null,'100px'],{padding:'2px'});$y(this.t1,{borderCollapse:'collapse'})
|
||||
this.lhs=$td(this.t1,0,0);this.main_head=$a(this.lhs,'h1','',def_ph_style.main_heading);this.sub_head=$a(this.lhs,'h4','',def_ph_style.sub_heading);this.separator=$a(this.wrapper,'div','',def_ph_style.separator);this.toolbar_area=$a(this.wrapper,'div','',def_ph_style.toolbar_area);this.padding_area=$a(this.wrapper,'div','',{padding:'3px'});$y($td(this.t1,0,1),{textAlign:'right',padding:'3px'});this.close_btn=$a($td(this.t1,0,1),'span','close',{},'×');this.close_btn.onclick=function(){nav_obj.show_last_open();};if(main_text)this.main_head.innerHTML=main_text;if(sub_text)this.sub_head.innerHTML=sub_text;this.buttons={};this.buttons2={};}
|
||||
PageHeader.prototype.add_button=function(label,fn,bold,icon,green){var tb=this.toolbar_area;if(this.buttons[label])return;var btn=$btn(tb,label,fn,{marginRight:'4px'},(green?'btn-info':''));if(bold)$y(btn,{fontWeight:'bold'});this.buttons[label]=btn;$ds(this.toolbar_area);return btn;}
|
||||
PageHeader.prototype.add_button=function(label,fn,bold,icon,green){var tb=this.toolbar_area;if(this.buttons[label])return;iconhtml=icon?('<i class="'+icon+'"></i> '):'';var $button=$('<button class="btn btn-small">'+iconhtml+label+'</button>').click(fn).appendTo(tb);if(green){$button.addClass('btn-info');$button.find('i').addClass('icon-white');}
|
||||
if(bold)$button.css('font-weight','bold');this.buttons[label]=$button.get(0);$ds(this.toolbar_area);return this.buttons[label];}
|
||||
PageHeader.prototype.clear_toolbar=function(){this.toolbar_area.innerHTML='';this.buttons={};}
|
||||
PageHeader.prototype.make_buttonset=function(){$(this.toolbar_area).buttonset();}
|
||||
/*
|
||||
@ -1382,7 +1384,7 @@ if(this.onmake)this.onmake();}
|
||||
Field.prototype.set_max_width=function(){var no_max=['Code','Text Editor','Text','Table','HTML']
|
||||
if(this.wrapper&&this.layout_cell&&this.layout_cell.parentNode.cells&&this.layout_cell.parentNode.cells.length==1&&!in_list(no_max,this.df.fieldtype)){$y(this.wrapper,{paddingRight:'50%'});}}
|
||||
Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.label!=this.df.label){this.label_span.innerHTML=this.df.label;this.label=this.df.label;}}
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','field_description','',this.df.description)
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help','',this.df.description)
|
||||
if(in_list(['Text Editor','Code'],this.df.fieldtype))
|
||||
$(this.desc_area).addClass('field_description_top');}}
|
||||
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
|
||||
@ -1607,14 +1609,14 @@ this.timestamp_area=$a($a(div,'div','',{marginTop:'3px'}),'span','field_descript
|
||||
_f.FrmHeader.prototype.show=function(){$ds(this.wrapper);}
|
||||
_f.FrmHeader.prototype.hide=function(){$dh(this.wrapper);}
|
||||
_f.FrmHeader.prototype.refresh=function(){var me=this;var p=cur_frm.get_doc_perms();this.page_head.clear_toolbar();if(cur_frm.meta.read_only_onload&&!cur_frm.doc.__islocal){if(!cur_frm.editable)
|
||||
this.page_head.add_button('Edit',function(){cur_frm.edit_doc();},1,'ui-icon-document',1);else
|
||||
this.page_head.add_button('Print View',function(){cur_frm.is_editable[cur_frm.docname]=0;cur_frm.refresh();},1,'ui-icon-document');}
|
||||
this.page_head.add_button('Edit',function(){cur_frm.edit_doc();},1,'icon-pencil',1);else
|
||||
this.page_head.add_button('Print View',function(){cur_frm.is_editable[cur_frm.docname]=0;cur_frm.refresh();},1,'icon-print');}
|
||||
if(cur_frm.editable&&cint(cur_frm.doc.docstatus)==0&&p[WRITE])
|
||||
this.page_head.add_button('Save',function(){cur_frm.save('Save');},1,'ui-icon-disk',1);if(cint(cur_frm.doc.docstatus)==0&&p[SUBMIT]&&(!cur_frm.doc.__islocal))
|
||||
this.page_head.add_button('Submit',function(){cur_frm.savesubmit();},0,'ui-icon-locked');if(cint(cur_frm.doc.docstatus)==1&&p[SUBMIT]){this.update_btn=this.page_head.add_button('Update',function(){cur_frm.saveupdate();},1,'ui-icon-disk',1);if(!cur_frm.doc.__unsaved)$dh(this.update_btn);}
|
||||
this.page_head.add_button('Save',function(){cur_frm.save('Save');},1,'icon-ok',1);if(cint(cur_frm.doc.docstatus)==0&&p[SUBMIT]&&(!cur_frm.doc.__islocal))
|
||||
this.page_head.add_button('Submit',function(){cur_frm.savesubmit();},0,'icon-lock');if(cint(cur_frm.doc.docstatus)==1&&p[SUBMIT]){this.update_btn=this.page_head.add_button('Update',function(){cur_frm.saveupdate();},1,'icon-ok',1);if(!cur_frm.doc.__unsaved)$dh(this.update_btn);}
|
||||
if(cint(cur_frm.doc.docstatus)==1&&p[CANCEL])
|
||||
this.page_head.add_button('Cancel',function(){cur_frm.savecancel()},0,'ui-icon-closethick');if(cint(cur_frm.doc.docstatus)==2&&p[AMEND])
|
||||
this.page_head.add_button('Amend',function(){cur_frm.amend_doc()},0,'ui-icon-scissors');}
|
||||
this.page_head.add_button('Cancel',function(){cur_frm.savecancel()},0,'icon-remove');if(cint(cur_frm.doc.docstatus)==2&&p[AMEND])
|
||||
this.page_head.add_button('Amend',function(){cur_frm.amend_doc()},0,'icon-pencil');}
|
||||
_f.FrmHeader.prototype.show_toolbar=function(){$ds(this.wrapper);this.refresh();}
|
||||
_f.FrmHeader.prototype.hide_toolbar=function(){$dh(this.wrapper);}
|
||||
_f.FrmHeader.prototype.refresh_toolbar=function(){var m=cur_frm.meta;if(m.hide_heading||cur_frm.in_dialog){this.hide();}else{this.show();if(m.hide_toolbar){this.hide_toolbar();}else{this.show_toolbar();}}}
|
||||
@ -1626,7 +1628,7 @@ var sp1=null;var sp2=null;if(doc.__islocal){label='Unsaved Draft';col='#F81';}el
|
||||
sp1=make_tag(label,col);this.set_in_recent(doc,col);return[sp1,sp2];}
|
||||
_f.FrmHeader.prototype.set_in_recent=function(doc,col){var tn=$i('rec_'+doc.doctype+'-'+doc.name);if(tn)
|
||||
$y(tn,{backgroundColor:col});}
|
||||
_f.FrmHeader.prototype.set_save_submit_color=function(doc){var save_btn=this.page_head.buttons['Save'];var submit_btn=this.page_head.buttons['Submit'];if(cint(doc.docstatus)==0&&submit_btn&&save_btn){if(cint(doc.__unsaved)){$(save_btn).addClass('btn-info');$(submit_btn).removeClass('btn-info');}else{$(submit_btn).addClass('btn-info');$(save_btn).removeClass('btn-info');}}}
|
||||
_f.FrmHeader.prototype.set_save_submit_color=function(doc){var save_btn=this.page_head.buttons['Save'];var submit_btn=this.page_head.buttons['Submit'];if(cint(doc.docstatus)==0&&submit_btn&&save_btn){if(cint(doc.__unsaved)){$(save_btn).addClass('btn-info');$(save_btn).find('i').addClass('icon-white');$(submit_btn).removeClass('btn-info');$(submit_btn).find('i').removeClass('icon-white');}else{$(submit_btn).addClass('btn-info');$(submit_btn).find('i').addClass('icon-white');$(save_btn).removeClass('btn-info');$(save_btn).find('i').removeClass('icon-white');}}}
|
||||
_f.FrmHeader.prototype.refresh_labels=function(f){var ph=this.page_head;var me=this;this.dt_area.innerHTML=get_doctype_label(f.doctype);this.dn_area.innerHTML='';if(!f.meta.issingle)
|
||||
this.dn_area.innerHTML=f.docname;var doc=locals[f.doctype][f.docname];var sl=this.get_status_tags(doc,f);this.set_save_submit_color(doc);var t=this.status_area;t.innerHTML='';t.appendChild(sl[0]);if(sl[1])t.appendChild(sl[1]);this.timestamp_area.innerHTML=me.get_timestamp(doc);}
|
||||
/*
|
||||
@ -1707,7 +1709,7 @@ if(!this.display)this.show_the_frm();if(!this.meta.in_dialog)page_body.change_to
|
||||
_f.Frm.prototype.refresh_footer=function(){var f=this.page_layout.footer;if(f.save_area){if(get_url_arg('embed')||(this.editable&&!this.meta.in_dialog&&this.doc.docstatus==0&&!this.meta.istable&&this.get_doc_perms()[WRITE])){f.show_save();}else{f.hide_save();}}}
|
||||
_f.Frm.prototype.refresh_fields=function(){for(var i=0;i<this.fields.length;i++){var f=this.fields[i];f.perm=this.perm;f.docname=this.docname;var fn=f.df.fieldname||f.df.label;if(fn)
|
||||
f.df=get_field(this.doctype,fn,this.docname);if(f.df.fieldtype!='Section Break'&&f.refresh){f.refresh();}}
|
||||
$.each(this.sections,function(i,f){f.refresh();})
|
||||
$.each(this.sections,function(i,f){f.refresh(true);})
|
||||
this.cleanup_refresh(this);}
|
||||
_f.Frm.prototype.cleanup_refresh=function(){var me=this;if(me.fields_dict['amended_from']){if(me.doc.amended_from){unhide_field('amended_from');unhide_field('amendment_date');}else{hide_field('amended_from');hide_field('amendment_date');}}
|
||||
if(me.fields_dict['trash_reason']){if(me.doc.trash_reason&&me.doc.docstatus==2){unhide_field('trash_reason');}else{hide_field('trash_reason');}}
|
||||
@ -1785,18 +1787,20 @@ this.make_row();if(this.df.label){if(!this.df.description)
|
||||
this.df.description='';$(this.row.main_head).html(repl('<div class="form-section-head" style="cursor: pointer">\
|
||||
<div class="head">%(label)s</h3>\
|
||||
<div class="help">%(description)s</div>\
|
||||
</div>',this.df));this.$expand=$(this.row.main_head).find('.form-section-head').click(function(){if($(me.row.main_head).find('h3').length){me.section_collapse();}else{me.section_expand();}
|
||||
</div>',this.df));this.$expand=$(this.row.main_head).find('.head').click(function(){if($(me.row.main_head).find('h3').length){me.section_collapse();}else{me.section_expand();}
|
||||
return false;});this.collapsible=true;}else{$(this.wrapper).html('<div class="form-section-head"></div>');}
|
||||
this.section_collapse=function(){$(me.row.main_head).find('.head').html('<i class="icon-play"></i> \
|
||||
this.section_collapse=function(){$(me.row.main_head).find('.head').html('<i class="icon-chevron-right"></i> \
|
||||
<a href="#" onclick="return false;">Show "'+me.df.label+'"</a>');$(me.row.main_body).toggle(false);}
|
||||
this.section_expand=function(){$(me.row.main_head).find('.head').html('<h3><i class="icon-minus" style="margin-top: 3px"></i> '
|
||||
+me.df.label+'</h3>');$(me.row.main_body).slideDown();}
|
||||
this.section_expand=function(no_animation){$(me.row.main_head).find('.head').html('<h3><i class="icon-chevron-down" style="vertical-align: middle; margin-bottom: 2px"></i> '
|
||||
+me.df.label+'</h3>');if(no_animation)
|
||||
$(me.row.main_body).toggle(true);else
|
||||
$(me.row.main_body).slideDown();}
|
||||
$y(this.row.body,{marginLeft:'17px'});}
|
||||
_f.SectionBreak.prototype.has_data=function(){var me=this;for(var i in me.fields){var f=me.fields[i];var v=f.get_value?f.get_value():null;defaultval=f.df['default']||sys_defaults[f.fieldname]||user_defaults[f.fieldname];if(v&&v!=defaultval){return true;}
|
||||
if(f.df.reqd&&!v){return true;}
|
||||
if(f.df.fieldtype=='Table'){if(f.grid.get_children().length||f.df.reqd){return true;}}}
|
||||
return false;}
|
||||
_f.SectionBreak.prototype.refresh=function(layout){if(this.df.hidden){if(this.row)this.row.hide();}else{if(this.collapsible){if(this.has_data()){this.section_expand();}else{this.section_collapse();}}}}
|
||||
_f.SectionBreak.prototype.refresh=function(from_form){if(this.df.hidden){if(this.row)this.row.hide();}else{if(this.collapsible){if(this.has_data()){this.section_expand(from_form);}else{this.section_collapse();}}}}
|
||||
_f.ImageField=function(){this.images={};}
|
||||
_f.ImageField.prototype=new Field();_f.ImageField.prototype.onmake=function(){this.no_img=$a(this.wrapper,'div','no_img');this.no_img.innerHTML="No Image";$dh(this.no_img);}
|
||||
_f.ImageField.prototype.get_image_src=function(doc){if(doc.file_list){file=doc.file_list.split(',');extn=file[0].split('.');extn=extn[extn.length-1].toLowerCase();var img_extn_list=['gif','jpg','bmp','jpeg','jp2','cgm','ief','jpm','jpx','png','tiff','jpe','tif'];if(in_list(img_extn_list,extn)){var src=wn.request.url+"?cmd=downloadfile&file_id="+file[1];}}else{var src="";}
|
||||
|
@ -114,7 +114,7 @@ wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==
|
||||
/*
|
||||
* lib/js/wn/model.js
|
||||
*/
|
||||
wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image'];
|
||||
wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image'];wn.model.can_delete=function(doctype){if(!doctype)return false;return locals.DocType[doctype].allow_trash&&wn.boot.profile.can_cancel.indexOf(doctype)!=-1;}
|
||||
/*
|
||||
* lib/js/wn/page.js
|
||||
*/
|
||||
@ -170,6 +170,7 @@ if(r.exc){errprint(r.exc);console.log(r.exc);};if(r.docs)LocalDB.sync(r.docs);}
|
||||
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});msgprint('Unable to complete request: '+textStatus)
|
||||
if(opts.error)opts.error(xhr)}})}
|
||||
wn.call=function(opts){var args=opts.args||{};if(opts.module&&opts.page){args.cmd=opts.module+'.page.'+opts.page+'.'+opts.page+'.'+opts.method}else if(opts.method){args.cmd=opts.method;}
|
||||
for(key in args){if(args[key]&&typeof args[key]!='string'){args[key]=JSON.stringify(args[key]);}}
|
||||
wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,freeze:opts.freeze,show_spinner:!opts.no_spinner});}
|
||||
/*
|
||||
* lib/js/core.js
|
||||
@ -435,7 +436,7 @@ if(this.onmake)this.onmake();}
|
||||
Field.prototype.set_max_width=function(){var no_max=['Code','Text Editor','Text','Table','HTML']
|
||||
if(this.wrapper&&this.layout_cell&&this.layout_cell.parentNode.cells&&this.layout_cell.parentNode.cells.length==1&&!in_list(no_max,this.df.fieldtype)){$y(this.wrapper,{paddingRight:'50%'});}}
|
||||
Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.label!=this.df.label){this.label_span.innerHTML=this.df.label;this.label=this.df.label;}}
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','field_description','',this.df.description)
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help','',this.df.description)
|
||||
if(in_list(['Text Editor','Code'],this.df.fieldtype))
|
||||
$(this.desc_area).addClass('field_description_top');}}
|
||||
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
|
||||
@ -679,30 +680,23 @@ this.widgets[d[1]]=b;}}
|
||||
/*
|
||||
* lib/js/wn/ui/listing.js
|
||||
*/
|
||||
wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype)
|
||||
this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);if(!this.opts.no_result_message){this.opts.no_result_message='Nothing to show'}},make:function(opts){if(opts){this.opts=opts;}
|
||||
$.extend(this,this.opts);this.prepare_opts();$(this.parent).html(repl('\
|
||||
wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype){if(wn.boot.profile.can_read.indexOf(this.opts.new_doctype)==-1){this.opts.new_doctype=null;}else{this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);}}
|
||||
if(!this.opts.no_result_message){this.opts.no_result_message='Nothing to show'}},make:function(opts){if(opts){this.opts=opts;}
|
||||
this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
|
||||
<div class="wnlist">\
|
||||
<div class="btn-group hide select-view" style="float: right;">\
|
||||
<a class="btn btn-small btn-info btn-list">\
|
||||
<i class="icon-list icon-white"></i> List</a>\
|
||||
<a class="btn btn-small btn-grid">\
|
||||
<i class="icon-th"></i> Grid</a>\
|
||||
</div>\
|
||||
\
|
||||
<h3 class="title hide">%(title)s</h3>\
|
||||
<div style="height: 37px;" class="list-toolbar-wrapper">\
|
||||
<div class="list-toolbar" style="float: left;">\
|
||||
<div class="list-toolbar">\
|
||||
<a class="btn btn-small btn-refresh btn-info">\
|
||||
<i class="icon-refresh icon-white"></i> Refresh</a>\
|
||||
<a class="btn btn-small btn-new">\
|
||||
<i class="icon-plus"></i> New %(new_doctype)s</a>\
|
||||
<i class="icon-plus"></i> New</a>\
|
||||
<a class="btn btn-small btn-filter">\
|
||||
<i class="icon-search"></i> Filter</a>\
|
||||
</div>\
|
||||
<img src="lib/images/ui/button-load.gif" \
|
||||
class="img-load"/>\
|
||||
</div>\
|
||||
class="img-load" style="float: left;"/>\
|
||||
</div><div style="clear:both"></div>\
|
||||
\
|
||||
<div class="list-filters hide">\
|
||||
<div class="show_filters well">\
|
||||
@ -727,30 +721,26 @@ $.extend(this,this.opts);this.prepare_opts();$(this.parent).html(repl('\
|
||||
<button class="btn btn-small btn-more hide">More...</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-refresh').click(function(){me.run();});this.$w.find('.btn-more').click(function(){me.run({append:true});});this.$w.find('.btn-list').click(function(){me.show_view($(this),me.$w.find('.result-list'),me.$w.find('.btn-grid'),me.$w.find('.result-grid'))});this.$w.find('.btn-grid').click(function(){me.show_view($(this),me.$w.find('.result-grid'),me.$w.find('.btn-list'),me.$w.find('.result-list'))});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
|
||||
',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},add_button:function(html,onclick,before){$(html).click(onclick).insertBefore(this.$w.find('.list-toolbar '+before));this.btn_groupify();},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-refresh').click(function(){me.run();});this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
|
||||
if(this.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype,me.new_doc_onload,true,me.new_doc_onsave);})}else{this.$w.find('.btn-new').remove();}
|
||||
if(!me.show_filters){this.$w.find('.btn-filter').remove();}
|
||||
if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').remove();}
|
||||
if(this.show_grid){this.$w.find('.select-view').toggle(true);}
|
||||
if(this.$w.find('.list-toolbar a').length>1){this.$w.find('.list-toolbar').addClass('btn-group')}
|
||||
if(this.$w.find('.list-toolbar a[hidden!="hidden"]').length==0){this.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
|
||||
this.btn_groupify();},btn_groupify:function(){var nbtns=this.$w.find('.list-toolbar a').length;if(nbtns>1){this.$w.find('.list-toolbar').addClass('btn-group')}
|
||||
if(nbtns==0){this.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
|
||||
this.onrun=a0;if(a0&&a0.callback)
|
||||
this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
|
||||
this.start=0;me.$w.find('.img-load').toggle(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.$w.find('.img-load').toggle(false);me.render_results(r)},no_spinner:this.opts.no_loading,btn:this.run_btn});},get_call_args:function(){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
|
||||
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading,btn:this.run_btn});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
|
||||
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
|
||||
if(this.args)
|
||||
$.extend(args,this.args)
|
||||
if(this.get_args){$.extend(args,this.get_args());}
|
||||
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);if(this.show_grid){this.render_grid();}}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
|
||||
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_grid:function(){if(this.columns[0].field!='_idx'){this.columns=[{field:'_idx',name:'Sr.',width:40}].concat(this.columns);}
|
||||
$.each(this.columns,function(i,c){if(!c.id)c.id=c.field;})
|
||||
$.each(this.data,function(i,v){v._idx=i+1;})
|
||||
wn.require('lib/js/lib/slickgrid/slick.grid.css');wn.require('lib/js/lib/slickgrid/slick-default-theme.css');wn.require('lib/js/lib/slickgrid/jquery.event.drag.min.js');wn.require('lib/js/lib/slickgrid/slick.core.js');wn.require('lib/js/lib/slickgrid/slick.grid.js');var options={enableCellNavigation:true,enableColumnReorder:false};grid=new Slick.Grid(this.$w.find('.result-grid').css('border','1px solid grey').css('height','500px').get(0),this.data,this.columns,options);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}
|
||||
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
|
||||
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}
|
||||
this.start+=m;if(values.length>=this.page_length)
|
||||
this.$w.find('.btn-more').toggle(true);},add_row:function(){return this.$w.find('.result-list').append('<div class="list-row">').find('.list-row:last').get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});wn.ui.FilterList=Class.extend({init:function(opts){$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.listobj.$w.find('.btn-filter').bind('click',function(){me.$w.find('.show_filters').slideToggle();if(!me.filters.length)
|
||||
me.add_filter();});this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.filter_field)
|
||||
me.add_filter();});this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').slideDown();}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
|
||||
values.push(f.get_value());})
|
||||
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.filter_field)fl.push(f);})
|
||||
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
|
||||
this.filters=fl;}});wn.ui.Filter=Class.extend({init:function(opts){$.extend(this,opts);this.doctype=this.flist.doctype;this.fields_by_name={};this.make();this.make_options();this.set_events();},make:function(){this.flist.$w.find('.filter_area').append('<div class="list_filter">\
|
||||
<select class="fieldname_select"></select>\
|
||||
<select class="condition">\
|
||||
@ -760,19 +750,21 @@ this.filters=fl;}});wn.ui.Filter=Class.extend({init:function(opts){$.extend(this
|
||||
<option value=">=">Less or equals</option>\
|
||||
<option value=">">Greater than</option>\
|
||||
<option value="<">Less than</option>\
|
||||
<option value="in">In</option>\
|
||||
<option value="!=">Not equals</option>\
|
||||
</select>\
|
||||
<span class="filter_field"></span>\
|
||||
<a class="close">×</a>\
|
||||
</div>');this.$w=this.flist.$w.find('.list_filter:last-child');this.$select=this.$w.find('.fieldname_select');},make_options:function(){if(this.filter_fields){for(var i in this.filter_fields)
|
||||
this.add_field_option(this.filter_fields[i])}else{this.render_field_select();}},set_events:function(){var me=this;this.$w.find('.fieldname_select').bind('change',function(){me.set_field(this.value);});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.filter_field.get_value();me.filter_field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
|
||||
this.add_field_option(this.filter_fields[i])}else{this.render_field_select();}},set_events:function(){var me=this;this.$w.find('.fieldname_select').bind('change',function(){me.set_field(this.value);});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.field.get_value();me.field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
|
||||
if(value){me.flist.listobj.run();}
|
||||
me.flist.update_filters();return false;});if(me.fieldname){me.set_field(me.fieldname);if(me.condition)me.$w.find('.condition').val(me.condition)
|
||||
if(me.value)me.filter_field.set_input(me.value)}else{me.set_field('name');}},render_field_select:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];$.each(std_filters.concat(fields_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(fields_list[table_df.options],function(i,df){me.add_field_option(df);});}})},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=get_label_doctype(me.doctype);if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}},set_field:function(fieldname){var me=this;me.$w.find('.fieldname_select').val(fieldname);wn.require('lib/js/legacy/widgets/form/fields.js');var field_area=me.$w.find('.filter_field').empty().get(0);var df=me.fields_by_name[fieldname];df.original_type=df.fieldtype;df.description='';if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}
|
||||
f=make_field(me.fields_by_name[fieldname],null,field_area,null,0,1);f.df.single_select=1;f.not_in_form=1;f.with_label=0;f.refresh();me.filter_field=f;if(df.fieldtype=='Data'){me.$w.find('.condition').val('like');}else{me.$w.find('.condition').val('=');}},get_value:function(){var me=this;var val=me.filter_field.get_value();var cond=me.$w.find('.condition').val();if(me.filter_field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||
me.flist.update_filters();return false;});me.$w.find('.condition').change(function(){if(!me.field.desc_area){me.field.desc_area=$a(me.field.wrapper,'span','help');}
|
||||
me.field.desc_area.innerHTML='';if($(this).val()=='in'){me.field.desc_area.innerHTML='Multiple values, separated by a comma'}});if(me.fieldname){me.set_field(me.fieldname);if(me.condition)me.$w.find('.condition').val(me.condition).change();if(me.value)me.field.set_input(me.value)}else{me.set_field('name');}},render_field_select:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];$.each(std_filters.concat(fields_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(fields_list[table_df.options],function(i,df){me.add_field_option(df);});}})},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=get_label_doctype(me.doctype);if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}},set_field:function(fieldname){var me=this;me.$w.find('.fieldname_select').val(fieldname);wn.require('lib/js/legacy/widgets/form/fields.js');var field_area=me.$w.find('.filter_field').empty().get(0);var df=me.fields_by_name[fieldname];df.original_type=df.fieldtype;df.description='';df.reqd=0;if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}
|
||||
f=make_field(me.fields_by_name[fieldname],null,field_area,null,0,1);f.df.single_select=1;f.not_in_form=1;f.with_label=0;f.refresh();me.field=f;if(df.fieldtype=='Data'){me.$w.find('.condition').val('like');}else{me.$w.find('.condition').val('=');}
|
||||
$(me.field.wrapper).find(':input').keydown(function(ev){if(ev.which==13){me.flist.listobj.run();}})},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||
if(cond=='like'){val=val+'%';}
|
||||
return[me.$w.find('.fieldname_select option:selected').attr('table'),me.filter_field.df.fieldname,me.$w.find('.condition').val(),val];}});
|
||||
return[me.$w.find('.fieldname_select option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),val];}});
|
||||
/*
|
||||
* lib/js/legacy/widgets/layout.js
|
||||
*/
|
||||
@ -805,7 +797,8 @@ LayoutCell.prototype.hide=function(){$dh(this.wrapper);}
|
||||
var def_ph_style={wrapper:{marginBottom:'16px',backgroundColor:'#EEE'},main_heading:{},sub_heading:{marginBottom:'8px',color:'#555',display:'none'},separator:{borderTop:'3px solid #777'},toolbar_area:{padding:'3px 0px',display:'none',borderBottom:'1px solid #AAA'}}
|
||||
function PageHeader(parent,main_text,sub_text){this.wrapper=$a(parent,'div','page_header');this.t1=make_table($a(this.wrapper,'div','',def_ph_style.wrapper.backgroundColor),1,2,'100%',[null,'100px'],{padding:'2px'});$y(this.t1,{borderCollapse:'collapse'})
|
||||
this.lhs=$td(this.t1,0,0);this.main_head=$a(this.lhs,'h1','',def_ph_style.main_heading);this.sub_head=$a(this.lhs,'h4','',def_ph_style.sub_heading);this.separator=$a(this.wrapper,'div','',def_ph_style.separator);this.toolbar_area=$a(this.wrapper,'div','',def_ph_style.toolbar_area);this.padding_area=$a(this.wrapper,'div','',{padding:'3px'});$y($td(this.t1,0,1),{textAlign:'right',padding:'3px'});this.close_btn=$a($td(this.t1,0,1),'span','close',{},'×');this.close_btn.onclick=function(){nav_obj.show_last_open();};if(main_text)this.main_head.innerHTML=main_text;if(sub_text)this.sub_head.innerHTML=sub_text;this.buttons={};this.buttons2={};}
|
||||
PageHeader.prototype.add_button=function(label,fn,bold,icon,green){var tb=this.toolbar_area;if(this.buttons[label])return;var btn=$btn(tb,label,fn,{marginRight:'4px'},(green?'btn-info':''));if(bold)$y(btn,{fontWeight:'bold'});this.buttons[label]=btn;$ds(this.toolbar_area);return btn;}
|
||||
PageHeader.prototype.add_button=function(label,fn,bold,icon,green){var tb=this.toolbar_area;if(this.buttons[label])return;iconhtml=icon?('<i class="'+icon+'"></i> '):'';var $button=$('<button class="btn btn-small">'+iconhtml+label+'</button>').click(fn).appendTo(tb);if(green){$button.addClass('btn-info');$button.find('i').addClass('icon-white');}
|
||||
if(bold)$button.css('font-weight','bold');this.buttons[label]=$button.get(0);$ds(this.toolbar_area);return this.buttons[label];}
|
||||
PageHeader.prototype.clear_toolbar=function(){this.toolbar_area.innerHTML='';this.buttons={};}
|
||||
PageHeader.prototype.make_buttonset=function(){$(this.toolbar_area).buttonset();}
|
||||
/*
|
||||
|
@ -1 +1 @@
|
||||
1019
|
||||
1049
|
Loading…
Reference in New Issue
Block a user