From d2ca624140df1eaf5f1f2738d7d5557b91b574f2 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Fri, 22 Sep 2023 11:02:13 +0530 Subject: [PATCH] Qwik fixes --- smart_service/apis/v2/master.py | 56 ++++++-- .../doctype/qwik_service/qwik_service.js | 32 ++++- smart_service/public/js/common_fun.js | 129 ++++++++++++------ 3 files changed, 159 insertions(+), 58 deletions(-) diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index 90c346a..bbc8815 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -109,7 +109,7 @@ def get_feature_finder(vehicle, variant, language): where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1) f['sop'] = {'content': sop_content, 'images': sop_images, - 'specificaton': sop_specification,'sop_name':f['sop_name']} + 'specificaton': sop_specification, 'sop_name': f['sop_name']} post_vin_data = frappe.db.sql(f'''select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id from `tabPost Vin Cutoff ID` where parent = '{f['name']}';''', as_dict=1) for p in post_vin_data: @@ -169,11 +169,10 @@ def new_publish(): elif module == "Mahindra Special Tool Information": flag, data = get_special_tool_information(vehicle) - + elif module == "Qwik Service": - flag, data = get_qwik_service(variant,language) - return data - + flag, data = get_qwik_service(variant, language) + if flag: return {'status': 1, 'error': None, 'data': data} else: @@ -244,20 +243,53 @@ def get_special_tool_information(vehicle): return True, special_tool_details except Exception as e: return False, e - + @frappe.whitelist(methods=['POST'], allow_guest=1) -def get_qwik_service(variant,language): +def get_qwik_service(variant, language): try: - qwik_service_details=frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status, + qwik_service_details = frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status, pdf,display_order,keywords,my_id from `tabQwik Service` where variant='%s' && - language='%s';'''%(variant,language),as_dict=1) + language='%s';''' % (variant, language), as_dict=1) for q in qwik_service_details: q['content'] = frappe.db.sql('''select idx as 'display_order',content_type,content from `tabQwik Service Content` - where parent='%s';'''%(q['name']),as_dict=1) + where parent='%s';''' % (q['name']), as_dict=1) for p in qwik_service_details: p['qwik_procedure'] = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure` - where parent ='%s';'''%(p['name']),as_dict=1) + where parent ='%s';''' % (p['name']), as_dict=1) return True, qwik_service_details except Exception as e: - return False, e \ No newline at end of file + return False, e + + +@frappe.whitelist(allow_guest=1) +def update_publish_mapping(vehicle, variant, language, module): + frappe.set_user('Administrator') + pub_data = frappe.db.get_list('Module Publish Mapping', filters={ + "vehicle": vehicle, + "variant": variant, + "language": language + }, fields=['name']) + + if pub_data: + doc = frappe.get_doc('Module Publish Mapping', pub_data[0]['name']) + else: + doc = frappe.get_doc({ + 'doctype': 'Module Publish Mapping', + "vehicle": vehicle, + "variant": variant, + "language": language + }) + if module == 'Automotive System': + doc.automotive_system = 1 + doc.tsb = 1 + doc.fsa = 1 + doc.tekalert = 1 + + elif module == 'Feature Finder': + doc.feature_finder = 1 + + elif module == 'Repair service': + doc.repairservice_check_sheet = 1 + doc.save() + return 1 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 eb03e99..0c95f71 100644 --- a/smart_service/phase_2/doctype/qwik_service/qwik_service.js +++ b/smart_service/phase_2/doctype/qwik_service/qwik_service.js @@ -16,12 +16,14 @@ frappe.ui.form.on('Qwik Service', { custom_tab_html(frm) } set_display_order(frm) + variant(frm) }, onload:function(frm){ if (!frm.is_new()) { custom_tab_html(frm) } set_display_order(frm) + variant(frm) }, validate:function(frm){ cur_frm.refresh_fields("display_order") @@ -55,7 +57,8 @@ frappe.ui.form.on('Qwik Service', { } } }); - } + } + check_field_character(frm.doc.service_time) }, after_save: function (frm) { cur_frm.refresh_fields("display_order") @@ -77,7 +80,6 @@ frappe.ui.form.on('Qwik Service', { frm.refresh_field('kilometers') } }) - }, }); @@ -417,3 +419,29 @@ frappe.ui.form.on('Qwik Service Content',{ } }) + +function check_field_character(field_name) { + if (field_name) { + if (field_name.length > 1) { + if (field_name.length > 3) { + frappe.throw("Service Time: Only 3 characters are allowed") + frappe.validated = false; + } + } + } +} + +function variant(frm){ + frappe.call({ + method: "smart_service.phase_2.doctype.qwik_service.qwik_service.get_kilometer", + args: { + vehicle: frm.doc.vehicle, + service_kilometers: frm.doc.service_kilometers + }, + callback: function (r) { + console.log(r.message) + frm.set_df_property('kilometers', 'options', r.message); + frm.refresh_field('kilometers') + } + }) +} diff --git a/smart_service/public/js/common_fun.js b/smart_service/public/js/common_fun.js index b5fc1db..57b688b 100644 --- a/smart_service/public/js/common_fun.js +++ b/smart_service/public/js/common_fun.js @@ -1,26 +1,28 @@ var row; var row1; var row2; -function dragstartFunction(evt){ - row = evt.target; +var row3; + +function dragstartFunction(evt) { + row = evt.target; } -function dragovertFunction(evt){ +function dragovertFunction(evt) { var global_name = 1 var e = evt; - e.preventDefault(); - let children= Array.from(e.target.parentNode.parentNode.children); + e.preventDefault(); + let children = Array.from(e.target.parentNode.parentNode.children); //change count value var count = 1 var unchecked_value = 0 children.map(h => { - var html = ''+count+'' - $(h).find('#spec_count').html(html) - - - count +=1 + var html = '' + count + '' + $(h).find('#spec_count').html(html) + + + count += 1 }) - $( document ).ready(function() { + $(document).ready(function () { // cur_frm.doc.__unsaved = 1 // $('.title-area').find('.indicator-pill').remove() $('.title-area').find('.indicator-pill').removeClass("hide"); @@ -28,38 +30,38 @@ function dragovertFunction(evt){ console.log("hiii") $('.title-area').find('.indicator-pill').find('span').remove() $('.title-area').find('.indicator-pill').append("Not Saved"); - // $('.specification_bl').find('.spec_custom_save').css("display","inline-block") + // $('.specification_bl').find('.spec_custom_save').css("display","inline-block") }) //end - if(children.indexOf(e.target.parentNode)>children.indexOf(row)){ + if (children.indexOf(e.target.parentNode) > children.indexOf(row)) { e.target.parentNode.after(row); } - else{ - e.target.parentNode.before(row); + else { + e.target.parentNode.before(row); } } -function dragstartFunction_1(evt){ - row1= evt.target; +function dragstartFunction_1(evt) { + row1 = evt.target; } -function dragovertFunction_1(evt){ +function dragovertFunction_1(evt) { var global_name = 1 var e = evt; - e.preventDefault(); - let children= Array.from(e.target.parentNode.parentNode.children); + e.preventDefault(); + let children = Array.from(e.target.parentNode.parentNode.children); //change count value var count = 1 var unchecked_value = 0 children.map(h => { - var html = ''+count+'' - $(h).find('#image_count').html(html) - - - count +=1 + var html = '' + count + '' + $(h).find('#image_count').html(html) + + + count += 1 }) - $( document ).ready(function() { + $(document).ready(function () { // cur_frm.doc.__unsaved = 1 // $('.title-area').find('.indicator-pill').remove() $('.title-area').find('.indicator-pill').removeClass("hide"); @@ -69,36 +71,36 @@ function dragovertFunction_1(evt){ // $('.feature_imgbl').find('.image_custom_save').css("display","inline-block") }) //end - if(children.indexOf(e.target.parentNode)>children.indexOf(row1)){ + if (children.indexOf(e.target.parentNode) > children.indexOf(row1)) { e.target.parentNode.after(row1); } - else{ - e.target.parentNode.before(row1); + else { + e.target.parentNode.before(row1); } } -function dragstartFunction_2(evt){ - row2 = evt.target; +function dragstartFunction_2(evt) { + row2 = evt.target; } -function dragovertFunction_2(evt){ +function dragovertFunction_2(evt) { var global_name = 1 var e = evt; - e.preventDefault(); - let children= Array.from(e.target.parentNode.parentNode.children); + e.preventDefault(); + let children = Array.from(e.target.parentNode.parentNode.children); //change count value var count = 1 var unchecked_value = 0 children.map(h => { - var html = ''+count+'' - $(h).find('#cont_count').html(html) - - - count +=1 + var html = '' + count + '' + $(h).find('#cont_count').html(html) + + + count += 1 }) - $( document ).ready(function() { + $(document).ready(function () { // cur_frm.doc.__unsaved = 1 // $('.title-area').find('.indicator-pill').remove() $('.title-area').find('.indicator-pill').removeClass("hide"); @@ -108,10 +110,49 @@ function dragovertFunction_2(evt){ // $('.feature_contbl').find('.content_custom_save').css("display","inline-block") }) //end - if(children.indexOf(e.target.parentNode)>children.indexOf(row2)){ + if (children.indexOf(e.target.parentNode) > children.indexOf(row2)) { e.target.parentNode.after(row2); } - else{ - e.target.parentNode.before(row2); + else { + e.target.parentNode.before(row2); + } +} + + + +function dragstartFunctionQwik(evt) { + row3 = evt.target; +} +function dragovertFunctionQwik(evt) { + var global_name = 1 + var e = evt; + e.preventDefault(); + let children = Array.from(e.target.parentNode.parentNode.children); + //change count value + var count = 1 + var unchecked_value = 0 + children.map(h => { + var html = '' + count + '' + $(h).find('#qwik_count').html(html) + + + count += 1 + }) + $(document).ready(function () { + // cur_frm.doc.__unsaved = 1 + // $('.title-area').find('.indicator-pill').remove() + $('.title-area').find('.indicator-pill').removeClass("hide"); + $('.title-area').find('.indicator-pill').addClass("orange"); + console.log("hiii") + $('.title-area').find('.indicator-pill').find('span').remove() + $('.title-area').find('.indicator-pill').append("Not Saved"); + // $('.specification_bl').find('.spec_custom_save').css("display","inline-block") + }) + //end + if (children.indexOf(e.target.parentNode) > children.indexOf(row)) { + e.target.parentNode.after(row); + } + else { + e.target.parentNode.before(row); } -} \ No newline at end of file +}