|
|
@ -16,6 +16,8 @@ frappe.ui.form.on('Special Tool Information', { |
|
|
|
|
|
|
|
}, |
|
|
|
validate:function(frm){ |
|
|
|
check_field_character(frm.doc.tool_name) |
|
|
|
check_field_character(frm.doc.aggregate_name) |
|
|
|
//for display_order
|
|
|
|
if (frm.doc.display_order == null || typeof (frm.doc.display_order) == String) { |
|
|
|
frappe.validated = false; |
|
|
@ -64,7 +66,7 @@ frappe.ui.form.on('Special Tool Information', { |
|
|
|
}); |
|
|
|
} |
|
|
|
frm.doc.name = frm.doc.vehicle + "-" + frm.doc.tool_type + "-" + frm.doc.category + "-" + frm.doc.aggregate_name |
|
|
|
|
|
|
|
// field validation
|
|
|
|
if (frm.doc.image) { |
|
|
|
frappe.call({ |
|
|
|
method: "smart_service.phase_2.doctype.special_tool_information.special_tool_information.file_validation", |
|
|
@ -115,6 +117,26 @@ frappe.ui.form.on('Special Tool Information', { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
if (frm.doc.pdf){ |
|
|
|
frappe.call({ |
|
|
|
method: "smart_service.phase_2.doctype.special_tool_information.special_tool_information.file_validation1", |
|
|
|
args: { |
|
|
|
image: frm.doc.pdf, |
|
|
|
name:frm.doc.name |
|
|
|
}, |
|
|
|
callback: function (r) { |
|
|
|
console.log(r.message, "r.message") |
|
|
|
if (r.message && r.message[0] == false) { |
|
|
|
if (r.message[1] == 1) { |
|
|
|
frappe.validated = false; |
|
|
|
frappe.msgprint("Invalid file type") |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
category: function (frm, cdt, cdn) { |
|
|
@ -252,3 +274,23 @@ frappe.ui.form.on('Instructions', { |
|
|
|
refresh_field("instructions"); |
|
|
|
}, |
|
|
|
}) |
|
|
|
function check_field_character(field_name) { |
|
|
|
if (field_name) { |
|
|
|
var alphanum = /^[a-zA-Z]+/; |
|
|
|
if (field_name.length > 1) { |
|
|
|
if (field_name.length > 100) { |
|
|
|
frappe.throw("<b>Tool Name:</b> Only <b> 100 </b> characters are allowed") |
|
|
|
frappe.validated = false; |
|
|
|
} else { |
|
|
|
if (alphanum.test(field_name) === true) { |
|
|
|
} else if (field_name) { |
|
|
|
frappe.throw(__("<b>Tool Name:</b> Enter letter or alpha numeric characters only.")); |
|
|
|
frappe.validated = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
frappe.throw("<b>Tool Names:</b> Single character not allowed") |
|
|
|
frappe.validated = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |