fix(file-format): move Preview/Auto-detect buttons into the tab body
The two helpers used to live in the form toolbar under a 'File Format' group, which added noise to the already busy header (Match/Create buttons for accounts/customers/suppliers/purposes plus Load Data are also there). They are now native Button fields inside the File Format tab, sitting in a two-column row directly under the Sample Excel File attach widget: [ Sample Excel File: ... ] [ Preview Sample ] [ Auto-detect Columns ] [ Format / Column Mappings sections ] Both buttons are gated by depends_on=sample_file, so they only appear when there's actually a file to operate on — same gating as before, just contextually placed next to the upload instead of in the global toolbar.
This commit is contained in:
parent
7f24bd6b2a
commit
54ac6288fd
|
|
@ -18,18 +18,6 @@ frappe.ui.form.on('Bank Statement Importer', {
|
|||
refresh(frm) {
|
||||
BIFileFormat.applySampleHeaders(frm);
|
||||
|
||||
// === File Format helpers — available even on new records since they
|
||||
// help the user set up the import format from a sample file. ===
|
||||
if (frm.doc.sample_file) {
|
||||
frm.add_custom_button(__('Preview Sample'), () => {
|
||||
BIFileFormat.showPreview(frm);
|
||||
}, __('File Format'));
|
||||
|
||||
frm.add_custom_button(__('Auto-detect Columns'), () => {
|
||||
BIFileFormat.autoDetect(frm);
|
||||
}, __('File Format'));
|
||||
}
|
||||
|
||||
if (frm.is_new()) return;
|
||||
|
||||
// === Load Data (file-based, registry-only) ===
|
||||
|
|
@ -142,6 +130,14 @@ frappe.ui.form.on('Bank Statement Importer', {
|
|||
header_row(frm) {
|
||||
if (frm.doc.sample_file) BIFileFormat.applySampleHeaders(frm, /*force*/ true);
|
||||
},
|
||||
|
||||
preview_sample_btn(frm) {
|
||||
BIFileFormat.showPreview(frm);
|
||||
},
|
||||
|
||||
auto_detect_btn(frm) {
|
||||
BIFileFormat.autoDetect(frm);
|
||||
},
|
||||
});
|
||||
|
||||
// ─── File Format helpers ─────────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
"default_territory",
|
||||
"file_format_tab",
|
||||
"sample_file",
|
||||
"ff_sample_actions_section",
|
||||
"preview_sample_btn",
|
||||
"ff_sample_actions_col",
|
||||
"auto_detect_btn",
|
||||
"ff_format_section",
|
||||
"header_row",
|
||||
"amount_mode",
|
||||
|
|
@ -169,6 +173,29 @@
|
|||
"fieldtype": "Attach",
|
||||
"label": "Sample Excel File"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.sample_file",
|
||||
"fieldname": "ff_sample_actions_section",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.sample_file",
|
||||
"description": "Show the first 20 data rows from the sample file with mapping status per column.",
|
||||
"fieldname": "preview_sample_btn",
|
||||
"fieldtype": "Button",
|
||||
"label": "Preview Sample"
|
||||
},
|
||||
{
|
||||
"fieldname": "ff_sample_actions_col",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.sample_file",
|
||||
"description": "Replace the Column Mappings table with a best-effort guess based on the sample file's headers.",
|
||||
"fieldname": "auto_detect_btn",
|
||||
"fieldtype": "Button",
|
||||
"label": "Auto-detect Columns"
|
||||
},
|
||||
{
|
||||
"fieldname": "ff_format_section",
|
||||
"fieldtype": "Section Break",
|
||||
|
|
|
|||
Loading…
Reference in New Issue