Skip to content

Commit 53007ae

Browse files
committed
Fix merge conflicts
2 parents 21917bc + fdfdf8d commit 53007ae

File tree

6 files changed

+160
-72
lines changed

6 files changed

+160
-72
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');

laboratory/api-src/org/labkey/api/laboratory/TabbedReportItem.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class TabbedReportItem extends AbstractNavItem
4646
private final Map<String, FieldKey> _additionalKeys = new HashMap<>();
4747

4848
public static final String OVERRIDES_PROP_KEY = "laboratory.tabItemOverride";
49-
public static final String FILTER_PROP_KEY = "laboratory.tabItemFilterOverride";
5049

5150
protected static final Logger _log = LogManager.getLogger(TabbedReportItem.class);
5251

@@ -177,6 +176,23 @@ public static String getOverridesPropertyKey(NavItem item)
177176
return item.getDataProvider().getKey() + "||tabReport||" + item.getReportCategory() + "||" + item.getName() + "||" + item.getLabel();
178177
}
179178

179+
public boolean hasOverride(Container c, String propName)
180+
{
181+
Map<String, String> map = PropertyManager.getProperties(c, OVERRIDES_PROP_KEY);
182+
if (!map.containsKey(getPropertyManagerKey()))
183+
{
184+
return false;
185+
}
186+
187+
JSONObject props = new JSONObject(map.get(getPropertyManagerKey()));
188+
if (!props.has(propName))
189+
{
190+
return false;
191+
}
192+
193+
return true;
194+
}
195+
180196
public static void applyOverrides(NavItem item, Container c, JSONObject json)
181197
{
182198
Map<String, String> map = PropertyManager.getProperties(c, OVERRIDES_PROP_KEY);
@@ -188,9 +204,9 @@ public static void applyOverrides(NavItem item, Container c, JSONObject json)
188204

189205
if (props.has("reportCategory"))
190206
json.put("reportCategory", props.get("reportCategory"));
191-
// retained for settings saved prior to refactor
192-
else if (props.has("category"))
193-
json.put("reportCategory", props.get("category"));
207+
208+
if (props.has("isDefaultReport"))
209+
json.put("isDefaultReport", props.get("isDefaultReport"));
194210
}
195211
}
196212
}

laboratory/resources/web/laboratory/panel/CustomizeDataBrowserPanel.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', {
6969
},{
7070
html: '<b>Visible?</b>',
7171
style: 'padding-bottom: 5px;margin-left: 5px;'
72+
},{
73+
html: '<b>Default Report?</b>',
74+
style: 'padding-bottom: 5px;margin-left: 5px;'
7275
}];
7376

7477
items = LDK.Utils.sortByProperty(items, 'name', false);
@@ -90,17 +93,22 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', {
9093
width: 300,
9194
value: item.label
9295
},{
93-
xtype: 'displayfield',
94-
value: item.visible,
96+
xtype: 'checkbox',
97+
checked: item.visible,
9598
style: 'margin-left: 15px;'
99+
},{
100+
xtype: 'radio',
101+
name: 'isDefaultReport',
102+
inputValue: true,
103+
checked: item.isDefaultReport
96104
}]);
97105
}, this);
98106

