[minor] allow button in list view for grid, and other minor fixes

This commit is contained in:
Rushabh Mehta 2016-08-09 16:42:22 +05:30
parent d763435500
commit fca0cf5ddf
5 changed files with 44 additions and 6 deletions

View file

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import re
import re, copy
import MySQLdb
import frappe
from frappe import _
@ -311,7 +311,7 @@ def validate_fields(meta):
frappe.throw(_("Max width for type Currency is 100px in row {0}").format(d.idx))
def check_in_list_view(d):
if d.in_list_view and (d.fieldtype in no_value_fields):
if d.in_list_view and (d.fieldtype in not_allowed_in_list_view):
frappe.throw(_("'In List View' not allowed for type {0} in row {1}").format(d.fieldtype, d.idx))
def check_dynamic_link_options(d):
@ -441,6 +441,10 @@ def validate_fields(meta):
frappe.throw(_("Timeline field must be a Link or Dynamic Link"), InvalidFieldNameError)
fields = meta.get("fields")
not_allowed_in_list_view = list(copy.copy(no_value_fields))
if meta.istable:
not_allowed_in_list_view.remove('Button')
for d in fields:
if not d.permlevel: d.permlevel = 0
if not d.fieldname:

View file

@ -104,8 +104,19 @@
.grid-body .editable-row input[data-fieldtype="Currency"] {
text-align: right;
}
.grid-body .grid-static-col[data-fieldtype="Button"] .field-area {
margin-top: 5px;
margin-left: 5px;
}
.grid-body .grid-static-col[data-fieldtype="Button"] .field-area button {
height: 27px;
}
.grid-body .grid-static-col[data-fieldtype="Code"] .static-area {
margin-top: -10px;
margin-top: -5px;
}
.grid-body .grid-static-col[data-fieldtype="Code"] .static-area pre {
background: none;
border: none;
}
@media (max-width: 767px) {
.grid-body .btn-open-row {

View file

@ -291,12 +291,17 @@ frappe.ui.form.Grid = Class.extend({
this.frm.script_manager.trigger(this.df.fieldname + "_add", d.doctype, d.name);
this.refresh();
if(show && !this.allow_on_grid_editing()) {
if(show) {
if(idx) {
// always open inserted rows
this.wrapper.find("[data-idx='"+idx+"']").data("grid_row")
.toggle_view(true, callback);
} else {
this.wrapper.find(".grid-row:last").data("grid_row").toggle_view(true, callback);
if(!this.allow_on_grid_editing()) {
// open last row only if on-grid-editing is disabled
this.wrapper.find(".grid-row:last").data("grid_row")
.toggle_view(true, callback);
}
}
}

View file

@ -136,8 +136,22 @@
}
}
.grid-static-col[data-fieldtype="Button"] .field-area {
margin-top: 5px;
margin-left: 5px;
button {
height: 27px;
}
}
.grid-static-col[data-fieldtype="Code"] .static-area {
margin-top: -10px;
margin-top: -5px;
pre {
background: none;
border: none;
}
}
}

View file

@ -114,6 +114,10 @@ def now_datetime():
dt = convert_utc_to_user_timezone(datetime.datetime.utcnow())
return dt.replace(tzinfo=None)
def get_eta(from_time, percent_complete):
diff = time_diff(now_datetime(), from_time).total_seconds()
return str(datetime.timedelta(seconds=(100 - percent_complete) / percent_complete * diff))
def _get_time_zone():
return frappe.db.get_system_setting('time_zone') or 'Asia/Kolkata'