@@ -26,6 +26,7 @@ | |||
} | |||
</script> | |||
{% endif %} | |||
<script src="lib/js/wn/pages/doclistview.js"></script> | |||
</head> | |||
<body> | |||
{{ body_html }} | |||
@@ -0,0 +1,29 @@ | |||
div.show_filters { | |||
display: none; | |||
} | |||
div.filter_list { | |||
padding: 13px; | |||
} | |||
div.show_filters.well { | |||
margin-top: 11px; | |||
margin-bottom: 0px; | |||
} | |||
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; | |||
} |
@@ -44,6 +44,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 | |||
*/ | |||
@@ -1,3 +0,0 @@ | |||
// home | |||
//login_file = 'index.html' |
@@ -95,7 +95,7 @@ function $ln(parent, label, onclick, 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'; | |||
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; | |||
@@ -171,6 +171,20 @@ $bs = function(ele, r) { $(ele).css('-moz-box-shadow',r).css('-webkit-box-shadow | |||
// Select | |||
// ==================================== | |||
function SelectWidget(parent, options, width, editable, bg_color) { | |||
var me = this; | |||
// native select | |||
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; | |||
@@ -87,7 +87,7 @@ function $c_obj_csv(doclist, method, arg) { | |||
args.docs = compress_doclist(doclist); | |||
// open | |||
open_url_post(outUrl, args); | |||
open_url_post(webnotes.request.url, args); | |||
} | |||
// call a url as POST | |||
@@ -144,7 +144,7 @@ nav_obj.get_page = function(loc) { | |||
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))) { | |||
if(!in_list(['Page/', 'Form/', 'Repor', 'DocBr', 'List/', 'List2'], loc.substr(0,5))) { | |||
loc = 'Page/' + loc; | |||
} | |||
return loc.split('/'); | |||
@@ -191,7 +191,11 @@ function historyChange(newLocation) { | |||
} 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() { | |||
@@ -301,3 +301,8 @@ function loaddocbrowser(dt, label, fields) { | |||
doc_browser_page.show(dt, label, fields); | |||
nav_obj.open_notify('List',dt,''); | |||
} | |||
function loaddocbrowser2(dt, label, fields) { | |||
wn.pages.doclistview.show(dt); | |||
return; | |||
} |
@@ -73,7 +73,7 @@ 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' : '')); | |||
var btn = $btn(tb,label,fn,{marginRight:'4px'}, (green ? 'btn-info' : '')); | |||
if(bold) $y(btn,{fontWeight:'bold'}); | |||
this.buttons[label]=btn; | |||
@@ -38,7 +38,7 @@ Uploader = function(parent, args, callback) { | |||
// upload form | |||
var div = $a(parent,'div'); | |||
div.innerHTML = '<form method="POST" enctype="multipart/form-data" action="'+outUrl+'" target="'+id+'"></form>'; | |||
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 = []; | |||
@@ -134,7 +134,7 @@ Dialog.prototype.make_row = function(d) { | |||
if(btn._onclick) btn._onclick(me) }, null, null, 1); | |||
b.dialog = me; | |||
if(!this.first_button) { | |||
$(b).addClass('btn-primary'); | |||
$(b).addClass('btn-info'); | |||
this.first_button = true; | |||
} | |||
if(d[2]) { | |||
@@ -58,5 +58,5 @@ function export_csv(q, report_name, sc_id, is_simple, filter_values, colnames) { | |||
if(colnames) | |||
args.colnames = colnames.join(','); | |||
args.report_name = report_name ? report_name : ''; | |||
open_url_post(outUrl, args); | |||
open_url_post(webnotes.request.url, args); | |||
} |
@@ -43,9 +43,9 @@ Field.prototype.make_body = function() { | |||
// parent element | |||
if(this.parent) | |||
this.wrapper = $a(this.parent, 'div'); | |||
this.wrapper = $a(this.parent, (this.with_label ? 'div' : 'span')); | |||
else | |||
this.wrapper = document.createElement('div'); | |||
this.wrapper = document.createElement((this.with_label ? 'div' : 'span')); | |||
this.label_area = $a(this.wrapper, 'div', '', {margin:'8px 0px 2px 0px'}); | |||
@@ -75,8 +75,8 @@ Field.prototype.make_body = function() { | |||
// make the input areas | |||
if(!this.input_area) { | |||
this.input_area = $a(this.wrapper, 'div'); | |||
this.disp_area = $a(this.wrapper, 'div'); | |||
this.input_area = $a(this.wrapper, (this.with_label ? 'div' : 'span')); | |||
this.disp_area = $a(this.wrapper, (this.with_label ? 'div' : 'span')); | |||
} | |||
// apply style | |||
@@ -95,6 +95,7 @@ Field.prototype.make_body = function() { | |||
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 | |||
@@ -228,7 +228,7 @@ _f.ImageField.prototype.get_image_src = function(doc) { | |||
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 = outUrl + "?cmd=downloadfile&file_id="+file[1]; | |||
var src = webnotes.request.url + "?cmd=downloadfile&file_id="+file[1]; | |||
} | |||
} else { | |||
var src = ""; | |||
@@ -248,7 +248,7 @@ _f.ImageField.prototype.onrefresh = function() { | |||
var doc = locals[this.frm.doctype][this.frm.docname]; | |||
if(!this.df.options) var src = this.get_image_src(doc); | |||
else var src = outUrl + '?cmd=get_file&fname='+this.df.options+"&__account="+account_id + (__sid150 ? ("&sid150="+__sid150) : ''); | |||
else var src = webnotes.request.url + '?cmd=get_file&fname='+this.df.options+"&__account="+account_id + (__sid150 ? ("&sid150="+__sid150) : ''); | |||
if(src) { | |||
@@ -198,11 +198,11 @@ _f.FrmHeader.prototype.set_save_submit_color = function(doc) { | |||
if(cint(doc.docstatus)==0 && submit_btn && save_btn) { | |||
if(cint(doc.__unsaved)) { | |||
$(save_btn).addClass('btn-primary'); | |||
$(submit_btn).removeClass('btn-primary'); | |||
$(save_btn).addClass('btn-info'); | |||
$(submit_btn).removeClass('btn-info'); | |||
} else { | |||
$(submit_btn).addClass('btn-primary'); | |||
$(save_btn).removeClass('btn-primary'); | |||
$(submit_btn).addClass('btn-info'); | |||
$(save_btn).removeClass('btn-info'); | |||
} | |||
} | |||
} | |||
@@ -1,153 +0,0 @@ | |||
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
// | |||
// MIT License (MIT) | |||
// | |||
// Permission is hereby granted, free of charge, to any person obtaining a | |||
// copy of this software and associated documentation files (the "Software"), | |||
// to deal in the Software without restriction, including without limitation | |||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
// and/or sell copies of the Software, and to permit persons to whom the | |||
// Software is furnished to do so, subject to the following conditions: | |||
// | |||
// The above copyright notice and this permission notice shall be included in | |||
// all copies or substantial portions of the Software. | |||
// | |||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
// | |||
ListSelector = function(title, intro, list, onupdate, selectable) { | |||
var me = this; this.list = list; this.selectable = selectable; | |||
this.dialog = new Dialog(400,600,title); | |||
this.items = []; | |||
// intro | |||
if(intro) { | |||
intro_area = $a(this.dialog.body, 'div', 'help_box', {margin:'16px', marginBottom:'0px', width:'312px'}); | |||
intro_area.innerHTML = intro; | |||
} | |||
// body | |||
this.body = $a(this.dialog.body, 'div', '', {margin:'16px', position: 'relative'}); | |||
// items | |||
this.render(); | |||
// --------------------------------------- | |||
// update button | |||
var btn = $btn(this.dialog.body, 'Update', function() { me.update() }, {margin:'0px 0px 16px 16px'}, 'green', 1); | |||
this.update = function() { | |||
if(me.selected_item) $bg(me.selected_item, '#FFF'); | |||
var ret = []; | |||
for(var i=0; i<me.items.length; i++) { | |||
// [label, idx, selected, det] | |||
ret.push([me.items[i].label, me.items[i].idx, (me.items[i].check ? (me.items[i].check.checked ? 1 : 0) : 0), me.items[i].det]); | |||
} | |||
me.dialog.hide(); | |||
// call the user with (done!) | |||
onupdate(ret); | |||
} | |||
this.dialog.show(); | |||
} | |||
// --------------------------------------- | |||
ListSelector.prototype.render = function(to_hide) { | |||
this.body.innerHTML = ''; this.items = []; | |||
// sort | |||
this.list.sort(function(a,b) { return a[1] > b[1]; }); | |||
// items | |||
for(i=0; i<this.list.length; i++) { | |||
// make checkbox for if selectable | |||
this.list[i][1]=i; | |||
this.items.push(new ListSelectorItem(this, this.list[i], i)); | |||
if(i==to_hide) $dh(this.items[i].body); | |||
} | |||
} | |||
// --------------------------------------- | |||
ListSelector.prototype.insert_at = function(item, new_idx) { | |||
for(var i=0;i<this.list.length; i++) { | |||
if(this.list[i][1] >= new_idx) this.list[i][1]++; | |||
} | |||
for(var i=0;i<this.list.length; i++) { | |||
if(this.list[i][1] >= item.idx) this.list[i][1]--; | |||
} | |||
this.list[item.idx][1] = new_idx; | |||
var n = new_idx - ((new_idx > item.idx) ? 1 : 0); | |||
this.render(n); | |||
this.items[n].body.onmousedown(); | |||
$(this.items[n].body).slideDown(); | |||
} | |||
// ===================================== | |||
ListSelectorItem = function(ls, det, idx) { | |||
this.det = det; this.ls = ls; this.idx = idx; | |||
this.body = $a(ls.body, 'div', '', {padding: '8px', margin:'4px 0px', | |||
border:'1px solid #AAA', position: 'relative', width:'320px', height:'14px', cursor:'move'}); | |||
if(ls.selectable) { | |||
// with checkbox | |||
this.make_with_checkbox(); | |||
} else { | |||
// no checkbox (only label) | |||
this.body.innerHTML = det[0]; | |||
} | |||
this.set_drag(); | |||
} | |||
// --------------------------------------- | |||
ListSelectorItem.prototype.make_with_checkbox = function() { | |||
this.body.tab = make_table(this.body, 1, 2, null, ['28px',null], {verticalAlign:'top'}); | |||
this.check = $a_input($td(this.body.tab, 0, 0), 'checkbox'); | |||
if(this.det[2]) this.check.checked = 1; | |||
$td(this.body.tab, 0, 1).innerHTML = this.det[0]; | |||
} | |||
// --------------------------------------- | |||
ListSelectorItem.prototype.set_drag = function() { | |||
var me = this; | |||
this.body.item = this; | |||
// color on mousedown | |||
this.body.onmousedown = function() { | |||
$bg(this, '#FFC'); | |||
if(me.ls.selected_item && me.ls.selected_item != this) $bg(me.ls.selected_item, '#FFF'); | |||
me.ls.selected_item = this; | |||
} | |||
// setup draggable | |||
$(this.body).draggable({ | |||
opacity: 0.6, | |||
helper: 'clone', | |||
containment: 'parent', | |||
scroll: false, | |||
cursor: 'move', | |||
drag:function(event, ui){ | |||
me.ls.drag_item = this.item; | |||
} | |||
}); | |||
$(this.body).droppable({ | |||
drop: function(event, ui) { | |||
me.ls.insert_at(me.ls.drag_item, me.idx + (me.ls.drag_item.idx < me.idx ? 1 : 0)); | |||
} | |||
}); | |||
} |
@@ -18,20 +18,9 @@ | |||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
// | |||
// | |||
/* Only using native widget now - no longer want to support IE6 */ | |||
wn.provide('wn.model'); | |||
function SelectWidget(parent, options, width, editable, bg_color) { | |||
var me = this; | |||
// native select | |||
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; | |||
} | |||
wn.model.no_value_type = ['Section Break', 'Column Break', 'HTML', 'Table', | |||
'Button', 'Image']; |
@@ -42,14 +42,275 @@ wn.pages.DocListView = Class.extend({ | |||
this.label : (this.label + ' List') | |||
this.make(); | |||
this.load_doctype(); | |||
}, | |||
make: function() { | |||
$(this.wrapper).html('<div class="layout_wrapper">\ | |||
<div class="header"></div>\ | |||
<div class="filters">[filters]</div>\ | |||
<div class="body">[body]</div>\ | |||
$(this.wrapper).html('<div class="layout-wrapper layout-wrapper-background">\ | |||
<div class="layout-main-section">\ | |||
<a class="close" onclick="window.history.back();">×</a>\ | |||
<h1>List</h1>\ | |||
<hr>\ | |||
<div id="list-filters"></div>\ | |||
<button class="btn btn-small btn-info run-btn" style="margin-top: 11px">\ | |||
<i class="icon-refresh icon-white"></i> Refresh</button>\ | |||
<div id="list-body"></div>\ | |||
</div>\ | |||
<div class="layout-side-section">\ | |||
</div>\ | |||
</div>'); | |||
// filter button | |||
$(this.wrapper).find('.run-btn').click(function() { | |||
me.list.run(); | |||
}); | |||
}, | |||
load_doctype: function() { | |||
var me = this; | |||
wn.call({ | |||
method: 'webnotes.widgets.form.load.getdoctype', | |||
args: {doctype:this.doctype}, | |||
callback: function() { | |||
me.make_filters(); | |||
me.make_list(); | |||
} | |||
}); | |||
}, | |||
make_filters: function() { | |||
this.filter_list = new wn.ui.FilterList(this, $('#list-filters').get(0), this.doctype); | |||
}, | |||
make_list: function() { | |||
var me = this; | |||
this.list = new wn.widgets.Listing({ | |||
parent: $('#list-body').get(0), | |||
method: 'webnotes.widgets.doclistview.get', | |||
args: { | |||
doctype: this.doctype, | |||
subject: locals.DocType[this.doctype].subject, | |||
}, | |||
get_args: function() { | |||
return {filters: JSON.stringify(me.filter_list.get_filters())} | |||
}, | |||
render_row: function(row, data) { | |||
row.innerHTML = data; | |||
}, | |||
hide_refresh: true | |||
}); | |||
this.list.run(); | |||
} | |||
}); | |||
wn.require('lib/css/ui/filter.css'); | |||
wn.ui.FilterList = Class.extend({ | |||
init: function(list_obj, parent, doctype) { | |||
this.filters = []; | |||
this.list_obj = list_obj; | |||
this.doctype = doctype; | |||
this.make(parent); | |||
this.set_events(); | |||
}, | |||
make: function(parent) { | |||
$(parent).html('<div>\ | |||
<span class="link_type set_filters">Filter this list</span>\ | |||
</div>\ | |||
<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>'); | |||
this.$w = $(parent); | |||
}, | |||
set_events: function() { | |||
var me = this; | |||
// show filters | |||
this.$w.find('.set_filters').bind('click', function() { | |||
me.$w.find('.show_filters').slideToggle(); | |||
if(!me.filters.length) | |||
me.add_filter(); | |||
}); | |||
// show filters | |||
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(this, this.doctype, fieldname, condition, value)); | |||
}, | |||
get_filters: function() { | |||
// get filter values as dict | |||
var values = []; | |||
$.each(this.filters, function(i, f) { | |||
if(f.filter_field) | |||
values.push(f.get_value()); | |||
}) | |||
return values; | |||
} | |||
}); | |||
wn.ui.Filter = Class.extend({ | |||
init: function(flist, doctype, fieldname, condition, value) { | |||
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">×</a>\ | |||
</div>'); | |||
this.fields_by_name = {}; | |||
this.flist = flist; | |||
this.$w = this.flist.$w.find('.list_filter:last-child'); | |||
this.doctype = doctype; | |||
this.fieldname = fieldname; | |||
this.condition = condition; | |||
this.value = value; | |||
this.set_events(); | |||
}, | |||
set_events: function() { | |||
var me = this; | |||
new PageHeader($(this.wrapper).find('.header').get(0), this.label) | |||
// render fields | |||
this.render_field_select(); | |||
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); | |||
me.list_obj.list.run(); | |||
} | |||
if(value) { | |||
me.list_obj.list.run(); | |||
} | |||
return false; | |||
}); | |||
// set the field | |||
if(me.fieldname) { | |||
// presents given (could be via tags!) | |||
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; | |||
var $fs = me.$w.find('.fieldname_select'); | |||
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} | |||
]; | |||
// main table | |||
$.each(std_filters.concat(fields_list[me.doctype]), function(i, df) { | |||
me.add_field_option(df, $fs); | |||
}); | |||
// child tables | |||
$.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, $fs); | |||
}); | |||
} | |||
}) | |||
}, | |||
add_field_option: function(df, $fs) { | |||
var me = this; | |||
if(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]) { | |||
$fs.append($('<option>', { | |||
value: df.fieldname, | |||
table: table | |||
}).text(label)); | |||
me.fields_by_name[df.fieldname] = df; | |||
} | |||
}, | |||
set_field: function(fieldname) { | |||
var me = this; | |||
// set in fieldname (again) | |||
me.$w.find('.fieldname_select').val(fieldname); | |||
wn.require('lib/js/legacy/widgets/form/fields.js'); | |||
var field_area = me.$w.find('.filter_field').get(0); | |||
field_area.innerHTML = ''; | |||
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; | |||
// set as "like" for data fields | |||
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]; | |||
} | |||
}) | |||
}); |
@@ -37,7 +37,7 @@ wn.widgets.FieldGroup = function() { | |||
// first button primary ? | |||
if(df.fieldtype=='Button' && !this.first_button) { | |||
$(f.input).addClass('btn-primary'); | |||
$(f.input).addClass('btn-info'); | |||
this.first_button = true; | |||
} | |||
} | |||
@@ -28,6 +28,7 @@ | |||
// parent | |||
// method (method to call on server) | |||
// args (additional args to method) | |||
// get_args (method to return args as dict) | |||
// query or get_query (will be deprecated) | |||
// query_max | |||
// no_result_message ("No result") | |||
@@ -202,6 +203,10 @@ wn.widgets.Listing = function(opts) { | |||
if(this.opts.args) | |||
$.extend(args, this.opts.args) | |||
if(this.opts.get_args) { | |||
$.extend(args, this.opts.get_args()); | |||
} | |||
// show loading | |||
if(this.loading_img) $di(this.loading_img); | |||
@@ -53,7 +53,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { | |||
}); | |||
} | |||
},1); | |||
$(cur_frm.frm_head.page_head.buttons.Update).addClass('btn-primary'); | |||
$(cur_frm.frm_head.page_head.buttons.Update).addClass('btn-info'); | |||
cur_frm.add_custom_button('Refresh Form', function() { | |||
cur_frm.cscript.doc_type(doc, dt, dn); | |||
@@ -0,0 +1,41 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
# | |||
"""build query for doclistview and return results""" | |||
import webnotes, json | |||
@webnotes.whitelist() | |||
def get(arg=None): | |||
""" | |||
build query | |||
gets doctype, subject, filters | |||
limit_start, limit_page_length | |||
""" | |||
data = webnotes.form_dict | |||
filters = json.loads(data['filters']) | |||
query = """select %(fields)s from %(tables)s where %(conditions)s | |||
limit %(limit_start)s, %(limit_page_length)s""" |