From 8b0834ad2f5ca500f4fc0228e486a3e4d54294ec Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 3 Jul 2013 10:32:31 +0530 Subject: [PATCH 1/2] [form] added icon in section break --- core/doctype/docfield/docfield.txt | 22 +++++++++++----------- core/doctype/doctype/doctype.js | 7 +++++++ public/js/wn/form/grid.js | 2 ++ public/js/wn/form/layout.js | 11 +++++++---- public/js/wn/views/communication.js | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) 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/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index 126eceb044..714104ea53 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -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]; diff --git a/public/js/wn/form/layout.js b/public/js/wn/form/layout.js index cffb0574e5..2a13815bac 100644 --- a/public/js/wn/form/layout.js +++ b/public/js/wn/form/layout.js @@ -78,8 +78,11 @@ wn.ui.form.Layout = Class.extend({ if(df) { if(df.label) { this.labelled_section_count++; - $('

' + this.labelled_section_count - + ". " + df.label + "

") + $('

' + + (df.options ? (' ') : "") + + this.labelled_section_count + ". " + + df.label + + "

") .css({"font-weight": "bold", "margin-bottom": "15px"}) .appendTo(this.section); if(this.frm.sections.length > 1) @@ -188,9 +191,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); diff --git a/public/js/wn/views/communication.js b/public/js/wn/views/communication.js index e5f97f3f25..560f8d64f6 100644 --- a/public/js/wn/views/communication.js +++ b/public/js/wn/views/communication.js @@ -42,7 +42,7 @@ wn.views.CommunicationList = Class.extend({ .empty() .css({"margin":"10px 0px"}); - this.wrapper = $("

"+wn._("Communication History")+"

\ + this.wrapper = $("
\
\ ') - .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 ='
' + txt + '
'; - } 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=0;i--) { var f = me.fields[i]; diff --git a/public/js/legacy/widgets/form/print_format.js b/public/js/legacy/widgets/form/print_format.js index 81ee50fff9..1bf044adf2 100644 --- a/public/js/legacy/widgets/form/print_format.js +++ b/public/js/legacy/widgets/form/print_format.js @@ -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: '

\ + \ + \ +

'}, + ] + }) - // 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 = $('
') + .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 = + $('
').prependTo(this.wrapper); + this.headline.html(html); + }, + set_headline_alert: function(text, alert_class, icon) { + this.set_headline(repl('
%(icon)s%(text)s
', { + "alert_class": alert_class || "", + "icon": 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('
\ +
\ + %(label)s\ + -\ +
', {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)); + }); + }, + +}) \ No newline at end of file diff --git a/public/js/wn/form/layout.js b/public/js/wn/form/layout.js index 2a13815bac..862a8f5462 100644 --- a/public/js/wn/form/layout.js +++ b/public/js/wn/form/layout.js @@ -8,7 +8,6 @@ wn.ui.form.Layout = Class.extend({ }, make: function() { this.wrapper = $('
').appendTo(this.parent); - this.dashboard = $('
').appendTo(this.wrapper); this.fields = wn.meta.get_docfields(this.frm.doctype); this.setup_tabbing(); }, @@ -83,10 +82,19 @@ wn.ui.form.Layout = Class.extend({ + this.labelled_section_count + ". " + df.label + "") - .css({"font-weight": "bold", "margin-bottom": "15px"}) + .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) { $('
' + df.description + '
').appendTo(this.section); diff --git a/public/js/wn/model/model.js b/public/js/wn/model/model.js index 2da082cb3d..3b5336980e 100644 --- a/public/js/wn/model/model.js +++ b/public/js/wn/model/model.js @@ -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); } }, diff --git a/public/js/wn/ui/field_group.js b/public/js/wn/ui/field_group.js index 4bf5257bc5..568e818333 100644 --- a/public/js/wn/ui/field_group.js +++ b/public/js/wn/ui/field_group.js @@ -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; } } diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index d8bc44419e..09546997b7 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -260,6 +260,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ }, callback: function() { me.set_working(false); + me.dirty = true; me.refresh(); } }) diff --git a/webnotes/widgets/form/run_method.py b/webnotes/widgets/form/run_method.py index f743d67844..b0f45454ec 100644 --- a/webnotes/widgets/form/run_method.py +++ b/webnotes/widgets/form/run_method.py @@ -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')