@ -10,35 +10,25 @@ cur_frm.fields_dict['variant_mapping'].get_query = function (doc, cdt, cdn) {
}
} ;
} ;
var selected_module = ''
var selected_module = ''
cur_frm . fields_dict [ 'vehicle' ] . get_query = function ( doc , cdt , cdn ) {
return { query : "smart_service.masters.doctype.vehicle.vehicle.vehicle_filter" , } ;
} ;
let lang_set_first_time = true ;
frappe . ui . form . on ( 'Publish Test' , {
// publish_module:function(frm){
// if(frm.doc.publish_module=='Automotive'){
// selected_module=1
// }
// else{
// selected_module=0
// }
// },
onload : function ( frm ) {
// $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
if ( frm . doc . docstatus == 0 && ! frm . is_new ( ) && frm . doc . publish_type != "Global" && frm . doc . publish_module == 'Others' ) {
if ( frm . doc . docstatus == 0 && ! frm . is_new ( ) && frm . doc . publish_type != "Global" && frm . doc . publish_module == 'Others' ) {
$ ( '[data-route="Form/Publish Test/' + frm . doc . name + '"]' ) . find ( '.primary-action' ) . html ( "Internal Publish" )
}
if ( frm . doc . docstatus == 0 && frm . doc . publish_type == "Global" && frm . doc . publish_module == 'Others' ) {
if ( frm . doc . docstatus == 0 && frm . doc . publish_type == "Global" && frm . doc . publish_module == 'Others' ) {
$ ( '[data-route="Form/Publish Test/' + frm . doc . name + '"]' ) . find ( '.primary-action' ) . html ( "Global Publish" )
}
if ( frm . doc . status = "Published" && frm . doc . publish_module == 'Others' ) {
frm . set_df_property ( 'repair_checksheet_publish' , 'hidden' , 0 )
if ( frm . doc . status = "Published" && frm . doc . publish_module == 'Others' ) {
frm . set_df_property ( 'repair_checksheet_publish' , 'hidden' , 0 )
frm . refresh_field ( 'repair_checksheet_publish' )
@ -86,250 +76,250 @@ frappe.ui.form.on('Publish Test', {
if ( frm . doc . docstatus == 0 && frm . doc . publish_type == "Global" ) {
$ ( '[data-route="Form/Publish Test/' + frm . doc . name + '"]' ) . find ( '.primary-action' ) . html ( "Global Publish" )
}
if ( frm . doc . publish_module == 'Automotive' ) {
if ( frm . doc . publish_module == 'Automotive' ) {
cur_frm . set_df_property ( 'system_mapping' , "read_only" , 1 ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-add-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-upload' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-remove-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-insert-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
frm . fields_dict . system_mapping . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-add-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-upload' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-remove-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-insert-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'system_mapping' ] . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
frm . fields_dict . system_mapping . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-add-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-upload' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-remove-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-insert-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
frm . fields_dict . variant_mapping_assets . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-add-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-upload' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-remove-all-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-remove-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-delete-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-delete_all_rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-move-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
frm . fields_dict . publish_documents . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
document . querySelectorAll ( "[data-fieldname='km_report']" ) [ 1 ] . style . backgroundColor = "#e31a37" ;
document . querySelectorAll ( "[data-fieldname='km_report']" ) [ 1 ] . style . color = "#FFFFFF" ;
document . querySelectorAll ( "[data-fieldname='add_variant_mapping_to_publish']" ) [ 1 ] . style . backgroundColor = "#e31a37" ;
document . querySelectorAll ( "[data-fieldname='add_variant_mapping_to_publish']" ) [ 1 ] . style . color = "#FFFFFF" ;
if ( frm . doc . docstatus === 1 && frm . doc . publish_type == "Internal" && frm . doc . publish_status == 'Published' && ! frm . doc . global_publish && frappe . user . has_role ( '_Publisher' ) ) {
frappe . call ( {
method : "smart_service.transactions.doctype.publish.publish.max_publish" ,
args : {
"doc" : frm . doc . name ,
} ,
callback : function ( r ) {
if ( r . message ) {
if ( r . message == frm . doc . version ) {
frm . add_custom_button ( __ ( 'Global Publish' ) , function ( ) {
frappe . call ( {
method : "smart_service.transactions.doctype.publish.publish.global_publish" ,
args : {
"doc" : frm . doc . name ,
} ,
callback : function ( r ) {
cur_frm . reload_doc ( ) ;
}
} ) ;
} ) . addClass ( "btn-warning" ) . css ( { 'background-color' : '#f5b0cd' , 'color' : 'black' } ) ;
}
}
}
} )
}
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-add-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-upload' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-remove-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-insert-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'variant_mapping_assets' ] . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
frm . fields_dict . variant_mapping_assets . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-add-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-upload' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-remove-all-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-remove-rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-delete-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-delete_all_rows' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-move-row' ) . hide ( ) ;
cur_frm . fields_dict [ 'publish_documents' ] . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
frm . fields_dict . publish_documents . grid . wrapper . find ( '.grid-append-row' ) . hide ( ) ;
document . querySelectorAll ( "[data-fieldname='km_report']" ) [ 1 ] . style . backgroundColor = "#e31a37" ;
document . querySelectorAll ( "[data-fieldname='km_report']" ) [ 1 ] . style . color = "#FFFFFF" ;
document . querySelectorAll ( "[data-fieldname='add_variant_mapping_to_publish']" ) [ 1 ] . style . backgroundColor = "#e31a37" ;
document . querySelectorAll ( "[data-fieldname='add_variant_mapping_to_publish']" ) [ 1 ] . style . color = "#FFFFFF" ;
if ( frm . doc . docstatus === 1 && frm . doc . publish_type == "Internal" && frm . doc . publish_status == 'Published' && ! frm . doc . global_publish && frappe . user . has_role ( '_Publisher' ) ) {
frappe . call ( {
method : "smart_service.transactions.doctype.publish.publish.max_publish" ,
args : {
"doc" : frm . doc . name ,
} ,
callback : function ( r ) {
if ( r . message ) {
if ( r . message == frm . doc . version ) {
frm . add_custom_button ( __ ( 'Global Publish' ) , function ( ) {
if ( frm . doc . docstatus === 1 && frm . doc . publish_status == 'To Publish' && frappe . user . has_role ( '_Publisher' ) ) {
frm . add_custom_button ( __ ( 'Publish' ) , function ( ) {
frappe . confirm ( 'Are you sure you want to Publish?' ,
( ) => {
// action to perform if Yes is selected
if ( frm . doc . vehicle && frm . doc . language && frm . doc . publish_type ) {
frappe . call ( {
method : "smart_service.transactions.doctype.publish.publish.global_publish" ,
method : 'smart_service.transactions.doctype.publish.publish.cal_ver' ,
args : {
"doc" : frm . doc . name ,
vehicle : frm . doc . vehicle ,
lang : frm . doc . language ,
publish_type : frm . doc . publish_type ,
doc : frm . doc . name
} ,
callback : function ( r ) {
cur_frm . reload_doc ( ) ;
}
} ) ;
} ) . addClass ( "btn-warning" ) . css ( { 'background-color' : '#f5b0cd' , 'color' : 'black' } ) ;
}
}
}
} )
}
callback : ( r ) => {
frm . set_value ( 'version' , r . message ) ;
cur_frm . refresh_field ( 'version' )
if ( frm . doc . docstatus === 1 && frm . doc . publish_status == 'To Publish' ) {
frappe . call ( {
// method: "smart_service.apis.publish_api.api_procedure",
method : "smart_service.apis.publish_api.new_publish" ,
args : {
"args" : frm . doc . name ,
"publish_type" : frm . doc . publish_type ,
"vehicle" : frm . doc . vehicle ,
"language" : frm . doc . language ,
"version" : frm . doc . version
} ,
callback : function ( r ) {
// if (r.message[0]) {
frm . set_value ( 'publish_status' , 'Published' ) ;
frm . page . clear_primary_action ( "Publish" ) ;
frm . set_value ( 'actual_published_date' , frappe . datetime . nowdate ( ) ) ;
frappe . call ( {
method : "smart_service.transactions.doctype.publish.publish.update_procedure_value" ,
args : {
"name" : frm . doc . name ,
"file_path" : r . message [ 1 ] ,
} ,
callback : ( r ) => {
// frm.save('Update');
}
} )
frappe . msgprint ( {
title : __ ( 'Notification' ) ,
message : __ ( '<b>Successfully Published:</b> ' + r . message [ 1 ] ) ,
primary_action : {
action ( values ) {
frm . save ( 'Update' ) ;
}
}
} ) ;
// }
// else {
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Not Successfully Published:</b> ' + r.message[1]),
// // primary_action: {
// // action(values) {
// // frm.save('Update');
// // }
// // }
// });
// }
// if (r.message != "Failed to save file") {
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
// args: {
// "name": frm.doc.name,
// "file_path": r.message,
// },
// callback: (r) => {
// // frm.save('Update');
// }
// })
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// } else {
// frappe.msgprint('Publish Failed')
// }
}
} ) ;
}
} ,
} )
}
} , ( ) => {
// action to perform if No is selected
} ) ;
} ) . addClass ( "btn-warning" ) . css ( { 'background-color' : '#f5b0cd' , 'color' : 'black' } ) ;
} else if ( frm . doc . publish_status == 'Published' ) {
frm . set_read_only ( ) ;
frm . set_df_property ( 'add_variant_mapping_to_publish' , 'hidden' , 1 ) ;
}
if ( frm . doc . docstatus === 1 && frm . doc . publish_status == 'To Publish' && frappe . user . has_role ( '_Publisher' ) ) {
frm . add_custom_button ( __ ( 'Publish' ) , function ( ) {
frappe . confirm ( 'Are you sure you want to Publish?' ,
( ) => {
// action to perform if Yes is selected
if ( frm . doc . vehicle && frm . doc . language && frm . doc . publish_type ) {
frappe . call ( {
method : 'smart_service.transactions.doctype.publish.publish.cal_ver' ,
args : {
vehicle : frm . doc . vehicle ,
lang : frm . doc . language ,
publish_type : frm . doc . publish_type ,
doc : frm . doc . name
} ,
callback : ( r ) => {
frm . set_value ( 'version' , r . message ) ;
cur_frm . refresh_field ( 'version' )
if ( frm . doc . docstatus === 1 && frm . doc . publish_status == 'To Publish' ) {
frappe . call ( {
// method: "smart_service.apis.publish_api.api_procedure",
method : "smart_service.apis.publish_api.new_publish" ,
args : {
"args" : frm . doc . name ,
"publish_type" : frm . doc . publish_type ,
"vehicle" : frm . doc . vehicle ,
"language" : frm . doc . language ,
"version" : frm . doc . version
} ,
callback : function ( r ) {
// if (r.message[0]) {
frm . set_value ( 'publish_status' , 'Published' ) ;
frm . page . clear_primary_action ( "Publish" ) ;
frm . set_value ( 'actual_published_date' , frappe . datetime . nowdate ( ) ) ;
frappe . call ( {
method : "smart_service.transactions.doctype.publish.publish.update_procedure_value" ,
args : {
"name" : frm . doc . name ,
"file_path" : r . message [ 1 ] ,
} ,
callback : ( r ) => {
// frm.save('Update');
}
} )
frappe . msgprint ( {
title : __ ( 'Notification' ) ,
message : __ ( '<b>Successfully Published:</b> ' + r . message [ 1 ] ) ,
primary_action : {
action ( values ) {
frm . save ( 'Update' ) ;
}
}
} ) ;
// }
// else {
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Not Successfully Published:</b> ' + r.message[1]),
// // primary_action: {
// // action(values) {
// // frm.save('Update');
// // }
// // }
// });
// }
// if (r.message != "Failed to save file") {
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
// args: {
// "name": frm.doc.name,
// "file_path": r.message,
// },
// callback: (r) => {
// // frm.save('Update');
// }
// })
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// } else {
// frappe.msgprint('Publish Failed')
// }
}
} ) ;
if ( frm . doc . docstatus === 0 && frm . doc . publish_status == 'To Publish' ) {
frm . get_field ( 'system_mapping' ) . grid . add_custom_button ( __ ( 'Add to Publish' ) , function ( ) {
let added = 0 ;
let topublish = [ ] ;
if ( frm . doc . publish_type == 'Global' ) { topublish = [ 'Publish Ready' ] ; } else { topublish = [ 'Review Pending' , 'Publish Ready' , 'Approval Pending' ] ; }
frm . doc . system_mapping . forEach ( row => {
if ( topublish . indexOf ( row . procedure_status ) > - 1 ) {
let dulicate = false ;
if ( frm . doc . publish_documents ) {
frm . doc . publish_documents . forEach ( publishrow => {
if ( frm . doc . variant_mapping == publishrow . variant_mapping &&
row . systems == publishrow . system &&
row . sub_systems == publishrow . sub_system && row . procedure == publishrow . procedure_link ) {
dulicate = true ;
}
} ,
} )
} ) ;
}
if ( dulicate === false ) {
let child = cur_frm . add_child ( "publish_documents" ) ;
child . variant_mapping = frm . doc . variant_mapping ;
child . system = row . systems ;
child . sub_system = row . sub_systems ;
child . procedure_link = row . procedure ;
child . procedure_status = row . procedure_status ;
child . update_procedure_status = row . procedure_status ;
child . item_category = "System Mapping" ;
child . variant = frm . doc . variant ;
refresh_field ( "publish_documents" ) ;
added += 1 ;
}
}
} , ( ) => {
// action to perform if No is selected
} ) ;
} ) . addClass ( "btn-warning" ) . css ( { 'background-color' : '#f5b0cd' , 'color' : 'black' } ) ;
} else if ( frm . doc . publish_status == 'Published' ) {
frm . set_read_only ( ) ;
frm . set_df_property ( 'add_variant_mapping_to_publish' , 'hidden' , 1 ) ;
}
if ( frm . doc . docstatus === 0 && frm . doc . publish_status == 'To Publish' ) {
frm . get_field ( 'system_mapping' ) . grid . add_custom_button ( __ ( 'Add to Publish' ) , function ( ) {
let added = 0 ;
let topublish = [ ] ;
if ( frm . doc . publish_type == 'Global' ) { topublish = [ 'Publish Ready' ] ; } else { topublish = [ 'Review Pending' , 'Publish Ready' , 'Approval Pending' ] ; }
frm . doc . system_mapping . forEach ( row => {
if ( topublish . indexOf ( row . procedure_status ) > - 1 ) {
let dulicate = false ;
if ( frm . doc . publish_documents ) {
frm . doc . publish_documents . forEach ( publishrow => {
if ( frm . doc . variant_mapping == publishrow . variant_mapping &&
row . systems == publishrow . system &&
row . sub_systems == publishrow . sub_system && row . procedure == publishrow . procedure_link ) {
dulicate = true ;
}
} ) ;
}
if ( dulicate === false ) {
let child = cur_frm . add_child ( "publish_documents" ) ;
child . variant_mapping = frm . doc . variant_mapping ;
child . system = row . systems ;
child . sub_system = row . sub_systems ;
child . procedure_link = row . procedure ;
child . procedure_status = row . procedure_status ;
child . update_procedure_status = row . procedure_status ;
child . item_category = "System Mapping" ;
child . variant = frm . doc . variant ;
refresh_field ( "publish_documents" ) ;
added += 1 ;
}
}
if ( added ) { frappe . msgprint ( __ ( added + " Doc(s) Added" ) ) ; }
else { frappe . msgprint ( __ ( "No Doc Added" ) ) ; }
} ) ;
frm . fields_dict . system_mapping . grid . grid_buttons . find ( '.btn-custom' ) . removeClass ( 'btn-default' ) . addClass ( 'btn-primary' ) ;
if ( added ) { frappe . msgprint ( __ ( added + " Doc(s) Added" ) ) ; }
else { frappe . msgprint ( __ ( "No Doc Added" ) ) ; }
} ) ;
frm . fields_dict . system_mapping . grid . grid_buttons . find ( '.btn-custom' ) . removeClass ( 'btn-default' ) . addClass ( 'btn-primary' ) ;
}
if ( frm . doc . docstatus === 0 && frm . doc . publish_status == 'To Publish' ) {
frm . get_field ( 'variant_mapping_assets' ) . grid . add_custom_button ( __ ( 'Add to Publish' ) , function ( ) {
let added = 0 ;
frm . doc . variant_mapping_assets . forEach ( row => {
if ( row . active_status == "Active" || row . active_status == "Inactive" ) {
let dulicate = false ;
if ( frm . doc . publish_documents ) {
frm . doc . publish_documents . forEach ( publishrow => {
if ( frm . doc . variant_mapping == publishrow . variant_mapping &&
row . category == publishrow . asset_category && row . attach_file == publishrow . attach_file ) {
dulicate = true ;
}
} ) ;
}
if ( dulicate === false ) {
let child = cur_frm . add_child ( "publish_documents" ) ;
child . variant_mapping = frm . doc . variant_mapping ;
child . asset_category = row . category ;
child . item_category = "Variant Mapping Assets" ;
child . variant = frm . doc . variant ;
child . attach_file = row . attach_file ;
refresh_field ( "publish_documents" ) ;
added += 1 ;
}
if ( frm . doc . docstatus === 0 && frm . doc . publish_status == 'To Publish' ) {
frm . get_field ( 'variant_mapping_assets' ) . grid . add_custom_button ( __ ( 'Add to Publish' ) , function ( ) {
let added = 0 ;
frm . doc . variant_mapping_assets . forEach ( row => {
if ( row . active_status == "Active" || row . active_status == "Inactive" ) {
let dulicate = false ;
if ( frm . doc . publish_documents ) {
frm . doc . publish_documents . forEach ( publishrow => {
if ( frm . doc . variant_mapping == publishrow . variant_mapping &&
row . category == publishrow . asset_category && row . attach_file == publishrow . attach_file ) {
dulicate = true ;
}
} ) ;
}
if ( dulicate === false ) {
let child = cur_frm . add_child ( "publish_documents" ) ;
child . variant_mapping = frm . doc . variant_mapping ;
child . asset_category = row . category ;
child . item_category = "Variant Mapping Assets" ;
child . variant = frm . doc . variant ;
child . attach_file = row . attach_file ;
refresh_field ( "publish_documents" ) ;
added += 1 ;
}
}
}
} ) ;
if ( added ) { frappe . msgprint ( __ ( added + " Doc(s) Added" ) ) ; }
else { frappe . msgprint ( __ ( "No Doc Added" ) ) ; }
} ) ;
if ( added ) { frappe . msgprint ( __ ( added + " Doc(s) Added" ) ) ; }
else { frappe . msgprint ( __ ( "No Doc Added" ) ) ; }
} ) ;
frm . fields_dict . variant_mapping_assets . grid . grid_buttons . find ( '.btn-custom' ) . removeClass ( 'btn-default' ) . addClass ( 'btn-primary' ) ;
}
if ( frm . doc . docstatus == 1 ) {
$ ( ".grid-buttons" ) . hide ( ) ;
frm . fields_dict . variant_mapping_assets . grid . grid_buttons . find ( '.btn-custom' ) . removeClass ( 'btn-default' ) . addClass ( 'btn-primary' ) ;
}
if ( frm . doc . docstatus == 1 ) {
$ ( ".grid-buttons" ) . hide ( ) ;
}
}
}
if ( frm . doc . docstatus == 1 && ! frm . is_new ( ) && frm . doc . publish_type != "Global" && frm . doc . publish_module == 'Others' ) {
if ( frm . doc . docstatus == 1 && ! frm . is_new ( ) && frm . doc . publish_type != "Global" && frm . doc . publish_module == 'Others' ) {
frm . add_custom_button ( __ ( 'Global Publish' ) , function ( ) {
@ -348,55 +338,10 @@ frappe.ui.form.on('Publish Test', {
} ) . addClass ( "btn-primary" ) ;
}
// if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher') && frm.doc.publish_module=='Others') {
// frm.add_custom_button(__('Global Publish'), function () {
// frappe.confirm('Are you sure you want to Publish?',
// () => {
// // action to perform if Yes is selected
// if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type) {
// frappe.call({
// method: 'smart_service.phase_2.doctype.publish_test.publish_test.repair_checksheet_publish',
// args: {
// vehicle: frm.doc.vehicle,
// language: frm.doc.language,
// publish_type: frm.doc.publish_type,
// release_description:frm.doc.release_description,
// vehicle_id:frm.doc.vehicle_id,
// variant:frm.doc.variant_mapping
// },
// callback: (r) => {
// if(r.message[0]==1){
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message[1]),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// }
// },
// })
// }
// }, () => {
// // action to perform if No is selected
// });
// }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
// } else if (frm.doc.publish_status == 'Published') {
// frm.set_read_only();
// // frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1);
// }
} ,
validate : function ( frm ) {
if ( frm . doc . publish_module == 'Automotive' ) {
if ( frm . doc . publish_module == 'Automotive' ) {
let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/ ;
if ( regex . test ( frm . doc . release_description ) === true ) {
frm . doc . release_description = '' ;
@ -415,7 +360,7 @@ frappe.ui.form.on('Publish Test', {
}
//check for atleast one data to publish
if ( frm . doc . publish_module == 'Others' && ! frm . doc . hasOwnProperty ( 'repair_checksheet_publish' ) ) {
if ( frm . doc . publish_module == 'Others' && ! frm . doc . hasOwnProperty ( 'repair_checksheet_publish' ) ) {
frappe . throw ( 'No Data Found To Publish' )
@ -459,7 +404,7 @@ frappe.ui.form.on('Publish Test', {
} ,
km_active_status : function ( frm ) {
if ( frm . doc . variant_mapping && frm . doc . publish_module == 'Automotive' ) {
if ( frm . doc . variant_mapping && frm . doc . publish_module == 'Automotive' ) {
frappe . show_alert ( {
message : __ ( 'Please wait until variant mapping details are loaded.' ) ,
indicator : 'yellow'
@ -467,7 +412,7 @@ frappe.ui.form.on('Publish Test', {
}
if ( frm . doc . km_active_status === "" || frm . doc . km_active_status === null ) { return ; }
let filter = frm . doc . variant_mapping + "-" + frm . doc . language + "-SM" ;
if ( frm . doc . variant_mapping_status == "Active" && frm . doc . km_active_status == "Active" && frm . doc . publish_module == 'Automotive' ) {
if ( frm . doc . variant_mapping_status == "Active" && frm . doc . km_active_status == "Active" && frm . doc . publish_module == 'Automotive' ) {
frappe . call ( {
"method" : "smart_service.transactions.doctype.publish.publish.get_system" ,
"args" : {
@ -540,7 +485,7 @@ frappe.ui.form.on('Publish Test', {
} )
} else {
if ( frm . doc . variant_mapping_status && frm . doc . publish_module == 'Automotive' ) {
if ( frm . doc . variant_mapping_status && frm . doc . publish_module == 'Automotive' ) {
frappe . msgprint ( {
title : __ ( 'Notification' ) ,
indicator : 'red' ,
@ -551,7 +496,7 @@ frappe.ui.form.on('Publish Test', {
} ,
add_variant_mapping_to_publish : function ( frm ) {
let dulicate = false ;
if ( frm . doc . publish_documents && frm . doc . publish_module == 'Automotive' ) {
if ( frm . doc . publish_documents && frm . doc . publish_module == 'Automotive' ) {
frm . doc . publish_documents . forEach ( publishrow => {
if ( frm . doc . variant_mapping == publishrow . variant_mapping && publishrow . systems === undefined && publishrow . sub_systems === undefined && publishrow . procedure === undefined ) {
dulicate = true ;
@ -559,7 +504,7 @@ frappe.ui.form.on('Publish Test', {
} ) ;
frappe . msgprint ( "Variant Mapping already added" ) ;
}
if ( dulicate === false && frm . doc . publish_module == 'Automotive' ) {
if ( dulicate === false && frm . doc . publish_module == 'Automotive' ) {
let child = cur_frm . add_child ( "publish_documents" ) ;
child . variant_mapping = frm . doc . variant_mapping ;
child . item_category = "Variant Mapping" ;
@ -570,8 +515,8 @@ frappe.ui.form.on('Publish Test', {
km_report : function ( frm , cdt , cdn ) {
frappe . set_route ( "query-report" , 'Kilometer Mapping' , { 'kilometer_mapping' : frm . doc . kilometer_mapping } ) ;
} ,
after_save : function ( frm ) {
frm . set_df_property ( 'repair_checksheet_publish' , 'hidden' , 0 )
after_save : function ( frm ) {
frm . set_df_property ( 'repair_checksheet_publish' , 'hidden' , 0 )
frm . refresh_field ( 'repair_checksheet_publish' )
} ,
@ -596,13 +541,13 @@ frappe.ui.form.on('Publish Test', {
}
} ) ;
if ( frm . doc . vehicle === undefined || frm . doc . vehicle === null && frm . doc . publish_module == 'Automotive' ) { return ; }
if ( frm . doc . vehicle === undefined || frm . doc . vehicle === null && frm . doc . publish_module == 'Automotive' ) { return ; }
$ ( "[data-fieldname=variant_mapping]" ) . focus ( ) ;
if ( frm . doc . vehicle ) {
frm . set_df_property ( 'vehicle' , 'read_only' , 1 ) ;
}
//other modules-Repair Checksheet
if ( frm . doc . publish_module == 'Others' ) {
if ( frm . doc . publish_module == 'Others' ) {
if ( frm . doc . repair_checksheet_publish && frm . doc . repair_checksheet_publish . length > 0 ) {
content_flag = 1
cur_frm . clear_table ( "repair_checksheet_publish" ) ;
@ -617,7 +562,7 @@ frappe.ui.form.on('Publish Test', {
} ,
language : function ( frm ) {
if ( frm . doc . publish_module == 'Others' ) {
if ( frm . doc . publish_module == 'Others' ) {
add_to_publish ( frm )
}
if ( ! lang_set_first_time ) {
@ -669,13 +614,13 @@ frappe.ui.form.on('Publish_Temp Doc', {
} ,
} )
function add_to_publish ( frm ) {
function add_to_publish ( frm ) {
frappe . call ( {
method : "smart_service.phase_2.doctype.publish_test.publish_test.get_service_repair" ,
args : { vehicle : frm . doc . vehicle , language_label : frm . doc . language , publish_type : frm . doc . publish_type } ,
callback : function ( r ) {
if ( r . message ) {
cur_frm . set_df_property ( 'repair_checksheet_publish' , 'hidden' , 0 )
cur_frm . set_df_property ( 'repair_checksheet_publish' , 'hidden' , 0 )
var records = r . message
debugger
records . map ( v => {