diff --git a/core/doctype/docfield/docfield.txt b/core/doctype/docfield/docfield.txt index 2c6afa4032..955891c30e 100644 --- a/core/doctype/docfield/docfield.txt +++ b/core/doctype/docfield/docfield.txt @@ -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", diff --git a/core/doctype/doctype/doctype.js b/core/doctype/doctype/doctype.js index 8fde2a34e9..579e2d7b2a 100644 --- a/core/doctype/doctype/doctype.js +++ b/core/doctype/doctype/doctype.js @@ -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'); diff --git a/core/doctype/letter_head/letter_head.py b/core/doctype/letter_head/letter_head.py index d0d0471f27..27661de2c9 100755 --- a/core/doctype/letter_head/letter_head.py +++ b/core/doctype/letter_head/letter_head.py @@ -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) diff --git a/public/build.json b/public/build.json index 0cb9831ba8..53f5beb0c8 100644 --- a/public/build.json +++ b/public/build.json @@ -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", diff --git a/public/css/ui/common.css b/public/css/ui/common.css index d9c4d2fac9..f1aa7a10c8 100644 --- a/public/css/ui/common.css +++ b/public/css/ui/common.css @@ -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 */ diff --git a/public/js/legacy/utils/datatype.js b/public/js/legacy/datatype.js similarity index 100% rename from public/js/legacy/utils/datatype.js rename to public/js/legacy/datatype.js diff --git a/public/js/legacy/utils/datetime.js b/public/js/legacy/datetime.js similarity index 100% rename from public/js/legacy/utils/datetime.js rename to public/js/legacy/datetime.js diff --git a/public/js/legacy/utils/dom.js b/public/js/legacy/dom.js similarity index 100% rename from public/js/legacy/utils/dom.js rename to public/js/legacy/dom.js diff --git a/public/js/legacy/utils/handler.js b/public/js/legacy/handler.js similarity index 99% rename from public/js/legacy/utils/handler.js rename to public/js/legacy/handler.js index 3151af7691..867601e243 100644 --- a/public/js/legacy/utils/handler.js +++ b/public/js/legacy/handler.js @@ -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 }; diff --git a/public/js/legacy/webpage/loaders.js b/public/js/legacy/loaders.js similarity index 100% rename from public/js/legacy/webpage/loaders.js rename to public/js/legacy/loaders.js diff --git a/public/js/legacy/utils/printElement.js b/public/js/legacy/printElement.js similarity index 100% rename from public/js/legacy/utils/printElement.js rename to public/js/legacy/printElement.js diff --git a/public/js/legacy/webpage/page_header.js b/public/js/legacy/webpage/page_header.js deleted file mode 100644 index 61bc96ee16..0000000000 --- a/public/js/legacy/webpage/page_header.js +++ /dev/null @@ -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 ? (' ') : ''; - - var $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(); -} \ No newline at end of file diff --git a/public/js/legacy/webpage/search.js b/public/js/legacy/webpage/search.js deleted file mode 100644 index c7b8921154..0000000000 --- a/public/js/legacy/webpage/search.js +++ /dev/null @@ -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 ='
\ + \ + \ +
'}, + ] + }) - // 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 diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index 4d2e9e42a2..1fdd688304 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -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; } diff --git a/public/js/wn/form/dashboard.js b/public/js/wn/form/dashboard.js new file mode 100644 index 0000000000..5b9071d43d --- /dev/null +++ b/public/js/wn/form/dashboard.js @@ -0,0 +1,55 @@ +wn.ui.form.Dashboard = Class.extend({ + init: function(opts) { + $.extend(this, opts); + this.wrapper = $('