From 68aab0d9a747c1ab5e9cae7a1674ba0bcc3476fb Mon Sep 17 00:00:00 2001 From: venkata akhil Date: Fri, 15 Dec 2023 19:15:16 +0530 Subject: [PATCH] Torque mapping colum HTML update --- .../torque_column_ref/torque_column_ref.json | 13 ++-- .../doctype/torque_manual/torque_manual.js | 77 +++++++++++++++++++ .../doctype/torque_manual/torque_manual.json | 20 +++-- .../doctype/torque_manual/torque_manual.py | 9 +++ .../torque_manual_mapping.json | 16 +--- 5 files changed, 110 insertions(+), 25 deletions(-) diff --git a/smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.json b/smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.json index 74ff182..ce1292f 100644 --- a/smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.json +++ b/smart_service/phase_2/doctype/torque_column_ref/torque_column_ref.json @@ -6,26 +6,27 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "column", + "column_id", "column_name" ], "fields": [ { - "fieldname": "column", + "fieldname": "column_name", "fieldtype": "Data", - "label": "Column Number" + "in_list_view": 1, + "label": "Column Name" }, { - "fieldname": "column_name", + "fieldname": "column_id", "fieldtype": "Data", "in_list_view": 1, - "label": "Column Name" + "label": "Column Id" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-12-12 12:02:49.911584", + "modified": "2023-12-15 16:25:14.032041", "modified_by": "Administrator", "module": "Phase-2", "name": "Torque Column Ref", diff --git a/smart_service/phase_2/doctype/torque_manual/torque_manual.js b/smart_service/phase_2/doctype/torque_manual/torque_manual.js index cb7c653..9039eac 100644 --- a/smart_service/phase_2/doctype/torque_manual/torque_manual.js +++ b/smart_service/phase_2/doctype/torque_manual/torque_manual.js @@ -2,12 +2,32 @@ // For license information, please see license.txt var original_display_order = 0; var vehicle_count = 0; +frappe.require('assets/smart_service/js/boostrap_table.js', () => { +}) + +frappe.require('assets/smart_service/css/boostrap_table.css', () => { + +}) frappe.ui.form.on('Torque Manual', { refresh: function(frm) { set_display_order(frm) }, + onload:function(frm){ + if (frm.doc.vehicle){ + get_column_data(frm) + + } + + }, + vehicle:function(frm){ + if (frm.doc.vehicle){ + get_column_data(frm) + + } + + } }); function set_display_order(frm){ @@ -31,4 +51,61 @@ function set_display_order(frm){ original_display_order = frm.doc.display_order; } }); +} + + +function get_column_data(frm){ + frappe.call({ + method: "smart_service.phase_2.doctype.torque_manual.torque_manual.get_column_details", + args: {vehicle: frm.doc.vehicle} + }).done((r) => { + let details = [] + + if(r.message.success == 1){ + + $.each(r.message.data, function(_i, e){ + debugger + details.push({"columnid":e.column_id,"column_name":e.column_name}); + debugger + }) + console.log(details) + var res = $(cur_frm.fields_dict.column_details.wrapper).empty(); + var html = "" + html = '
' + $(res).append(html) + $('#tblEmployee').bootstrapTable({ + data: details, + // height: 500, + pagination: false, + pageSize: 10, + // pageList: [], + search: false, + showExport: false, + + exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel', 'pdf'], + columns: [{ + field: 'columnid', + title: 'Column Number', + align: 'center', + valign: 'bottom', + sortable: false, + width: '10%' + }, + { + field: 'column_name', + title: 'Column Name', + align: 'left', + valign: 'bottom', + sortable: false, + width: '10%' + }] + + }) + + + } + + + }) + } \ No newline at end of file diff --git a/smart_service/phase_2/doctype/torque_manual/torque_manual.json b/smart_service/phase_2/doctype/torque_manual/torque_manual.json index f219858..fcdb85e 100644 --- a/smart_service/phase_2/doctype/torque_manual/torque_manual.json +++ b/smart_service/phase_2/doctype/torque_manual/torque_manual.json @@ -19,7 +19,8 @@ "display_order", "keywords", "section_break_cmyhs", - "torque_coulmn_name", + "column_details", + "section_break_s6fxa", "torque_table" ], "fields": [ @@ -27,7 +28,8 @@ "default": "0", "fieldname": "is_published", "fieldtype": "Check", - "label": "Published" + "label": "Published", + "read_only": 1 }, { "fieldname": "section_break_qg2b0", @@ -114,15 +116,19 @@ "options": "Torque Manual Details" }, { - "fieldname": "torque_coulmn_name", - "fieldtype": "Table", - "label": "Torque Coulmn Name", - "options": "Torque Column Ref" + "fieldname": "column_details", + "fieldtype": "HTML", + "label": "Column Details", + "read_only": 1 + }, + { + "fieldname": "section_break_s6fxa", + "fieldtype": "Section Break" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-12 12:03:24.953779", + "modified": "2023-12-15 18:31:16.172009", "modified_by": "Administrator", "module": "Phase-2", "name": "Torque Manual", diff --git a/smart_service/phase_2/doctype/torque_manual/torque_manual.py b/smart_service/phase_2/doctype/torque_manual/torque_manual.py index ddf9a75..fd0cce8 100644 --- a/smart_service/phase_2/doctype/torque_manual/torque_manual.py +++ b/smart_service/phase_2/doctype/torque_manual/torque_manual.py @@ -45,6 +45,15 @@ class TorqueManual(Document): raise e +@frappe.whitelist(allow_guest = 1) +def get_column_details(vehicle=None): + try: + torque_column_mapping = frappe.db.sql(f''' select idx as display_order, concat('col',idx) as column_id,column_name from `tabTorque Column Mapping` where parent = '{vehicle}' order by idx; ''', as_dict=1) + return {"success":1,"data":torque_column_mapping} + except Exception as e: + return {"success":0,"data":None,msg:str(e)} + + # @frappe.whitelist() # def file_validation_child(name=None, value=None): diff --git a/smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json b/smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json index bf799a7..08aae46 100644 --- a/smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json +++ b/smart_service/phase_2/doctype/torque_manual_mapping/torque_manual_mapping.json @@ -1,32 +1,24 @@ { "actions": [], "allow_rename": 1, - "autoname": "format:{variant}", + "autoname": "format:{vehicle}", "creation": "2023-12-12 14:44:55.388191", "doctype": "DocType", "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "variant", "vehicle", "section_break_bytf4", "torque_table_columns" ], "fields": [ - { - "fieldname": "variant", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Variant", - "options": "Variant Mapping", - "reqd": 1 - }, { "fetch_from": "variant.vehicle", "fieldname": "vehicle", - "fieldtype": "Data", + "fieldtype": "Link", "in_list_view": 1, "label": "Vehicle", + "options": "Vehicle", "reqd": 1 }, { @@ -42,7 +34,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-12 15:05:37.251699", + "modified": "2023-12-15 16:17:58.889238", "modified_by": "Administrator", "module": "Phase-2", "name": "Torque Manual Mapping",