Skip to content

Commit

Permalink
CDS learn group page refactor (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-klum authored Feb 27, 2024
1 parent 68b97bc commit 4aefcbb
Show file tree
Hide file tree
Showing 17 changed files with 367 additions and 497 deletions.
26 changes: 0 additions & 26 deletions resources/queries/cds/learn_groups.sql

This file was deleted.

59 changes: 20 additions & 39 deletions resources/queries/cds/learn_studiesforgroups.sql
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
SELECT DISTINCT
-- Query for studies with either product or assay data associated with it, used by the learn group store
-- to get the list of studies for the group summary pages

g.group_id,
g.study_label,
g.group_name,
group_concat(g.has_data) AS has_data, -- since LK SQL doesn't support boolean aggregate, going this route
g.study_name,
g.description
SELECT DISTINCT g.study_name,
g.study_label,
g.description,
g.has_data
FROM (SELECT s.study_name,
s.label AS study_label,
s.description,
CASE
WHEN (afs.has_data IS NULL AND pfs.has_data IS NULL) THEN false
WHEN (afs.has_data IS NULL) THEN pfs.has_data
WHEN (pfs.has_data IS NULL) THEN afs.has_data
ELSE (afs.has_data OR pfs.has_data)
END AS has_data

FROM
(SELECT DISTINCT
sgm.groupId.rowid AS group_id,
s.label AS study_label,
sgm.groupId.label AS group_name,
(CASE WHEN afs.has_data IS NULL OR pfs.has_data IS NULL THEN false ELSE (afs.has_data OR pfs.has_data) END) AS has_data,
s.study_name AS study_name,
s.description
FROM cds.study s
LEFT JOIN cds.learn_productsforstudies pfs
ON s.study_name = pfs.study_name
LEFT JOIN cds.learn_assaysforstudies afs ON s.study_name = afs.prot) g

FROM
study.subjectgroupmap sgm
LEFT JOIN study.subjectcategory sc ON sgm.groupId.CategoryId.RowId = sc.RowId
LEFT JOIN cds.study s ON sgm.container.name = s.study_name -- each study protocol has a container of the same name as the study protocol
LEFT JOIN cds.learn_productsforstudies pfs ON sgm.container.name = pfs.study_name
LEFT JOIN cds.learn_assaysforstudies afs ON sgm.container.name = afs.prot

WHERE sc.OwnerId IN (-1, userid()) -- Get Shared/Curated groups and Saved Groups created by the current user

GROUP BY
sgm.groupId.rowid,
s.label,
sgm.groupId.label,
afs.has_data,
pfs.has_data,
s.study_name,
s.description) g

GROUP BY
g.group_id,
g.study_label,
g.group_name,
g.study_name,
g.description
GROUP BY g.study_name, g.study_label, g.description, g.has_data
1 change: 0 additions & 1 deletion src/org/labkey/cds/view/template/ConnectorTemplate.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
srcPath + "/model/InfoPaneMember.js",
srcPath + "/model/TimepointPane.js",
srcPath + "/model/Summary.js",
srcPath + "/model/Group.js",
srcPath + "/model/Grid.js",
srcPath + "/model/MabDetail.js",
srcPath + "/model/MabGrid.js",
Expand Down
19 changes: 7 additions & 12 deletions test/src/org/labkey/test/components/cds/ActiveFilterDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,28 @@ public void saveGroup()
getWrapper().waitForElement(Locator.linkWithText(getGroupName()));
}

public ActiveFilterDialog saveExpectingError(String errorMsg)
public ActiveFilterDialog saveExpectingError(String expectedMsg)
{
final int RETRY_LIMIT = 5;
boolean worked = false;
boolean done = false;
int count = 0;
String errMsg = "";
String msg = "";
getWrapper().shortWait().until(ExpectedConditions.elementToBeClickable(elementCache().saveGroup));
while (!worked)
while (!done && (count++ <= RETRY_LIMIT))
{
count++;
try
{
elementCache().saveGroup.click();
errMsg = elementCache().errorMsg.findElement(_activeFilterDialogEl).getText();
worked = true;
msg = elementCache().errorMsg.findElement(_activeFilterDialogEl).getText();
done = expectedMsg.equals(msg);
}
catch (NoSuchElementException ex)
{
if (count > RETRY_LIMIT)
throw ex;

BaseWebDriverTest.sleep(500);
worked = false;
}
}

Assert.assertEquals("Error message is not as expected", errorMsg, errMsg);
Assert.assertEquals("Error message is not as expected", expectedMsg, msg);
return this;
}

