diff --git a/core/doctype/doctype/doctype.py b/core/doctype/doctype/doctype.py
index c6dbb1e0c4..617659971f 100644
--- a/core/doctype/doctype/doctype.py
+++ b/core/doctype/doctype/doctype.py
@@ -26,9 +26,6 @@ import webnotes
from webnotes.utils import now, cint
msgprint = webnotes.msgprint
-
-
-
class DocType:
def __init__(self, doc=None, doclist=[]):
self.doc = doc
@@ -68,6 +65,9 @@ class DocType:
msgprint('Series already in use: The series "%s" is already used in "%s"' % (prefix, used_in[0][0]), raise_exception=1)
def validate(self):
+ for c in [".", "/", "#", "&", "=", ":", "'", '"']:
+ if c in self.name:
+ webnotes.msgprint(c + " not allowed in name", raise_exception=1)
self.validate_series()
self.scrub_field_names()
validate_fields(filter(lambda d: d.doctype=="DocField", self.doclist))
@@ -182,7 +182,7 @@ def validate_fields_for_doctype(doctype):
def validate_fields(fields):
def check_illegal_characters(fieldname):
for c in ['.', ',', ' ', '-', '&', '%', '=', '"', "'", '*', '$',
- '(', ')', '[', ']']:
+ '(', ')', '[', ']', '/']:
if c in fieldname:
webnotes.msgprint("'%s' not allowed in fieldname (%s)" % (c, fieldname))
diff --git a/public/build.json b/public/build.json
index 2678025f3c..679a367198 100644
--- a/public/build.json
+++ b/public/build.json
@@ -54,13 +54,10 @@
"lib/public/js/wn/provide.js",
"lib/public/js/wn/assets.js",
"lib/public/js/wn/dom.js",
- "lib/public/js/wn/model.js",
- "lib/public/js/wn/perm.js",
"lib/public/js/wn/meta.js",
"lib/public/js/wn/misc/user.js",
"lib/public/js/wn/misc/utils.js",
"lib/public/js/lib/public/json2.js",
- "lib/public/js/wn/router.js",
"lib/public/js/wn/ui/messages.js",
"lib/public/js/wn/ui/listing.js",
"lib/public/js/wn/views/container.js",
@@ -79,8 +76,6 @@
"lib/public/js/wn/ui/button.js",
"lib/public/js/legacy/widgets/dialog.js",
"lib/public/js/legacy/webpage/loaders.js",
- "lib/public/js/legacy/model/local_data.js",
- "lib/public/js/legacy/model/doclist.js",
"lib/public/js/wn/app.js"
]
},
@@ -98,6 +93,13 @@
"lib/public/js/lib/tiny_mce_3.5.7/jquery.tinymce.js:concat",
"lib/public/js/lib/mousetrap.min.js",
+ "lib/public/js/wn/router.js",
+ "lib/public/js/wn/model/model.js",
+ "lib/public/js/wn/model/doclist.js",
+ "lib/public/js/wn/model/sync.js",
+ "lib/public/js/wn/model/create_new.js",
+ "lib/public/js/wn/model/perm.js",
+
"lib/public/js/wn/misc/tools.js",
"lib/public/js/legacy/utils/printElement.js",
"lib/public/js/legacy/widgets/form/fields.js",
diff --git a/public/js/legacy/globals.js b/public/js/legacy/globals.js
index a211330125..a819a51180 100644
--- a/public/js/legacy/globals.js
+++ b/public/js/legacy/globals.js
@@ -10,6 +10,8 @@ wn.provide('_r');
wn.provide('_c');
wn.provide('_e');
wn.provide('_startup_data')
+wn.provide('locals')
+wn.provide('locals.DocType')
// setup custom binding for history
wn.settings.no_history = 1;
@@ -52,6 +54,4 @@ var FILTER_SEP = '\1';
var frms={};
var cur_frm=null;
var pscript = {};
-var validated = true;
-var validation_message = '';
var tinymce_loaded = null;
\ No newline at end of file
diff --git a/public/js/legacy/model/doclist.js b/public/js/legacy/model/doclist.js
deleted file mode 100644
index d5e2438198..0000000000
--- a/public/js/legacy/model/doclist.js
+++ /dev/null
@@ -1,175 +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.
-//
-
-function compress_doclist(list) {
- var kl = {}; var vl = []; var flx = {};
- for(var i=0; i1)return true;
- var fl = wn.meta.docfield_list[dt];
-
- if(!fl)return true; // no doctype loaded
-
- var all_clear = true;
- var errfld = [];
- for(var i=0;iMandatory fields required in '+
- (doc.parenttype ? (wn.meta.docfield_map[doc.parenttype][doc.parentfield].label + ' (Table)') :
- doc.doctype) + ':\n' + errfld.join('\n'));
- return all_clear;
-}
diff --git a/public/js/legacy/model/local_data.js b/public/js/legacy/model/local_data.js
deleted file mode 100644
index e41cfd410d..0000000000
--- a/public/js/legacy/model/local_data.js
+++ /dev/null
@@ -1,288 +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.
-//
-
-// Local DB
-//-----------
-
-var locals = {'DocType':{}};
-var LocalDB={};
-var READ = 0; var WRITE = 1; var CREATE = 2; var SUBMIT = 3; var CANCEL = 4; var AMEND = 5;
-
-LocalDB.getchildren = function(child_dt, parent, parentfield, parenttype) {
- var l = [];
- for(var key in locals[child_dt]) {
- var d = locals[child_dt][key];
- if((d.parent == parent)&&(d.parentfield == parentfield)) {
- if(parenttype) {
- if(d.parenttype==parenttype)l.push(d);
- } else { // ignore for now
- l.push(d);
- }
- }
- }
- l.sort(function(a,b){return (cint(a.idx)-cint(b.idx))}); return l;
-}
-
-// Add Doc
-// ======================================================================================
-
-LocalDB.add=function(dt, dn) {
- if(!locals[dt]) locals[dt] = {}; if(locals[dt][dn]) delete locals[dt][dn];
- locals[dt][dn] = {'name':dn, 'doctype':dt, 'docstatus':0};
- return locals[dt][dn];
-}
-
-// Delete Doc
-// ======================================================================================
-
-LocalDB.delete_doc=function(dt, dn) {
- var doc = get_local(dt, dn);
- if(!doc) return;
-
- for(var ndt in locals) { // all doctypes
- if(locals[ndt]) {
- for(var ndn in locals[ndt]) {
- var doc = locals[ndt][ndn];
- if(doc && doc.parenttype==dt && (doc.parent==dn||doc.__oldparent==dn)) {
- delete locals[ndt][ndn];
- }
- }
- }
- }
- delete locals[dt][dn];
-}
-
-function get_local(dt, dn) { return locals[dt] ? locals[dt][dn] : null; }
-
-// Sync Records from Server
-// ======================================================================================
-
-LocalDB.sync = function(list) {
- if(keys(list._kl))
- list = expand_doclist(list);
- if(list.length) {
- LocalDB.clear_locals(list[0].doctype, list[0].name);
- } else {
- return;
- }
- for(var i=0;i
Click here to create a new %(dtl)s', {dt:me.df.options, dtl:get_doctype_label(me.df.options)})
- msgprint(repl('error:%(val)s is not a valid %(dt)s.
You must first create a new %(dt)s %(val)s and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s', {val:me.txt.value, dt:get_doctype_label(me.df.options), add:astr}));
+ if(in_list(profile.can_create, me.df.options)) astr = repl('
Click here to create a new %(dtl)s', {dt:me.df.options, dtl:wn._(me.df.options)})
+ msgprint(repl('error:%(val)s is not a valid %(dt)s.
You must first create a new %(dt)s %(val)s and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s', {val:me.txt.value, dt:wn._(me.df.options), add:astr}));
me.txt.value = '';
me.set('');
}
diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js
index e591f6eab5..bfedbce113 100644
--- a/public/js/legacy/widgets/form/form.js
+++ b/public/js/legacy/widgets/form/form.js
@@ -46,6 +46,7 @@ _f.Frm = function(doctype, parent, in_form) {
this.docname = '';
this.doctype = doctype;
this.display = 0;
+ this.refresh_if_stale_for = 600;
var me = this;
this.is_editable = {};
@@ -215,7 +216,7 @@ _f.Frm.prototype.print_doc = function() {
_f.Frm.prototype.email_doc = function(message) {
new wn.views.CommunicationComposer({
doc: this.doc,
- subject: get_doctype_label(this.meta.name) + ': ' + this.docname,
+ subject: wn._(this.meta.name) + ': ' + this.docname,
recipients: this.doc.email || this.doc.email_id || this.doc.contact_email,
attach_document_print: true,
message: message,
@@ -237,7 +238,7 @@ _f.Frm.prototype.rename_notify = function(dt, old, name) {
if(this.docname == old)
this.docname = name;
else
- return; // thats it, not for children!
+ return;
// editable
this.is_editable[name] = this.is_editable[old];
@@ -245,9 +246,9 @@ _f.Frm.prototype.rename_notify = function(dt, old, name) {
// cleanup
if(this && this.opendocs[old]) {
- // local doctype copy
- local_dt[dt][name] = local_dt[dt][old];
- local_dt[dt][old] = null;
+ // delete docfield copy
+ wn.meta.docfield_copy[dt][name] = wn.meta.docfield_copy[dt][old];
+ delete wn.meta.docfield_copy[dt][old];
}
delete this.opendocs[old];
@@ -260,19 +261,16 @@ _f.Frm.prototype.rename_notify = function(dt, old, name) {
// SETUP
_f.Frm.prototype.setup_meta = function(doctype) {
- this.meta = get_local('DocType',this.doctype);
+ this.meta = wn.model.get_doc('DocType',this.doctype);
this.perm = wn.perm.get_perm(this.doctype); // for create
if(this.meta.istable) { this.meta.in_dialog = 1 }
this.setup_print();
}
-
-
_f.Frm.prototype.setup_sidebar = function() {
this.sidebar = new wn.widgets.form.sidebar.Sidebar(this);
}
-
_f.Frm.prototype.setup_footer = function() {
var me = this;
@@ -372,7 +370,6 @@ _f.Frm.prototype.setup_fields_std = function() {
}
}
-// --------------------------------------------------------------------------------------
_f.Frm.prototype.add_custom_button = function(label, fn, icon) {
this.frm_head.appframe.add_button(label, fn, icon);
}
@@ -380,8 +377,6 @@ _f.Frm.prototype.clear_custom_buttons = function() {
this.frm_head.refresh_toolbar()
}
-// --------------------------------------------------------------------------------------
-
_f.Frm.prototype.add_fetch = function(link_field, src_field, tar_field) {
if(!this.fetch_dict[link_field]) {
this.fetch_dict[link_field] = {'columns':[], 'fields':[]}
@@ -390,8 +385,6 @@ _f.Frm.prototype.add_fetch = function(link_field, src_field, tar_field) {
this.fetch_dict[link_field].fields.push(tar_field);
}
-// --------------------------------------------------------------------------------------
-
_f.Frm.prototype.setup_client_script = function() {
// setup client obj
@@ -400,8 +393,6 @@ _f.Frm.prototype.setup_client_script = function() {
}
}
-// --------------------------------------------------------------------------------------
-
_f.Frm.prototype.refresh_print_layout = function() {
$ds(this.print_wrapper);
$dh(this.page_layout.wrapper);
@@ -432,8 +423,6 @@ _f.Frm.prototype.refresh_print_layout = function() {
}
-// --------------------------------------------------------------------------------------
-
_f.Frm.prototype.show_the_frm = function() {
// show the dialog
if(this.meta.in_dialog && !this.parent.dialog.display) {
@@ -443,38 +432,15 @@ _f.Frm.prototype.show_the_frm = function() {
}
}
-// --------------------------------------------------------------------------------------
_f.Frm.prototype.set_print_heading = function(txt) {
this.pformat[cur_frm.docname] = txt;
}
-// --------------------------------------------------------------------------------------
-
_f.Frm.prototype.defocus_rest = function() {
// deselect others
if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();
}
-// -------- Permissions -------
-// Returns global permissions, at all levels
-// ======================================================================================
-
-_f.Frm.prototype.get_doc_perms = function() {
- var p = [0,0,0,0,0,0];
- for(var i=0; i this.refresh_if_stale_for) {
+ this.reload_doc();
+ return;
+ }
}
- // set the doc
- this.doc = get_local(this.doctype, this.docname);
-
// do setup
if(!this.setup_done) this.setup();
@@ -621,13 +588,11 @@ _f.Frm.prototype.refresh = function(docname) {
}
}
-// --------------------------------------------------------------------------------------
-
_f.Frm.prototype.refresh_footer = function() {
var f = this.page_layout.footer;
if(f.save_area) {
if(this.editable && (!this.meta.in_dialog || this.in_form)
- && this.doc.docstatus==0 && !this.meta.istable && this.get_doc_perms()[WRITE]
+ && this.doc.docstatus==0 && !this.meta.istable && this.perm[0][WRITE]
&& (this.fields && this.fields.length > 7)) {
f.show_save();
} else {
@@ -755,18 +720,14 @@ _f.Frm.prototype.setnewdoc = function(docname) {
return;
}
- //if(!this.meta)
- // this.setup_meta();
-
// make a copy of the doctype for client script settings
// each record will have its own client script
- Meta.make_local_dt(this.doctype,docname);
+ wn.meta.make_docfield_copy_for(this.doctype,docname);
this.docname = docname;
+
var me = this;
-
- var viewname = docname;
- if(this.meta.issingle) viewname = this.doctype;
+ var viewname = this.meta.issingle ? this.doctype : docname;
// Client Script
this.runclientscript('onload', this.doctype, this.docname);
@@ -788,82 +749,12 @@ _f.Frm.prototype.show_doc = function(dn) {
this.refresh(dn);
}
-// ======================================================================================
-var validated; // bad design :(
-_f.Frm.prototype.save = function(save_action, callback, btn) {
- // removes focus from a field before save,
- // so that its change event gets triggered before saving
- $(document.activeElement).blur();
-
- //alert(save_action);
- if(!save_action) {
- if(cint(this.doc.docstatus) > 0) return;
- save_action = 'Save';
- }
-
- if(save_action=='Submit') {
- locals[this.doctype][this.docname].submitted_on = dateutil.full_str();
- locals[this.doctype][this.docname].submitted_by = user;
- }
-
- if(save_action=='Trash') {
- var reason = prompt('Reason for trash (mandatory)', '');
- if(!strip(reason)) {
- msgprint('Reason is mandatory, not trashed');
- return;
- }
- locals[this.doctype][this.docname].trash_reason = reason;
- }
-
- // run validations
- if(save_action=='Cancel') {
- var reason = prompt('Reason for cancellation (mandatory)', '');
- if(!strip(reason)) {
- msgprint('Reason is mandatory, not cancelled');
- return;
- }
- locals[this.doctype][this.docname].cancel_reason = reason;
- locals[this.doctype][this.docname].cancelled_on = dateutil.full_str();
- locals[this.doctype][this.docname].cancelled_by = user;
- } else if(save_action=='Update') {
- // no validation for update
- } else { // no validation for cancellation
- validated = true;
- if(this.cscript.validate)
- this.runclientscript('validate');
-
- if(!validated) {
- return 'Error';
- }
- }
-
-
- var onsave = function(r) {
- if(!me.meta.istable && r) {
- me.refresh(r.docname);
- }
- callback && callback(r)
- }
-
- var me = this;
- var onerr = function(r) {
- var doc = locals[me.doctype][me.docname];
- onsave(r);
- }
-
- if(this.docname && validated) {
- // scroll to top
- scroll(0, 0);
- return save_doclist(this.doctype, this.docname, save_action, onsave, onerr, btn);
- }
-}
-
_f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) {
var me = this;
if(this.docname) {
// make doc list
- var doclist = compress_doclist(make_doclist(this.doctype, this.docname));
+ var doclist = wn.model.compress(make_doclist(this.doctype, this.docname));
// send to run
if(callingfield)
$(callingfield.input).set_working();
@@ -906,7 +797,7 @@ _f.Frm.prototype.runclientscript = function(caller, cdt, cdn) {
if(caller && caller.toLowerCase()=='setup') {
- var doctype = get_local('DocType', this.doctype);
+ var doctype = wn.model.get_doc('DocType', this.doctype);
// js
var cs = doctype.__js || (doctype.client_script_core + doctype.client_script);
@@ -941,7 +832,7 @@ _f.Frm.prototype.copy_doc = function(onload, from_amend) {
var dn = this.docname;
// copy parent
- var newdoc = LocalDB.copy(this.doctype, dn, from_amend);
+ var newdoc = wn.model.copy_doc(this.doctype, dn, from_amend);
// do not copy attachments
if(this.meta.allow_attach && newdoc.file_list && !from_amend)
@@ -962,7 +853,7 @@ _f.Frm.prototype.copy_doc = function(onload, from_amend) {
}
if(d1.parent==dn && cint(tf_dict[d1.parentfield].no_copy)!=1) {
- var ch = LocalDB.copy(d1.doctype, d1.name, from_amend);
+ var ch = wn.model.copy_doc(d1.doctype, d1.name, from_amend);
ch.parent = newdoc.name;
ch.docstatus = 0;
ch.owner = user;
@@ -1003,6 +894,31 @@ _f.Frm.prototype.reload_doc = function() {
}
}
+var validated;
+_f.Frm.prototype.save = function(save_action, callback, btn) {
+ $(document.activeElement).blur();
+ var me = this;
+ var doclist = new wn.model.DocList(this.doctype, this.docname);
+
+ // validate
+ if(save_action!="Cancel") {
+ validated = true;
+ if(this.cscript.validate)
+ this.runclientscript('validate');
+
+ if(!validated) {
+ return;
+ }
+ }
+ doclist.save(save_action || "Save", function(r) {
+ if(!r.exc) {
+ me.refresh();
+ }
+ callback && callback(r);
+ }, btn);
+}
+
+
_f.Frm.prototype.savesubmit = function(btn) {
var me = this;
wn.confirm("Permanently Submit "+this.docname+"?", function() {
@@ -1017,7 +933,10 @@ _f.Frm.prototype.savesubmit = function(btn) {
_f.Frm.prototype.savecancel = function(btn) {
var me = this;
wn.confirm("Permanently Cancel "+this.docname+"?", function() {
- me.save('Cancel', null, btn);
+ var doclist = new wn.model.DocList(me.doctype, me.docname);
+ doclist.cancel(function(r) {
+ if(!r.exc) me.refresh();
+ }, btn);
});
}
diff --git a/public/js/legacy/widgets/form/form_grid.js b/public/js/legacy/widgets/form/form_grid.js
index b28b903bb4..44bfb56ad3 100644
--- a/public/js/legacy/widgets/form/form_grid.js
+++ b/public/js/legacy/widgets/form/form_grid.js
@@ -158,7 +158,7 @@ _f.FormGrid.prototype.insert_row = function() {
_f.FormGrid.prototype.new_row_doc = function() {
// create row doc
- var n = LocalDB.create(this.doctype);
+ var n = wn.model.make_new_doc_and_get_name(this.doctype);
var d = locals[this.doctype][n];
d.parent = this.field.frm.docname;
d.parentfield = this.field.df.fieldname;
@@ -220,7 +220,7 @@ _f.FormGrid.prototype.check_selected = function() {
_f.FormGrid.prototype.delete_row = function(dt, dn) {
if(dt && dn) {
- LocalDB.delete_record(dt, dn);
+ wn.model.clear_doc(dt, dn);
this.refresh();
} else {
if(!this.check_selected()) return;
@@ -230,7 +230,7 @@ _f.FormGrid.prototype.delete_row = function(dt, dn) {
var ci = _f.cur_grid_cell.cellIndex;
var ri = _f.cur_grid_cell.row.rowIndex;
- LocalDB.delete_record(this.doctype, r.docname);
+ wn.model.clear_doc(this.doctype, r.docname);
this.refresh();
if(ri < (this.tab.rows.length-1))
diff --git a/public/js/legacy/widgets/form/form_header.js b/public/js/legacy/widgets/form/form_header.js
index e270f69c22..8e7b6be30f 100644
--- a/public/js/legacy/widgets/form/form_header.js
+++ b/public/js/legacy/widgets/form/form_header.js
@@ -80,7 +80,7 @@ _f.FrmHeader = Class.extend({
this.$w.find('.avatar img').centerImage();
},
refresh_labels: function() {
- cur_frm.doc = get_local(cur_frm.doc.doctype, cur_frm.doc.name);
+ cur_frm.doc = wn.model.get_doc(cur_frm.doc.doctype, cur_frm.doc.name);
var labinfo = {
0: ['Saved', 'label-success'],
1: ['Submitted', 'label-info'],
@@ -121,7 +121,7 @@ _f.FrmHeader = Class.extend({
}
this.appframe.clear_buttons();
- var p = cur_frm.get_doc_perms();
+ var p = cur_frm.perm[0];
// Edit
if(cur_frm.meta.read_only_onload && !cur_frm.doc.__islocal) {
diff --git a/public/js/legacy/widgets/form/print_format.js b/public/js/legacy/widgets/form/print_format.js
index 0b34eed048..8b3075a115 100644
--- a/public/js/legacy/widgets/form/print_format.js
+++ b/public/js/legacy/widgets/form/print_format.js
@@ -452,7 +452,7 @@ $.extend(_p, {
}
}
// if not, just have doctype has heading
- h1.innerHTML = val ? val : get_doctype_label(doctype);
+ h1.innerHTML = val ? val : wn._(doctype);
}
var h2_style = {
diff --git a/public/js/legacy/widgets/report_builder/report_builder.js b/public/js/legacy/widgets/report_builder/report_builder.js
index 1ab923d384..071c7f292a 100644
--- a/public/js/legacy/widgets/report_builder/report_builder.js
+++ b/public/js/legacy/widgets/report_builder/report_builder.js
@@ -132,7 +132,7 @@ _r.ReportBuilder = function(parent, doctype, onload) {
$ds(me.wrapper);
// reset main title
- this.set_main_title('Report: ' + get_doctype_label(me.doctype));
+ this.set_main_title('Report: ' + wn._(me.doctype));
if(my_onload)my_onload(me);
}
@@ -156,7 +156,7 @@ _r.ReportBuilder.prototype.make_tabs = function() {
_r.ReportBuilder.prototype.make_body = function() {
- this.set_main_title('Report: ' + get_doctype_label(this.doctype));
+ this.set_main_title('Report: ' + wn._(this.doctype));
var me = this;
this.make_save_criteria();
@@ -204,7 +204,7 @@ _r.ReportBuilder.prototype.save_criteria = function(save_as) {
if(!criteria_name)
return;
- var dn = createLocal('Search Criteria');
+ var dn = wn.model.make_new_doc_and_get_name('Search Criteria');
var doc = locals['Search Criteria'][dn];
doc.criteria_name = criteria_name;
@@ -243,12 +243,7 @@ _r.ReportBuilder.prototype.save_criteria = function(save_as) {
me.sc_dict[criteria_name] = r.main_doc_name;
me.set_criteria_sel(criteria_name);
}
- //if(this.current_loaded && overwrite) {
- // msgprint('Filters and Columns Synchronized. You must also "Save" the Search Criteria to update');
- // loaddoc('Search Criteria', this.sc_dict[this.current_loaded]);
- //} else {
- save_doclist(doc.doctype, doc.name, 'Save', fn); // server-side save
- //}
+ new wn.model.DocList(doc.doctype, doc.name).save("Save", fn);
}
// -------------------------------------------------------------------------------------
@@ -292,7 +287,7 @@ _r.ReportBuilder.prototype.clear_criteria = function() {
this.set_sort_options();
- this.set_main_title('Report: ' + get_doctype_label(this.doctype));
+ this.set_main_title('Report: ' + wn._(this.doctype));
this.current_loaded = null;
this.customized_filters = null;
@@ -503,10 +498,10 @@ _r.ReportBuilder.prototype.setup_dt_filters_and_cols = function(fl, dt) {
// set section headings
var lab = $a(me.filter_area,'div','filter_dt_head');
- lab.innerHTML = 'Filters for ' + get_doctype_label(dt);
+ lab.innerHTML = 'Filters for ' + wn._(dt);
var lab = $a(me.picker_area,'div','builder_dt_head');
- lab.innerHTML = 'Select columns for ' + get_doctype_label(dt);
+ lab.innerHTML = 'Select columns for ' + wn._(dt);
// get fields
var dt_fields = wn.meta.docfield_list[dt];
@@ -678,7 +673,7 @@ _r.ReportBuilder.prototype.make_datatable = function() {
// get search criteria
if(me.current_loaded && me.sc_dict[me.current_loaded]) {
- var sc = get_local('Search Criteria', me.sc_dict[me.current_loaded]);
+ var sc = wn.model.get_doc('Search Criteria', me.sc_dict[me.current_loaded]);
}
if(sc) me.dt.search_criteria = sc;
@@ -1221,7 +1216,7 @@ _r.ReportColumnPicker.prototype.set_options = function(s, l) {
for(var i=0; i