Merge branch 'responsive' of git://github.com/webnotes/wnframework into responsive
This commit is contained in:
commit
dd484536fc
27 changed files with 159 additions and 625 deletions
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"creation": "2013-02-22 01:27:33",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-07 07:03:20",
|
||||
"modified": "2013-07-03 10:03:56",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
|
|
@ -94,6 +94,16 @@
|
|||
"search_index": 0,
|
||||
"width": "50px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
"print_width": "300px",
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"doctype": "DocField",
|
||||
|
|
@ -241,16 +251,6 @@
|
|||
"search_index": 0,
|
||||
"width": "50px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
"print_width": "300px",
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "oldfieldname",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,13 @@
|
|||
// -------------
|
||||
// Menu Display
|
||||
// -------------
|
||||
|
||||
$(cur_frm.wrapper).on("grid-row-render", function(e, grid_row) {
|
||||
if(grid_row.doc && grid_row.doc.fieldtype=="Section Break") {
|
||||
$(grid_row.row).css({"font-weight": "bold"});
|
||||
}
|
||||
})
|
||||
|
||||
cur_frm.cscript.allow_attach = function(doc, cdt, cdn) {
|
||||
if(doc.allow_attach) {
|
||||
unhide_field('max_attachments');
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class DocType:
|
|||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def on_update(self):
|
||||
def validate(self):
|
||||
self.set_as_default()
|
||||
|
||||
# clear the cache so that the new letter head is uploaded
|
||||
|
|
@ -38,6 +38,9 @@ class DocType:
|
|||
|
||||
def set_as_default(self):
|
||||
from webnotes.utils import set_default
|
||||
if not self.doc.is_default:
|
||||
if not sql("""select count(*) from `tabLetter Head` where ifnull(is_default,0)=1"""):
|
||||
self.doc.is_default = 1
|
||||
if self.doc.is_default:
|
||||
sql("update `tabLetter Head` set is_default=0 where name != %s",
|
||||
self.doc.name)
|
||||
|
|
|
|||
|
|
@ -55,9 +55,13 @@
|
|||
"lib/public/js/wn/defaults.js",
|
||||
|
||||
"lib/public/js/legacy/globals.js",
|
||||
"lib/public/js/legacy/utils/datatype.js",
|
||||
"lib/public/js/legacy/utils/datetime.js",
|
||||
"lib/public/js/legacy/utils/dom.js",
|
||||
"lib/public/js/legacy/datatype.js",
|
||||
"lib/public/js/legacy/datetime.js",
|
||||
"lib/public/js/legacy/dom.js",
|
||||
"lib/public/js/legacy/handler.js",
|
||||
"lib/public/js/legacy/printElement.js",
|
||||
"lib/public/js/legacy/loaders.js",
|
||||
|
||||
"lib/public/js/wn/ui/appframe.js",
|
||||
"lib/public/js/wn/ui/field_group.js",
|
||||
"lib/public/js/wn/ui/dialog.js",
|
||||
|
|
@ -78,11 +82,6 @@
|
|||
"lib/public/js/wn/misc/datetime.js",
|
||||
"lib/public/js/wn/misc/number_format.js",
|
||||
|
||||
"lib/public/js/legacy/utils/handler.js",
|
||||
"lib/public/js/legacy/utils/printElement.js",
|
||||
"lib/public/js/legacy/widgets/dialog.js",
|
||||
"lib/public/js/legacy/webpage/loaders.js",
|
||||
|
||||
"lib/public/js/wn/upload.js",
|
||||
"lib/public/js/wn/ui/filters.js",
|
||||
"lib/public/js/wn/ui/search.js",
|
||||
|
|
@ -105,10 +104,7 @@
|
|||
"lib/public/js/wn/views/test_runner.js",
|
||||
"lib/public/js/wn/form/formatters.js",
|
||||
|
||||
"lib/public/js/legacy/webpage/page_header.js",
|
||||
"lib/public/js/legacy/widgets/layout.js",
|
||||
"lib/public/js/legacy/widgets/export_query.js",
|
||||
"lib/public/js/legacy/wn/page_layout.js",
|
||||
|
||||
"lib/public/js/wn/ui/toolbar/selector_dialog.js",
|
||||
"lib/public/js/wn/ui/toolbar/new.js",
|
||||
|
|
@ -125,6 +121,7 @@
|
|||
|
||||
"lib/public/js/wn/form/toolbar.js",
|
||||
"lib/public/js/wn/form/layout.js",
|
||||
"lib/public/js/wn/form/dashboard.js",
|
||||
"lib/public/js/wn/form/script_manager.js",
|
||||
"lib/public/js/wn/form/control.js",
|
||||
"lib/public/js/wn/form/link_selector.js",
|
||||
|
|
|
|||
|
|
@ -64,12 +64,11 @@ a {
|
|||
.form-headline {
|
||||
margin-bottom: 10px;
|
||||
font-size: 130%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.form-dashboard {
|
||||
display: none;
|
||||
border-bottom: 1px solid #eee;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* module */
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function $c_obj(doclist, method, arg, callback, no_spinner, freeze_msg, btn) {
|
|||
|
||||
args = {
|
||||
cmd:'runserverobj',
|
||||
arg: arg,
|
||||
args: arg,
|
||||
method: method
|
||||
};
|
||||
|
||||
|
|
@ -1,94 +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.
|
||||
//
|
||||
|
||||
/* standard page header
|
||||
|
||||
+ wrapper
|
||||
+ [table]
|
||||
+ [r1c1]
|
||||
+ main_head
|
||||
+ sub_head
|
||||
+ [r1c2]
|
||||
+ close_btn
|
||||
+ toolbar_area
|
||||
+ tag_area
|
||||
+ seperator
|
||||
*/
|
||||
|
||||
var def_ph_style = {
|
||||
wrapper: {marginBottom:'16px', backgroundColor:'#EEE'}
|
||||
,main_heading: { }
|
||||
,sub_heading: { marginBottom:'8px', color:'#555', display:'none' }
|
||||
,separator: { borderTop:'1px solid #ddd' } // show this when there is no toolbar
|
||||
,toolbar_area: { padding:'3px 0px', display:'none',borderBottom:'1px solid #ddd'}
|
||||
}
|
||||
|
||||
function PageHeader(parent, main_text, sub_text) {
|
||||
|
||||
this.wrapper = $a(parent,'div','page_header');
|
||||
this.close_btn = $a(this.wrapper, 'a', 'close', {}, '×');
|
||||
this.close_btn.onclick = function() { window.history.back(); };
|
||||
|
||||
this.main_head = $a(this.wrapper, 'h1', '', def_ph_style.main_heading);
|
||||
this.sub_head = $a(this.wrapper, 'h4', '', def_ph_style.sub_heading);
|
||||
|
||||
this.separator = $a(this.wrapper, 'div', '', def_ph_style.separator);
|
||||
this.toolbar_area = $a(this.wrapper, 'div', '', def_ph_style.toolbar_area);
|
||||
this.padding_area = $a(this.wrapper, 'div', '', {padding:'3px'});
|
||||
|
||||
if(main_text) this.main_head.innerHTML = main_text;
|
||||
if(sub_text) this.sub_head.innerHTML = sub_text;
|
||||
|
||||
this.buttons = {};
|
||||
this.buttons2 = {};
|
||||
}
|
||||
|
||||
PageHeader.prototype.add_button = function(label, fn, bold, icon, green) {
|
||||
|
||||
var tb = this.toolbar_area;
|
||||
if(this.buttons[label]) return;
|
||||
|
||||
iconhtml = icon ? ('<i class="'+icon+'"></i> ') : '';
|
||||
|
||||
var $button = $('<button class="btn">'+ iconhtml + label +'</button>')
|
||||
.click(fn)
|
||||
.appendTo(tb);
|
||||
if(green) {
|
||||
$button.addClass('btn-info');
|
||||
$button.find('i').addClass('icon-white');
|
||||
}
|
||||
if(bold) $button.css('font-weight', 'bold');
|
||||
|
||||
this.buttons[label] = $button.get(0);
|
||||
$ds(this.toolbar_area);
|
||||
|
||||
return this.buttons[label];
|
||||
}
|
||||
|
||||
PageHeader.prototype.clear_toolbar = function() {
|
||||
this.toolbar_area.innerHTML = '';
|
||||
this.buttons = {};
|
||||
}
|
||||
|
||||
PageHeader.prototype.make_buttonset = function() {
|
||||
$(this.toolbar_area).buttonset();
|
||||
}
|
||||
|
|
@ -1,231 +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.
|
||||
//
|
||||
|
||||
search_fields = {};
|
||||
|
||||
// Search Selector 2.0
|
||||
// -------------------
|
||||
|
||||
function setlinkvalue(name) {
|
||||
//selector.input.set(name);// in local - this will be set onchange
|
||||
selector.input.set_input(name); // on screen
|
||||
selector.hide();
|
||||
}
|
||||
|
||||
// Link Selector
|
||||
// -------------
|
||||
|
||||
function makeselector() {
|
||||
var d = new Dialog(540,440, 'Search');
|
||||
|
||||
d.make_body([
|
||||
['HTML', 'Help'],
|
||||
['Data', 'Beginning With', 'Tip: You can use wildcard "%"'],
|
||||
['Select', 'Search By'],
|
||||
['Button', 'Search'],
|
||||
['HTML', 'Result']
|
||||
]);
|
||||
|
||||
// search with
|
||||
var inp = d.widgets['Beginning With'];
|
||||
var field_sel = d.widgets['Search By'];
|
||||
var btn = d.widgets['Search'];
|
||||
|
||||
// result
|
||||
d.sel_type = '';
|
||||
d.values_len = 0;
|
||||
d.set = function(input, type, label) {
|
||||
d.sel_type = type;
|
||||
d.input = input;
|
||||
if(d.style!='Link') {
|
||||
d.rows['Result'].innerHTML ='';
|
||||
d.values_len = 0;
|
||||
}
|
||||
d.style = 'Link';
|
||||
d.set_query_description()
|
||||
|
||||
if(!d.sel_type)d.sel_type = 'Value';
|
||||
d.set_title("Select");
|
||||
d.set_query_description('Select a "'+ d.sel_type +'" for field "'+label+'"');
|
||||
}
|
||||
d.set_search = function(dt) {
|
||||
if(d.style!='Search') {
|
||||
d.rows['Result'].innerHTML ='';
|
||||
d.values_len = 0;
|
||||
}
|
||||
d.style = 'Search';
|
||||
if(d.input) { d.input = null; sel_type = null; }
|
||||
d.sel_type = dt;
|
||||
d.set_title('Quick Search for ' + dt);
|
||||
}
|
||||
|
||||
$(inp).keydown(function(e) {
|
||||
if(e.which==13) {
|
||||
if(!btn.disabled)btn.onclick();
|
||||
}
|
||||
})
|
||||
|
||||
d.set_query_description = function(txt) {
|
||||
txt = d.input && d.input.query_description || txt;
|
||||
if(txt) {
|
||||
d.rows['Help'].innerHTML ='<div class="alert" style="margin-top:0px">' + txt + '</div>';
|
||||
} else {
|
||||
d.rows['Help'].innerHTML =''
|
||||
}
|
||||
}
|
||||
d.onshow = function() {
|
||||
if(d.set_doctype!=d.sel_type) {
|
||||
d.rows['Result'].innerHTML ='';
|
||||
d.values_len = 0;
|
||||
}
|
||||
|
||||
inp.value = '';
|
||||
if(d.input && d.get_value) {
|
||||
inp.value = d.get_value();
|
||||
}
|
||||
try{inp.focus();} catch(e){}
|
||||
|
||||
// temp function to strip labels from search fields
|
||||
var get_sf_list = function(dt) {
|
||||
var l = []; var lf = search_fields[dt];
|
||||
for(var i=0; i<lf.length; i++) l.push(lf[i][1]);
|
||||
return l;
|
||||
}
|
||||
|
||||
// set fields
|
||||
$ds(d.rows['Search By']);
|
||||
|
||||
if(search_fields[d.sel_type]) {
|
||||
empty_select(field_sel);
|
||||
add_sel_options(field_sel, get_sf_list(d.sel_type), 'ID');
|
||||
} else {
|
||||
// set default select by
|
||||
empty_select(field_sel);
|
||||
add_sel_options(field_sel, ['ID'], 'ID');
|
||||
|
||||
$c('webnotes.widgets.search.getsearchfields', {'doctype':d.sel_type}, function(r,rt) {
|
||||
search_fields[d.sel_type] = r.searchfields;
|
||||
empty_select(field_sel);
|
||||
add_sel_options(field_sel, get_sf_list(d.sel_type));
|
||||
field_sel.selectedIndex = 0;
|
||||
} );
|
||||
}
|
||||
}
|
||||
d.onhide = function() {
|
||||
//if(d.input && d.input.txt) // link, call onchange
|
||||
// d.input.txt.set_input_value()
|
||||
}
|
||||
|
||||
btn.onclick = function() {
|
||||
if(this.disabled) return;
|
||||
|
||||
this.args.is_ajax = true;
|
||||
d.set_doctype = d.sel_type;
|
||||
var q = '';
|
||||
args = {};
|
||||
|
||||
if(d.input && d.input.get_query) {
|
||||
var doc = {};
|
||||
args.is_simple = 1;
|
||||
if(cur_frm) doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
var q = d.input.get_query(doc, d.input.doctype, d.input.docname);
|
||||
|
||||
if(!q) { return ''; }
|
||||
|
||||
if (typeof(q)==="string") {
|
||||
args.query = q;
|
||||
} else if($.isPlainObject(q)) {
|
||||
if(q.filters) {
|
||||
$.each(q.filters, function(key, value) {
|
||||
q.filters[key] = value===undefined ? null : value;
|
||||
});
|
||||
}
|
||||
|
||||
$.extend(args, q);
|
||||
}
|
||||
}
|
||||
|
||||
// for field type, return field name
|
||||
var get_sf_fieldname = function(v) {
|
||||
var lf = search_fields[d.sel_type];
|
||||
|
||||
// still loading options
|
||||
if(!lf)
|
||||
return 'name'
|
||||
|
||||
for(var i=0; i<lf.length; i++) if(lf[i][1]==v) return lf[i][0];
|
||||
}
|
||||
|
||||
// build args
|
||||
$.extend(args, {
|
||||
'txt':strip(inp.value),
|
||||
'doctype':d.sel_type,
|
||||
'searchfield':get_sf_fieldname(sel_val(field_sel))
|
||||
});
|
||||
|
||||
// run the query
|
||||
wn.call({
|
||||
method: "webnotes.widgets.search.search_widget",
|
||||
args: args,
|
||||
callback: function(r) {
|
||||
if(r.coltypes)r.coltypes[0]='Link'; // first column must always be selectable even if it is not a link
|
||||
d.values_len = r.values.length;
|
||||
d.set_result(r);
|
||||
},
|
||||
btn: btn
|
||||
});
|
||||
}
|
||||
|
||||
d.set_result = function(r) {
|
||||
d.rows['Result'].innerHTML = '';
|
||||
var c = $a(d.rows['Result'],'div','comment',{paddingBottom:'4px',marginBottom:'4px',borderBottom:'1px solid #CCC', marginLeft:'4px'});
|
||||
if(r.values.length==50)
|
||||
c.innerHTML = 'Showing max 50 results. Use filters to narrow down your search';
|
||||
else
|
||||
c.innerHTML = 'Showing '+r.values.length+' resuts.';
|
||||
|
||||
var w = $a(d.rows['Result'],'div','',{height:'240px',overflow:'auto',margin:'4px'});
|
||||
for(var i=0; i<r.values.length; i++) {
|
||||
var div = $a(w,'div','',
|
||||
{marginBottom:'4px',paddingBottom:'4px',borderBottom:'1px dashed #CCC'});
|
||||
|
||||
// link
|
||||
var l = $a($a(div,'div'),'span','link_type');
|
||||
l.innerHTML = r.values[i][0];
|
||||
l.link_name = r.values[i][0];
|
||||
l.dt = r.coloptions && r.coloptions[0];
|
||||
|
||||
if(d.input)
|
||||
l.onclick = function() { setlinkvalue(this.link_name); }
|
||||
else
|
||||
l.onclick = function() { loaddoc(this.dt, this.link_name); d.hide(); }
|
||||
|
||||
// support
|
||||
var cl = []
|
||||
for(var j=1; j<r.values[i].length; j++) cl.push(r.values[i][j]);
|
||||
var c = $a(div,'div','comment',{marginTop:'2px'}); c.innerHTML = cl.join(', ');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
selector = d;
|
||||
}
|
||||
|
|
@ -1,145 +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.
|
||||
//
|
||||
|
||||
//
|
||||
// Dialog - old style dialog - deprecated
|
||||
//
|
||||
|
||||
|
||||
var Dialog = wn.ui.Dialog.extend({
|
||||
init: function(w, h, title, content) {
|
||||
this._super({
|
||||
width: w,
|
||||
title: title
|
||||
});
|
||||
|
||||
if(content)this.make_body(content);
|
||||
|
||||
this.onshow = '';
|
||||
this.oncancel = '';
|
||||
this.no_cancel_flag = 0; // allow to cancel
|
||||
this.display = false;
|
||||
this.first_button = false;
|
||||
},
|
||||
make_body: function(content) {
|
||||
this.rows = {}; this.widgets = {};
|
||||
for(var i in content) this.make_row(content[i]);
|
||||
},
|
||||
clear_inputs: function(d) {
|
||||
for(var wid in this.widgets) {
|
||||
var w = this.widgets[wid];
|
||||
|
||||
var tn = w.tagName ? w.tagName.toLowerCase() : '';
|
||||
if(tn=='input' || tn=='textarea') {
|
||||
w.value = '';
|
||||
} else if(tn=='select') {
|
||||
sel_val(w.options[0].value);
|
||||
} else if(w.txt) {
|
||||
w.txt.value = '';
|
||||
} else if(w.input) {
|
||||
w.input.value = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
make_row: function(d) {
|
||||
var me = this;
|
||||
|
||||
this.rows[d[1]] = $a(this.body, 'div', 'dialog_row');
|
||||
var row = this.rows[d[1]];
|
||||
|
||||
if(d[0]!='HTML') {
|
||||
var t = make_table(row,1,2,'100%',['30%','70%']);
|
||||
row.tab = t;
|
||||
var c1 = $td(t,0,0);
|
||||
var c2 = $td(t,0,1);
|
||||
if(d[0]!='Check' && d[0]!='Button')
|
||||
$(c1).text(d[1]);
|
||||
}
|
||||
|
||||
if(d[0]=='HTML') {
|
||||
if(d[2])row.innerHTML = d[2];
|
||||
this.widgets[d[1]]=row;
|
||||
}
|
||||
else if(d[0]=='Check') {
|
||||
var i = $a_input(c2, 'checkbox','',{width:'20px'});
|
||||
c1.innerHTML = d[1];
|
||||
this.widgets[d[1]] = i;
|
||||
}
|
||||
else if(d[0]=='Data') {
|
||||
c1.innerHTML = d[1];
|
||||
c2.style.overflow = 'auto';
|
||||
this.widgets[d[1]] = $a_input(c2, 'text');
|
||||
if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
|
||||
}
|
||||
else if(d[0]=='Link') {
|
||||
c1.innerHTML = d[1];
|
||||
var f = make_field({fieldtype:'Link', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
|
||||
f.not_in_form = 1;
|
||||
f.dialog = this;
|
||||
f.refresh();
|
||||
this.widgets[d[1]] = f.input;
|
||||
}
|
||||
else if(d[0]=='Date') {
|
||||
c1.innerHTML = d[1];
|
||||
var f = make_field({fieldtype:'Date', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
|
||||
f.not_in_form = 1;
|
||||
f.refresh();
|
||||
f.dialog = this;
|
||||
this.widgets[d[1]] = f.input;
|
||||
}
|
||||
else if(d[0]=='Password') {
|
||||
c1.innerHTML = d[1];
|
||||
c2.style.overflow = 'auto';
|
||||
this.widgets[d[1]] = $a_input(c2, 'password');
|
||||
if(d[3])$a(c2, 'div', 'field_description').innerHTML = d[3];
|
||||
|
||||
}
|
||||
else if(d[0]=='Select') {
|
||||
c1.innerHTML = d[1];
|
||||
this.widgets[d[1]] = $a(c2, 'select', '', {width:'160px'})
|
||||
if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
|
||||
if(d[3])add_sel_options(this.widgets[d[1]], d[3], d[3][0]);
|
||||
}
|
||||
else if(d[0]=='Text') {
|
||||
c1.innerHTML = d[1];
|
||||
c2.style.overflow = 'auto';
|
||||
this.widgets[d[1]] = $a(c2, 'textarea');
|
||||
if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
|
||||
}
|
||||
else if(d[0]=='Button') {
|
||||
c2.style.height = '32px';
|
||||
var b = $btn(c2, d[1], function(btn) {
|
||||
if(btn._onclick) btn._onclick(me) }, null, null, 1);
|
||||
b.dialog = me;
|
||||
if(!this.first_button) {
|
||||
$(b).addClass('btn-info');
|
||||
this.first_button = true;
|
||||
}
|
||||
if(d[2]) {
|
||||
b._onclick = d[2];
|
||||
}
|
||||
this.widgets[d[1]] = b;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -1,62 +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.
|
||||
//
|
||||
|
||||
var export_dialog;
|
||||
function export_query(query, callback) {
|
||||
|
||||
if(!export_dialog) {
|
||||
var d = new Dialog(400, 300, "Export...");
|
||||
d.make_body([
|
||||
['Data', 'Max rows', 'Blank to export all rows'],
|
||||
['Button', 'Go'],
|
||||
]);
|
||||
d.widgets['Go'].onclick = function() {
|
||||
export_dialog.hide();
|
||||
n = export_dialog.widgets['Max rows'].value;
|
||||
if(cint(n))
|
||||
export_dialog.query += ' LIMIT 0,' + cint(n);
|
||||
callback(export_dialog.query);
|
||||
}
|
||||
d.onshow = function() {
|
||||
this.widgets['Max rows'].value = '500';
|
||||
}
|
||||
export_dialog = d;
|
||||
}
|
||||
export_dialog.query = query;
|
||||
export_dialog.show();
|
||||
}
|
||||
|
||||
function export_csv(q, report_name, sc_id, is_simple, filter_values, colnames) {
|
||||
var args = {}
|
||||
args.cmd = 'webnotes.widgets.query_builder.runquery_csv';
|
||||
if(is_simple)
|
||||
args.simple_query = q;
|
||||
else
|
||||
args.query = q;
|
||||
|
||||
args.sc_id = sc_id ? sc_id : '';
|
||||
args.filter_values = filter_values ? filter_values: '';
|
||||
if(colnames)
|
||||
args.colnames = colnames.join(',');
|
||||
args.report_name = report_name ? report_name : '';
|
||||
open_url_post(wn.request.url, args);
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ _f.Frm.prototype.set_value = function(field, value) {
|
|||
_f.Frm.prototype.call = function(opts) {
|
||||
var me = this;
|
||||
if(!opts.doc) {
|
||||
if(opts.method.indexOf(".")==-1)
|
||||
if(opts.method.indexOf(".")===-1)
|
||||
opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method;
|
||||
opts.original_callback = opts.callback;
|
||||
opts.callback = function(r) {
|
||||
|
|
|
|||
|
|
@ -190,10 +190,6 @@ _f.Frm.prototype.setup_std_layout = function() {
|
|||
this.body_header = $a(this.main, 'div');
|
||||
this.body = $a(this.main, 'div');
|
||||
|
||||
if(this.heading) {
|
||||
this.page_head = new PageHeader(this.head, this);
|
||||
}
|
||||
|
||||
// only tray
|
||||
this.meta.section_style='Simple'; // always simple!
|
||||
|
||||
|
|
@ -203,6 +199,10 @@ _f.Frm.prototype.setup_std_layout = function() {
|
|||
doctype: this.doctype,
|
||||
frm: this,
|
||||
})
|
||||
|
||||
this.dashboard = new wn.ui.form.Dashboard({
|
||||
frm: this,
|
||||
})
|
||||
|
||||
// state
|
||||
this.states = new wn.ui.form.States({
|
||||
|
|
@ -535,7 +535,6 @@ _f.Frm.prototype.refresh_dependency = function() {
|
|||
|
||||
if(!has_dep)return;
|
||||
|
||||
|
||||
// show / hide based on values
|
||||
for(var i=me.fields.length-1;i>=0;i--) {
|
||||
var f = me.fields[i];
|
||||
|
|
|
|||
|
|
@ -68,59 +68,46 @@ $.extend(_p, {
|
|||
},
|
||||
|
||||
make_dialog: function() {
|
||||
// Prepare Dialog Box Layout
|
||||
var d = new Dialog(
|
||||
360, // w
|
||||
140, // h
|
||||
'Print Formats', // title
|
||||
[ // content
|
||||
['HTML', 'Select'],
|
||||
['Check', 'No Letterhead'],
|
||||
['HTML', 'Buttons']
|
||||
]);
|
||||
//d.widgets['No Letterhead'].checked = 1;
|
||||
// Prepare Dialog Box Layout
|
||||
var dialog = new wn.ui.Dialog({
|
||||
title: "Print Formats",
|
||||
fields: [
|
||||
{fieldtype:"Select", label:"Print Format", fieldname:"print_format", reqd:1},
|
||||
{fieldtype:"Check", label:"No Letter Head", fieldname:"no_letterhead"},
|
||||
{fieldtype:"HTML", options: '<p style="text-align: right;">\
|
||||
<button class="btn btn-primary btn-print">Print</button>\
|
||||
<button class="btn btn-default btn-preview">Preview</button>\
|
||||
</p>'},
|
||||
]
|
||||
})
|
||||
|
||||
// Print Button
|
||||
$(d.widgets.Buttons).css({"height": "60px"})
|
||||
$btn(d.widgets.Buttons, 'Print', function() {
|
||||
_p.build(
|
||||
sel_val(cur_frm.print_sel), // fmtname
|
||||
_p.go, // onload
|
||||
d.widgets['No Letterhead'].checked // no_letterhead
|
||||
);
|
||||
},
|
||||
{
|
||||
cssFloat: 'right',
|
||||
marginBottom: '16px',
|
||||
marginLeft: '7px',
|
||||
}, 'green');
|
||||
dialog.$wrapper.find(".btn-print").click(function() {
|
||||
var args = dialog.get_values();
|
||||
_p.build(
|
||||
args.print_format, // fmtname
|
||||
_p.go, // onload
|
||||
args.no_letterhead // no_letterhead
|
||||
);
|
||||
});
|
||||
|
||||
dialog.$wrapper.find(".btn-preview").click(function() {
|
||||
var args = dialog.get_values();
|
||||
_p.build(
|
||||
args.print_format, // fmtname
|
||||
_p.preview, // onload
|
||||
args.no_letterhead // no_letterhead
|
||||
);
|
||||
});
|
||||
|
||||
// Print Preview
|
||||
$btn(d.widgets.Buttons, 'Preview', function() {
|
||||
_p.build(
|
||||
sel_val(cur_frm.print_sel), // fmtname
|
||||
_p.preview, // onload
|
||||
d.widgets['No Letterhead'].checked // no_letterhead
|
||||
);
|
||||
},
|
||||
{
|
||||
cssFloat: 'right',
|
||||
marginBottom: '16px'
|
||||
}, '');
|
||||
|
||||
// Delete previous print format select list and Reload print format list from current form
|
||||
d.onshow = function() {
|
||||
var c = _p.dialog.widgets['Select'];
|
||||
if(c.cur_sel && c.cur_sel.parentNode == c) {
|
||||
c.removeChild(c.cur_sel);
|
||||
}
|
||||
c.appendChild(cur_frm.print_sel);
|
||||
c.cur_sel = cur_frm.print_sel;
|
||||
dialog.onshow = function() {
|
||||
var $print = dialog.fields_dict.print_format.$input;
|
||||
$print.add_options(cur_frm.print_formats);
|
||||
|
||||
if(cur_frm.$print_view_select && cur_frm.$print_view_select.val())
|
||||
c.cur_sel.value= cur_frm.$print_view_select.val();
|
||||
$print.val(cur_frm.$print_view_select.val());
|
||||
}
|
||||
|
||||
_p.dialog = d;
|
||||
|
||||
_p.dialog = dialog;
|
||||
},
|
||||
|
||||
// Define formats dict
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ wn.ui.form.Control = Class.extend({
|
|||
undefined;
|
||||
},
|
||||
set_model_value: function(value) {
|
||||
if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname, value)) {
|
||||
if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname,
|
||||
value, this.df.fieldtype)) {
|
||||
this.frm && this.frm.dirty();
|
||||
this.last_value = value;
|
||||
}
|
||||
|
|
|
|||
55
public/js/wn/form/dashboard.js
Normal file
55
public/js/wn/form/dashboard.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
wn.ui.form.Dashboard = Class.extend({
|
||||
init: function(opts) {
|
||||
$.extend(this, opts);
|
||||
this.wrapper = $('<div class="row form-dashboard">')
|
||||
.prependTo(this.frm.layout.wrapper);
|
||||
|
||||
},
|
||||
reset: function(doc) {
|
||||
this.wrapper.empty().toggle(doc.__islocal ? false : true);
|
||||
this.headline = null;
|
||||
},
|
||||
set_headline: function(html) {
|
||||
if(!this.headline)
|
||||
this.headline =
|
||||
$('<div class="form-headline col col-lg-12">').prependTo(this.wrapper);
|
||||
this.headline.html(html);
|
||||
},
|
||||
set_headline_alert: function(text, alert_class, icon) {
|
||||
this.set_headline(repl('<div class="alert %(alert_class)s">%(icon)s%(text)s</div>', {
|
||||
"alert_class": alert_class || "",
|
||||
"icon": icon ? '<i class="'+icon+'" /> ' : "",
|
||||
"text": text
|
||||
}));
|
||||
},
|
||||
add_doctype_badge: function(doctype, fieldname) {
|
||||
if(wn.model.can_read(doctype)) {
|
||||
this.add_badge(wn._(doctype), function() {
|
||||
wn.route_options = {};
|
||||
wn.route_options[fieldname] = cur_frm.doc.name;
|
||||
wn.set_route("List", doctype);
|
||||
}).attr("data-doctype", doctype);
|
||||
}
|
||||
},
|
||||
add_badge: function(label, onclick) {
|
||||
var badge = $(repl('<div class="col col-lg-4">\
|
||||
<div class="alert alert-badge">\
|
||||
<a class="badge-link">%(label)s</a>\
|
||||
<span class="badge pull-right">-</span>\
|
||||
</div></div>', {label:label}))
|
||||
.appendTo(this.wrapper)
|
||||
|
||||
badge.find(".badge-link").click(onclick);
|
||||
|
||||
return badge.find(".alert-badge");
|
||||
},
|
||||
set_badge_count: function(data) {
|
||||
var me = this;
|
||||
$.each(data, function(doctype, count) {
|
||||
$(me.wrapper)
|
||||
.find(".alert-badge[data-doctype='"+doctype+"'] .badge")
|
||||
.html(cint(count));
|
||||
});
|
||||
},
|
||||
|
||||
})
|
||||
|
|
@ -273,6 +273,8 @@ wn.ui.form.GridRow = Class.extend({
|
|||
$col.css({"text-align": "right"})
|
||||
}
|
||||
});
|
||||
|
||||
$(this.frm.wrapper).trigger("grid-row-render", [this]);
|
||||
},
|
||||
toggle_view: function(show, callback) {
|
||||
this.doc = locals[this.doc.doctype][this.doc.name];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ wn.ui.form.Layout = Class.extend({
|
|||
},
|
||||
make: function() {
|
||||
this.wrapper = $('<div class="form-layout">').appendTo(this.parent);
|
||||
this.dashboard = $('<div class="row form-dashboard">').appendTo(this.wrapper);
|
||||
this.fields = wn.meta.get_docfields(this.frm.doctype);
|
||||
this.setup_tabbing();
|
||||
},
|
||||
|
|
@ -78,12 +77,24 @@ wn.ui.form.Layout = Class.extend({
|
|||
if(df) {
|
||||
if(df.label) {
|
||||
this.labelled_section_count++;
|
||||
$('<h3 class="col col-lg-12">' + this.labelled_section_count
|
||||
+ ". " + df.label + "</h3>")
|
||||
.css({"font-weight": "bold", "margin-bottom": "15px"})
|
||||
$('<h3 class="col col-lg-12">'
|
||||
+ (df.options ? (' <i class="text-muted '+df.options+'"></i> ') : "")
|
||||
+ this.labelled_section_count + ". "
|
||||
+ df.label
|
||||
+ "</h3>")
|
||||
.css({
|
||||
"margin-bottom": "15px",
|
||||
"font-weight": "bold",
|
||||
// "color": "white",
|
||||
// "background-color": "#16a085",
|
||||
// "padding": "7px"
|
||||
})
|
||||
.appendTo(this.section);
|
||||
if(this.frm.sections.length > 1)
|
||||
this.section.css({"margin-top": "15px", "border-top": "1px solid #eee"});
|
||||
this.section.css({
|
||||
"margin-top": "15px",
|
||||
"border-top": "1px solid #ddd"
|
||||
});
|
||||
}
|
||||
if(df.description) {
|
||||
$('<div class="col col-lg-12 small text-muted">' + df.description + '</div>').appendTo(this.section);
|
||||
|
|
@ -188,9 +199,9 @@ wn.ui.form.Layout = Class.extend({
|
|||
clear_dashboard: function() {
|
||||
this.dashboard.empty();
|
||||
},
|
||||
add_doctype_badge: function(label, doctype, fieldname) {
|
||||
add_doctype_badge: function(doctype, fieldname) {
|
||||
if(wn.model.can_read(doctype)) {
|
||||
this.add_badge(label, function() {
|
||||
this.add_badge(wn._(doctype), function() {
|
||||
wn.route_options = {};
|
||||
wn.route_options[fieldname] = cur_frm.doc.name;
|
||||
wn.set_route("List", doctype);
|
||||
|
|
|
|||
|
|
@ -193,13 +193,17 @@ $.extend(wn.model, {
|
|||
}
|
||||
},
|
||||
|
||||
set_value: function(doctype, name, fieldname, value) {
|
||||
set_value: function(doctype, name, fieldname, value, fieldtype) {
|
||||
/* help: Set a value locally (if changed) and execute triggers */
|
||||
var doc = locals[doctype] && locals[doctype][name] || null;
|
||||
if(doc && doc[fieldname] !== value) {
|
||||
doc[fieldname] = value;
|
||||
wn.model.trigger(fieldname, value, doc);
|
||||
return true;
|
||||
} else {
|
||||
// execute link triggers (want to reselect to execute triggers)
|
||||
if(fieldtype=="Link")
|
||||
wn.model.trigger(fieldname, value, doc);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ wn.ui.FieldGroup = Class.extend({
|
|||
|
||||
// first button primary ?
|
||||
if(df.fieldtype=='Button' && !this.first_button) {
|
||||
$(f.input).addClass('btn-info');
|
||||
$(f.input).removeClass("btn-default").addClass('btn-info');
|
||||
this.first_button = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ wn.views.CommunicationList = Class.extend({
|
|||
.empty()
|
||||
.css({"margin":"10px 0px"});
|
||||
|
||||
this.wrapper = $("<div><h4>"+wn._("Communication History")+"</h4>\
|
||||
this.wrapper = $("<div>\
|
||||
<div style='margin-bottom: 8px;'>\
|
||||
<button class='btn btn-default' \
|
||||
onclick='cur_frm.communication_view.add_reply()'>\
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ wn.views.DocListView = wn.ui.Listing.extend({
|
|||
},
|
||||
callback: function() {
|
||||
me.set_working(false);
|
||||
me.dirty = true;
|
||||
me.refresh();
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ def runserverobj():
|
|||
|
||||
wrapper = None
|
||||
method = webnotes.form_dict.get('method')
|
||||
arg = webnotes.form_dict.get('arg')
|
||||
arg = webnotes.form_dict.get('args')
|
||||
dt = webnotes.form_dict.get('doctype')
|
||||
dn = webnotes.form_dict.get('docname')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue