diff --git a/LDK/api-src/org/labkey/api/ldk/notification/AbstractNotification.java b/LDK/api-src/org/labkey/api/ldk/notification/AbstractNotification.java
index 39587709..cd0ce795 100644
--- a/LDK/api-src/org/labkey/api/ldk/notification/AbstractNotification.java
+++ b/LDK/api-src/org/labkey/api/ldk/notification/AbstractNotification.java
@@ -19,8 +19,13 @@
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.data.SimpleFilter;
+import org.labkey.api.data.TableInfo;
+import org.labkey.api.data.TableSelector;
import org.labkey.api.module.Module;
+import org.labkey.api.query.QueryService;
import org.labkey.api.query.QueryUrls;
+import org.labkey.api.query.UserSchema;
+import org.labkey.api.security.User;
import org.labkey.api.settings.LookAndFeelProperties;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.logging.LogHelper;
@@ -85,4 +90,40 @@ public Module getOwnerModule()
{
return _owner;
}
+
+ protected void genericQueryCheck(Container c, User u, StringBuilder msg, String schemaName, String queryName, String message)
+ {
+ genericQueryCheck(c, u, msg, schemaName, queryName, message, null);
+ }
+
+ protected void genericQueryCheck(Container c, User u, StringBuilder msg, String schemaName, String queryName, String message, @Nullable SimpleFilter filter)
+ {
+ TableInfo ti = getTableInfo(u, c, schemaName, queryName);
+
+ TableSelector ts = new TableSelector(ti, filter, null);
+ long count = ts.getRowCount();
+ if (count > 0)
+ {
+ msg.append("WARNING: There are ").append(count).append(" ").append(message).append("
\n");
+ msg.append("
Click here to view them
\n\n");
+ msg.append("
\n\n");
+ }
+ }
+
+ protected TableInfo getTableInfo(User u, Container c, String schemaName, String queryName)
+ {
+ UserSchema us = QueryService.get().getUserSchema(u, c, schemaName);
+ if (us == null)
+ {
+ throw new IllegalStateException("Missing user schema: " + schemaName);
+ }
+
+ TableInfo ti = us.getTable(queryName);
+ if (ti == null)
+ {
+ throw new IllegalStateException("Missing table: " + schemaName + "." + queryName);
+ }
+
+ return ti;
+ }
}
diff --git a/LDK/resources/web/LDK/ux/DateTimeField.js b/LDK/resources/web/LDK/ux/DateTimeField.js
index 9f713373..f8b25cd9 100644
--- a/LDK/resources/web/LDK/ux/DateTimeField.js
+++ b/LDK/resources/web/LDK/ux/DateTimeField.js
@@ -79,7 +79,6 @@ Ext4.define('Ext.ux.form.field.DateTime', {
me.dateField = Ext4.create('Ext.form.field.Date', Ext4.apply({
format:me.dateFormat,
- bubbleEvents: ['change'],
flex:1,
isFormField:false, //exclude from field query's
submitValue:false,
@@ -114,6 +113,8 @@ Ext4.define('Ext.ux.form.field.DateTime', {
this.timeField.setValue(val);
}
}
+
+ this.checkChange();
}
},
getErrors: function(value){
@@ -132,7 +133,6 @@ Ext4.define('Ext.ux.form.field.DateTime', {
me.timeField = Ext4.create('Ext.form.field.Time', Ext4.apply({
format:me.timeFormat,
- bubbleEvents: ['change'],
flex:1,
isFormField:false, //exclude from field query's
submitValue:false,
@@ -153,6 +153,8 @@ Ext4.define('Ext.ux.form.field.DateTime', {
if (date && !this.dateField.getValue()){
this.dateField.setValue(date);
}
+
+ this.checkChange();
}
},
getErrors: function(value){
@@ -191,6 +193,8 @@ Ext4.define('Ext.ux.form.field.DateTime', {
me.callParent();
me.initField();
+ // Compare later changes against the parsed Date, not a configured string
+ me.originalValue = me.lastValue = me.getValue();
},
getDefaultDate: function(){
@@ -258,8 +262,11 @@ Ext4.define('Ext.ux.form.field.DateTime', {
}
}
}
- this.dateField.setValue(value);
- this.timeField.setValue(value);
+ var me = this;
+ me.batchChanges(function(){
+ me.dateField.setValue(value);
+ me.timeField.setValue(value);
+ });
},
getFormat: function(){
diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java
index 700304ce..a2d44efd 100644
--- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java
+++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java
@@ -52,6 +52,7 @@
import org.labkey.test.util.ext4cmp.Ext4ComboRef;
import org.labkey.test.util.ext4cmp.Ext4FieldRef;
import org.labkey.test.util.external.labModules.LabModuleHelper;
+import org.openqa.selenium.WebElement;
import java.io.File;
import java.io.UnsupportedEncodingException;
@@ -857,37 +858,28 @@ private void dataSourcesTest() throws Exception
waitAndClickAndWait(_helper.toolIcon("Settings"));
waitAndClickAndWait(Locator.linkContainingText("Manage Data and Demographics Sources"));
waitForText("Below are the extra data and sample sources registered for this folder"); //proxy for data loading
- waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), WAIT_FOR_JAVASCRIPT);
+ waitForElementToDisappear(LabModuleHelper.LOADING, WAIT_FOR_JAVASCRIPT);
//precaution mainly important to resuming a test in the middle
cleanupDataSources();
//add data source
- Ext4CmpRef addDataSourceBtn = _ext4Helper.queryOne("#" + manageDataSources + " button[text='Add Default Sources']", Ext4CmpRef.class);
- waitAndClick(Locator.id(addDataSourceBtn.getId()));
- waitAndClick(Ext4Helper.Locators.menuItem(DATA_SOURCE + " (\"/home\".core.Users)"));
+ selectDefaultSource(manageDataSources, DATA_SOURCE + " (\"/home\".core.Users)");
new Window.WindowFinder(getDriver()).withTitle("Success").waitFor();
click(Ext4Helper.Locators.ext4Button("OK"));
+ waitForRemoveBtnCount(manageDataSources, 1);
- addDataSourceBtn = _ext4Helper.queryOne("#" + manageDataSources + " button[text='Add Default Sources']", Ext4CmpRef.class);
- waitAndClick(Locator.id(addDataSourceBtn.getId()));
- waitAndClick(Ext4Helper.Locators.menuItem(GROUP_SOURCE + " (core.Groups)"));
+ selectDefaultSource(manageDataSources, GROUP_SOURCE + " (core.Groups)");
new Window.WindowFinder(getDriver()).withTitle("Success").waitFor();
click(Ext4Helper.Locators.ext4Button("OK"));
-
- waitForText("Item Type");
- assertEquals("Incorrect number of remove buttons", 2, getRemoveBtns(manageDataSources).size());
+ waitForRemoveBtnCount(manageDataSources, 2);
//add demographics source
- Ext4CmpRef addDemographicsSourceBtn = _ext4Helper.queryOne("#" + manageDemographicsSources + " button[text='Add Default Sources']", Ext4CmpRef.class);
- waitAndClick(Locator.id(addDemographicsSourceBtn.getId()));
- waitAndClick(Ext4Helper.Locators.menuItem(SUBJECT_LIST + " (laboratory.subjects)"));
+ selectDefaultSource(manageDemographicsSources, SUBJECT_LIST + " (laboratory.subjects)");
new Window.WindowFinder(getDriver()).withTitle("Success").waitFor();
click(Ext4Helper.Locators.ext4Button("OK"));
-
- waitForText("Table Name");
+ waitForRemoveBtnCount(manageDemographicsSources, 1);
waitForText("New Data Sources");
- assertEquals("Incorrect number of remove buttons", 1, getRemoveBtns(manageDemographicsSources).size());
//query to make sure columns added:
Connection cn = WebTestHelper.getRemoteApiConnection();
@@ -987,6 +979,27 @@ private List getRemoveBtns(String parentItemId)
return _ext4Helper.componentQuery("#" + parentItemId + " button[text='Remove']", Ext4CmpRef.class);
}
+ private void selectDefaultSource(String panelItemId, String sourceText)
+ {
+ Locator menuItem = Ext4Helper.Locators.menuItem(sourceText);
+ // A click on the menu button can be lost while the panel finishes reloading after the previous save
+ waitFor(() -> {
+ Ext4CmpRef addSourceBtn = _ext4Helper.queryOne("#" + panelItemId + " button[text='Add Default Sources']", Ext4CmpRef.class);
+ click(Locator.id(addSourceBtn.getId()));
+ return waitFor(() -> menuItem.findOptionalElement(getDriver()).filter(WebElement::isDisplayed).isPresent(), 2_000);
+ }, "'Add Default Sources' menu did not show " + sourceText, WAIT_FOR_JAVASCRIPT);
+ click(menuItem);
+ }
+
+ // Saving a source reloads the panel asynchronously, which also rebuilds its 'Add Default Sources' menu
+ private void waitForRemoveBtnCount(String parentItemId, int expectedCount)
+ {
+ waitForEquals("Incorrect number of remove buttons", () -> expectedCount, () -> {
+ List btns = getRemoveBtns(parentItemId);
+ return btns == null ? 0 : btns.size();
+ }, WAIT_FOR_JAVASCRIPT);
+ }
+
private String replaceNonVisibleChars(String value)
{
//the DB might not store unicode chars correctly, so we just eliminate them here
@@ -1008,7 +1021,7 @@ private void deleteSourceByLabel(String label, String parentItemId)
click(Ext4Helper.Locators.ext4Button("OK"));
waitForText("Loading...");
- waitForElementToDisappear(Locator.xpath("//div[" + Locator.NOT_HIDDEN + " and contains(text(), 'Loading...')]"), WAIT_FOR_JAVASCRIPT);
+ waitForElementToDisappear(LabModuleHelper.LOADING.notHidden(), WAIT_FOR_JAVASCRIPT);
}
private void settingsTest()
@@ -1790,7 +1803,7 @@ private void searchPanelTest()
{
_helper.goToLabHome();
_helper.clickNavPanelItem("DNA_Oligos:", "Search");
- waitForTextToDisappear("Loading...");
+ waitForElementToDisappear(LabModuleHelper.LOADING);
waitForElement(Locator.name("name"));
sleep(50);
_helper.setFormField("name", "TestPrimer");
diff --git a/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java b/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java
index 5615ca1b..6d968506 100644
--- a/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java
+++ b/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java
@@ -48,6 +48,8 @@ public class LabModuleHelper
public static final String IMPORT_DATA_TEXT = "Import Data";
public static final String UPLOAD_RESULTS_TEXT = "Upload Results";
public static final String LAB_HOME_TEXT = "Types of Data:";
+ // The header product menu's collapsed dropdown always holds a "Loading..." placeholder
+ public static final Locator.XPathLocator LOADING = Locator.xpath("//div[contains(text(), 'Loading...')][not(ancestor::*[@id='headerProductDropdown'])]");
public static final String POS_COLOR = "rgb(255, 192, 203)";
public static final String UNKNOWN_COLOR = "rgb(0, 0, 255)";
@@ -324,7 +326,7 @@ public void addDataSource(String type, String label, String reportCategory, Stri
_test.waitAndClick(Locator.id(addBtn.getId()));
_test.waitForElement(Ext4Helper.Locators.window("Add Data Source"));
- _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
waitForField("Item Type");
Ext4FieldRef.getForLabel(_test, "Item Type").setValue(type);
Ext4FieldRef.getForLabel(_test, "Label").setValue(label);
@@ -333,13 +335,13 @@ public void addDataSource(String type, String label, String reportCategory, Stri
{
Ext4ComboRef combo = new Ext4ComboRef(Ext4FieldRef.getForLabel(_test, "Container (optional)"), _test);
combo.setComboByDisplayValue(containerPath);
- _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
}
Ext4FieldRef schemaField = Ext4FieldRef.getForLabel(_test, "Schema");
schemaField.waitForEnabled();
schemaField.setValue(schema);
- _test.waitForElementToDisappear(Locator.tagWithText("div", "Loading..."), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3);
Ext4FieldRef queryField = Ext4FieldRef.getForLabel(_test, "Query");
queryField.waitForEnabled();
@@ -361,7 +363,7 @@ public void addDemographicsSource(String label, String containerPath, String sch
_test.waitAndClick(Locator.id(addBtn.getId()));
_test.waitForElement(Ext4Helper.Locators.window("Add Demographics Source"));
- _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
waitForField("Label");
Ext4FieldRef.getForLabel(_test, "Label").setValue(label);
@@ -369,14 +371,14 @@ public void addDemographicsSource(String label, String containerPath, String sch
{
Ext4ComboRef combo = new Ext4ComboRef(Ext4FieldRef.getForLabel(_test, "Container (optional)"), _test);
combo.setComboByDisplayValue(containerPath);
- _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
}
Ext4FieldRef.getForLabel(_test, "Schema").setValue(schema);
- _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3);
Ext4FieldRef.getForLabel(_test, "Query").setValue(query);
- _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
+ _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT);
if (targetColumn != null)
Ext4FieldRef.getForLabel(_test, "Target Column").setValue(targetColumn);