From a90b021a8911bd78f9a8a5684a2a2a17139b58d3 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:55:23 +0200 Subject: [PATCH] feat(Catch Log Days and Counts): fishing area restricts water body --- .../catch_log_days_and_counts.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/landa/water_body_management/report/catch_log_days_and_counts/catch_log_days_and_counts.js b/landa/water_body_management/report/catch_log_days_and_counts/catch_log_days_and_counts.js index f6c33d00..0dd9c06e 100644 --- a/landa/water_body_management/report/catch_log_days_and_counts/catch_log_days_and_counts.js +++ b/landa/water_body_management/report/catch_log_days_and_counts/catch_log_days_and_counts.js @@ -14,7 +14,14 @@ frappe.query_reports["Catch Log Days and Counts"] = { fieldname: "water_body", fieldtype: "MultiSelectList", label: __("Water Body"), - get_data: (txt) => frappe.db.get_link_options("Water Body", txt), + get_data: (txt) => { + const fishing_areas = frappe.query_report.get_filter_value("fishing_area") || []; + const filters = {}; + if (fishing_areas.length > 0) { + filters.fishing_area = ["in", fishing_areas]; + } + return frappe.db.get_link_options("Water Body", txt, filters); + }, }, { fieldname: "organization", @@ -44,7 +51,6 @@ frappe.query_reports["Catch Log Days and Counts"] = { ], }; - function get_extra_columns(txt) { const extra_columns = [ { @@ -62,7 +68,7 @@ function get_extra_columns(txt) { label: __("Water Body Status"), description: "", }, - ] + ]; return extra_columns.filter((d) => d.label.toLowerCase().includes(txt.toLowerCase())); }