updates to listview

This commit is contained in:
Rushabh Mehta 2014-07-30 18:33:01 +05:30 committed by Anand Doshi
parent 53088f9a32
commit c80f460bba
5 changed files with 60 additions and 22 deletions

View file

@ -40,7 +40,6 @@ a.form-link {
}
.text-ellipsis {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@ -148,6 +147,10 @@ div#freeze {
/* list */
.progress {
height: 10px;
}
.doclist-row {
position: relative;
padding-top: 5px;
@ -155,6 +158,18 @@ div#freeze {
border-bottom: "1px solid #eee";
}
.doclist-row .progress {
margin-top: 12px;
}
.doclist-row .filterable {
cursor: pointer;
}
.doclist-row .label {
margin-right: 8px;
}
.list-timestamp {
position: absolute;
right: 15px;

View file

@ -147,3 +147,15 @@ frappe.format = function(value, df, options, doc) {
return formatter(value, df, options, doc);
}
frappe.get_format_helper = function(doc) {
var helper = {
get_formatted: function(fieldname) {
var df = frappe.meta.get_docfield(doc.doctype, fieldname);
if(!df) { console.log("fieldname not found: " + fieldname); };
return frappe.format(doc[fieldname], df, {inline:1}, doc);
}
};
$.extend(helper, doc);
return helper;
}

View file

@ -275,7 +275,10 @@ frappe.ui.form.GridRow = Class.extend({
if(this.grid.template) {
$('<div class="col-xs-10">').appendTo(this.row)
.html(frappe.render(this.grid.template, {
doc:this.doc || null, frm:this.frm, row: this}));
doc: this.doc ? frappe.get_format_helper(this.doc) : null,
frm: this.frm,
row: this
}));
} else {
this.add_visible_columns();
}
@ -318,7 +321,7 @@ frappe.ui.form.GridRow = Class.extend({
var df = this.static_display_template[ci][0];
var colsize = this.static_display_template[ci][1];
var txt = this.doc ?
this.get_formatted(df.fieldname) :
frappe.format(this.doc[df.fieldname], df, null, this.doc) :
__(df.label);
if(this.doc && df.fieldtype === "Select") {
txt = __(txt);
@ -542,7 +545,8 @@ frappe.ui.form.GridRow = Class.extend({
refresh_field: function(fieldname) {
var $col = this.row.find("[data-fieldname='"+fieldname+"']");
if($col.length) {
$col.html(this.get_formatted(fieldname));
$col.html(frappe.format(this.doc[fieldname],
frappe.meta.get_docfield(this.doc.doctype, fieldname, this.frm.docname), null, this.frm.doc));
}
// in form
@ -550,11 +554,6 @@ frappe.ui.form.GridRow = Class.extend({
this.fields_dict[fieldname].refresh();
}
},
get_formatted: function(fieldname) {
var df = frappe.meta.get_docfield(this.grid.doctype, fieldname, this.frm.docname);
if(!df) { console.log("fieldname not found: " + fieldname); }
return frappe.format(this.doc[fieldname], df, {inline:1}, this.doc);
},
get_visible_columns: function(blacklist) {
var visible_columns = $.map(this.docfields, function(df) {
if(df.print_hide || df.hidden

View file

@ -85,6 +85,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
this.appframe.set_title_left(this.listview.settings.set_title_left);
}
this.make_help();
this.setup_filterable();
this.$page.find(".show_filters").css({"padding":"15px", "margin":"0px -15px"});
var me = this;
this.$w.on("render-complete", function() {
@ -101,6 +102,23 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
this.$page.find(".layout-main-section").css({"min-height": h_side});
},
setup_filterable: function() {
var me = this;
this.$page.on("click", ".filterable", function(e) {
var filters = $(this).attr("data-filter").split("|");
$.each(filters, function(i, f) {
f = f.split(",");
if(f[2]==="Today") {
f[2] = frappe.datetime.get_today();
} else if(f[2]=="User") {
f[2] = user;
}
me.filter_list.add_filter(me.doctype, f[0], f[1], f[2]);
});
me.run();
})
},
show_match_help: function() {
var me = this;
var match_rules = frappe.perm.get_match_rules(this.doctype);
@ -296,6 +314,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
return $(e).parents(".list-row:first").data('data');
});
},
delete_items: function() {
var me = this;
var dl = this.get_checked_items();

View file

@ -46,7 +46,7 @@ frappe.views.ListView = Class.extend({
// add title field
if(this.meta.title_field) {
this.title_field = meta.title_field;
this.title_field = this.meta.title_field;
add_field(this.meta.title_field);
}
@ -181,17 +181,10 @@ frappe.views.ListView = Class.extend({
},
render_template: function (row, data) {
var me = this,
helper = {
get_formatted: function(fieldname) {
var df = frappe.meta.get_docfield(me.doctype, fieldname);
if(!df) { console.log("fieldname not found: " + fieldname); };
return frappe.format(data[fieldname], df, {inline:1}, data);
}
};
$(frappe.render(this.template,
{ doc : data, list : this, row : helper}))
.appendTo($('<div class="doclist-row"></div>').appendTo(row));
$(frappe.render(this.template, {
doc: frappe.get_format_helper(data),
list: this
})).appendTo($('<div class="doclist-row"></div>').appendTo(row));
},
render_standard_columns: function(row, data) {
@ -327,7 +320,7 @@ frappe.views.ListView = Class.extend({
}
// title
html += repl('<a class="form-link list-id" style="margin-left: 5px" \
html += repl('<a class="form-link list-id" style="margin-left: 5px; margin-right: 8px;" \
href="#Form/%(doctype)s/%(name)s" title="%(title)s">%(title)s</a>', {
doctype: data.doctype,
name: encodeURIComponent(data.name),