Merge branch 'handlerupdate' of github.com:webnotes/erpnext into handlerupdate

This commit is contained in:
Rushabh Mehta 2012-03-08 07:23:00 +01:00
commit 80698620db
38 changed files with 339 additions and 172 deletions

View File

@ -7,6 +7,7 @@
"lib/js/wn/assets.js",
"lib/js/wn/require.js",
"lib/js/wn/dom.js",
"lib/js/wn/model.js",
"lib/js/wn/page.js",
"lib/js/wn/misc/user.js",
"lib/js/lib/json2.js",
@ -61,6 +62,7 @@
"lib/css/legacy/dialog.css",
"lib/css/legacy/tabs.css",
"lib/css/legacy/sidebar.css",
"lib/css/ui/list.css",
"lib/css/bootstrap/headings.css",
"lib/css/bootstrap/buttons.css",
"lib/css/bootstrap/navbar.css",
@ -91,7 +93,6 @@
"lib/js/wn/ui/listing.js",
"lib/js/legacy/widgets/layout.js",
"lib/js/legacy/webpage/page_header.js",
"lib/js/legacy/widgets/select.js",
"lib/js/legacy/webpage/history.js",
"lib/js/legacy/webpage/search.js",
"lib/js/legacy/webpage/spinner.js",
@ -131,11 +132,9 @@
"lib/js/wn/ui/dialog.js",
"lib/js/legacy/widgets/dialog.js",
"lib/js/legacy/widgets/listing.js",
"lib/js/wn/ui/listing.js",
"lib/js/legacy/widgets/layout.js",
"lib/js/legacy/widgets/tabbedpage.js",
"lib/js/legacy/webpage/page_header.js",
"lib/js/legacy/widgets/select.js",
"lib/js/legacy/widgets/tags.js",
"lib/js/legacy/widgets/export_query.js",
"lib/js/legacy/webpage/history.js",

View File

@ -239,7 +239,6 @@ div.std-footer-item {
margin-bottom: -7px;
max-width: 24px;
}
/*
* lib/css/legacy/messages.css
*/
@ -1143,6 +1142,80 @@ div.psidebar div.section-item, div.psidebar .section-link {
font-size: 11px;
color: #666;
}
/*
* lib/css/ui/list.css
*/.hide {
display: none;
}
.list-filters {
margin: 7px 0px;
}
.wnlist .img-load {
display: none;
float: left;
margin-left: 11px;
margin-top: 8px;
}
div.list-row {
border-bottom: 1px solid #eee;
padding: 3px 0px;
}
div.list-row:hover {
background-color: #eef
}
div.show_filters {
display: none;
}
div.filter_list {
padding: 13px;
}
div.show_filters.well {
margin-top: 11px;
margin-bottom: 11px;
}
div.filter_list .run_btn {
text-align: right;
}
div.filter_list .add_filter {
margin: 3px 0px;
}
div.list_filter {
margin: 7px 0px;
}
div.list_filter input, div.list_filter select {
width: 130px;
margin-right: 7px;
}
span.bar-outer {
display: inline-block;
margin: 0px 7px;
margin-top: 3px;
background-color: #fff;
border: 1px solid #aaa;
height: 10px;
}
span.bar-inner {
display: inline-block;
background-color: #bdf;
height: 100%;
margin-bottom: 2px;
}
span.bar-complete {
background-color: green;
}
/*
* lib/css/bootstrap/headings.css
*//* heading from bootstrap */

View File

@ -239,7 +239,6 @@ div.std-footer-item {
margin-bottom: -7px;
max-width: 24px;
}
/*
* lib/css/legacy/messages.css
*/

View File

@ -17,8 +17,8 @@
cur_frm.cscript.tname = "PV Detail";
cur_frm.cscript.fname = "entries";
cur_frm.cscript.other_fname = "purchase_tax_details";
$import(Purchase Other Charges)
$import(Purchase Common)
wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
// On Load
// --------

View File

@ -22,9 +22,10 @@ cur_frm.cscript.sales_team_fname = "sales_team";
// print heading
cur_frm.pformat.print_heading = 'Invoice';
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
// On Load
// -------
@ -476,7 +477,6 @@ cur_frm.cscript.convert_into_recurring_invoice = function(doc) {
}
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Sales Invoice',

View File

@ -17,8 +17,8 @@
cur_frm.cscript.tname = "Indent Detail";
cur_frm.cscript.fname = "indent_details";
$import(Purchase Common)
$import(SMS Control)
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.indent_doctype_label = get_doctype_label('Indent');
//========================== On Load =================================================

View File

@ -71,9 +71,9 @@ cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
//parent flds
par_cols_base = {'net_total': 'Net Total', 'total_tax': 'Total Tax', 'grand_total': 'Grand Total', /*'rounded_total': 'Rounded Total',*/
'in_words': 'In Words', 'other_charges_added': 'Other Charges Added', 'other_charges_deducted': 'Other Charges Deducted'}
'in_words': 'In Words', 'other_charges_added': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Added', 'other_charges_deducted': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Deducted'}
par_cols_import = {'net_total_import': 'Net Total', 'grand_total_import': 'Grand Total', 'in_words_import': 'In Words',
'other_charges_added_import': 'Other Charges Added', 'other_charges_deducted_import': 'Other Charges Deducted'};
'other_charges_added_import': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Added', 'other_charges_deducted_import': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Deducted'};
for (d in par_cols_base) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_base[d]+' (' + base_curr + ')';
for (d in par_cols_import) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_import[d]+' (' + doc.currency + ')';
@ -430,7 +430,7 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
// ------------------
cur_frm.fields_dict['Tax Calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Other Charges and Landed cost:</b>';
cur_frm.fields_dict['Tax Calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); and Landed cost:</b>';
var cl = getchildren(tname, doc.name, fname);
var tax = getchildren('Purchase Tax Detail', doc.name, other_fname,doc.doctype);
// make display table

View File

@ -17,9 +17,11 @@
cur_frm.cscript.tname = "PO Detail";
cur_frm.cscript.fname = "po_details";
cur_frm.cscript.other_fname = "purchase_tax_details";
$import(Purchase Common)
$import(Purchase Other Charges)
$import(SMS Control)
wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
//========================== On Load =================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
@ -270,7 +272,6 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){
return out;
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Purchase Order',

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
$import(Contact Control)
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
cur_frm.cscript.onload = function(doc,dt,dn){
@ -54,7 +54,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
cur_frm.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.widgets.Listing({
cur_frm.address_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Address HTML'].wrapper,
page_length: 2,
new_doctype: "Address",
@ -96,7 +96,7 @@ cur_frm.cscript.make_address = function() {
cur_frm.cscript.make_contact = function() {
if(!cur_frm.contact_list) {
cur_frm.contact_list = new wn.widgets.Listing({
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Contact HTML'].wrapper,
page_length: 2,
new_doctype: "Contact",

View File

@ -1,5 +1,5 @@
wn.pages['activity'].onload = function(wrapper) {
var list = new wn.widgets.Listing({
var list = new wn.ui.Listing({
method: 'home.page.activity.activity.get_feed',
parent: $('#activity-list'),
render_row: function(row, data) {

View File

@ -470,7 +470,7 @@ FeedList.prototype.make_list = function() {
var me = this;
this.list_area = $a(this.wrapper,'div')
this.list = new wn.widgets.Listing({
this.list = new wn.ui.Listing({
parent: this.list_area,
query: repl('select \
distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.modified_by, \

View File

@ -179,7 +179,7 @@ MemberList.prototype.make_list = function() {
var me = this;
this.lst_area = $a(this.list_wrapper, 'div');
this.lst = new wn.widgets.Listing({
this.lst = new wn.ui.Listing({
parent: this.lst_area,
as_dict: 1,
get_query: function() {
@ -692,7 +692,7 @@ MemberConversation = function(parent, uid, fullname) {
this.my_messages_box = $a(this.lst_area, 'div', 'my-company-conversation-head', {marginBottom:'7px'}, 'Messages by everyone to me<br>To send a message, click on the user on the left')
}
this.lst = new wn.widgets.Listing({
this.lst = new wn.ui.Listing({
parent: this.lst_area,
as_dict: 1,
no_result_message: (user==uid

View File

@ -100,7 +100,7 @@ cur_frm.cscript.sanctioned_amount = function(doc,cdt,cdn){
cur_frm.cscript.calculate_total(doc,cdt,cdn);
}
$import(Notification Control);
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
cur_frm.cscript['Approve'] = function(doc,cdt,cdn){
@ -244,7 +244,6 @@ cur_frm.cscript['Update Voucher'] = function(doc){
});
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Expense Voucher',

View File

@ -131,7 +131,7 @@ KBAnswerList = function(args) {
this.make_list = function() {
this.list = new wn.widgets.Listing({
this.list = new wn.ui.Listing({
parent: me.parent,
as_dict: 1,
no_result_message: 'No answers yet, be the first one to answer!',
@ -185,4 +185,4 @@ KBAnswer = function(body, data, ans_list) {
}
$import(knowledge_base/page/kb_common/kb_common.js);
wn.require('erpnext/knowledge_base/page/kb_common/kb_common.js');

View File

@ -107,7 +107,7 @@ function KnowledgeBase(w) {
this.list_area = $a(w, 'div', '', {marginRight:'13px'})
this.no_result = $a(w, 'div','help_box',{display:'none'},'No questions asked yet! Be the first one to ask')
this.list = new wn.widgets.Listing({
this.list = new wn.ui.Listing({
parent: this.list_area,
no_results_message: 'No questions found. Ask a new question!',
as_dict: 1,
@ -215,4 +215,4 @@ KBQuestion = function(parent, det, kb) {
this.make()
}
$import(knowledge_base/page/kb_common/kb_common.js);
wn.require('erpnext/knowledge_base/page/kb_common/kb_common.js');

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
$import(Contact Control)
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
/* ********************************* onload ********************************************* */
@ -68,7 +68,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
cur_frm.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.widgets.Listing({
cur_frm.address_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Address HTML'].wrapper,
page_length: 2,
new_doctype: "Address",
@ -110,7 +110,7 @@ cur_frm.cscript.make_address = function() {
cur_frm.cscript.make_contact = function() {
if(!cur_frm.contact_list) {
cur_frm.contact_list = new wn.widgets.Listing({
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Contact HTML'].wrapper,
page_length: 2,
new_doctype: "Contact",

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
$import(SMS Control)
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.refresh = function(doc, cdt, cdn){

View File

@ -16,7 +16,7 @@
// Module CRM
$import(SMS Control)
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(user =='Guest'){

View File

@ -21,9 +21,10 @@ cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
// =====================================================================================
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
// ONLOAD
// ===================================================================================
@ -326,7 +327,6 @@ cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query=
return repl("SELECT name, item_name, description FROM tabItem WHERE `tabItem`.%(key)s LIKE '%s' %(cond)s ORDER BY tabItem.item_code DESC LIMIT 50", {cond:cond});
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Quotation',

View File

@ -18,7 +18,7 @@
// ------
// cur_frm.cscript.tname - Details table name
// cur_frm.cscript.fname - Details fieldname
// cur_frm.cscript.other_fname - Other Charges fieldname
// cur_frm.cscript.other_fname - wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); fieldname
// cur_frm.cscript.sales_team_fname - Sales Team fieldname
// ============== Load Default Taxes ===================
@ -96,7 +96,7 @@ cur_frm.cscript.customer = function(doc, cdt, cdn) {
var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
//parent flds
par_cols_base = {'net_total': 'Net Total', 'other_charges_total': 'Other Charges Total',
par_cols_base = {'net_total': 'Net Total', 'other_charges_total': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Total',
'grand_total': 'Grand Total', 'rounded_total': 'Rounded Total', 'in_words': 'In Words'}
par_cols_export = {'grand_total_export': 'Grand Total', 'rounded_total_export': 'Rounded Total', 'in_words_export': 'In Words'};
@ -339,7 +339,7 @@ cur_frm.cscript.export_rate = function(doc,cdt,cdn) {
// ************* GET OTHER CHARGES BASED ON COMPANY *************
cur_frm.fields_dict.charge.get_query = function(doc) {
return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
return 'SELECT DISTINCT `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.name FROM `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');` WHERE `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.company = "'+doc.company+'" AND `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.company is not NULL AND `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.docstatus != 2 AND `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.%(key)s LIKE "%s" ORDER BY `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.name LIMIT 50';
}
// ********************* Get Charges ****************************
@ -433,14 +433,14 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
doc = locals[doc.doctype][doc.name];
// Make Display Area
cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML =
'<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>';
cur_frm.fields_dict['wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Calculation'].disp_area.innerHTML =
'<b style="padding: 8px 0px;">Calculation Details for wn.require('erpnext/setup/doctype/other_charges/other_charges.js');:</b>';
var cl = getchildren(tname, doc.name, fname);
var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
// Make display table
var otc = make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area,
var otc = make_table(cur_frm.fields_dict['wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Calculation'].disp_area,
cl.length + 1, tax.length + 1, '90%', [], { border:'1px solid #AAA', padding:'2px' });
$y(otc,{marginTop:'8px'});
@ -795,10 +795,10 @@ cur_frm.cscript.allocated_percentage = function(doc, cdt, cdn) {
// =================================================================================
cur_frm.cscript.validate = function(doc, cdt, cdn) {
cur_frm.cscript.validate_items(doc);
var cl = getchildren('Other Charges', doc.name, 'other_charges');
var cl = getchildren('wn.require('erpnext/setup/doctype/other_charges/other_charges.js');', doc.name, 'other_charges');
for(var i =0;i<cl.length;i++) {
if(!cl[i].amount) {
alert("Please Enter Amount in Row no. "+cl[i].idx+" in Other Charges table");
alert("Please Enter Amount in Row no. "+cl[i].idx+" in wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); table");
validated = false;
}
}

View File

@ -0,0 +1,50 @@
// 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"}
],
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 = '';
if(data.per_delivered == 100) data.bar_class_delivered = 'bar-complete';
if(data.per_billed == 100) data.bar_class_billed = 'bar-complete';
// lock for docstatus
data.icon = '';
if(data.docstatus==1) {
data.icon = ' <i class="icon-lock" title="Submitted"></i>';
}
$(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');
}
}

View File

@ -22,9 +22,10 @@ cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
// ONLOAD
@ -352,7 +353,6 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Sales Order',

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
$import(Contact Control)
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
cur_frm.cscript.onload = function(doc,dt,dn){
// history doctypes and scripts
@ -48,7 +48,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
cur_frm.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.widgets.Listing({
cur_frm.address_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Address HTML'].wrapper,
page_length: 2,
new_doctype: "Address",
@ -80,7 +80,7 @@ cur_frm.cscript.make_address = function() {
cur_frm.cscript.make_contact = function() {
if(!cur_frm.contact_list) {
cur_frm.contact_list = new wn.widgets.Listing({
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Contact HTML'].wrapper,
page_length: 2,
new_doctype: "Contact",

View File

@ -47,7 +47,7 @@ pscript['onload_Import Data'] = function() {
dt.onclick = function(){
var ovr = $('input[name="overwrite"]:checked').length;
window.location = outUrl + '?cmd=get_template&dt=' + this.nm + (ovr ? '&overwrite=1' : '');
window.location = webnotes.request.url + '?cmd=get_template&dt=' + this.nm + (ovr ? '&overwrite=1' : '');
}
}
}

View File

@ -61,7 +61,7 @@ erpnext.module_page.hide_links = function(wrapper) {
erpnext.module_page.make_list = function(module, wrapper) {
// make project listing
wrapper.list = new wn.widgets.Listing({
wrapper.list = new wn.ui.Listing({
parent: $(wrapper).find('.reports-list').get(0),
method: 'utilities.get_report_list',
render_row: function(row, data) {

View File

@ -20,9 +20,10 @@ cur_frm.cscript.fname = "delivery_note_details";
cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
// ONLOAD
// ================================================================================================
@ -322,7 +323,6 @@ cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){
return out;
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Delivery Note',

View File

@ -18,9 +18,10 @@ cur_frm.cscript.tname = "Purchase Receipt Detail";
cur_frm.cscript.fname = "purchase_receipt_details";
cur_frm.cscript.other_fname = "purchase_tax_details";
$import(Purchase Common)
$import(Purchase Other Charges)
$import(SMS Control)
wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
//========================== On Load ================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
@ -315,7 +316,6 @@ cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){
return out;
}
$import(Notification Control)
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Purchase Receipt',

View File

@ -81,7 +81,7 @@ $.extend(cur_frm.cscript, {
}, null, -1)
// render thread
cs.thread_list = new wn.widgets.Listing({
cs.thread_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['Thread HTML'].wrapper,
no_result_message: 'No responses yet',
get_query: function() {

View File

@ -91,7 +91,7 @@ erpnext.messages = {
return user;
},
make_list: function() {
erpnext.messages.list = new wn.widgets.Listing({
erpnext.messages.list = new wn.ui.Listing({
parent: $('#message-list').get(0),
method: 'utilities.page.messages.messages.get_list',
args: {

View File

@ -269,8 +269,8 @@ erpnext.RoleEditor = Class.extend({
</div>', {role: this.roles[i]}));
}
$(this.dialog.body).append('<div style="clear: both">\
<button class="btn btn-small btn-primary">Save</button></div>');
$(this.dialog.body).find('button.btn-primary').click(function() {
<button class="btn btn-small btn-info">Save</button></div>');
$(this.dialog.body).find('button.btn-info').click(function() {
me.save();
});
$(this.dialog.body).find('.user-role a').click(function() {
@ -314,7 +314,7 @@ erpnext.RoleEditor = Class.extend({
unset_roles: JSON.stringify(unset_roles),
uid: this.uid
},
btn: $(this.dialog.body).find('.btn-primary').get(0),
btn: $(this.dialog.body).find('.btn-info').get(0),
callback: function() {
}

View File

@ -21,7 +21,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) {
var side = $(wrapper).find('.web-side-section')
.append('<h4>Recent Posts</h4>').get(0);
wrapper.recent_list = new wn.widgets.Listing({
wrapper.recent_list = new wn.ui.Listing({
parent: side,
query: 'select name, title, left(content, 100) as content from tabBlog\
where ifnull(published,1)=1',
@ -39,7 +39,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) {
// comments
$(wrapper).find('.web-main-section').append('<hr><h3>Comments</h3>');
wrapper.comment_list = new wn.widgets.Listing({
wrapper.comment_list = new wn.ui.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
query: 'select comment, comment_by_fullname, modified\
from `tabComment Widget Record` where comment_doctype="Page"\

View File

@ -30,7 +30,7 @@ pscript["onload_{{ doc.page_name }}"] = function(wrapper) {
});
// similar products
wrapper.similar = new wn.widgets.Listing({
wrapper.similar = new wn.ui.Listing({
parent: $(wrapper).find('.similar-products').get(0),
hide_refresh: true,
page_length: 5,

View File

@ -18,7 +18,7 @@
erpnext.product_item_group = {}
erpnext.make_product_categories = function(wrapper) {
wrapper.category_list = new wn.widgets.Listing({
wrapper.category_list = new wn.ui.Listing({
parent: $(wrapper).find('.more-categories').get(0),
query: 'select label, count(t2.name) as items, t1.item_group \
from `tabProduct Group` t1, `tabProduct` t2, tabItem t3\

View File

@ -16,7 +16,7 @@
pscript.onload_blog = function(wrapper) {
wrapper.blog_list = new wn.widgets.Listing({
wrapper.blog_list = new wn.ui.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
query: 'select tabBlog.name, title, left(content, 300) as content, tabBlog.modified, \
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \

View File

@ -57,7 +57,7 @@ erpnext.products.get_group = function() {
}
erpnext.products.make_product_list = function(wrapper) {
wrapper.mainlist = new wn.widgets.Listing({
wrapper.mainlist = new wn.ui.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
run_btn: $(wrapper).find('.products-search .btn').get(0),
hide_refresh: true,

File diff suppressed because one or more lines are too long

View File

@ -106,6 +106,10 @@ c.className=className;}
if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;}
wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;}
wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==-1||c=="")return"";var ind1=t.indexOf(';',ind);if(ind1==-1)ind1=t.length;return unescape(t.substring(ind+c.length+1,ind1));}
/*
* lib/js/wn/model.js
*/
wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image'];
/*
* lib/js/wn/page.js
*/
@ -160,7 +164,7 @@ if(r.server_messages)msgprint(r.server_messages)
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=module+'.page.'+page+'.'+page+'.'+method}else if(opts.method){args.cmd=opts.method;}
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;}
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
@ -290,7 +294,7 @@ span.set_working=function(){this.disabled=1;$di(this.loading_img);}
span.done_working=function(){this.disabled=0;$dh(this.loading_img);}
return span;}}
function $ln(parent,label,onclick,style){return wn.ele.link({parent:parent,label:label,onclick:onclick,style:style})}
function $btn(parent,label,onclick,style,css_class,is_ajax){wn.require('lib/js/wn/ui/button.js');if(css_class==='green')css_class='btn-primary';return new wn.ui.Button({parent:parent,label:label,onclick:onclick,style:style,is_ajax:is_ajax,css_class:css_class}).btn;}
function $btn(parent,label,onclick,style,css_class,is_ajax){wn.require('lib/js/wn/ui/button.js');if(css_class==='green')css_class='btn-info';return new wn.ui.Button({parent:parent,label:label,onclick:onclick,style:style,is_ajax:is_ajax,css_class:css_class}).btn;}
$item_normal=function(ele){$y(ele,{padding:'6px 8px',cursor:'pointer',marginRight:'8px',whiteSpace:'nowrap',overflow:'hidden',borderBottom:'1px solid #DDD'});$bg(ele,'#FFF');$fg(ele,'#000');}
$item_active=function(ele){$bg(ele,'#FE8');$fg(ele,'#000');}
$item_selected=function(ele){$bg(ele,'#777');$fg(ele,'#FFF');}
@ -298,6 +302,9 @@ $item_pressed=function(ele){$bg(ele,'#F90');$fg(ele,'#FFF');};(function($){$.fn.
$.fn.done_working=function(){var ele=this.get(0);ele.disabled=0;if(ele.loading_img){$dh(ele.loading_img)};}})(jQuery);function set_opacity(ele,ieop){var op=ieop/100;if(ele.filters){try{ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieop;}catch(e){ele.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';}}else{ele.style.opacity=op;}}
$br=function(ele,r,corners){if(corners){var cl=['top-left','top-right','bottom-right','bottom-left'];for(var i=0;i<4;i++){if(corners[i]){$(ele).css('-moz-border-radius-'+cl[i].replace('-',''),r).css('-webkit-'+cl[i]+'-border-radius',r);}}}else{$(ele).css('-moz-border-radius',r).css('-webkit-border-radius',r).css('border-radius',r);}}
$bs=function(ele,r){$(ele).css('-moz-box-shadow',r).css('-webkit-box-shadow',r).css('box-shadow',r);}
function SelectWidget(parent,options,width,editable,bg_color){var me=this;this.inp=$a(parent,'select');if(options)add_sel_options(this.inp,options);if(width)$y(this.inp,{width:width});this.set_width=function(w){$y(this.inp,{width:w})};this.set_options=function(o){add_sel_options(this.inp,o);}
this.inp.onchange=function(){if(me.onchange)me.onchange(this);}
return;}
function empty_select(s){if(s.custom_select){s.empty();return;}
if(s.inp)s=s.inp;if(s){var tmplen=s.length;for(var i=0;i<tmplen;i++)s.options[0]=null;}}
function sel_val(s){if(s.custom_select){return s.inp.value?s.inp.value:'';}
@ -374,7 +381,7 @@ function $c_page(module,page,method,arg,callback,no_spinner,freeze_msg,btn){if(a
function $c_obj_csv(doclist,method,arg){var args={}
args.cmd='runserverobj';args.as_csv=1;args.method=method;args.arg=arg;if(doclist.substr)
args.doctype=doclist;else
args.docs=compress_doclist(doclist);open_url_post(outUrl,args);}
args.docs=compress_doclist(doclist);open_url_post(webnotes.request.url,args);}
function open_url_post(URL,PARAMS,new_window){var temp=document.createElement("form");temp.action=URL;temp.method="POST";temp.style.display="none";if(new_window){temp.target='_blank';}
for(var x in PARAMS){var opt=document.createElement("textarea");opt.name=x;opt.value=PARAMS[x];temp.appendChild(opt);}
document.body.appendChild(temp);temp.submit();return temp;}
@ -411,12 +418,12 @@ jQuery.each(["keydown","keyup","keypress"],function(){jQuery.event.special[this]
*/
var no_value_fields=['Section Break','Column Break','HTML','Table','FlexTable','Button','Image'];var codeid=0;var code_editors={};function Field(){this.with_label=1;}
Field.prototype.make_body=function(){var ischk=(this.df.fieldtype=='Check'?1:0);if(this.parent)
this.wrapper=$a(this.parent,'div');else
this.wrapper=document.createElement('div');this.label_area=$a(this.wrapper,'div','',{margin:'8px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});}
this.wrapper=$a(this.parent,(this.with_label?'div':'span'));else
this.wrapper=document.createElement((this.with_label?'div':'span'));this.label_area=$a(this.wrapper,'div','',{margin:'8px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});}
if(this.with_label){this.label_span=$a(this.label_area,'span','field_label')
this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='lib/images/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='lib/images/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'})
$dh(this.label_area);}
if(!this.input_area){this.input_area=$a(this.wrapper,'div');this.disp_area=$a(this.wrapper,'div');}
if(!this.input_area){this.input_area=$a(this.wrapper,(this.with_label?'div':'span'));this.disp_area=$a(this.wrapper,(this.with_label?'div':'span'));}
if(this.in_grid){if(this.label_area)$dh(this.label_area);}else{this.input_area.className='input_area';$y(this.wrapper,{marginBottom:'4px'});this.set_description();}
if(this.onmake)this.onmake();}
Field.prototype.set_max_width=function(){var no_max=['Code','Text Editor','Text','Table','HTML']
@ -617,7 +624,7 @@ if(f.init)f.init();f.make_body();return f;}
*/
wn.widgets.FieldGroup=function(){this.first_button=false;this.make_fields=function(body,fl){$y(this.body,{padding:'11px'});this.fields_dict={};for(var i=0;i<fl.length;i++){var df=fl[i];var div=$a(body,'div','',{margin:'6px 0px'})
f=make_field(df,null,div,null);f.not_in_form=1;this.fields_dict[df.fieldname]=f
f.refresh();if(df.fieldtype=='Button'&&!this.first_button){$(f.input).addClass('btn-primary');this.first_button=true;}}}
f.refresh();if(df.fieldtype=='Button'&&!this.first_button){$(f.input).addClass('btn-info');this.first_button=true;}}}
this.get_values=function(){var ret={};var errors=[];for(var key in this.fields_dict){var f=this.fields_dict[key];var v=f.get_value?f.get_value():null;if(f.df.reqd&&!v)
errors.push(f.df.label+' is mandatory');if(v)ret[f.df.fieldname]=v;}
if(errors.length){msgprint('<b>Please check the following Errors</b>\n'+errors.join('\n'));return null;}
@ -657,35 +664,103 @@ else if(d[0]=='Password'){c1.innerHTML=d[1];c2.style.overflow='auto';this.widget
else if(d[0]=='Select'){c1.innerHTML=d[1];this.widgets[d[1]]=$a(c2,'select','',{width:'160px'})
if(d[2])$a(c2,'div','field_description').innerHTML=d[2];if(d[3])add_sel_options(this.widgets[d[1]],d[3],d[3][0]);}
else if(d[0]=='Text'){c1.innerHTML=d[1];c2.style.overflow='auto';this.widgets[d[1]]=$a(c2,'textarea');if(d[2])$a(c2,'div','field_description').innerHTML=d[2];}
else if(d[0]=='Button'){c2.style.height='32px';var b=$btn(c2,d[1],function(btn){if(btn._onclick)btn._onclick(me)},null,null,1);b.dialog=me;if(!this.first_button){$(b).addClass('btn-primary');this.first_button=true;}
else if(d[0]=='Button'){c2.style.height='32px';var b=$btn(c2,d[1],function(btn){if(btn._onclick)btn._onclick(me)},null,null,1);b.dialog=me;if(!this.first_button){$(b).addClass('btn-info');this.first_button=true;}
if(d[2]){b._onclick=d[2];}
this.widgets[d[1]]=b;}}
/*
* lib/js/wn/ui/listing.js
*/
wn.widgets.Listing=function(opts){this.opts=opts;this.page_length=20;this.btns={};this.start=0;var me=this;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');this.results_area=$a(this.wrapper,'div','listing-results');this.more_button_area=$a(this.wrapper,'div','listing-more');this.no_results_area=$a(this.wrapper,'div','help_box',{display:'none'},(this.opts.no_result_message?this.opts.no_result_message:'No results'));if(opts)this.opts=opts;this.page_length=this.opts.page_length?this.opts.page_length:this.page_length;this.make_toolbar();this.make_filters();this.make_more_button();}
this.make_filters=function(){if(this.opts.filters){$ds(this.filters_area);this.filters=new wn.widgets.FieldGroup(this.filters_area,this.opts.fields);}}
this.make_toolbar=function(){if(!(this.opts.hide_refresh||this.opts.no_refresh)){if(this.opts.title){$a(this.toolbar_area,'h3','',{display:'inline-block',marginRight:'15px'},this.opts.title);}
this.ref_img=$a(this.toolbar_area,'span','link_type',{color:'#888'},'[refresh]');this.ref_img.onclick=function(){me.run();}
this.loading_img=$a(this.toolbar_area,'img','lib/images/ui/button-load.gif',{display:'none',marginLeft:'3px',marginBottom:'-2px'});}
if(this.opts.new_doctype){this.new_btn=$btn(this.toolbar_area,'New '+get_doctype_label(this.opts.new_doctype),function(){newdoc(me.opts.new_doctype,me.opts.new_doc_onload,me.opts.new_doc_indialog,me.opts.new_doc_onsave);},{marginLeft:'7px'});}}
this.make_more_button=function(){this.more_btn=$btn(this.more_button_area,'More...',function(){me.more_btn.set_working();me.run(function(){me.more_btn.done_working();},1);},'',0,1);$y(this.more_btn.loading_img,{marginBottom:'0px'});}
this.clear=function(){this.results_area.innerHTML='';this.table=null;$ds(this.results_area);$dh(this.no_results_area);}
this.make_results=function(r,rt){if(this.start==0)this.clear();$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;var m=Math.min(r.values.length,this.page_length);for(var i=0;i<m;i++){var row=this.add_row();this.opts.render_row(row,r.values[i],this,i);}
this.start+=m;if(r.values.length>=this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}}
if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();if(this.opts.callback)this.opts.callback(r);}
this.add_row=function(){return $a(this.results_area,'div','',(opts.cell_style?opts.cell_style:{padding:'3px 0px'}));}
this.run=function(callback,append){if(callback)
this.onrun=callback;if(!append)
this.start=0;if(!this.opts.method){this.query=this.opts.get_query?this.opts.get_query():this.opts.query;this.add_limits();var args={query_max:this.query_max||this.opts.query_max||'',as_dict:1}
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);},make:function(opts){if(opts){this.opts=opts;}
$.extend(this,this.opts);this.prepare_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: 30px;">\
<div class="btn-group" style="float: left;">\
<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>\
<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>\
\
<div style="clear: both; height: 11px;"></div>\
<div class="list-filters hide">\
<div class="show_filters well">\
<div class="filter_area"></div>\
<div>\
<button class="btn btn-small add-filter-btn">\
<i class="icon-plus"></i> Add Filter</button>\
</div>\
</div>\
</div>\
\
<div class="no-result help hide">\
%(no_result_message)s\
</div>\
\
<div class="result">\
<div class="result-list"></div>\
<div class="result-grid"></div>\
</div>\
\
<div class="paging-button hide">\
<button class="btn btn-small btn-more">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);}
if(this.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype);})}else{this.$w.find('.btn-new').toggle(false);}
if(!me.show_filters){this.$w.find('.btn-filter').toggle(false);}
if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').toggle(false);}
if(this.show_grid){this.$w.find('.select-view').toggle(true);}},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}
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
if(this.opts.args)
$.extend(args,this.opts.args)
if(this.loading_img)$di(this.loading_img);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:args,callback:function(r,rt){me.make_results(r,rt)},no_spinner:this.opts.no_loading,btn:this.opts.run_btn});}
this.refresh=this.run;this.add_limits=function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}
if(opts)this.make();}
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(){$.each(this.columns,function(i,c){if(!c.id)c.id=c.field;})
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);}
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)
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);})
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">\
<option value="=">Equals</option>\
<option value="like">Like</option>\
<option value=">=">Greater or equals</option>\
<option value=">=">Less or equals</option>\
<option value=">">Greater than</option>\
<option value="<">Less than</option>\
<option value="!=">Not equals</option>\
</select>\
<span class="filter_field"></span>\
<a class="close">&times;</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);}
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);}
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];}});
/*
* lib/js/legacy/widgets/layout.js
*/
@ -718,15 +793,9 @@ 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',{},'&times;');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-primary':''));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;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.clear_toolbar=function(){this.toolbar_area.innerHTML='';this.buttons={};}
PageHeader.prototype.make_buttonset=function(){$(this.toolbar_area).buttonset();}
/*
* lib/js/legacy/widgets/select.js
*/
function SelectWidget(parent,options,width,editable,bg_color){var me=this;this.inp=$a(parent,'select');if(options)add_sel_options(this.inp,options);if(width)$y(this.inp,{width:width});this.set_width=function(w){$y(this.inp,{width:w})};this.set_options=function(o){add_sel_options(this.inp,o);}
this.inp.onchange=function(){if(me.onchange)me.onchange(this);}
return;}
/*
* lib/js/legacy/webpage/history.js
*/
@ -746,13 +815,13 @@ var _history_current;function history_get_name(t){var parts=[];if(t.length>=3){f
return parts.join('/')}
nav_obj.get_page=function(loc){if(!loc)loc=window.location.hash;if(loc.substr(0,1)=='#'){loc=loc.substr(1);}
if(loc.substr(0,1)=='!'){loc=loc.substr(1);}
if(!in_list(['Page/','Form/','Repor','DocBr','List/'],loc.substr(0,5))){loc='Page/'+loc;}
if(!in_list(['Page/','Form/','Repor','DocBr','List/','List2'],loc.substr(0,5))){loc='Page/'+loc;}
return loc.split('/');}
function historyChange(newLocation){var t=nav_obj.get_page(newLocation)
for(var i=0;i<t.length;i++)
t[i]=decodeURIComponent(t[i]);if(nav_obj.ol.length){var c=nav_obj.ol[nav_obj.ol.length-1];if(t.length==2){if(c[0]==t[0]&&c[1]==t[1])return;}else{if(c[0]==t[0]&&c[1]==t[1]&&c[2]==t[2])return;}}
if(t[2])
var docname=history_get_name(t);if(t[0]=='Form'){_history_current=newLocation;if(docname.substr(0,3)=='New'&&!(locals[t[1]]&&locals[t[1]][docname])){newdoc(t[1]);}else{loaddoc(t[1],docname);}}else if(t[0]=='Report'){_history_current=newLocation;loadreport(t[1],docname);}else if(t[0]=='Page'){_history_current=newLocation;loadpage(t[1]);}else if(t[0]=='Application'){_history_current=newLocation;loadapp(t[1]);}else if(t[0]=='DocBrowser'||t[0]=='List'){_history_current=newLocation;loaddocbrowser(t[1]);}};$(window).bind('hashchange',function(){historyChange(location.hash);});
var docname=history_get_name(t);if(t[0]=='Form'){_history_current=newLocation;if(docname.substr(0,3)=='New'&&!(locals[t[1]]&&locals[t[1]][docname])){newdoc(t[1]);}else{loaddoc(t[1],docname);}}else if(t[0]=='Report'){_history_current=newLocation;loadreport(t[1],docname);}else if(t[0]=='Page'){_history_current=newLocation;loadpage(t[1]);}else if(t[0]=='Application'){_history_current=newLocation;loadapp(t[1]);}else if(t[0]=='DocBrowser'||t[0]=='List'){_history_current=newLocation;loaddocbrowser(t[1]);}else if(t[0]=='List2'){_history_current=newLocation;loaddocbrowser2(t[1]);}};$(window).bind('hashchange',function(){historyChange(location.hash);});
/*
* lib/js/legacy/webpage/search.js
*/
@ -846,11 +915,12 @@ function loadscript(src,call_back){set_loading();var script=$a('head','script');
script.onreadystatechange=function(){if(this.readyState=='complete'||this.readyState=='loaded'){hide_loading();call_back();}}}
var doc_browser_page;function loaddocbrowser(dt,label,fields){wn.require('lib/js/legacy/webpage/docbrowser.js');dt=get_label_doctype(dt);if(!doc_browser_page)
doc_browser_page=new ItemBrowserPage();doc_browser_page.show(dt,label,fields);nav_obj.open_notify('List',dt,'');}
function loaddocbrowser2(dt,label,fields){wn.pages.doclistview.show(dt);return;}
/*
* lib/js/legacy/webpage/uploader.js
*/
var uploaders={};var upload_frame_count=0;Uploader=function(parent,args,callback){var id='frame'+upload_frame_count;upload_frame_count++;this.callback=callback;var div=$a(parent,'div');div.innerHTML='<iframe id="'+id+'" name="'+id+'" src="blank.html" \
style="width:0px; height:0px; border:0px"></iframe>';var div=$a(parent,'div');div.innerHTML='<form method="POST" enctype="multipart/form-data" action="'+outUrl+'" target="'+id+'"></form>';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';}
style="width:0px; height:0px; border:0px"></iframe>';var div=$a(parent,'div');div.innerHTML='<form method="POST" enctype="multipart/form-data" action="'+webnotes.request.url+'" target="'+id+'"></form>';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';}
var inp=$a_input($a(ul_form,'span'),'hidden',{name:'uploader_id'});inp.value=id;var inp=$a_input($a(ul_form,'span'),'submit',null,{marginLeft:'7px'});inp.value='Upload';$y(inp,{width:'80px'});for(var key in args){var inp=$a_input($a(ul_form,'span'),'hidden',{name:key});inp.value=args[key];}
uploaders[id]=this;}
function upload_callback(id,fid){uploaders[id].callback(fid);}

View File

@ -1 +1 @@
841
894