Skip to content

Commit 4b2d7f9

Browse files
committed
Read subjectId off URL
1 parent c39e17f commit 4b2d7f9

File tree

3 files changed

+74
-60
lines changed

3 files changed

+74
-60
lines changed

LDK/resources/web/LDK/panel/TabbedReportPanel.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,8 @@ Ext4.define('LDK.panel.TabbedReportPanel', {
10711071
return filter ? Ext4.apply({}, filter) : null;
10721072
},
10731073

1074-
getFiltersFromUrl: function(){
1075-
var context = {};
1074+
getFiltersFromUrl: function(context){
1075+
context = context || {};
10761076

10771077
if (document.location.hash){
10781078
var token = document.location.hash.split('#');
@@ -1302,18 +1302,11 @@ Ext4.define('LDK.panel.TabbedReportPanel', {
13021302
if (report)
13031303
this.silentlySetActiveTab(report);
13041304
}
1305-
else if (this.defaultTab) {
1306-
var tab = tabPanel.down('#' + this.defaultTab);
1307-
tabPanel.suspendEvents();
1308-
tab.suspendEvents();
1309-
tabPanel.setActiveTab(tab);
1310-
tab.resumeEvents();
1311-
tabPanel.resumeEvents();
1312-
}
13131305

13141306
//populate initial fields
13151307
var shouldChange = true;
1316-
this.initialContext = this.getFiltersFromUrl();
1308+
1309+
this.initialContext = this.getFiltersFromUrl(this.initialContext);
13171310
var filterType = this.initialContext.inputType;
13181311
if (filterType){
13191312
var radio = this.down('#inputType');
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Ext4.define('Laboratory.panel.DataBrowserPanel', {
2+
extend: 'LDK.panel.TabbedReportPanel',
3+
4+
initComponent: function(){
5+
Ext4.ns('Laboratory.tabbedReports');
6+
7+
Ext4.apply(this, {
8+
//defaultReport: 'abstract',
9+
reportNamespace: Laboratory.tabbedReports
10+
});
11+
12+
Ext4.Msg.wait('Loading...');
13+
Laboratory.Utils.getDataItems({
14+
types: ['tabbedReports'],
15+
scope: this,
16+
success: this.onDataLoad,
17+
failure: LDK.Utils.getErrorCallback()
18+
});
19+
20+
this.callParent();
21+
},
22+
23+
onDataLoad: function(results){
24+
Ext4.Msg.hide();
25+
this.reports = [];
26+
Ext4.each(results.tabbedReports, function(report){
27+
LDK.Assert.assertNotEmpty('Tabbed Report is null', report);
28+
if (report && report.key){
29+
report.id = report.key.replace(/:/g, '_');
30+
report.category = report.reportCategory;
31+
32+
if (report.targetContainer){
33+
report.containerPath = report.targetContainer;
34+
}
35+
this.reports.push(report);
36+
}
37+
}, this);
38+
39+
this.reports = LDK.Utils.sortByProperty(this.reports, 'name', false);
40+
this.reports = LDK.Utils.sortByProperty(this.reports, 'reportCategory', false);
41+
42+
this.createTabPanel();
43+
},
44+
45+
filterTypes: [{
46+
xtype: 'ldk-singlesubjectfiltertype',
47+
inputValue: LDK.panel.SingleSubjectFilterType.filterName,
48+
label: LDK.panel.SingleSubjectFilterType.DEFAULT_LABEL
49+
},{
50+
xtype: 'ldk-multisubjectfiltertype',
51+
inputValue: LDK.panel.MultiSubjectFilterType.filterName,
52+
label: LDK.panel.MultiSubjectFilterType.label
53+
},{
54+
xtype: 'ldk-nofiltersfiltertype',
55+
inputValue: LDK.panel.NoFiltersFilterType.filterName,
56+
label: LDK.panel.NoFiltersFilterType.label
57+
}]
58+
});

laboratory/src/org/labkey/laboratory/view/dataBrowser.jsp

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
public void addClientDependencies(ClientDependencies dependencies)
2828
{
2929
dependencies.add("laboratory.context");
30+
dependencies.add("/laboratory/panel/DataBrowserPanel.js");
31+
dependencies.add("LDK/panel/AbstractFilterType.js");
32+
dependencies.add("LDK/panel/SingleSubjectFilterType.js");
33+
dependencies.add("LDK/panel/MultiSubjectFilterType.js");
34+
dependencies.add("LDK/panel/NoFiltersFilterType.js");
3035
}
3136
3237
private String getFilterConfig()
@@ -59,53 +64,13 @@
5964
<div id="<%=h(wpId)%>"></div>
6065

6166
<script type="text/javascript" nonce="<%=getScriptNonce()%>">
62-
Ext4.onReady(function(){
63-
var webpartId = <%=q(wpId)%>;
64-
65-
Ext4.define('Laboratory.panel.TabbedReportPanel', {
66-
extend: 'LDK.panel.TabbedReportPanel',
67-
68-
initComponent: function(){
69-
Ext4.ns('Laboratory.tabbedReports');
70-
71-
Ext4.apply(this, {
72-
//defaultReport: 'abstract',
73-
reportNamespace: Laboratory.tabbedReports
74-
});
75-
76-
Ext4.Msg.wait('Loading...');
77-
Laboratory.Utils.getDataItems({
78-
types: ['tabbedReports'],
79-
scope: this,
80-
success: this.onDataLoad,
81-
failure: LDK.Utils.getErrorCallback()
82-
});
83-
84-
this.callParent();
85-
},
86-
87-
onDataLoad: function(results){
88-
Ext4.Msg.hide();
89-
this.reports = [];
90-
Ext4.each(results.tabbedReports, function(report){
91-
LDK.Assert.assertNotEmpty('Tabbed Report is null', report);
92-
if (report && report.key){
93-
report.id = report.key.replace(/:/g, '_');
94-
report.category = report.reportCategory;
95-
96-
if (report.targetContainer){
97-
report.containerPath = report.targetContainer;
98-
}
99-
this.reports.push(report);
100-
}
101-
}, this);
102-
103-
this.reports = LDK.Utils.sortByProperty(this.reports, 'name', false);
104-
this.reports = LDK.Utils.sortByProperty(this.reports, 'reportCategory', false);
105-
106-
this.createTabPanel();
107-
},
67+
var subjectId = LABKEY.ActionURL.getParameter('subjectId');
10868
69+
Ext4.onReady(function(){
70+
Ext4.create('Laboratory.panel.DataBrowserPanel', {
71+
initialContext: subjectId ? {
72+
subjects: subjectId
73+
} : null,
10974
filterTypes: [{
11075
xtype: 'ldk-singlesubjectfiltertype',
11176
inputValue: LDK.panel.SingleSubjectFilterType.filterName,
@@ -119,8 +84,6 @@
11984
inputValue: LDK.panel.NoFiltersFilterType.filterName,
12085
label: LDK.panel.NoFiltersFilterType.label
12186
}]
122-
});
123-
124-
Ext4.create('Laboratory.panel.TabbedReportPanel').render(webpartId);
87+
}).render(<%=q(wpId)%>);
12588
});
12689
</script>

0 commit comments

Comments
 (0)