From f38c446e91e88333ccac3e5a95abf3e65bfb34f3 Mon Sep 17 00:00:00 2001 From: venkata akhil Date: Fri, 29 Sep 2023 12:51:26 +0530 Subject: [PATCH] QWIK field udpate --- smart_service/apis/v2/master.py | 6 +- .../doctype/feature_finder/feature_finder.js | 185 +++++++++--------- .../doctype/qwik_service/qwik_service.js | 25 ++- .../doctype/qwik_service/qwik_service.json | 4 +- 4 files changed, 115 insertions(+), 105 deletions(-) diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index d01a605..b3daa3a 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -269,14 +269,14 @@ def get_special_tool_information(vehicle): # my_id,keywords from `tabSpecial Tool Information` # where vehicle="{vehicle}";''', as_dict=1) - special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type,category,tool_name,aggregate_name,aggregate_image, - pdf,image,keywords,display_order,my_id,active_status from `tabSpecial Tool Information` + special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type,category,tool_name,aggregate_name,tool_image, + pdf,image,video,keywords,display_order,my_id,active_status from `tabSpecial Tool Information` where vehicle= '%s' ;''' % (vehicle), as_dict=1) for s in special_tool_information: # s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status # from `tabMST Information Assets` where parent = '{s['name']}' order by display_order;''', as_dict=1) - s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name,content_type,content,attach_file + s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name,content_type,content,attach_file,title from `tabInstructions` where parent = '%s' order by display_order;''' % (s['name']), as_dict=1) return True, special_tool_information except Exception as e: diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.js b/smart_service/phase_2/doctype/feature_finder/feature_finder.js index 70ae0d7..066cfab 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.js +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.js @@ -7,7 +7,7 @@ var filter_value = 0 frappe.ui.form.on('Feature Finder', { refresh: function (frm) { - if (!frm.doc.feature_finder_images){ + if (!frm.doc.feature_finder_images) { $(cur_frm.fields_dict.image_html.wrapper).empty(); } if (!frm.is_new()) { @@ -23,7 +23,7 @@ frappe.ui.form.on('Feature Finder', { // is_sop=0 // } // }) - + // } // if(is_sop==1){ // var childTable = cur_frm.add_child("post_vin_cutoff_id_tab"); @@ -31,11 +31,11 @@ frappe.ui.form.on('Feature Finder', { // cur_frm.refresh_fields("post_vin_cutoff_id_tab"); // } - - + + }, onload: function (frm) { - if (!frm.doc.feature_finder_images){ + if (!frm.doc.feature_finder_images) { $(cur_frm.fields_dict.image_html.wrapper).empty(); } if (!frm.is_new()) { @@ -54,8 +54,7 @@ frappe.ui.form.on('Feature Finder', { if (frm.doc.variant) { frm.toggle_display('feature_name', true) frm.toggle_display('features_names', true) - } else - { + } else { frm.toggle_display('features_names', false) frm.toggle_display('feature_name', false) } @@ -64,28 +63,28 @@ frappe.ui.form.on('Feature Finder', { }, features_names: function (frm) { - + frappe.db.get_list('Feature Finder Master', { - fields: ['name','feature_category'], + fields: ['name', 'feature_category'], filters: { feature_name: frm.doc.features_names, vehicle: frm.doc.vehicle } }).then(records => { - if(records.length>0){ + if (records.length > 0) { frm.doc.feature_name = records[0].name frm.doc.feature_category = records[0].feature_category cur_frm.refresh_fields("feature_name") cur_frm.refresh_fields("feature_category") - }else{ + } else { frm.doc.feature_name = "" - frm.doc.feature_category ="" + frm.doc.feature_category = "" cur_frm.refresh_fields("feature_name") cur_frm.refresh_fields("feature_category") } }) - + }, create_feature_finder_images: function (frm) { if (click_count == 0) { @@ -119,39 +118,39 @@ frappe.ui.form.on('Feature Finder', { }) } }, - + validate: function (frm) { //save swap child table var spec_id_dis = [] var image_id_dis = [] var cont_id_dis = [] - + $(document).ready(function () { $('.specification_bl').find('table > tbody > tr').each(function (index, tr) { spec_id_dis.push(this.id); }); - if(spec_id_dis && spec_id_dis.length>0){ - console.log(spec_id_dis,"---spec_id_dis") - set_display_order_child("Feature Finder Specification", spec_id_dis,frm) + if (spec_id_dis && spec_id_dis.length > 0) { + console.log(spec_id_dis, "---spec_id_dis") + set_display_order_child("Feature Finder Specification", spec_id_dis, frm) } $('.feature_imgbl').find('table > tbody > tr').each(function (index, tr) { image_id_dis.push(this.id); }); - if(image_id_dis && image_id_dis.length>0){ - - set_display_order_child("Feature Finder Images", image_id_dis,frm) + if (image_id_dis && image_id_dis.length > 0) { + + set_display_order_child("Feature Finder Images", image_id_dis, frm) } $('.feature_contbl').find('table > tbody > tr').each(function (index, tr) { cont_id_dis.push(this.id); }); - if(cont_id_dis && cont_id_dis.length>0){ - set_display_order_child("Feature Finder Content", cont_id_dis,frm) + if (cont_id_dis && cont_id_dis.length > 0) { + set_display_order_child("Feature Finder Content", cont_id_dis, frm) } }) - + //end swap child table if (frm.doc.language == "en") { @@ -170,7 +169,7 @@ frappe.ui.form.on('Feature Finder', { language: frm.doc.language, } }).then(records => { - console.log(records,"records") + console.log(records, "records") if (records.length) { frappe.db.set_value('Feature Finder', records[0].name, { display_order: original_display_order @@ -202,8 +201,8 @@ frappe.ui.form.on('Feature Finder', { frm.reload_doc() } }); -function set_display_order_child(doctype_name, values,frm) { - if (values.length>0){ +function set_display_order_child(doctype_name, values, frm) { + if (values.length > 0) { frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.set_display_order", args: { @@ -211,31 +210,31 @@ function set_display_order_child(doctype_name, values,frm) { values: values }, callback: function (r) { - console.log(r.message,"---rmessage") + console.log(r.message, "---rmessage") if (r.message) { frm.refresh() } } }) } - + } function show_images(frm) { var res = $(cur_frm.fields_dict.image_html.wrapper).empty(); var feature_finder_images_ = frm.doc.feature_finder_images.filter(o => o.feature_type == frm.doc.tab_ref) - if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0 && feature_finder_images_.length>0) { - + if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0 && feature_finder_images_.length > 0) { + var img_html = "" img_html += "
" - cur_frm.doc.feature_finder_images.map(val =>{ - if(val.post_vin_cutoff_name==frm.doc.tab_ref){ + cur_frm.doc.feature_finder_images.map(val => { + if (val.post_vin_cutoff_name == frm.doc.tab_ref) { img_html += "
" } - if (val.feature_type==frm.doc.tab_ref){ + if (val.feature_type == frm.doc.tab_ref) { img_html += "
" } }); - + img_html += "
" $(res).append(img_html) } @@ -245,24 +244,24 @@ function custom_tab_html(frm) { var res = $(cur_frm.fields_dict.test_html.wrapper).empty(); var ret = '
' content_custom_dt += '
' - + $(res).find('.feature_contbl').empty() $(res).find('.feature_contbl').append(content_custom_dt) @@ -575,7 +574,7 @@ function custom_tab_html(frm) { $(res).find('.specification_bl').empty() $(res).find('.specification_bl').append(spec_custom_dt) - if(nav_spec.feature_type=='SOP'){ + if (nav_spec.feature_type == 'SOP') { $(res).find('#postvin1').hide() $(res).find('#postvin2').hide() $(res).find('#postvin3').hide() @@ -620,14 +619,14 @@ function custom_tab_html(frm) { // frm.doc.__unsaved = 0 // }) // }); - + $(res).find('.specification_bl').find('.spec_custom_save').click(function (event) { var spec_id_dis = [] $(document).ready(function () { $('.specification_bl').find('table > tbody > tr').each(function (index, tr) { spec_id_dis.push(this.id); }); - set_display_order_child("Feature Finder Specification", spec_id_dis,frm) + set_display_order_child("Feature Finder Specification", spec_id_dis, frm) }) }) @@ -637,7 +636,7 @@ function custom_tab_html(frm) { $('.feature_imgbl').find('table > tbody > tr').each(function (index, tr) { image_id_dis.push(this.id); }); - set_display_order_child("Feature Finder Images", image_id_dis,frm) + set_display_order_child("Feature Finder Images", image_id_dis, frm) }) }) @@ -647,13 +646,13 @@ function custom_tab_html(frm) { $('.feature_contbl').find('table > tbody > tr').each(function (index, tr) { cont_id_dis.push(this.id); }); - set_display_order_child("Feature Finder Content", cont_id_dis,frm) + set_display_order_child("Feature Finder Content", cont_id_dis, frm) }) }) - function set_display_order_child(doctype_name, values,frm) { + function set_display_order_child(doctype_name, values, frm) { frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.set_display_order", args: { @@ -835,18 +834,18 @@ function custom_tab_html(frm) { // // Start counting from the third row // var counter = 3; - + // $(".spec_custom_add").on("click", function (event) { // event.preventDefault(); - + // var newRow = $(''); // var cols = ''; - + // frappe.call({ // method: "smart_service.phase_2.doctype.feature_finder.feature_finder.get_specification_list", // args: { - + // }, // callback: function (r) { // if (r.message) { @@ -857,7 +856,7 @@ function custom_tab_html(frm) { // r.message.map(v=>{ // cols += '' // }) - + // cols += '' // cols += ''; // cols += ''; @@ -871,9 +870,9 @@ function custom_tab_html(frm) { // } // }) - + // }); - + // // Remove row when delete btn is clicked // $(".spec-table").on("click", "#deleteRow", function (event) { // $(this).closest("tr").remove(); @@ -901,12 +900,12 @@ function custom_tab_html(frm) { fieldtype: 'Link', options: "Feature Finder Specification Master", default: spec_dialog_value.specification, - get_query() { - return { - filters: { 'active_status': 'Active' } - } + get_query() { + return { + filters: { 'active_status': 'Active' } } - + } + }, { label: 'Value', @@ -927,7 +926,7 @@ function custom_tab_html(frm) { fieldtype: 'Data', default: spec_dialog_value.feature_type, read_only: 1, - hidden:1 + hidden: 1 }, { label: 'Post Vin Cutoff Name', @@ -935,7 +934,7 @@ function custom_tab_html(frm) { fieldtype: 'Data', default: spec_dialog_value.post_vin_cutoff_name, depends_on: "eval:doc.feature_type=='Post Vin CutOff'", - hidden:1 + hidden: 1 }, ], @@ -948,11 +947,11 @@ function custom_tab_html(frm) { args: { doc_name: frm.doc.name, values: values, - tab_ref:frm.doc.tab_ref + tab_ref: frm.doc.tab_ref }, callback: function (r) { if (r.message.status == "success") { - + cur_frm.reload_doc() cur_frm.refresh() } @@ -998,7 +997,7 @@ function custom_tab_html(frm) { fieldtype: 'Data', default: image_dialog_value.feature_type, read_only: 1, - hidden:1 + hidden: 1 }, { label: 'Post Vin Cutoff Name', @@ -1007,7 +1006,7 @@ function custom_tab_html(frm) { default: image_dialog_value.post_vin_cutoff_name, depends_on: "eval:doc.feature_type=='Post Vin CutOff'", read_only: 1, - hidden:1 + hidden: 1 }, ], // size: 'small', // small, large, extra-large @@ -1019,7 +1018,7 @@ function custom_tab_html(frm) { args: { doc_name: frm.doc.name, values: values, - tab_ref:frm.doc.tab_ref + tab_ref: frm.doc.tab_ref }, callback: function (r) { if (r.message.status == "success") { @@ -1069,7 +1068,7 @@ function custom_tab_html(frm) { fieldtype: 'Data', default: content_dialog_value.feature_type, read_only: 1, - hidden:1 + hidden: 1 }, { label: 'Post Vin Cutoff Name', @@ -1078,7 +1077,7 @@ function custom_tab_html(frm) { default: content_dialog_value.post_vin_cutoff_name, depends_on: "eval:doc.feature_type=='Post Vin CutOff'", read_only: 1, - hidden:1 + hidden: 1 }, ], // size: 'small', // small, large, extra-large @@ -1090,7 +1089,7 @@ function custom_tab_html(frm) { args: { doc_name: frm.doc.name, values: values, - tab_ref:frm.doc.tab_ref + tab_ref: frm.doc.tab_ref }, callback: function (r) { if (r.message.status == "success") { @@ -1109,7 +1108,7 @@ function custom_tab_html(frm) { } function set_display_order(frm) { - + if (frm.doc.variant && frm.doc.vehicle && frm.doc.language) { frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.get_feature_list", diff --git a/smart_service/phase_2/doctype/qwik_service/qwik_service.js b/smart_service/phase_2/doctype/qwik_service/qwik_service.js index c4d61dc..683cdd2 100644 --- a/smart_service/phase_2/doctype/qwik_service/qwik_service.js +++ b/smart_service/phase_2/doctype/qwik_service/qwik_service.js @@ -150,9 +150,9 @@ function custom_tab_html(frm){ frm.doc.tab_ref = $(this)[0].id cur_frm.refresh_fields("tab_ref") frm.reload_doc() - nav_spec.sides = $(this)[0].id + nav_spec.side = $(this)[0].id - qwik_procedure = frm.doc.qwik_procedure.filter(o => o.sides == $(this)[0].id) + qwik_procedure = frm.doc.qwik_procedure.filter(o => o.side == $(this)[0].id) } frappe.call({ @@ -319,7 +319,7 @@ function custom_tab_html(frm){ label: 'Content', fieldname: 'content', fieldtype: 'Text Editor', - default: qwik_dialog_value.content + default: qwik_dialog_value.content, }, { label: 'Side', @@ -349,6 +349,21 @@ function custom_tab_html(frm){ } }) } + var is_content =1 + if(values.content && values.content==""){ + values.content.map(v=>{ + if(values.content=="Null"){ + is_content=0 + } + }) + + } + if(is_content==1){ + values.content=="Null" + // var df = frappe.meta.get_docfield("Instructions", "content_type", cur_frm.doc.name); + // df.read_only = 1; + cur_frm.refresh_fields("values.content"); + } qwik_dia.hide(); } }); @@ -357,10 +372,6 @@ function custom_tab_html(frm){ } } - - - - function set_display_order(frm){ if (frm.is_new()) { diff --git a/smart_service/phase_2/doctype/qwik_service/qwik_service.json b/smart_service/phase_2/doctype/qwik_service/qwik_service.json index d31f8ba..354e314 100644 --- a/smart_service/phase_2/doctype/qwik_service/qwik_service.json +++ b/smart_service/phase_2/doctype/qwik_service/qwik_service.json @@ -12,12 +12,12 @@ "kilometers", "language", "service_time", + "keywords", "column_break_vmliz", "vehicle", "display_order", "active_status", "pdf", - "keywords", "section_break_mosyy", "content", "qwik_procedure", @@ -143,7 +143,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-09-28 10:45:37.763086", + "modified": "2023-09-28 10:59:46.184734", "modified_by": "Administrator", "module": "Phase-2", "name": "Qwik Service",