From 00e343cbb59d707059904bfc49f927557778eb89 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Thu, 27 Jun 2019 13:00:55 -0700 Subject: [PATCH] Issue 37826: Lookup from linked schema query to a non-linked schema target fails to apply proper ContainerFilter Also, prompt for parameters on linked schema queries that include them New QueryWebPart option to suppress filters and parameter values in the header --- api/src/org/labkey/api/data/DataRegion.java | 22 +++++++++++-------- api/webapp/clientapi/dom/DataRegion.js | 4 ++++ query/src/org/labkey/query/LinkedSchema.java | 3 ++- .../src/org/labkey/query/LinkedTableInfo.java | 11 +++++++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/api/src/org/labkey/api/data/DataRegion.java b/api/src/org/labkey/api/data/DataRegion.java index ee2fed90d98..31770bd2b5d 100644 --- a/api/src/org/labkey/api/data/DataRegion.java +++ b/api/src/org/labkey/api/data/DataRegion.java @@ -2769,19 +2769,23 @@ public Map prepareMessages(RenderContext ctx) throws IOException protected void prepareParameters(RenderContext ctx) { - Map parameters = getQueryParameters(); - - if (!parameters.isEmpty()) + // Treat parameters like filters in terms of showing them or not in the header of the grid + if (isShowFilterDescription()) { - for (Map.Entry entry : parameters.entrySet()) + Map parameters = getQueryParameters(); + + if (!parameters.isEmpty()) { - String text = entry.getKey() + " = " + entry.getValue(); + for (Map.Entry entry : parameters.entrySet()) + { + String text = entry.getKey() + " = " + entry.getValue(); - ContextAction.Builder action = new ContextAction.Builder() - .iconCls("question") - .text(text); + ContextAction.Builder action = new ContextAction.Builder() + .iconCls("question") + .text(text); - _contextActions.add(action.build()); + _contextActions.add(action.build()); + } } } } diff --git a/api/webapp/clientapi/dom/DataRegion.js b/api/webapp/clientapi/dom/DataRegion.js index 40bea91f858..9ab4cc5a476 100644 --- a/api/webapp/clientapi/dom/DataRegion.js +++ b/api/webapp/clientapi/dom/DataRegion.js @@ -372,6 +372,8 @@ if (!LABKEY.DataRegions) { showRecordSelectors: false, + showFilterDescription: true, + showReports: undefined, /** @@ -3648,6 +3650,7 @@ if (!LABKEY.DataRegions) { 'showPaginationCount', 'showReports', 'showSurroundingBorder', + 'showFilterDescription', 'showUpdateColumn', 'showViewPanel', 'timeout', @@ -4449,6 +4452,7 @@ if (!LABKEY.DataRegions) { * @param {boolean} [config.showRStudioButton] Show the export to RStudio button menu in the button bar. Requires export button to work. (default false). * @param {boolean} [config.showBorders] Render the table with borders (default true). * @param {boolean} [config.showSurroundingBorder] Render the table with a surrounding border (default true). + * @param {boolean} [config.showFilterDescription] Include filter and parameter values in the grid header, if present (default true). * @param {boolean} [config.showRecordSelectors] Render the select checkbox column (default undefined, meaning they will be shown if the query is updatable by the current user). * If 'showDeleteButton' is true, the checkboxes will be included regardless of the 'showRecordSelectors' config option. * @param {boolean} [config.showPagination] Show the pagination links and count (default true). diff --git a/query/src/org/labkey/query/LinkedSchema.java b/query/src/org/labkey/query/LinkedSchema.java index eaf620bd26f..1852a3ea55b 100644 --- a/query/src/org/labkey/query/LinkedSchema.java +++ b/query/src/org/labkey/query/LinkedSchema.java @@ -283,8 +283,9 @@ protected TableInfo createSourceTable(String name) @Override public @NotNull ContainerFilter getDefaultContainerFilter() { + return super.getDefaultContainerFilter(); // NOTE: The source table ContainerFilter is already set by _sourceSchema.getTable() - return new ContainerFilter.InternalNoContainerFilter(getUser()); +// return new ContainerFilter.InternalNoContainerFilter(getUser()); } @Override diff --git a/query/src/org/labkey/query/LinkedTableInfo.java b/query/src/org/labkey/query/LinkedTableInfo.java index 5ff1f3e4a4f..3c7e1b03015 100644 --- a/query/src/org/labkey/query/LinkedTableInfo.java +++ b/query/src/org/labkey/query/LinkedTableInfo.java @@ -38,8 +38,11 @@ import org.labkey.api.query.UserIdQueryForeignKey; import org.labkey.api.query.UserSchema; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; @@ -194,9 +197,11 @@ protected Collection addDomainColumns() public Collection getNamedParameters() { // LinkedTableInfo only exposes named parameters defined in the original TableInfo - // and removes named parameters that are added to the generated LinkedSchema.createQueryDef() query. - //return super.getNamedParameters(); - return Collections.emptyList(); + // and named parameters already have a value supplied via the template + List result = new ArrayList<>(getRealTable().getNamedParameters()); + Map values = fireCustomizeParameterValues(); + result.removeIf(param -> values.get(param.getName()) != null); + return result; } @NotNull