Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Loading state and double renders (BAN-15) #112

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,31 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
});
this.match_field_group.make()

this.summary_empty_state();
await this.populate_matching_vouchers();
}

summary_empty_state() {
let summary_field = this.match_field_group.get_field("transaction_amount_summary").$wrapper;
summary_field.append(
`<div class="report-summary reconciliation-summary" style="height: 90px;">
</div>`
this.render_transaction_amount_summary(0, 0, 0, this.transaction.currency);
}

matching_vouchers_empty_state() {
this.match_field_group.get_field("vouchers").$wrapper.empty();
this.match_field_group.get_field("vouchers").$wrapper.append(
`<div class="text-muted text-center mb-4">${__("Loading ...")}</div>`
);
}

async populate_matching_vouchers() {
async populate_matching_vouchers(event_obj) {
if (event_obj && event_obj.type === "input") {
// `bind_change_event` in `data.js` triggers both an input and change event
// This triggers the `populate_matching_vouchers` twice on clicking on filters
// Since the input event is debounced, we can ignore it for a checkbox
return;
}

this.summary_empty_state();
this.matching_vouchers_empty_state();
marination marked this conversation as resolved.
Show resolved Hide resolved

let filter_fields = this.match_field_group.get_values();
let document_types = Object.keys(filter_fields).filter(field => filter_fields[field] === 1);

Expand Down Expand Up @@ -261,17 +273,17 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "payment_entry",
fieldtype: "Check",
default: filters_state.payment_entry,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
label: __("Journal Entry"),
fieldname: "journal_entry",
fieldtype: "Check",
default: filters_state.journal_entry,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
Expand All @@ -282,17 +294,17 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "purchase_invoice",
fieldtype: "Check",
default: filters_state.purchase_invoice,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
label: __("Sales Invoice"),
fieldname: "sales_invoice",
fieldtype: "Check",
default: filters_state.sales_invoice,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
Expand All @@ -303,17 +315,17 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "loan_repayment",
fieldtype: "Check",
default: filters_state.loan_repayment,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
label: __("Loan Disbursement"),
fieldname: "loan_disbursement",
fieldtype: "Check",
default: filters_state.loan_disbursement,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
Expand All @@ -324,17 +336,17 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "expense_claim",
fieldtype: "Check",
default: filters_state.expense_claim,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
label: __("Bank Transaction"),
fieldname: "bank_transaction",
fieldtype: "Check",
default: filters_state.bank_transaction,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
Expand All @@ -345,8 +357,8 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "exact_match",
fieldtype: "Check",
default: filters_state.exact_match,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
}
},
{
Expand All @@ -357,8 +369,8 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "exact_party_match",
fieldtype: "Check",
default: this.transaction.party_type && this.transaction.party ? 1 : 0,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
},
read_only: !Boolean(this.transaction.party_type && this.transaction.party)
},
Expand All @@ -370,8 +382,8 @@ erpnext.accounts.bank_reconciliation.MatchTab = class MatchTab {
fieldname: "unpaid_invoices",
fieldtype: "Check",
default: filters_state.unpaid_invoices,
onchange: () => {
this.populate_matching_vouchers();
onchange: (e) => {
this.populate_matching_vouchers(e);
},
depends_on: "eval: doc.sales_invoice || doc.purchase_invoice || doc.expense_claim",
},
Expand Down
Loading