From 4b2d7f9a6ce66a918516f8aff28d66a29fdada29 Mon Sep 17 00:00:00 2001 From: bbimber Date: Mon, 7 Jul 2025 14:01:26 -0700 Subject: [PATCH 1/2] Read subjectId off URL --- .../web/LDK/panel/TabbedReportPanel.js | 15 ++--- .../web/laboratory/panel/DataBrowserPanel.js | 58 ++++++++++++++++++ .../labkey/laboratory/view/dataBrowser.jsp | 61 ++++--------------- 3 files changed, 74 insertions(+), 60 deletions(-) create mode 100644 laboratory/resources/web/laboratory/panel/DataBrowserPanel.js diff --git a/LDK/resources/web/LDK/panel/TabbedReportPanel.js b/LDK/resources/web/LDK/panel/TabbedReportPanel.js index a910c718..78b0a760 100644 --- a/LDK/resources/web/LDK/panel/TabbedReportPanel.js +++ b/LDK/resources/web/LDK/panel/TabbedReportPanel.js @@ -1071,8 +1071,8 @@ Ext4.define('LDK.panel.TabbedReportPanel', { return filter ? Ext4.apply({}, filter) : null; }, - getFiltersFromUrl: function(){ - var context = {}; + getFiltersFromUrl: function(context){ + context = context || {}; if (document.location.hash){ var token = document.location.hash.split('#'); @@ -1302,18 +1302,11 @@ Ext4.define('LDK.panel.TabbedReportPanel', { if (report) this.silentlySetActiveTab(report); } - else if (this.defaultTab) { - var tab = tabPanel.down('#' + this.defaultTab); - tabPanel.suspendEvents(); - tab.suspendEvents(); - tabPanel.setActiveTab(tab); - tab.resumeEvents(); - tabPanel.resumeEvents(); - } //populate initial fields var shouldChange = true; - this.initialContext = this.getFiltersFromUrl(); + + this.initialContext = this.getFiltersFromUrl(this.initialContext); var filterType = this.initialContext.inputType; if (filterType){ var radio = this.down('#inputType'); diff --git a/laboratory/resources/web/laboratory/panel/DataBrowserPanel.js b/laboratory/resources/web/laboratory/panel/DataBrowserPanel.js new file mode 100644 index 00000000..5c47e0f5 --- /dev/null +++ b/laboratory/resources/web/laboratory/panel/DataBrowserPanel.js @@ -0,0 +1,58 @@ +Ext4.define('Laboratory.panel.DataBrowserPanel', { + extend: 'LDK.panel.TabbedReportPanel', + + initComponent: function(){ + Ext4.ns('Laboratory.tabbedReports'); + + Ext4.apply(this, { + //defaultReport: 'abstract', + reportNamespace: Laboratory.tabbedReports + }); + + Ext4.Msg.wait('Loading...'); + Laboratory.Utils.getDataItems({ + types: ['tabbedReports'], + scope: this, + success: this.onDataLoad, + failure: LDK.Utils.getErrorCallback() + }); + + this.callParent(); + }, + + onDataLoad: function(results){ + Ext4.Msg.hide(); + this.reports = []; + Ext4.each(results.tabbedReports, function(report){ + LDK.Assert.assertNotEmpty('Tabbed Report is null', report); + if (report && report.key){ + report.id = report.key.replace(/:/g, '_'); + report.category = report.reportCategory; + + if (report.targetContainer){ + report.containerPath = report.targetContainer; + } + this.reports.push(report); + } + }, this); + + this.reports = LDK.Utils.sortByProperty(this.reports, 'name', false); + this.reports = LDK.Utils.sortByProperty(this.reports, 'reportCategory', false); + + this.createTabPanel(); + }, + + filterTypes: [{ + xtype: 'ldk-singlesubjectfiltertype', + inputValue: LDK.panel.SingleSubjectFilterType.filterName, + label: LDK.panel.SingleSubjectFilterType.DEFAULT_LABEL + },{ + xtype: 'ldk-multisubjectfiltertype', + inputValue: LDK.panel.MultiSubjectFilterType.filterName, + label: LDK.panel.MultiSubjectFilterType.label + },{ + xtype: 'ldk-nofiltersfiltertype', + inputValue: LDK.panel.NoFiltersFilterType.filterName, + label: LDK.panel.NoFiltersFilterType.label + }] +}); \ No newline at end of file diff --git a/laboratory/src/org/labkey/laboratory/view/dataBrowser.jsp b/laboratory/src/org/labkey/laboratory/view/dataBrowser.jsp index 70beda3c..137d72de 100644 --- a/laboratory/src/org/labkey/laboratory/view/dataBrowser.jsp +++ b/laboratory/src/org/labkey/laboratory/view/dataBrowser.jsp @@ -27,6 +27,11 @@ public void addClientDependencies(ClientDependencies dependencies) { dependencies.add("laboratory.context"); + dependencies.add("/laboratory/panel/DataBrowserPanel.js"); + dependencies.add("LDK/panel/AbstractFilterType.js"); + dependencies.add("LDK/panel/SingleSubjectFilterType.js"); + dependencies.add("LDK/panel/MultiSubjectFilterType.js"); + dependencies.add("LDK/panel/NoFiltersFilterType.js"); } private String getFilterConfig() @@ -59,53 +64,13 @@
\ No newline at end of file From fdfdf8d17e79f0ff5284123cbff9c984faf9dbd5 Mon Sep 17 00:00:00 2001 From: bbimber Date: Mon, 7 Jul 2025 14:44:11 -0700 Subject: [PATCH 2/2] Allow admin to set DataBrowser default report --- .../api/laboratory/TabbedReportItem.java | 24 ++++++++-- .../panel/CustomizeDataBrowserPanel.js | 20 ++++++--- .../web/laboratory/panel/DataBrowserPanel.js | 12 ++++- .../laboratory/LaboratoryController.java | 44 +++++++++++++++++-- 4 files changed, 87 insertions(+), 13 deletions(-) diff --git a/laboratory/api-src/org/labkey/api/laboratory/TabbedReportItem.java b/laboratory/api-src/org/labkey/api/laboratory/TabbedReportItem.java index 8859393f..d0dc301a 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/TabbedReportItem.java +++ b/laboratory/api-src/org/labkey/api/laboratory/TabbedReportItem.java @@ -46,7 +46,6 @@ public class TabbedReportItem extends AbstractNavItem private final Map _additionalKeys = new HashMap<>(); public static final String OVERRIDES_PROP_KEY = "laboratory.tabItemOverride"; - public static final String FILTER_PROP_KEY = "laboratory.tabItemFilterOverride"; protected static final Logger _log = LogManager.getLogger(TabbedReportItem.class); @@ -177,6 +176,23 @@ public static String getOverridesPropertyKey(NavItem item) return item.getDataProvider().getKey() + "||tabReport||" + item.getReportCategory() + "||" + item.getName() + "||" + item.getLabel(); } + public boolean hasOverride(Container c, String propName) + { + Map map = PropertyManager.getProperties(c, OVERRIDES_PROP_KEY); + if (!map.containsKey(getPropertyManagerKey())) + { + return false; + } + + JSONObject props = new JSONObject(map.get(getPropertyManagerKey())); + if (!props.has(propName)) + { + return false; + } + + return true; + } + public static void applyOverrides(NavItem item, Container c, JSONObject json) { Map map = PropertyManager.getProperties(c, OVERRIDES_PROP_KEY); @@ -188,9 +204,9 @@ public static void applyOverrides(NavItem item, Container c, JSONObject json) if (props.has("reportCategory")) json.put("reportCategory", props.get("reportCategory")); - // retained for settings saved prior to refactor - else if (props.has("category")) - json.put("reportCategory", props.get("category")); + + if (props.has("isDefaultReport")) + json.put("isDefaultReport", props.get("isDefaultReport")); } } } diff --git a/laboratory/resources/web/laboratory/panel/CustomizeDataBrowserPanel.js b/laboratory/resources/web/laboratory/panel/CustomizeDataBrowserPanel.js index 49b3b789..0df95d10 100644 --- a/laboratory/resources/web/laboratory/panel/CustomizeDataBrowserPanel.js +++ b/laboratory/resources/web/laboratory/panel/CustomizeDataBrowserPanel.js @@ -69,6 +69,9 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', { },{ html: 'Visible?', style: 'padding-bottom: 5px;margin-left: 5px;' + },{ + html: 'Default Report?', + style: 'padding-bottom: 5px;margin-left: 5px;' }]; items = LDK.Utils.sortByProperty(items, 'name', false); @@ -90,9 +93,14 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', { width: 300, value: item.label },{ - xtype: 'displayfield', - value: item.visible, + xtype: 'checkbox', + checked: item.visible, style: 'margin-left: 15px;' + },{ + xtype: 'radio', + name: 'isDefaultReport', + inputValue: true, + checked: item.isDefaultReport }]); }, this); @@ -100,7 +108,7 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', { itemId: 'theTable', layout: { type: 'table', - columns: 4 + columns: 5 }, border: false, defaults: { @@ -117,15 +125,17 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', { doSave: function(btn){ var toSave = {}; var items = btn.up('form').down('#theTable').items; - var cols = 4; + var cols = 5; var rows = (items.getCount() / cols); for (var i=1;i results = new HashMap<>(); WritablePropertyMap propMap = PropertyManager.getWritableProperties(getContainer(), TabbedReportItem.OVERRIDES_PROP_KEY, true); + WritablePropertyMap visibilityMap = PropertyManager.getWritableProperties(getContainer(), NavItem.PROPERTY_CATEGORY, true); + boolean shouldSaveVisibility = false; List tabbedReports = LaboratoryService.get().getTabbedReportItems(getContainer(), getUser()); Map reportMap = new HashMap(); @@ -1669,7 +1671,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) JSONObject json = new JSONObject(form.getJsonData()); for (String key : json.keySet()) { - JSONObject toSave= new JSONObject(); + JSONObject toSave = new JSONObject(); TabbedReportItem ti = reportMap.get(key); if (ti == null) @@ -1685,13 +1687,49 @@ public ApiResponse execute(JsonDataForm form, BindException errors) if (reportCategory != null && !ti.getReportCategory().equals(reportCategory)) toSave.put("reportCategory", reportCategory); - if (toSave.keySet().size() > 0) + String isDefaultReport = StringUtils.trimToNull(props.optString("isDefaultReport")); + if (isDefaultReport != null) + { + if (!ti.hasOverride(getContainer(), "isDefaultReport")) + { + if ("true".equals(isDefaultReport)) + { + toSave.put("isDefaultReport", isDefaultReport); + } + } + else + { + toSave.put("isDefaultReport", isDefaultReport); + } + } + + String isVisible = StringUtils.trimToNull(props.optString("isVisible")); + if (isVisible != null) + { + if (!isVisible.equals(visibilityMap.get(ti.getPropertyManagerKey()))) + { + visibilityMap.put(ti.getPropertyManagerKey(), isVisible); + shouldSaveVisibility = true; + } + } + + if (!toSave.isEmpty()) + { propMap.put(key, toSave.toString()); - else propMap.remove(key); + } + else + { + propMap.remove(key); + } } propMap.save(); + if (shouldSaveVisibility) + { + visibilityMap.save(); + } + results.put("success", true); return new ApiSimpleResponse(results); }