Skip to content

Merge 25.3 to develop #251

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

Merged
merged 3 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 4 additions & 11 deletions LDK/resources/web/LDK/panel/TabbedReportPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('#');
Expand Down Expand Up @@ -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');
Expand Down
24 changes: 20 additions & 4 deletions laboratory/api-src/org/labkey/api/laboratory/TabbedReportItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class TabbedReportItem extends AbstractNavItem
private final Map<String, FieldKey> _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);

Expand Down Expand Up @@ -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<String, String> 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<String, String> map = PropertyManager.getProperties(c, OVERRIDES_PROP_KEY);
Expand All @@ -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"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', {
},{
html: '<b>Visible?</b>',
style: 'padding-bottom: 5px;margin-left: 5px;'
},{
html: '<b>Default Report?</b>',
style: 'padding-bottom: 5px;margin-left: 5px;'
}];

items = LDK.Utils.sortByProperty(items, 'name', false);
Expand All @@ -90,17 +93,22 @@ 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);

var cfg = {
itemId: 'theTable',
layout: {
type: 'table',
columns: 4
columns: 5
},
border: false,
defaults: {
Expand All @@ -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<rows;i++){
var base = i * cols;
var navItem = items.get(base).navItem;
toSave[navItem.overridesKey] = {
reportCategory: items.get(base + 1).getValue(),
label: items.get(base + 2).getValue(),
reportCategory: items.get(base + 1).getValue()
isVisible: items.get(base + 3).getValue(),
isDefaultReport: items.get(base + 4).getValue()
}
}

Expand Down
68 changes: 68 additions & 0 deletions laboratory/resources/web/laboratory/panel/DataBrowserPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Ext4.define('Laboratory.panel.DataBrowserPanel', {
extend: 'LDK.panel.TabbedReportPanel',

initComponent: function(){
Ext4.ns('Laboratory.tabbedReports');

Ext4.apply(this, {
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 = [];
var foundDefault = false;
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);

if (report.isDefaultReport) {
this.defaultReport = report.id;
if (foundDefault) {
log.error('More than one TabbedReport marked as default!');
}

foundDefault = true;
console.log(this.defaultReport);
}
}
}, 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
}]
});
44 changes: 41 additions & 3 deletions laboratory/src/org/labkey/laboratory/LaboratoryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,8 @@ public ApiResponse execute(JsonDataForm form, BindException errors)
Map<String, Object> 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<TabbedReportItem> tabbedReports = LaboratoryService.get().getTabbedReportItems(getContainer(), getUser());
Map<String, TabbedReportItem> reportMap = new HashMap<>();
Expand All @@ -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)
Expand All @@ -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().isEmpty())
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);
}
Expand Down
61 changes: 12 additions & 49 deletions laboratory/src/org/labkey/laboratory/view/dataBrowser.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -59,53 +64,13 @@
<div id="<%=h(wpId)%>"></div>

<script type="text/javascript" nonce="<%=getScriptNonce()%>">
Ext4.onReady(function(){
var webpartId = <%=q(wpId)%>;

Ext4.define('Laboratory.panel.TabbedReportPanel', {
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();
},
var subjectId = LABKEY.ActionURL.getParameter('subjectId');

Ext4.onReady(function(){
Ext4.create('Laboratory.panel.DataBrowserPanel', {
initialContext: subjectId ? {
subjects: subjectId
} : null,
filterTypes: [{
xtype: 'ldk-singlesubjectfiltertype',
inputValue: LDK.panel.SingleSubjectFilterType.filterName,
Expand All @@ -119,8 +84,6 @@
inputValue: LDK.panel.NoFiltersFilterType.filterName,
label: LDK.panel.NoFiltersFilterType.label
}]
});

Ext4.create('Laboratory.panel.TabbedReportPanel').render(webpartId);
}).render(<%=q(wpId)%>);
});
</script>