99107
var cfg = {
100108
itemId: 'theTable',
101109
layout: {
102110
type: 'table',
103-
columns: 4
111+
columns: 5
104112
},
105113
border: false,
106114
defaults: {
@@ -117,15 +125,17 @@ Ext4.define('Laboratory.panel.CustomizeDataBrowserPanel', {
117125
doSave: function(btn){
118126
var toSave = {};
119127
var items = btn.up('form').down('#theTable').items;
120-
var cols = 4;
128+
var cols = 5;
121129
var rows = (items.getCount() / cols);
122130

123131
for (var i=1;i<rows;i++){
124132
var base = i * cols;
125133
var navItem = items.get(base).navItem;
126134
toSave[navItem.overridesKey] = {
135+
reportCategory: items.get(base + 1).getValue(),
127136
label: items.get(base + 2).getValue(),
128-
reportCategory: items.get(base + 1).getValue()
137+
isVisible: items.get(base + 3).getValue(),
138+
isDefaultReport: items.get(base + 4).getValue()
129139
}
130140
}
131141

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
reportNamespace: Laboratory.tabbedReports
9+
});
10+
11+
Ext4.Msg.wait('Loading...');
12+
Laboratory.Utils.getDataItems({
13+
types: ['tabbedReports'],
14+
scope: this,
15+
success: this.onDataLoad,
16+
failure: LDK.Utils.getErrorCallback()
17+
});
18+
19+
this.callParent();
20+
},
21+
22+
onDataLoad: function(results){
23+
Ext4.Msg.hide();
24+
this.reports = [];
25+
var foundDefault = false;
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+
if (report.isDefaultReport) {
38+
this.defaultReport = report.id;
39+
if (foundDefault) {
40+
log.error('More than one TabbedReport marked as default!');
41+
}
42+
43+
foundDefault = true;
44+
console.log(this.defaultReport);
45+
}
46+
}
47+
}, this);
48+
49+
this.reports = LDK.Utils.sortByProperty(this.reports, 'name', false);
50+
this.reports = LDK.Utils.sortByProperty(this.reports, 'reportCategory', false);
51+
52+
this.createTabPanel();
53+
},
54+
55+
filterTypes: [{
56+
xtype: 'ldk-singlesubjectfiltertype',
57+
inputValue: LDK.panel.SingleSubjectFilterType.filterName,
58+
label: LDK.panel.SingleSubjectFilterType.DEFAULT_LABEL
59+
},{
60+
xtype: 'ldk-multisubjectfiltertype',
61+
inputValue: LDK.panel.MultiSubjectFilterType.filterName,
62+
label: LDK.panel.MultiSubjectFilterType.label
63+
},{
64+
xtype: 'ldk-nofiltersfiltertype',
65+
inputValue: LDK.panel.NoFiltersFilterType.filterName,
66+
label: LDK.panel.NoFiltersFilterType.label
67+
}]
68+
});

laboratory/src/org/labkey/laboratory/LaboratoryController.java

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,8 @@ public ApiResponse execute(JsonDataForm form, BindException errors)
16581658
Map<String, Object> results = new HashMap<>();
16591659

16601660
WritablePropertyMap propMap = PropertyManager.getWritableProperties(getContainer(), TabbedReportItem.OVERRIDES_PROP_KEY, true);
1661+
WritablePropertyMap visibilityMap = PropertyManager.getWritableProperties(getContainer(), NavItem.PROPERTY_CATEGORY, true);
1662+
boolean shouldSaveVisibility = false;
16611663

16621664
List<TabbedReportItem> tabbedReports = LaboratoryService.get().getTabbedReportItems(getContainer(), getUser());
16631665
Map<String, TabbedReportItem> reportMap = new HashMap<>();
@@ -1669,7 +1671,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors)
16691671
JSONObject json = new JSONObject(form.getJsonData());
16701672
for (String key : json.keySet())
16711673
{
1672-
JSONObject toSave= new JSONObject();
1674+
JSONObject toSave = new JSONObject();
16731675

16741676
TabbedReportItem ti = reportMap.get(key);
16751677
if (ti == null)
@@ -1685,13 +1687,49 @@ public ApiResponse execute(JsonDataForm form, BindException errors)
16851687
if (reportCategory != null && !ti.getReportCategory().equals(reportCategory))
16861688
toSave.put("reportCategory", reportCategory);
16871689

1688-
if (!toSave.keySet().isEmpty())
1690+
String isDefaultReport = StringUtils.trimToNull(props.optString("isDefaultReport"));
1691+
if (isDefaultReport != null)
1692+
{
1693+
if (!ti.hasOverride(getContainer(), "isDefaultReport"))
1694+
{
1695+
if ("true".equals(isDefaultReport))
1696+
{
1697+
toSave.put("isDefaultReport", isDefaultReport);
1698+
}
1699+
}
1700+
else
1701+
{
1702+
toSave.put("isDefaultReport", isDefaultReport);
1703+
}
1704+
}
1705+
1706+
String isVisible = StringUtils.trimToNull(props.optString("isVisible"));
1707+
if (isVisible != null)
1708+
{
1709+
if (!isVisible.equals(visibilityMap.get(ti.getPropertyManagerKey())))
1710+
{
1711+
visibilityMap.put(ti.getPropertyManagerKey(), isVisible);
1712+
shouldSaveVisibility = true;
1713+
}
1714+
}
1715+
1716+
if (!toSave.isEmpty())
1717+
{
16891718
propMap.put(key, toSave.toString());
1690-
else propMap.remove(key);
1719+
}
1720+
else
1721+
{
1722+
propMap.remove(key);
1723+
}
16911724
}
16921725

16931726
propMap.save();
16941727

1728+
if (shouldSaveVisibility)
1729+
{
1730+
visibilityMap.save();
1731+
}
1732+
16951733
results.put("success", true);
16961734
return new ApiSimpleResponse(results);
16971735
}

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)