commonfied std fields in client in filter and report
This commit is contained in:
parent
40470d2489
commit
fad4ee0e84
4 changed files with 36 additions and 85 deletions
|
|
@ -1,68 +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.
|
||||
//
|
||||
|
||||
// Fitler object
|
||||
// pass a list of docfields that need to be set as filters
|
||||
// creates ranges for dates and number types
|
||||
//
|
||||
// -------------
|
||||
// Filter By:
|
||||
// Label [Input] [[ to [Input]]] [x]
|
||||
// Label [Input] [[ to [Input]]] [x]
|
||||
// [select:Add a filter]
|
||||
|
||||
wn.widgets.Filters = function(parent, fields) {
|
||||
this.fields = fields;
|
||||
this.filters = [];
|
||||
|
||||
this.make = function() {
|
||||
this.filter_area = $a(parent, 'div', 'filters-wrapper')
|
||||
this.create_add_fitler_select()
|
||||
}
|
||||
|
||||
this.create_add_fitler_select = function() {
|
||||
|
||||
this.add_btn = $btn(parent, '+ Add a new Filter', this.add_filter);
|
||||
}
|
||||
|
||||
this.add_filter = function(df) {
|
||||
|
||||
}
|
||||
|
||||
this.get_values = function() {
|
||||
var values = {}
|
||||
for(var i=0;i<this.fitlers.length;i++) {
|
||||
var f = this.filters[i];
|
||||
values[f.df.fieldname] = f.field.get_value();
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// single fitler - label, input, (input1), delete btn
|
||||
wn.widgets.SingleFilter = function(parent, docfield) {
|
||||
this.parent = parent;
|
||||
this.df = docfield;
|
||||
|
||||
}
|
||||
|
|
@ -26,8 +26,34 @@ wn.model = {
|
|||
no_value_type: ['Section Break', 'Column Break', 'HTML', 'Table',
|
||||
'Button', 'Image'],
|
||||
|
||||
std_fields: [
|
||||
{fieldname:'name', fieldtype:'Link', label:'ID'},
|
||||
{fieldname:'owner', fieldtype:'Data', label:'Created By'},
|
||||
{fieldname:'creation', fieldtype:'Date', label:'Created On'},
|
||||
{fieldname:'modified', fieldtype:'Date', label:'Last Updated On'},
|
||||
{fieldname:'modified_by', fieldtype:'Date', label:'Last Updated By'},
|
||||
{fieldname:'_user_tags', fieldtype:'Data', label:'Tags'},
|
||||
{fieldname:'docstatus', fieldtype:'Int', label:'Document Status'},
|
||||
],
|
||||
|
||||
std_fields_table: [
|
||||
{fieldname:'parent', fieldtype:'Data', label:'Parent'},
|
||||
{fieldname:'idx', fieldtype:'Int', label:'Row No.'},
|
||||
],
|
||||
|
||||
new_names: {},
|
||||
|
||||
get_std_field: function(fieldname) {
|
||||
var docfield = $.map([].concat(wn.model.std_fields).concat(wn.model.std_fields_table),
|
||||
function(d) {
|
||||
if(d.fieldname==fieldname) return d;
|
||||
});
|
||||
if(!docfield.length) {
|
||||
msgprint("Unknown Column: " + fieldname);
|
||||
}
|
||||
return docfield[0];
|
||||
},
|
||||
|
||||
with_doctype: function(doctype, callback) {
|
||||
if(locals.DocType[doctype]) {
|
||||
callback();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
wn.ui.FilterList = Class.extend({
|
||||
init: function(opts) {
|
||||
wn.require('js/fields.js');
|
||||
if(!window.make_field)
|
||||
wn.require('js/fields.js');
|
||||
$.extend(this, opts);
|
||||
this.filters = [];
|
||||
this.$w = this.$parent;
|
||||
|
|
@ -289,19 +290,9 @@ wn.ui.FieldSelect = Class.extend({
|
|||
build_options: 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:'creation', fieldtype:'Date', label:'Created On',
|
||||
parent:me.doctype},
|
||||
{fieldname:'_user_tags', fieldtype:'Data', label:'Tags',
|
||||
parent:me.doctype},
|
||||
{fieldname:'docstatus', fieldtype:'Int', label:'Doc Status',
|
||||
parent:me.doctype},
|
||||
];
|
||||
var std_filters = $.map(wn.model.std_fields, function(d) {
|
||||
return $.extend(copy_dict(d), {parent: me.doctype});
|
||||
});
|
||||
|
||||
// add parenttype column
|
||||
var doctype_obj = locals['DocType'][me.doctype];
|
||||
|
|
|
|||
|
|
@ -132,9 +132,11 @@ wn.views.ReportView = wn.ui.Listing.extend({
|
|||
var me = this;
|
||||
return $.map(this.columns, function(c) {
|
||||
var docfield = wn.meta.docfield_map[c[1] || me.doctype][c[0]];
|
||||
if(c[0]=="name") {
|
||||
var docfield = {fieldname:"name", label:"ID",
|
||||
fieldtype:"Link", options:me.doctype }
|
||||
if(!docfield) {
|
||||
var docfield = wn.model.get_std_field(c[0]);
|
||||
if(c[0]=="name") {
|
||||
docfield.options = me.doctype;
|
||||
}
|
||||
}
|
||||
coldef = {
|
||||
id: c[0],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue