@@ -26,4 +26,29 @@ div.list_filter { | |||
div.list_filter input, div.list_filter select { | |||
width: 130px; | |||
margin-right: 7px; | |||
} | |||
span.bar-outer { | |||
display: inline-block; | |||
margin: 0px 7px; | |||
margin-top: 3px; | |||
background-color: #fff; | |||
border: 1px solid #aaa; | |||
height: 10px; | |||
} | |||
span.bar-inner { | |||
display: inline-block; | |||
background-color: #bdf; | |||
height: 100%; | |||
margin-bottom: 2px; | |||
} | |||
span.bar-complete { | |||
background-color: green; | |||
} | |||
div.list-row { | |||
border-bottom: 1px solid #eee; | |||
} | |||
div.list-row:hover { | |||
background-color: #eef | |||
} |
@@ -21,6 +21,7 @@ | |||
// | |||
wn.provide('wn.pages.doclistview'); | |||
wn.provide('wn.doclistviews'); | |||
wn.pages.doclistview.pages = {}; | |||
wn.pages.doclistview.show = function(doctype) { | |||
@@ -45,6 +46,7 @@ wn.pages.DocListView = Class.extend({ | |||
this.load_doctype(); | |||
}, | |||
make: function() { | |||
var me = this; | |||
$(this.wrapper).html('<div class="layout-wrapper layout-wrapper-background">\ | |||
<div class="layout-main-section">\ | |||
<a class="close" onclick="window.history.back();">×</a>\ | |||
@@ -57,18 +59,32 @@ wn.pages.DocListView = Class.extend({ | |||
</div>\ | |||
<div class="layout-side-section">\ | |||
</div>\ | |||
<div style="clear: both"></div>\ | |||
</div>'); | |||
// filter button | |||
$(this.wrapper).find('.run-btn').click(function() { | |||
me.list.run(); | |||
}); | |||
$(this.wrapper).find('h1').html(this.label); | |||
}, | |||
load_doctype: function() { | |||
var me = this; | |||
wn.call({ | |||
method: 'webnotes.widgets.form.load.getdoctype', | |||
args: {doctype:this.doctype}, | |||
args: {doctype: me.doctype}, | |||
callback: function() { | |||
if(locals.DocType[me.doctype].__listjs) { | |||
eval(locals.DocType[me.doctype].__listjs); | |||
me.listview = wn.doclistviews[me.doctype]; | |||
} else { | |||
me.listview = {} | |||
} | |||
if(!me.listview.fields) | |||
me.listview.fields = ['name', 'modified', 'owner']; | |||
if(!me.listview.render) | |||
me.listview.render = me.default_render; | |||
me.make_filters(); | |||
me.make_list(); | |||
} | |||
@@ -85,16 +101,27 @@ wn.pages.DocListView = Class.extend({ | |||
args: { | |||
doctype: this.doctype, | |||
subject: locals.DocType[this.doctype].subject, | |||
fields: JSON.stringify(me.listview.fields), | |||
}, | |||
get_args: function() { | |||
return {filters: JSON.stringify(me.filter_list.get_filters())} | |||
}, | |||
render_row: function(row, data) { | |||
row.innerHTML = data; | |||
data.fullname = wn.user_info(data.owner).fullname; | |||
data.avatar = wn.user_info(data.owner).image; | |||
data.when = dateutil.comment_when(data.modified); | |||
data.doctype = me.doctype; | |||
me.listview.render(row, data, me); | |||
}, | |||
hide_refresh: true | |||
}); | |||
this.list.run(); | |||
}, | |||
default_render: function(row, data) { | |||
$(row).html(repl('<span class="avatar-small"><img src="%(avatar)s" /></span>\ | |||
<a href="#!Form/%(doctype)s/%(name)s">%(name)s</span>\ | |||
<span style="float:right; font-size: 11px; color: #888">%(when)s</span>', data)) | |||
.addClass('list-row'); | |||
} | |||
}); | |||
@@ -1,133 +0,0 @@ | |||
# DocType, Module Def Item | |||
[ | |||
# These values are common in all dictionaries | |||
{ | |||
'creation': '2011-07-22 15:59:00', | |||
'docstatus': 0, | |||
'modified': '2011-07-22 15:59:00', | |||
'modified_by': 'Administrator', | |||
'owner': 'Administrator' | |||
}, | |||
# These values are common for all DocType | |||
{ | |||
'autoname': 'MDI.#####', | |||
'colour': 'White:FFF', | |||
'doctype': 'DocType', | |||
'istable': 1, | |||
'module': 'Core', | |||
'name': '__common__', | |||
'section_style': 'Simple', | |||
'server_code_error': ' ', | |||
'show_in_menu': 0, | |||
'version': 15 | |||
}, | |||
# These values are common for all DocField | |||
{ | |||
'doctype': 'DocField', | |||
'name': '__common__', | |||
'parent': 'Module Def Item', | |||
'parentfield': 'fields', | |||
'parenttype': 'DocType', | |||
'permlevel': 0 | |||
}, | |||
# DocType, Module Def Item | |||
{ | |||
'doctype': 'DocType', | |||
'name': 'Module Def Item' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'doc_type', | |||
'fieldtype': 'Select', | |||
'idx': 1, | |||
'label': 'Doc Type', | |||
'oldfieldname': 'doc_type', | |||
'oldfieldtype': 'Select', | |||
'options': 'Forms\nPages\nReports\nSeparator\nMore Reports\nSetup Forms\nSetup Pages\nSingle DocType' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'doc_name', | |||
'fieldtype': 'Data', | |||
'idx': 2, | |||
'label': 'Doc Name', | |||
'oldfieldname': 'doc_name', | |||
'oldfieldtype': 'Data' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'display_name', | |||
'fieldtype': 'Data', | |||
'idx': 3, | |||
'label': 'Display Name', | |||
'oldfieldname': 'display_name', | |||
'oldfieldtype': 'Data' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'icon', | |||
'fieldtype': 'Select', | |||
'idx': 4, | |||
'label': 'Icon', | |||
'oldfieldname': 'icon', | |||
'oldfieldtype': 'Select', | |||
'options': '\naccept.gif\nadd.gif\napplication.gif\narrow_down.gif\narrow_left.gif\narrow_right.gif\narrow_up.gif\ncalculator.gif\ncalendar.gif\ncancel.gif\nchart_bar.gif\nclose.gif\ncomments.gif\ndisk.gif\ndown-arrow.gif\nemail.gif\nerror.gif\nfolder.gif\ngroup.gif\nhelp.gif\nicon-recommend.gif\nlightbulb.gif\nmagnifier.gif\nminus.gif\nnote.gif\npage.gif\npage_add.gif\npage_copy.gif\npage_excel.gif\npage_refresh.gif\npaperclip.gif\nplus.gif\nprinter.gif\nresultset_first.gif\nresultset_last.gif\nresultset_next.gif\nresultset_previous.gif\nsort_asc.gif\nsort_desc.gif\nstar.gif\ntable.gif\ntable_row_delete.gif\ntable_row_insert.gif\nuser.gif\nwrench.gif' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'description', | |||
'fieldtype': 'Text', | |||
'idx': 5, | |||
'label': 'Description', | |||
'oldfieldname': 'description', | |||
'oldfieldtype': 'Text', | |||
'width': '300px' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'fields', | |||
'fieldtype': 'Text', | |||
'idx': 6, | |||
'label': 'Fields', | |||
'oldfieldname': 'fields', | |||
'oldfieldtype': 'Text' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'click_function', | |||
'fieldtype': 'Data', | |||
'idx': 7, | |||
'label': 'Click Function', | |||
'oldfieldname': 'click_function', | |||
'oldfieldtype': 'Data' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'hide', | |||
'fieldtype': 'Check', | |||
'idx': 8, | |||
'label': 'Hide', | |||
'oldfieldname': 'hide', | |||
'oldfieldtype': 'Check' | |||
} | |||
] |
@@ -1,54 +0,0 @@ | |||
# DocType, Module Def Role | |||
[ | |||
# These values are common in all dictionaries | |||
{ | |||
'creation': '2011-07-22 15:59:00', | |||
'docstatus': 0, | |||
'modified': '2011-07-22 15:59:00', | |||
'modified_by': 'Administrator', | |||
'owner': 'Administrator' | |||
}, | |||
# These values are common for all DocType | |||
{ | |||
'autoname': 'MDR.#####', | |||
'colour': 'White:FFF', | |||
'doctype': 'DocType', | |||
'istable': 1, | |||
'module': 'Core', | |||
'name': '__common__', | |||
'section_style': 'Simple', | |||
'server_code_error': ' ', | |||
'show_in_menu': 0, | |||
'version': 1 | |||
}, | |||
# These values are common for all DocField | |||
{ | |||
'doctype': 'DocField', | |||
'fieldname': 'role', | |||
'fieldtype': 'Link', | |||
'idx': 1, | |||
'label': 'Role', | |||
'name': '__common__', | |||
'oldfieldname': 'role', | |||
'oldfieldtype': 'Link', | |||
'options': 'Role', | |||
'parent': 'Module Def Role', | |||
'parentfield': 'fields', | |||
'parenttype': 'DocType', | |||
'permlevel': 0 | |||
}, | |||
# DocType, Module Def Role | |||
{ | |||
'doctype': 'DocType', | |||
'name': 'Module Def Role' | |||
}, | |||
# DocField | |||
{ | |||
'doctype': 'DocField' | |||
} | |||
] |
@@ -329,6 +329,29 @@ class _DocType: | |||
if d.doctype=='DocField': | |||
d.idx = docfields.index(d.name) + 1 | |||
def _add_code(self, doc): | |||
"""add js, css code""" | |||
import os | |||
from webnotes.defs import modules_path | |||
from webnotes.modules import scrub | |||
path = os.path.join(modules_path, scrub(doc.module), 'doctype', scrub(doc.name)) | |||
fpath = os.path.join(path, scrub(doc.name) + '.js') | |||
if os.path.exists(fpath): | |||
with open(fpath, 'r') as f: | |||
doc.fields['__js'] = f.read() | |||
fpath = os.path.join(path, scrub(doc.name) + '.css') | |||
if os.path.exists(fpath): | |||
with open(fpath, 'r') as f: | |||
doc.fields['__css'] = f.read() | |||
fpath = os.path.join(path, 'listview.js') | |||
if os.path.exists(fpath): | |||
with open(fpath, 'r') as f: | |||
doc.fields['__listjs'] = f.read() | |||
def make_doclist(self): | |||
""" | |||
@@ -369,13 +392,7 @@ class _DocType: | |||
from webnotes.model.code import get_custom_script | |||
custom = get_custom_script(doc.name, 'Client') or '' | |||
doc.fields['__js'] = \ | |||
Module(doc.module).get_doc_file('doctype', doc.name, '.js').read() \ | |||
+ '\n' + custom | |||
doc.fields['__css'] = \ | |||
Module(doc.module).get_doc_file('doctype', doc.name, '.css').read() | |||
self._add_code(doc) | |||
self._load_select_options(doclist) | |||
self._clear_code(doclist) | |||
@@ -35,7 +35,30 @@ def get(arg=None): | |||
data = webnotes.form_dict | |||
filters = json.loads(data['filters']) | |||
fields = json.loads(data['fields']) | |||
tables = ['`tab' + data['doctype'] + '`'] | |||
conditions = [tables[0] + '.docstatus < 2'] | |||
joined = [tables[0]] | |||
# make conditions from filters | |||
for f in filters: | |||
tname = ('`tab' + f[0] + '`') | |||
if not tname in tables: | |||
tables.append(tname) | |||
conditions.append(tname + '.' + f[1] + " " + f[2] + " '" + f[3].replace("'", "\'") + "'") | |||
if not tname in joined: | |||
conditions.append(tname + '.parent = ' + tables[0] + '.name') | |||
joined.append(tname) | |||
data['tables'] = ', '.join(tables) | |||
data['conditions'] = ' and '.join(conditions) | |||
data['fields'] = ', '.join(fields) | |||
if not data.get('order_by'): | |||
data['order_by'] = tables[0] + '.modified desc' | |||
query = """select %(fields)s from %(tables)s where %(conditions)s | |||
limit %(limit_start)s, %(limit_page_length)s""" | |||
order by %(order_by)s | |||
limit %(limit_start)s, %(limit_page_length)s""" % data | |||
return webnotes.conn.sql(query, as_dict=1, debug=1) |