From b7fc73606ef5be8f3f1d5441b240ef1139babd45 Mon Sep 17 00:00:00 2001 From: timmyhadwen <4350849+timmyhadwen@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:35:22 +1000 Subject: [PATCH] Fix plugin API signatures and dashboard JS for InvenTree compatibility - Add context parameter to get_ui_panels and get_ui_dashboard_items - Fix renderDashboardItem signature to (target, data) per InvenTree API - Export plugin class from __init__.py for discovery --- inventree_print_demand/__init__.py | 6 ++++++ inventree_print_demand/plugin.py | 4 ++-- inventree_print_demand/static/print_demand/dashboard.js | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/inventree_print_demand/__init__.py b/inventree_print_demand/__init__.py index e69de29..b0c5f57 100644 --- a/inventree_print_demand/__init__.py +++ b/inventree_print_demand/__init__.py @@ -0,0 +1,6 @@ +"""InvenTree 3D Print Demand Plugin.""" + +from .plugin import PrintDemandPlugin + +__all__ = ["PrintDemandPlugin"] +__version__ = "0.1.0" diff --git a/inventree_print_demand/plugin.py b/inventree_print_demand/plugin.py index d811f5a..2bf35d6 100644 --- a/inventree_print_demand/plugin.py +++ b/inventree_print_demand/plugin.py @@ -38,10 +38,10 @@ class PrintDemandPlugin(SettingsMixin, UrlsMixin, UserInterfaceMixin, InvenTreeP re_path(r'^api/demand/', self.api_demand, name='api-demand'), ] - def get_ui_panels(self, request, **kwargs): + def get_ui_panels(self, request, context, **kwargs): return [] - def get_ui_dashboard_items(self, request, **kwargs): + def get_ui_dashboard_items(self, request, context, **kwargs): return [ { 'key': 'print-demand', diff --git a/inventree_print_demand/static/print_demand/dashboard.js b/inventree_print_demand/static/print_demand/dashboard.js index 0041c77..70b2060 100644 --- a/inventree_print_demand/static/print_demand/dashboard.js +++ b/inventree_print_demand/static/print_demand/dashboard.js @@ -5,8 +5,11 @@ * a colour-coded table showing stock vs demand for every 3D-printed part. */ -export function renderDashboardItem(context) { - const target = context.target; +export function renderDashboardItem(target, data) { + if (!target) { + console.error("No target provided to renderDashboardItem"); + return; + } target.innerHTML = 'Loading 3D print demand data...';