@ -37,7 +37,6 @@ frappe.ui.form.on('System Mapping', {
}
} ;
} ) ;
frm . trigger ( 'fnLoadmat_initial_values' ) ;
} ,
validate : function ( frm ) {
@ -86,6 +85,37 @@ frappe.ui.form.on('System Mapping', {
} else {
frm . trigger ( 'fnSave_caller' ) ;
}
frm . doc . system_filter = "All" ;
if ( frm . doc . system_filter == "All" ) {
frm . get_field ( 'system_sub_systems' ) . grid . static_rows = false ;
frm . fields_dict . system_sub_systems . grid . grid_rows . forEach ( ( row ) => {
$ ( "div[data-fieldname=system_sub_systems]" ) . find ( 'div.grid-row[data-idx="' + row . doc . idx + '"]' ) . show ( ) ;
} ) ;
}
frappe . call ( {
"method" : "smart_service.transactions.doctype.system_mapping.system_mapping.sys_filter" ,
"args" : {
"parent" : frm . doc . name ,
"systems" : "" ,
"record" : "All"
} ,
callback : function ( r ) {
frm . set_value ( "system_sub_systems" , "" ) ;
for ( var i = 0 ; i <= r . message . length ; i ++ ) {
frm . add_child ( "system_sub_systems" , {
'systems' : r . message [ i ] . systems ,
'sub_systems' : r . message [ i ] . sub_systems ,
'active_status' : r . message [ i ] . active_status ,
'procedure' : r . message [ i ] . procedure ,
'procedure_status' : r . message [ i ] . procedure_status
} ) ;
}
refresh_field ( 'system_sub_systems' )
}
} ) ;
frm . refresh ( ) ;
} ,
after_save : function ( frm ) {
cur_frm . reload_doc ( ) ;
@ -145,6 +175,30 @@ frappe.ui.form.on('System Mapping', {
} ,
system_filter : function ( frm ) {
if ( frm . doc . system_filter == "All" ) {
frm . doc . sub_system_filter = "All" ;
frappe . call ( {
"method" : "smart_service.transactions.doctype.system_mapping.system_mapping.sys_filter" ,
"args" : {
"parent" : frm . doc . name ,
"systems" : "" ,
"record" : "All"
} ,
callback : function ( r ) {
debugger
frm . set_value ( "system_sub_systems" , "" ) ;
for ( var i = 0 ; i <= r . message . length ; i ++ ) {
frm . add_child ( "system_sub_systems" , {
'systems' : r . message [ i ] . systems ,
'sub_systems' : r . message [ i ] . sub_systems ,
'active_status' : r . message [ i ] . active_status ,
'procedure' : r . message [ i ] . procedure ,
'procedure_status' : r . message [ i ] . procedure_status
} ) ;
}
refresh_field ( 'system_sub_systems' )
}
} ) ;
frm . get_field ( 'system_sub_systems' ) . grid . static_rows = false ;
frm . fields_dict . system_sub_systems . grid . grid_rows . forEach ( ( row ) => {
$ ( "div[data-fieldname=system_sub_systems]" ) . find ( 'div.grid-row[data-idx="' + row . doc . idx + '"]' ) . show ( ) ;
@ -157,14 +211,37 @@ frappe.ui.form.on('System Mapping', {
} else {
frm . get_field ( 'system_sub_systems' ) . grid . static_rows = false ;
frm . fields_dict . system_sub_systems . grid . grid_rows . forEach ( ( row ) => {
if ( row . doc . systems != frm . doc . system_filter ) {
$ ( "div[data-fieldname=system_sub_systems]" ) . find ( 'div.grid-row[data-idx="' + row . doc . idx + '"]' ) . hide ( ) ;
} else {
$ ( "div[data-fieldname=system_sub_systems]" ) . find ( 'div.grid-row[data-idx="' + row . doc . idx + '"]' ) . show ( ) ;
frappe . call ( {
"method" : "smart_service.transactions.doctype.system_mapping.system_mapping.sys_filter" ,
"args" : {
"parent" : frm . doc . name ,
"systems" : frm . doc . system_filter
} ,
callback : function ( r ) {
debugger
frm . set_value ( "system_sub_systems" , "" ) ;
for ( var i = 0 ; i <= r . message . length ; i ++ ) {
frm . add_child ( "system_sub_systems" , {
'systems' : r . message [ i ] . systems ,
'sub_systems' : r . message [ i ] . sub_systems ,
'active_status' : r . message [ i ] . active_status ,
'procedure' : r . message [ i ] . procedure ,
'procedure_status' : r . message [ i ] . procedure_status
} ) ;
}
refresh_field ( 'system_sub_systems' )
}
} ) ;
// frm.fields_dict.system_sub_systems.grid.grid_rows.forEach((row) => {
// if (row.doc.systems != frm.doc.system_filter) {
// $("div[data-fieldname=system_sub_systems]").find('div.grid-row[data-idx="' + row.doc.idx + '"]').hide();
// } else {
// $("div[data-fieldname=system_sub_systems]").find('div.grid-row[data-idx="' + row.doc.idx + '"]').show();
// }
// });
frm . get_field ( 'systems_assets' ) . grid . static_rows = false ;
frm . fields_dict . systems_assets . grid . grid_rows . forEach ( ( row ) => {
if ( row . doc . systems != frm . doc . system_filter ) {
@ -174,6 +251,7 @@ frappe.ui.form.on('System Mapping', {
}
} ) ;
}
} ,
special_character : function ( frm ) {
var regex = /[!@#$%^&*()_+\=\[\]{};'`~:"\\|,.<>\/?]+/ ;
@ -206,16 +284,35 @@ frappe.ui.form.on('System Mapping', {
} ,
fnsetsystemsfilter : function ( frm ) {
var filtered_systems = frm . doc . system_filter ;
$ ( "select[data-fieldname='system_filter']" ) . empty ( ) ;
$ ( "select[data-fieldname='system_filter']" ) . append ( new Option ( "All" , "All" ) ) ;
frm . fields_dict . system_sub_systems . grid . grid_rows . forEach ( ( row ) => {
let value = row . doc . systems ;
if ( value )
if ( $ ( "select[data-fieldname='system_filter'] option[value='" + value + "']" ) . length === 0 ) {
// $("select[data-fieldname='system_filter']").empty();
// $("select[data-fieldname='system_filter']").append(new Option("All", "All"));
// frm.fields_dict.system_sub_systems.grid.grid_rows.forEach((row) => {
// let value = row.doc.systems;
frappe . call ( {
"method" : "smart_service.transactions.doctype.system_mapping.system_mapping.get_syatem_value" ,
"args" : {
name : frm . doc . name
} ,
callback : function ( r ) {
debugger
for ( var i = 0 ; i < r . message . length ; i ++ ) {
let value = r . message [ i ]
debugger
$ ( "select[data-fieldname='system_filter']" ) . append ( new Option ( value , value ) ) ;
}
// let value = r.message;
// if (value)
// if ($("select[data-fieldname='system_filter'] option[value='" + value + "']").length === 0) {
// $("select[data-fieldname='system_filter']").append(new Option(value, value));
// }
}
} )
} ) ;
// });
console . log ( filtered_systems )
frm . doc . system_filter = filtered_systems ;
} ,
fnLoadmat_initial_values : function ( frm ) {