Expand Down
1 change: 1 addition & 0 deletions test/src/org/labkey/test/tests/cds/CDSGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public void testUpdateThisGroup()

log("Verify group description is updated");
detailsPage = cds.goToGroup(STUDY_GROUP);
detailsPage.waitForPage();
Assert.assertEquals("Group Name is incorrect", STUDY_GROUP, detailsPage.getGroupName());
Assert.assertEquals("Group description is incorrect", studyGroupDescModified, detailsPage.getGroupDescription());

Expand Down
1 change: 0 additions & 1 deletion webapp/Connector/extapp.lib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<script path="Connector/src/model/InfoPaneMember.js"/>
<script path="Connector/src/model/TimepointPane.js"/>
<script path="Connector/src/model/Summary.js"/>
<script path="Connector/src/model/Group.js"/>
<script path="Connector/src/model/Grid.js"/>
<script path="Connector/src/model/MabDetail.js"/>
<script path="Connector/src/model/MabGrid.js"/>
Expand Down
57 changes: 47 additions & 10 deletions webapp/Connector/src/app/model/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,57 @@ Ext.define('Connector.app.model.Group', {

extend : 'Ext.data.Model',

idProperty: 'group_name',
idProperty: 'label',

labelProperty: 'group_name',
labelProperty: 'label',

resolvableField: 'group_name',
resolvableField: 'label',

fields: [
{name: 'group_name', sortType: 'asUCString'},
{name: 'group_type'},
{name: 'label', sortType: 'asUCString'},
{name: 'id'},
{name: 'rowid'},

// fields for the home page listing and group summary
{name: 'filters'},
{name: 'containsPlot', type: 'boolean', defaultValue: false, convert : function(value, partial) {
if (partial.raw){
if (partial.raw.type === 'mab')
return value;
var raw = partial.raw.filters;
var containsPlot = false;
if (Ext.isString(raw)) {
var filterArray = Connector.model.Filter.fromJSON(raw);
if (Ext.isArray(filterArray)) {
Ext.each(filterArray, function(filter) {
if (filter.isPlot === true) {
containsPlot = true;
}
});
}
}
return containsPlot;
}
}},
{name: 'categoryId'},
{name: 'shared', type: 'boolean', defaultValue: false, convert : function(value, partial) {
if (partial.raw){
if (partial.raw.type === 'mab')
return value;
return partial.raw.category.shared;
}
}},
{name: 'type'},
{name: 'participantIds', convert : Connector.model.Filter.asArray},
{name: 'modified', type: 'DATE'},
{name: 'isMab', type: 'Boolean'},
{name: 'group_id'},
{name: 'description'},
{name: 'description', convert : function(value, partial) {
if (partial.raw){
return partial.raw.description ? partial.raw.description : 'No description given.'
}
}},

// fields for the learn grid
{name: 'study_label'},
{name: 'studies', convert : Connector.model.Filter.asArray},
{name: 'studySpecies', convert : Connector.model.Filter.asArray},
Expand All @@ -28,15 +67,13 @@ Ext.define('Connector.app.model.Group', {
{name: 'products', convert : Connector.model.Filter.asArray},
{name: 'assay_identifier'},
{name: 'assays', convert : Connector.model.Filter.asArray},

{name: 'study_names', convert : Connector.model.Filter.asArray},
{name: 'product_names', convert : Connector.model.Filter.asArray},
{name: 'assay_names', convert : Connector.model.Filter.asArray},
{name: 'species_names', convert : Connector.model.Filter.asArray},

{name: 'study_names_to_sort_on'},
{name: 'product_to_sort_on'},
{name: 'species_to_sort_on'},
{name: 'assay_to_sort_on'},
{name: 'assay_to_sort_on'}
]
});
Loading

0 comments on commit 4aefcbb

Please sign in to comment.