fix(bank-integration): keep "use original description" hidden state across Action changes
The previous attempt double-set custom_purpose's hidden property (visible in the forEach, then hidden in a follow-up if) and relied on refresh_fields, which didn't re-render the hidden state. Now _applyModeVisibility computes the final hidden value for each field in one pass — folding the "Use original description" checkbox into the custom_purpose decision — and calls refresh() on each field explicitly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6c395f9e3b
commit
e600a77806
|
|
@ -355,15 +355,19 @@ const BIBRT = {
|
|||
|
||||
_applyModeVisibility: function (d) {
|
||||
const isDR = d.get_value("mode") === "Documents & Reconcile";
|
||||
const toHide = ["preview_html", "sec_options", "document_type", "use_original_purpose",
|
||||
// "Use original description" also hides custom_purpose; fold that into the
|
||||
// per-field decision so toggling Action modes never reveals a field the
|
||||
// checkbox had hidden.
|
||||
const useOriginal = !!d.get_value("use_original_purpose");
|
||||
const fields = ["preview_html", "sec_options", "document_type", "use_original_purpose",
|
||||
"custom_purpose", "sec_accounts", "paid_from", "col_break", "paid_to"];
|
||||
toHide.forEach(fn => d.set_df_property(fn, "hidden", isDR ? 1 : 0));
|
||||
// The "use original description" checkbox also hides custom_purpose — re-apply
|
||||
// it so switching Action modes doesn't reveal a field the checkbox had hidden.
|
||||
if (!isDR && d.get_value("use_original_purpose")) {
|
||||
d.set_df_property("custom_purpose", "hidden", 1);
|
||||
}
|
||||
d.refresh_fields(toHide);
|
||||
fields.forEach(function (fn) {
|
||||
let hidden = isDR ? 1 : 0;
|
||||
if (fn === "custom_purpose" && !isDR && useOriginal) hidden = 1;
|
||||
d.set_df_property(fn, "hidden", hidden);
|
||||
const field = d.get_field(fn);
|
||||
if (field && typeof field.refresh === "function") field.refresh();
|
||||
});
|
||||
},
|
||||
|
||||
_submit: function (dialog, txns, sourceType, sourceName, paid_from, paid_to, document_type, mode) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue