Merge branch 'handlerupdate' of github.com:webnotes/wnframework into handlerupdate
This commit is contained in:
commit
023f780dee
11 changed files with 150 additions and 216 deletions
|
|
@ -1,14 +1,14 @@
|
|||
/* FORMS */
|
||||
|
||||
div.form-section-break {
|
||||
div.form-section-head {
|
||||
margin: 15px 0px 3px 0px;
|
||||
}
|
||||
|
||||
div.form-section-break h3 {
|
||||
div.form-section-head h3 {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
div.form-section-break hr {
|
||||
div.form-section-head hr {
|
||||
margin: 9px 0px;
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +160,10 @@ div.time_field select{
|
|||
color: #888;
|
||||
}
|
||||
|
||||
.help ol {
|
||||
padding-left: 19px;
|
||||
}
|
||||
|
||||
.field_description_top {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,35 +265,11 @@ pscript.update_page_history = function(page_name, no_history) {
|
|||
nav_obj.open_notify('Page', page_name, arg, no_history);
|
||||
}
|
||||
|
||||
//
|
||||
// Load Script
|
||||
//
|
||||
function loadscript(src, call_back) {
|
||||
set_loading();
|
||||
var script = $a('head','script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = src;
|
||||
script.onload = function() {
|
||||
if(call_back)call_back(); hide_loading();
|
||||
}
|
||||
// IE 6 & 7
|
||||
script.onreadystatechange = function() {
|
||||
if (this.readyState == 'complete' || this.readyState == 'loaded') {
|
||||
hide_loading();
|
||||
call_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load DocBrowser
|
||||
// -------------------------------------------------------------------------------
|
||||
|
||||
var doc_browser_page;
|
||||
function loaddocbrowser(dt, label, fields) {
|
||||
//wn.require('lib/js/wn/pages/doclistview.js');
|
||||
//wn.pages.doclistview.show(dt);
|
||||
//return;
|
||||
|
||||
function loaddocbrowser(dt, label, fields) {
|
||||
wn.require('lib/js/legacy/webpage/docbrowser.js');
|
||||
dt = get_label_doctype(dt);
|
||||
if(!doc_browser_page)
|
||||
|
|
|
|||
|
|
@ -134,9 +134,6 @@ Field.prototype.get_status = function() {
|
|||
if(this.not_in_form) {
|
||||
return 'Write';
|
||||
}
|
||||
|
||||
var fn = this.df.fieldname?this.df.fieldname:this.df.label;
|
||||
this.df = get_field(this.doctype, fn, this.docname);
|
||||
|
||||
if(!this.df.permlevel) this.df.permlevel = 0;
|
||||
|
||||
|
|
@ -990,7 +987,7 @@ SelectField.prototype.make_input = function() {
|
|||
this.set_as_single = function() {
|
||||
var i = this.input;
|
||||
i.multiple = false;
|
||||
i.style.height = null; // default
|
||||
i.style.height = null;
|
||||
if(i.lab)$dh(i.lab)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ _f.Frm = function(doctype, parent) {
|
|||
var me = this;
|
||||
this.is_editable = {};
|
||||
this.opendocs = {};
|
||||
this.cur_section = {};
|
||||
this.sections = [];
|
||||
this.sections_by_label = {};
|
||||
this.section_count;
|
||||
|
|
@ -184,23 +183,6 @@ _f.Frm.prototype.setup_std_layout = function() {
|
|||
|
||||
// create fields
|
||||
this.setup_fields_std();
|
||||
|
||||
// description
|
||||
if(this.meta.description)
|
||||
this.add_description();
|
||||
}
|
||||
|
||||
// ======================================================================================
|
||||
|
||||
_f.Frm.prototype.add_description = function() {
|
||||
if(!wn.md2html) {
|
||||
wn.require('lib/js/lib/showdown.js');
|
||||
wn.md2html = new Showdown.converter();
|
||||
}
|
||||
|
||||
this.description_wrapper = $a(this.page_layout.footer.help_area, 'div',
|
||||
'well', {marginTop:'11px'},
|
||||
wn.md2html.makeHtml('#### Help\n\n' + this.meta.description));
|
||||
}
|
||||
|
||||
_f.Frm.prototype.setup_print = function() {
|
||||
|
|
@ -267,10 +249,6 @@ _f.Frm.prototype.email_doc = function() {
|
|||
_f.Frm.prototype.rename_notify = function(dt, old, name) {
|
||||
if(this.doctype != dt) return;
|
||||
|
||||
// sections
|
||||
this.cur_section[name] = this.cur_section[old];
|
||||
delete this.cur_section[old];
|
||||
|
||||
// editable
|
||||
this.is_editable[name] = this.is_editable[old];
|
||||
delete this.is_editable[old];
|
||||
|
|
@ -298,19 +276,6 @@ _f.Frm.prototype.set_heading = function() {
|
|||
}
|
||||
|
||||
|
||||
// PAGING
|
||||
// ======================================================================================
|
||||
|
||||
_f.Frm.prototype.set_section = function(sec_id) {
|
||||
if(!this.sections[sec_id] || !this.sections[sec_id].expand)
|
||||
return; // Simple type
|
||||
|
||||
if(this.sections[this.cur_section[this.docname]])
|
||||
this.sections[this.cur_section[this.docname]].collapse();
|
||||
this.sections[sec_id].expand();
|
||||
this.cur_section[this.docname] = sec_id;
|
||||
}
|
||||
|
||||
// SETUP
|
||||
// ======================================================================================
|
||||
|
||||
|
|
@ -337,7 +302,7 @@ _f.Frm.prototype.setup_footer = function() {
|
|||
var f = this.page_layout.footer;
|
||||
|
||||
// save buttom
|
||||
f.save_area = $a(this.page_layout.footer,'div','',{display:'none'});
|
||||
f.save_area = $a(this.page_layout.footer,'div','',{display:'none', marginTop:'11px'});
|
||||
f.help_area = $a(this.page_layout.footer,'div');
|
||||
|
||||
var b = $btn(f.save_area, 'Save',
|
||||
|
|
@ -371,23 +336,23 @@ _f.Frm.prototype.setup_fields_std = function() {
|
|||
var sec;
|
||||
for(var i=0;i<fl.length;i++) {
|
||||
var f=fl[i];
|
||||
|
||||
// no section breaks in embedded forms
|
||||
if(get_url_arg('embed') && (in_list(['Section Break','Column Break'], f.fieldtype))) continue;
|
||||
|
||||
|
||||
// if section break and next item
|
||||
// is a section break then ignore
|
||||
if(f.fieldtype=='Section Break' && fl[i+1] && fl[i+1].fieldtype=='Section Break') continue;
|
||||
if(f.fieldtype=='Section Break' && fl[i+1] && fl[i+1].fieldtype=='Section Break')
|
||||
continue;
|
||||
|
||||
var fn = f.fieldname?f.fieldname:f.label;
|
||||
|
||||
var fld = make_field(f, this.doctype, this.layout.cur_cell, this);
|
||||
|
||||
this.fields[this.fields.length] = fld;
|
||||
this.fields_dict[fn] = fld;
|
||||
|
||||
// Add to section break so that this section can be shown when there is an error
|
||||
if(this.meta.section_style != 'Simple')
|
||||
if(sec && ['Section Break', 'Column Break'].indexOf(f.fieldtype)==-1) {
|
||||
fld.parent_section = sec;
|
||||
sec.fields.push(fld);
|
||||
}
|
||||
|
||||
if(f.fieldtype=='Section Break' && f.options != 'Simple')
|
||||
sec = fld;
|
||||
|
|
@ -638,10 +603,7 @@ _f.Frm.prototype.refresh = function(docname) {
|
|||
// to use this
|
||||
// $(docuemnt).bind('form_refresh', function() { })
|
||||
$(document).trigger('form_refresh')
|
||||
|
||||
// tabs
|
||||
this.refresh_tabs();
|
||||
|
||||
|
||||
// fields
|
||||
this.refresh_fields();
|
||||
|
||||
|
|
@ -681,19 +643,6 @@ _f.Frm.prototype.refresh = function(docname) {
|
|||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
_f.Frm.prototype.refresh_tabs = function() {
|
||||
var me = this;
|
||||
if(me.meta.section_style=='Tray'||me.meta.section_style=='Tabbed') {
|
||||
for(var i in me.sections) {
|
||||
me.sections[i].collapse();
|
||||
}
|
||||
|
||||
me.set_section(me.cur_section[me.docname]);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
_f.Frm.prototype.refresh_footer = function() {
|
||||
var f = this.page_layout.footer;
|
||||
if(f.save_area) {
|
||||
|
|
@ -713,7 +662,14 @@ _f.Frm.prototype.refresh_fields = function() {
|
|||
var f = this.fields[i];
|
||||
f.perm = this.perm;
|
||||
f.docname = this.docname;
|
||||
if(f.refresh)f.refresh();
|
||||
|
||||
// if field is identifiable (not blank section or column break)
|
||||
// get the "customizable" parameters for this record
|
||||
var fn = f.df.fieldname || f.df.label;
|
||||
if(fn)
|
||||
f.df = get_field(this.doctype, fn, this.docname);
|
||||
if(f.refresh)
|
||||
f.refresh();
|
||||
}
|
||||
|
||||
// cleanup activities after refresh
|
||||
|
|
@ -831,9 +787,6 @@ _f.Frm.prototype.setnewdoc = function(docname) {
|
|||
this.is_editable[docname] = 1;
|
||||
if(this.meta.read_only_onload) this.is_editable[docname] = 0;
|
||||
|
||||
// Section Type
|
||||
if(this.meta.section_style=='Tray'||this.meta.section_style=='Tabbed') { this.cur_section[docname] = 0; }
|
||||
|
||||
this.opendocs[docname] = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,86 +50,122 @@ _f.ColumnBreak.prototype.make_body = function() {
|
|||
_f.ColumnBreak.prototype.refresh = function(layout) {
|
||||
if(!this.cell)return; // no perm
|
||||
|
||||
var fn = this.df.fieldname?this.df.fieldname:this.df.label;
|
||||
if(fn) {
|
||||
this.df = get_field(this.doctype, fn, this.docname);
|
||||
|
||||
// hidden
|
||||
if(this.set_hidden!=this.df.hidden) {
|
||||
if(this.df.hidden)
|
||||
this.cell.hide();
|
||||
else
|
||||
this.cell.show();
|
||||
this.set_hidden = this.df.hidden;
|
||||
}
|
||||
// hidden
|
||||
if(this.set_hidden!=this.df.hidden) {
|
||||
if(this.df.hidden)
|
||||
this.cell.hide();
|
||||
else
|
||||
this.cell.show();
|
||||
this.set_hidden = this.df.hidden;
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================================
|
||||
|
||||
_f.SectionBreak = function() {
|
||||
this.fields = [];
|
||||
this.set_input = function() { };
|
||||
this.make_row = function() {
|
||||
this.row = this.df.label ? this.frm.layout.addrow() : this.frm.layout.addsubrow();
|
||||
}
|
||||
}
|
||||
|
||||
_f.SectionBreak.prototype.make_row = function() {
|
||||
this.row = this.df.label ? this.frm.layout.addrow() : this.frm.layout.addsubrow();
|
||||
}
|
||||
|
||||
_f.SectionBreak.prototype.add_to_sections = function() {
|
||||
this.sec_id = this.frm.sections.length;
|
||||
this.frm.sections[this.sec_id] = this;
|
||||
this.frm.sections_by_label[this.df.label] = this;
|
||||
}
|
||||
|
||||
_f.cur_sec_header = null;
|
||||
_f.SectionBreak.prototype.make_body = function() {
|
||||
var me = this;
|
||||
if((!this.perm[this.df.permlevel]) || (!this.perm[this.df.permlevel][READ]) || this.df.hidden) {
|
||||
// no display
|
||||
return;
|
||||
}
|
||||
|
||||
this.make_row();
|
||||
this.wrapper = $a(this.row.main_head, 'div');
|
||||
|
||||
if(this.df.label) {
|
||||
if(!this.df.description) this.df.description = '';
|
||||
$(this.wrapper).html(repl('<div class="form-section-break">\
|
||||
<h3>%(label)s</h3>\
|
||||
<div class="help">%(description)s</div>\
|
||||
if(!this.df.description)
|
||||
this.df.description = '';
|
||||
$(this.row.main_head).html(repl('<div class="form-section-head" style="cursor: pointer">\
|
||||
<div class="head">%(label)s</h3>\
|
||||
<div class="help">%(description)s</div>\
|
||||
</div>', this.df));
|
||||
|
||||
this.$expand = $(this.row.main_head).find('.form-section-head').click(function() {
|
||||
if($(me.row.main_head).find('h3').length) {
|
||||
me.section_collapse();
|
||||
} else {
|
||||
me.section_expand();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.collapsible = true;
|
||||
} else {
|
||||
$(this.wrapper).html('<div class="form-section-break"></div>');
|
||||
// simple
|
||||
$(this.wrapper).html('<div class="form-section-head"></div>');
|
||||
}
|
||||
|
||||
// collapse section
|
||||
this.section_collapse = function() {
|
||||
$(me.row.main_head).find('.head')
|
||||
.html('<i class="icon-play"></i> \
|
||||
<a href="#" onclick="return false;">Show "' + me.df.label + '"</a>');
|
||||
$(me.row.main_body).toggle(false);
|
||||
|
||||
}
|
||||
|
||||
// expand section
|
||||
this.section_expand = function() {
|
||||
$(me.row.main_head).find('.head')
|
||||
.html('<h3><i class="icon-minus" style="margin-top: 3px"></i> '
|
||||
+ me.df.label + '</h3>');
|
||||
$(me.row.main_body).slideDown();
|
||||
}
|
||||
|
||||
// indent
|
||||
$y(this.row.body, { marginLeft:'17px' });
|
||||
}
|
||||
|
||||
_f.SectionBreak.prototype.has_data = function() {
|
||||
// return true if
|
||||
// 1. any field in the section is mandatory & not set as default
|
||||
// 2. any field in the section has data that is not default
|
||||
// 3. if table, table has rows
|
||||
|
||||
var me = this;
|
||||
for(var i in me.fields) {
|
||||
var f = me.fields[i];
|
||||
var v = f.df.get_value ? f.df.get_value() : null;
|
||||
|
||||
// value that is not default
|
||||
defaultval = f.df['default'] || sys_defaults[f.fieldname] || user_defaults[f.fieldname];
|
||||
if(v && v != defaultval) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// unfilled mandatory field
|
||||
if(!v && f.df.reqd) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// filled table
|
||||
if(f.df.fieldtype=='Table') {
|
||||
if(f.grid.get_children.length || f.df.reqd) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_f.SectionBreak.prototype.refresh = function(layout) {
|
||||
var fn = this.df.fieldname?this.df.fieldname:this.df.label;
|
||||
|
||||
if(fn)
|
||||
this.df = get_field(this.doctype, fn, this.docname);
|
||||
|
||||
// hidden
|
||||
if(this.set_hidden!=this.df.hidden) {
|
||||
if(this.df.hidden) {
|
||||
if(this.frm.meta.section_style=='Tabbed') {
|
||||
$dh(this.mytab);
|
||||
} else if(this.tray_item)
|
||||
this.tray_item.hide();
|
||||
|
||||
if(this.row)this.row.hide();
|
||||
} else {
|
||||
if(this.frm.meta.section_style=='Tabbed') {
|
||||
$di(this.mytab);
|
||||
} else if(this.tray_item)
|
||||
this.tray_item.show();
|
||||
|
||||
if(this.expanded)this.row.show();
|
||||
if(this.df.hidden) {
|
||||
if(this.row)this.row.hide();
|
||||
} else {
|
||||
if(this.collapsible) {
|
||||
if(this.has_data()) {
|
||||
this.section_expand();
|
||||
} else {
|
||||
this.section_collapse();
|
||||
}
|
||||
}
|
||||
this.set_hidden = this.df.hidden;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,8 +115,12 @@ _f.FormGrid.prototype.set_column_label = function(fieldname, label) {
|
|||
}
|
||||
}
|
||||
|
||||
_f.FormGrid.prototype.get_children = function() {
|
||||
return getchildren(this.doctype, this.field.frm.docname, this.field.df.fieldname, this.field.frm.doctype);
|
||||
}
|
||||
|
||||
_f.FormGrid.prototype.refresh = function() {
|
||||
var docset = getchildren(this.doctype, this.field.frm.docname, this.field.df.fieldname, this.field.frm.doctype);
|
||||
var docset = this.get_children();
|
||||
var data = [];
|
||||
|
||||
//alert(docset.length);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ Layout.prototype.close_borders = function() {
|
|||
|
||||
function LayoutRow(layout, parent) {
|
||||
this.layout = layout;
|
||||
this.wrapper = $a(parent,'div');
|
||||
this.wrapper = $a(parent,'div','form-layout-row');
|
||||
|
||||
// main head
|
||||
this.main_head = $a(this.wrapper, 'div');
|
||||
|
|
|
|||
|
|
@ -38,6 +38,16 @@ wn.widgets.form.sidebar = { Sidebar: function(form) {
|
|||
onclick: function() { new_doc(me.form.doctype) }
|
||||
},
|
||||
|
||||
{
|
||||
type: 'link',
|
||||
label: 'List',
|
||||
icon: 'icon-list',
|
||||
display: function() {
|
||||
return true;
|
||||
},
|
||||
onclick: function() { window.location.href="#!List2/" + me.form.doctype }
|
||||
},
|
||||
|
||||
{
|
||||
type: 'link',
|
||||
label: 'Refresh',
|
||||
|
|
@ -124,6 +134,20 @@ wn.widgets.form.sidebar = { Sidebar: function(form) {
|
|||
function() { });
|
||||
},
|
||||
display: function() { return !me.form.doc.__islocal }
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Help',
|
||||
render: function(wrapper) {
|
||||
if(!wn.md2html) {
|
||||
wn.require('lib/js/lib/showdown.js');
|
||||
wn.md2html = new Showdown.converter();
|
||||
}
|
||||
|
||||
$a(wrapper, 'div', 'help', {},
|
||||
wn.md2html.makeHtml(me.form.meta.description));
|
||||
},
|
||||
display: function() { return me.form.meta.description }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@
|
|||
// page_length (20)
|
||||
// hide_refresh (False)
|
||||
// new_doctype
|
||||
// new_doc_onload
|
||||
// new_doc_onsave
|
||||
// [function] render_row(parent, data)
|
||||
// [function] onrun
|
||||
// no_loading (no ajax indicator)
|
||||
|
|
@ -167,20 +169,20 @@ wn.ui.Listing = Class.extend({
|
|||
// new
|
||||
if(this.new_doctype) {
|
||||
this.$w.find('.btn-new').toggle(true).click(function() {
|
||||
newdoc(me.new_doctype);
|
||||
newdoc(me.new_doctype, me.new_doc_onload, true, me.new_doc_onsave);
|
||||
})
|
||||
} else {
|
||||
this.$w.find('.btn-new').toggle(false).attr('hidden', 'hidden');
|
||||
this.$w.find('.btn-new').remove();
|
||||
}
|
||||
|
||||
// hide-filter
|
||||
if(!me.show_filters) {
|
||||
this.$w.find('.btn-filter').toggle(false).attr('hidden', 'hidden');
|
||||
this.$w.find('.btn-filter').remove();
|
||||
}
|
||||
|
||||
// hide-refresh
|
||||
if(this.hide_refresh || this.no_refresh) {
|
||||
this.$w.find('.btn-refresh').toggle(false).attr('hidden', 'hidden');
|
||||
this.$w.find('.btn-refresh').remove();
|
||||
}
|
||||
|
||||
// toggle-view
|
||||
|
|
@ -189,7 +191,7 @@ wn.ui.Listing = Class.extend({
|
|||
}
|
||||
|
||||
// btn group only if more than 1 button
|
||||
if(this.$w.find('.list-toolbar a[hidden!="hidden"]').length>1) {
|
||||
if(this.$w.find('.list-toolbar a').length>1) {
|
||||
this.$w.find('.list-toolbar').addClass('btn-group')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
# DocType, DocFormat
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-05-12 11:19:11',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'yogesh@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_copy': 0,
|
||||
'allow_email': 0,
|
||||
'allow_print': 0,
|
||||
'autoname': 'DF.######',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'idx': 0,
|
||||
'issingle': 0,
|
||||
'istable': 1,
|
||||
'module': 'Core',
|
||||
'name': '__common__',
|
||||
'read_only': 0,
|
||||
'server_code_error': ' '
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'format',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 0,
|
||||
'idx': 1,
|
||||
'label': 'Format',
|
||||
'name': '__common__',
|
||||
'oldfieldname': 'format',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Print Format',
|
||||
'parent': 'DocFormat',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocType, DocFormat
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'DocFormat'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField'
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Reference in a new issue