fix(file-format): offer to re-run auto-detect on sample re-upload
Previously a re-upload (clear → re-attach) just refreshed the Excel Column dropdown and silently kept the existing mapping rows — pointing the user at the new file but leaving the table tied to the old one. Now the form asks before overwriting: empty table still auto-detects silently, populated table prompts with a Confirm dialog before clearing and re-running.
This commit is contained in:
parent
d87da25417
commit
a27e9b08f5
|
|
@ -189,14 +189,24 @@ const BIFileFormat = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called when the user attaches / replaces the Sample Excel File. Refresh
|
// Called when the user attaches / replaces / clears the Sample Excel File.
|
||||||
// the Excel Column dropdown and, if the table is still empty, run
|
// Refresh the Excel Column dropdown, then either auto-detect silently
|
||||||
// auto-detect silently. We never overwrite a user-filled table.
|
// (empty table) or ask before overwriting an existing mapping (re-upload).
|
||||||
onSampleFileChange(frm) {
|
onSampleFileChange(frm) {
|
||||||
this.applySampleHeaders(frm, /*force*/ true);
|
this.applySampleHeaders(frm, /*force*/ true);
|
||||||
|
if (!frm.doc.sample_file) return;
|
||||||
|
|
||||||
const hasRows = (frm.doc.column_mappings || []).some(r => r.excel_column || r.standard_field);
|
const hasRows = (frm.doc.column_mappings || []).some(r => r.excel_column || r.standard_field);
|
||||||
if (!frm.doc.sample_file || hasRows) return;
|
if (!hasRows) {
|
||||||
this.autoDetect(frm, /*silent*/ true);
|
this.autoDetect(frm, /*silent*/ true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
frappe.confirm(
|
||||||
|
__('Re-run auto-detect and replace the existing {0} Column Mapping row(s)?', [
|
||||||
|
frm.doc.column_mappings.length,
|
||||||
|
]),
|
||||||
|
() => this.autoDetect(frm, /*silent*/ true),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
setColumnOptions(frm, headers) {
|
setColumnOptions(frm, headers) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue