Browse Source

Qwik fixes

version2
venkataakhil 1 year ago
parent
commit
d2ca624140
  1. 56
      smart_service/apis/v2/master.py
  2. 32
      smart_service/phase_2/doctype/qwik_service/qwik_service.js
  3. 129
      smart_service/public/js/common_fun.js

56
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
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

32
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("<b>Service Time:</b> Only <b> 3 </b> 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')
}
})
}

129
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 = '<input id='+count+' type="checkbox" class="speccheck grid-row-check pull-left"><span class="spec_check">'+count+'</span>'
$(h).find('#spec_count').html(html)
count +=1
var html = '<input id=' + count + ' type="checkbox" class="speccheck grid-row-check pull-left"><span class="spec_check">' + count + '</span>'
$(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("<span>Not Saved</span>");
// $('.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 = '<input id='+count+' type="checkbox" class="imagecheck grid-row-check pull-left"><span class="image_check">'+count+'</span>'
$(h).find('#image_count').html(html)
count +=1
var html = '<input id=' + count + ' type="checkbox" class="imagecheck grid-row-check pull-left"><span class="image_check">' + count + '</span>'
$(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 = '<input id='+count+' type="checkbox" class="contentcheck grid-row-check pull-left"><span class="content_check">'+count+'</span>'
$(h).find('#cont_count').html(html)
count +=1
var html = '<input id=' + count + ' type="checkbox" class="contentcheck grid-row-check pull-left"><span class="content_check">' + count + '</span>'
$(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 = '<input id=' + count + ' type="checkbox" class="qwikcheck grid-row-check pull-left"><span class="qwik_check">' + count + '</span>'
$(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("<span>Not Saved</span>");
// $('.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);
}
}
}

Loading…
Cancel
Save