From eb8753e8b6419d6d50765d42975d3fcf800db078 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 15:56:36 +0530 Subject: [PATCH 1/3] [fix] [minor] new grid to hide delete button on new row & added description --- setup/doctype/price_list/price_list.js | 6 +++--- setup/doctype/price_list/price_list.txt | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index cbca413f0c..397e9826ad 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -164,7 +164,7 @@ wn.ui.form.TableGrid = Class.extend({ if (row) this.dialog.set_values(this.make_dialog_values(row)); - $a(this.dialog.body, 'div', '', '', this.make_dialog_buttons()); + $a(this.dialog.body, 'div', '', '', this.make_dialog_buttons(row)); this.dialog.show(); this.dialog.$wrapper.find('button.update').on('click', function() { @@ -186,12 +186,12 @@ wn.ui.form.TableGrid = Class.extend({ return dialog_values; }, - make_dialog_buttons: function() { + make_dialog_buttons: function(row) { var me = this; var buttons = ''; // if user can delete then only add the delete button in dialog - if (wn.model.can_delete(me.frm.doc.doctype)) + if (wn.model.can_delete(me.frm.doc.doctype) && row) buttons += ' '; return buttons; diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt index 46905a6591..343331dd0c 100644 --- a/setup/doctype/price_list/price_list.txt +++ b/setup/doctype/price_list/price_list.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-25 11:35:09", "docstatus": 0, - "modified": "2013-09-06 15:03:38", + "modified": "2013-09-30 15:50:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -85,6 +85,7 @@ "reqd": 1 }, { + "description": "To change row values, click on the respective row", "doctype": "DocField", "fieldname": "item_prices_section", "fieldtype": "Section Break", From 4233ae2258a1f60edb9e5cc331fc79312e2c08c8 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 18:18:19 +0530 Subject: [PATCH 2/3] [pos] pos related fixes --- accounts/doctype/sales_invoice/pos.js | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index e19652d25f..0dba40fabc 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -214,7 +214,7 @@ erpnext.POS = Class.extend({ // if form is local then allow this function if (me.frm.doc.docstatus===0) { - $("div.pos-item").on("click", function() { + $(me.wrapper).find("div.pos-item").on("click", function() { if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && me.frm.doc.quotation_to == "Customer") || me.frm.doctype != "Quotation")) { @@ -313,7 +313,7 @@ erpnext.POS = Class.extend({ // taxes var taxes = wn.model.get_children(this.sales_or_purchase + " Taxes and Charges", this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype); - $(".tax-table") + $(this.wrapper).find(".tax-table") .toggle((taxes && taxes.length) ? true : false) .find("tbody").empty(); @@ -345,18 +345,18 @@ erpnext.POS = Class.extend({ // if form is local then only run all these functions if (this.frm.doc.docstatus===0) { - $("input.qty").on("focus", function() { + $(this.wrapper).find("input.qty").on("focus", function() { $(this).select(); }); // append quantity to the respective item after change from input box - $("input.qty").on("change", function() { + $(this.wrapper).find("input.qty").on("change", function() { var item_code = $(this).closest("tr")[0].id; me.update_qty(item_code, $(this).val(), true); }); // on td click toggle the highlighting of row - me.wrapper.find("#cart tbody tr td").on("click", function() { + $(this.wrapper).find("#cart tbody tr td").on("click", function() { var row = $(this).closest("tr"); if (row.attr("data-selected") == "false") { row.attr("class", "warning"); @@ -376,16 +376,22 @@ erpnext.POS = Class.extend({ // if form is submitted & cancelled then disable all input box & buttons if (this.frm.doc.docstatus>=1) { - me.wrapper.find('input, button').each(function () { + $(this.wrapper).find('input, button').each(function () { $(this).prop('disabled', true); }); - $(".delete-items").hide(); - $(".make-payment").hide(); + $(this.wrapper).find(".delete-items").hide(); + $(this.wrapper).find(".make-payment").hide(); + } + else { + $(this.wrapper).find('input, button').each(function () { + $(this).prop('disabled', false); + }); + $(this.wrapper).find(".make-payment").show(); } // Show Make Payment button only in Sales Invoice if (this.frm.doctype != "Sales Invoice") - $(".make-payment").hide(); + $(this.wrapper).find(".make-payment").hide(); // If quotation to is not Customer then remove party if (this.frm.doctype == "Quotation") { @@ -395,7 +401,7 @@ erpnext.POS = Class.extend({ } }, refresh_delete_btn: function() { - $(".delete-items").toggle($(".item-cart .warning").length ? true : false); + $(this.wrapper).find(".delete-items").toggle($(".item-cart .warning").length ? true : false); }, add_item_thru_barcode: function() { var me = this; @@ -417,9 +423,9 @@ erpnext.POS = Class.extend({ remove_selected_item: function() { var me = this; var selected_items = []; - var no_of_items = me.wrapper.find("#cart tbody tr").length; + var no_of_items = $(this.wrapper).find("#cart tbody tr").length; for(var x=0; x<=no_of_items - 1; x++) { - var row = me.wrapper.find("#cart tbody tr:eq(" + x + ")"); + var row = $(this.wrapper).find("#cart tbody tr:eq(" + x + ")"); if(row.attr("data-selected") == "true") { selected_items.push(row.attr("id")); } @@ -442,7 +448,7 @@ erpnext.POS = Class.extend({ }, make_payment: function() { var me = this; - var no_of_items = me.wrapper.find("#cart tbody tr").length; + var no_of_items = $(this.wrapper).find("#cart tbody tr").length; var mode_of_payment = []; if (no_of_items == 0) From 67a9ea68008c6a73e89bdd18fd75d8b135714299 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 19:05:36 +0530 Subject: [PATCH 3/3] [price_list] [minor] move header of new grid to right if currency --- setup/doctype/price_list/price_list.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 397e9826ad..2c24d7ec89 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -93,11 +93,16 @@ wn.ui.form.TableGrid = Class.extend({ // Make other headers with label as heading $.each(this.fields, function(i, obj) { - if (obj.in_list_view===1) - var th = document.createElement("th"); + var th = document.createElement("th"); + + // If currency then move header to right + if (obj.fieldtype == "Currency") + $(th).attr("style", "vertical-align:middle; text-align:right;"); + else $(th).attr("style", "vertical-align:middle"); - $(th).html(obj.label); - $(th).appendTo(row); + + $(th).html(obj.label); + $(th).appendTo(row); }); return header;