Browse Source

QWIK field udpate

version2
venkata akhil 1 year ago
parent
commit
f38c446e91
  1. 6
      smart_service/apis/v2/master.py
  2. 185
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  3. 25
      smart_service/phase_2/doctype/qwik_service/qwik_service.js
  4. 4
      smart_service/phase_2/doctype/qwik_service/qwik_service.json

6
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:

185
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 += "<div style='height: 300px;overflow-y: auto;overflow-x: hidden;border:1px solid var(--table-border-color);margin: 5px 0px 10px 0px;'><div style='padding: 5px;' class='row'>"
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 += "<div class='col-3' style='padding-top:13px;'><img src=" + "'" + val.image + "'" + "></div>"
}
if (val.feature_type==frm.doc.tab_ref){
if (val.feature_type == frm.doc.tab_ref) {
img_html += "<div class='col-3' style='padding-top:13px;'><img src=" + "'" + val.image + "'" + "></div>"
}
});
img_html += "</div></div>"
$(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 = '<div class="main"><div class="custom_tab style="border:1px solid var(--table-border-color);"><ul class="nav nav-tabs" role="tablist">'
ret += '<li class="nav-item">'
if(frm.doc.sop_name){
ret += '<a class="nav-link active" id="SOP" data-toggle="tab" role="tab" value="SOP">'+ frm.doc.sop_name+'</a>'
}else{
if (frm.doc.sop_name) {
ret += '<a class="nav-link active" id="SOP" data-toggle="tab" role="tab" value="SOP">' + frm.doc.sop_name + '</a>'
} else {
ret += '<a class="nav-link active" id="SOP" data-toggle="tab" role="tab" value="SOP">SOP</a>'
}
ret += '</li>'
if (frm.doc.post_vin_cutoff_id_tab && frm.doc.post_vin_cutoff_id_tab.length > 0) {
frm.doc.post_vin_cutoff_id_tab.map(val => {
ret += '<li class="nav-item">'
if(val.post_vin_cutoff_name=="SOP"){
if (val.post_vin_cutoff_name == "SOP") {
// ret += '<a class="nav-link" id="' + val.post_vin_cutoff_name + '" value=' + val.post_vin_cutoff_name + ' data-toggle="tab" role="tab">' + val.post_vin_cutoff_name + '</a>'
}
else{
else {
ret += '<a class="nav-link" id="' + val.post_vin_cutoff_name + '" value=' + val.post_vin_cutoff_name + ' data-toggle="tab" role="tab">PV-' + val.post_vin_cutoff_name + '</a>'
}
ret += '</li>'
})
@ -275,28 +274,28 @@ function custom_tab_html(frm) {
$(res).find('.main').append(`<div class="feature_contbl"></div>`)
$(res).find('.main').append(`<div class="feature_imgbl"></div>`)
$(res).find('.main').append(`<div class="specification_bl"></div>`)
res.append(`<style>.custom_tab{border:1px solid var(--table-border-color);}.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {background-color:lavender !important;}.nav-tabs {
border-bottom:none !important;}.feature_contbl{margin:10px;}.specification_bl{margin:10px;}.feature_imgbl{margin:10px;}.main{border: 1px solid var(--table-border-color);margin:15px 0px 15px 0px}.spec_custom_add{margin:10px 0px 0px 0px}</style>`)
if(frm.doc.tab_ref){
if (frm.doc.tab_ref) {
$('.nav').find('.nav-link').removeClass('active')
$('.nav').find('#'+frm.doc.tab_ref).addClass('active')
$('.nav').find('#' + frm.doc.tab_ref).addClass('active')
}
var specification = ""
var feature_finder_images = ""
var feature_finder_content = ""
if (frm.doc.specification && frm.doc.feature_finder_images && frm.doc.feature_finder_content){
if (frm.doc.specification && frm.doc.feature_finder_images && frm.doc.feature_finder_content) {
specification = frm.doc.specification.filter(o => o.feature_type == "SOP")
feature_finder_images = frm.doc.feature_finder_images.filter(o => o.feature_type == "SOP")
feature_finder_content = frm.doc.feature_finder_content.filter(o => o.feature_type == "SOP")
if(frm.doc.tab_ref !='SOP'){
if (frm.doc.tab_ref != 'SOP') {
specification = frm.doc.specification.filter(o => o.post_vin_cutoff_name == frm.doc.tab_ref)
feature_finder_images = frm.doc.feature_finder_images.filter(o => o.post_vin_cutoff_name == frm.doc.tab_ref)
feature_finder_content = frm.doc.feature_finder_content.filter(o => o.post_vin_cutoff_name == frm.doc.tab_ref)
@ -305,14 +304,14 @@ function custom_tab_html(frm) {
feature_finder_images.sort((a, b) => a.display_order - b.display_order);
feature_finder_content.sort((a, b) => a.display_order - b.display_order);
}
var spec_dialog_value = ""
var image_dialog_value = ""
var content_dialog_value = ""
var nav_spec = {}
nav_spec.feature_type = "SOP"
if(frm.doc.tab_ref !='SOP'){
if (frm.doc.tab_ref != 'SOP') {
nav_spec.feature_type = "Post Vin CutOff"
nav_spec.post_vin_cutoff_name = frm.doc.tab_ref
}
@ -332,7 +331,7 @@ function custom_tab_html(frm) {
specification.sort((a, b) => a.display_order - b.display_order);
feature_finder_images.sort((a, b) => a.display_order - b.display_order);
feature_finder_content.sort((a, b) => a.display_order - b.display_order);
frappe.call({
method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_tab_ref",
args: {
@ -340,7 +339,7 @@ function custom_tab_html(frm) {
tab_ref: "SOP"
},
callback: function (r) {
console.log("tab",r)
console.log("tab", r)
frm.refresh_field('tab_ref')
}
})
@ -360,7 +359,7 @@ function custom_tab_html(frm) {
feature_finder_images.sort((a, b) => a.display_order - b.display_order);
feature_finder_content.sort((a, b) => a.display_order - b.display_order);
frappe.call({
method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_tab_ref",
args: {
@ -375,8 +374,8 @@ function custom_tab_html(frm) {
}
all_tabs()
})
@ -451,7 +450,7 @@ function custom_tab_html(frm) {
//end heading
//list
var specification_count = 0
@ -469,9 +468,9 @@ function custom_tab_html(frm) {
// spec_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
// }
// else {
// spec_custom_dt += '<td> </td>'
// spec_custom_dt += '<td> </td>'
// }
spec_custom_dt += '<td id=' + val.name + ' class="spec_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
spec_custom_dt += '</tr>'
@ -496,7 +495,7 @@ function custom_tab_html(frm) {
// image_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
// }
// else {
// image_custom_dt += '<td> </td>'
// image_custom_dt += '<td> </td>'
// }
image_custom_dt += '<td id=' + val.name + ' class="image_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
@ -522,7 +521,7 @@ function custom_tab_html(frm) {
// content_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
// }
// else {
// content_custom_dt += '<td> </td>'
// content_custom_dt += '<td> </td>'
// }
content_custom_dt += '<td id=' + val.name + ' class="content_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
@ -564,7 +563,7 @@ function custom_tab_html(frm) {
image_custom_dt += '</div>'
content_custom_dt += '</div>'
$(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 = $('<tr draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)">');
// 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 += '<option value="'+v.name+'">'+v.name+'</option>'
// })
// cols += '</select></td>'
// cols += '<td><input class="form-control rounded-0" type="text" name="value" placeholder="value"></td>';
// cols += '<td><input class="form-control rounded-0" type="text" name="active_status" placeholder="active_status"></td>';
@ -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",

25
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()) {

4
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",

Loading…
Cancel
Save