moved draft/submitted/cancelled selectors to listing.js, fixes frappe/erpnext#1519
This commit is contained in:
parent
8da423b46e
commit
a833627bb5
4 changed files with 32 additions and 40 deletions
|
|
@ -64,6 +64,20 @@ frappe.ui.Listing = Class.extend({
|
|||
$.extend(this, this.opts);
|
||||
|
||||
$(this.parent).html(repl('\
|
||||
<div class="show-docstatus hide">\
|
||||
<div class="pull-right" style="margin-left: 15px;"><div class="checkbox"><label>\
|
||||
<input type="checkbox" data-docstatus="2">\
|
||||
<span class="text-muted small">'+__('Cancelled')+'</span>\
|
||||
</label></div></div>\
|
||||
<div class="pull-right" style="margin-left: 15px;"><div class="checkbox"><label>\
|
||||
<input type="checkbox" data-docstatus="1" checked="checked">\
|
||||
<span class="text-muted small">'+__('Submitted')+'</span>\
|
||||
</label></div></div>\
|
||||
<div class="pull-right" style="margin-left: 15px;"><div class="checkbox"><label>\
|
||||
<input type="checkbox" data-docstatus="0" checked="checked">\
|
||||
<span class="text-muted small">'+__('Drafts')+'</span>\
|
||||
</label></div></div>\
|
||||
</div>\
|
||||
<div class="frappe-list">\
|
||||
<h3 class="title hide">%(title)s</h3>\
|
||||
\
|
||||
|
|
@ -120,6 +134,7 @@ frappe.ui.Listing = Class.extend({
|
|||
if(this.show_filters) {
|
||||
this.make_filters();
|
||||
}
|
||||
this.setup_docstatus_filter();
|
||||
},
|
||||
add_button: function(label, click, icon) {
|
||||
if(this.appframe) {
|
||||
|
|
@ -213,6 +228,17 @@ frappe.ui.Listing = Class.extend({
|
|||
});
|
||||
},
|
||||
|
||||
setup_docstatus_filter: function() {
|
||||
var me = this;
|
||||
this.can_submit = frappe.model.is_submittable(me.doctype);
|
||||
if(this.can_submit) {
|
||||
$(this.parent).find('.show-docstatus').removeClass('hide');
|
||||
$(this.parent).find('.show-docstatus input').click(function() {
|
||||
me.run();
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.data = [];
|
||||
this.$w.find('.result-list').empty();
|
||||
|
|
@ -263,6 +289,11 @@ frappe.ui.Listing = Class.extend({
|
|||
}
|
||||
}
|
||||
|
||||
args.docstatus = this.can_submit ? $.map($(this.parent).find('.show-docstatus :checked'),
|
||||
function(inp) {
|
||||
return $(inp).attr('data-docstatus');
|
||||
}) : []
|
||||
|
||||
// append user-defined arguments
|
||||
if(this.args)
|
||||
$.extend(args, this.args)
|
||||
|
|
|
|||
|
|
@ -57,25 +57,6 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
|
|||
<div class="help">'+__('Loading')+'...</div></div>')
|
||||
.appendTo(this.$page.find(".layout-main-section"));
|
||||
|
||||
$('<div class="show-docstatus hide side-panel">\
|
||||
<h5 class="text-muted">Show</h5>\
|
||||
<div class="side-panel-body">\
|
||||
<div class="checkbox"><label>\
|
||||
<input type="checkbox" data-docstatus="0" checked="checked">\
|
||||
<span class="text-muted">'+__('Drafts')+'</span>\
|
||||
</label></div>\
|
||||
<div class="checkbox"><label>\
|
||||
<input type="checkbox" data-docstatus="1" checked="checked">\
|
||||
<span class="text-muted">'+__('Submitted')+'</span>\
|
||||
</label></div>\
|
||||
<div class="checkbox"><label>\
|
||||
<input type="checkbox" data-docstatus="2">\
|
||||
<span class="text-muted">'+__('Cancelled')+'</span>\
|
||||
</label></div>\
|
||||
</div>\
|
||||
</div>')
|
||||
.appendTo(this.$page.find(".layout-side-section"));
|
||||
|
||||
this.$page.find(".layout-main-section")
|
||||
.addClass("listview-main-section")
|
||||
.parent().css({"margin-top":"-15px"});
|
||||
|
|
@ -93,7 +74,6 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
|
|||
this.meta = locals.DocType[this.doctype];
|
||||
this.$page.find('.frappe-list-area').empty(),
|
||||
this.setup_listview();
|
||||
this.setup_docstatus_filter();
|
||||
this.init_list(false);
|
||||
this.init_stats();
|
||||
this.init_minbar();
|
||||
|
|
@ -149,19 +129,6 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
|
|||
this.appframe.add_help_button(this.meta.description);
|
||||
}
|
||||
},
|
||||
setup_docstatus_filter: function() {
|
||||
var me = this;
|
||||
this.can_submit = $.map(locals.DocPerm || [], function(d) {
|
||||
if(d.parent==me.meta.name && d.submit) return 1
|
||||
else return null;
|
||||
}).length;
|
||||
if(this.can_submit) {
|
||||
this.$page.find('.show-docstatus').removeClass('hide');
|
||||
this.$page.find('.show-docstatus input').click(function() {
|
||||
me.run();
|
||||
})
|
||||
}
|
||||
},
|
||||
setup_listview: function() {
|
||||
this.listview = frappe.views.get_listview(this.doctype, this);
|
||||
this.wrapper = this.$page.find('.frappe-list-area');
|
||||
|
|
@ -252,16 +219,10 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
|
|||
this.listview.render(row, data, this);
|
||||
},
|
||||
get_args: function() {
|
||||
var docstatus_list = this.can_submit ? $.map(this.$page.find('.show-docstatus :checked'),
|
||||
function(inp) {
|
||||
return $(inp).attr('data-docstatus');
|
||||
}) : []
|
||||
|
||||
var args = {
|
||||
doctype: this.doctype,
|
||||
fields: this.listview.fields,
|
||||
filters: this.filter_list.get_filters(),
|
||||
docstatus: docstatus_list,
|
||||
order_by: this.listview.order_by || undefined,
|
||||
group_by: this.listview.group_by || undefined,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ frappe.views.ListView = Class.extend({
|
|||
var col = $("<div class='col'>")
|
||||
.appendTo(body)
|
||||
.addClass("col-sm-" + cint(colspan))
|
||||
.addClass("col-xs-" + (cint(colspan) + 2))
|
||||
.css({
|
||||
"white-space": "nowrap",
|
||||
"text-overflow": "ellipsis",
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
|
|||
fields: $.map(this.columns, function(v) { return me.get_full_column_name(v) }),
|
||||
order_by: this.get_order_by(),
|
||||
filters: this.filter_list.get_filters(),
|
||||
docstatus: ['0','1','2'],
|
||||
with_childnames: 1
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue