From 2ebbe95e0464e0a273bdcd057ed3f69bc144ad8a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 12:44:59 +0530 Subject: [PATCH] [minor] [fix] item prices html table --- setup/doctype/price_list/price_list.js | 248 ++++++++++-------------- setup/doctype/price_list/price_list.txt | 8 +- 2 files changed, 112 insertions(+), 144 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 2c24d7ec89..1dd9ec53de 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -14,46 +14,42 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.show_item_prices = function() { var item_price = wn.model.get("Item Price", {parent: cur_frm.doc.name}); - cur_frm.toggle_display("item_prices", true); - $(cur_frm.fields_dict.item_prices.wrapper).empty(); + $(cur_frm.fields_dict.item_prices_html.wrapper).empty(); new wn.ui.form.TableGrid({ - parent: cur_frm.fields_dict.item_prices.wrapper, + parent: cur_frm.fields_dict.item_prices_html.wrapper, frm: cur_frm, - table_field: wn.model.get("DocField", {parent:"Price List", fieldname:"item_prices"})[0] + table_field: wn.meta.get_docfield("Price List", "item_prices", cur_frm.doc.name) }); } wn.ui.form.TableGrid = Class.extend({ init: function(opts) { $.extend(this, opts); - this.fields = wn.model.get("DocField", {parent: this.table_field.options}); + this.fields = wn.meta.get_docfields("Item Price", cur_frm.doc.name); this.make_table(); }, make_table: function() { var me = this; // Creating table & assigning attributes var grid_table = document.createElement("table"); - $(grid_table).attr("class", "table table-hover table-bordered grid"); + grid_table.className = "table table-hover table-bordered grid"; // Appending header & rows to table - - $(this.make_table_headers()).appendTo(grid_table); - $(this.make_table_rows()).appendTo(grid_table); + grid_table.appendChild(this.make_table_headers()); + grid_table.appendChild(this.make_table_rows()); // Creating button to add new row var btn_div = document.createElement("div"); var new_row_btn = document.createElement("button"); - $new_row_btn = $(new_row_btn); - $new_row_btn.attr({ - "class": "btn btn-success table-new-row", - "title": "Add new row" - }); + new_row_btn.className = "btn btn-success table-new-row"; + new_row_btn.title = "Add new row"; + var btn_icon = document.createElement("i"); - $(btn_icon).attr("class", "icon-plus"); - $(btn_icon).appendTo(new_row_btn); - $new_row_btn.append(" Add new row"); - $new_row_btn.appendTo(btn_div); + btn_icon.className = "icon-plus"; + new_row_btn.appendChild(btn_icon); + new_row_btn.innerHTML += " Add new row"; + btn_div.appendChild(new_row_btn); // Appending table & button to parent var $grid_table = $(grid_table).appendTo($(this.parent)); @@ -75,35 +71,33 @@ wn.ui.form.TableGrid = Class.extend({ // Creating header row var row = document.createElement("tr"); - $(row).attr({ - "class": "active", - "style": "height:50px" - }); - $(row).appendTo(header); - + row.className = "active"; + // row.style = "height:50px"; + + // Creating head first cell var th = document.createElement("th"); - $(th).attr({ - "width": "8%", - "style": "vertical-align:middle", - "class": "text-center" - }); - $(th).html("#"); - $(th).appendTo(row); + th.width = "8%"; + th.className = "text-center"; + th.innerHTML = "#"; + row.appendChild(th); // Make other headers with label as heading - $.each(this.fields, function(i, obj) { - var th = document.createElement("th"); + for(var i=0, l=this.fields.length; i