Skip to content

Commit 01df03e

Browse files
authored
Issue 52556: Add data-fieldkey attribute to grid header elements and input elements (#2437)
- DetailTableEdit valueCellWithName locator removal of toLowerCase() for data-fieldkey - FieldSelectionDialog location class name change to field-caption - BatchUpdateSamplesDialog and EntityBulkInsertDialog update to helpers to get/set date/time fields based on fieldKey - EntityBulkUpdateDialog setDateField() to use fieldKey now
1 parent 4eb3518 commit 01df03e

4 files changed

Lines changed: 18 additions & 25 deletions

File tree

src/org/labkey/test/components/ui/entities/EntityBulkInsertDialog.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void setInsertFieldValues(List<FieldDefinition> fields, Map<String, Objec
233233
else if (field.getType() == FieldDefinition.ColumnType.Integer || field.getType() == FieldDefinition.ColumnType.Decimal || field.getType() == FieldDefinition.ColumnType.Double)
234234
setNumericField(fieldKey, String.valueOf(value));
235235
else if (field.getType() == FieldDefinition.ColumnType.Date || field.getType() == FieldDefinition.ColumnType.DateAndTime || field.getType() == FieldDefinition.ColumnType.Time)
236-
setDateTimeField(field.getName(), value, fieldKey);
236+
setDateTimeField(fieldKey, value);
237237
else if (field.getType() == FieldDefinition.ColumnType.TextChoice)
238238
setSelectionField(field.getLabel(), (List<String>) value);
239239
else
@@ -246,24 +246,20 @@ else if (field.getType() == FieldDefinition.ColumnType.TextChoice)
246246
* object to use the picker to set the field. If a text value is passed in it is used as a literal and jut typed
247247
* into the textbox.
248248
*
249-
* @param fieldName Field to update.
249+
* @param fieldKey Field to update.
250250
* @param dateTime A LocalDateTime, LocalDate, LocalTime or String.
251251
* @return A reference to this page.
252252
*/
253-
public EntityBulkInsertDialog setDateTimeField(String fieldName, Object dateTime)
253+
public EntityBulkInsertDialog setDateTimeField(String fieldKey, Object dateTime)
254254
{
255-
return setDateTimeField(fieldName, dateTime, null);
256-
}
257-
public EntityBulkInsertDialog setDateTimeField(String fieldName, Object dateTime, @Nullable String fieldKey)
258-
{
259-
ReactDateTimePicker dateTimePicker = elementCache().dateInput(fieldName, fieldKey);
255+
ReactDateTimePicker dateTimePicker = elementCache().dateInput(fieldKey);
260256
dateTimePicker.select(dateTime);
261257
return this;
262258
}
263259

264-
public String getDateTimeField(String fieldName, @Nullable String fieldKey)
260+
public String getDateTimeField(String fieldKey)
265261
{
266-
return elementCache().dateInput(fieldName, fieldKey).get();
262+
return elementCache().dateInput(fieldKey).get();
267263
}
268264

269265
public EntityBulkInsertDialog setBooleanField(String fieldKey, boolean checked)
@@ -410,13 +406,10 @@ public Input numericInput(String fieldKey)
410406
return new Input(inputEl, getDriver());
411407
}
412408

413-
public ReactDateTimePicker dateInput(String fieldName, @Nullable String fieldKey)
409+
public ReactDateTimePicker dateInput(String fieldKey)
414410
{
415-
if (fieldKey == null)
416-
fieldKey = fieldName;
417-
418411
return new ReactDateTimePicker.ReactDateTimeInputFinder(getDriver())
419-
.withInputId(fieldKey).find(formRow(fieldName));
412+
.withInputId(fieldKey).find(formRow(fieldKey));
420413
}
421414

422415
public List<WebElement> fieldLabels()

src/org/labkey/test/components/ui/entities/EntityBulkUpdateDialog.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void setValue(FieldDefinition field, Object newValue)
8585
else if (field.getType() == FieldDefinition.ColumnType.Integer || field.getType() == FieldDefinition.ColumnType.Decimal || field.getType() == FieldDefinition.ColumnType.Double)
8686
setNumericField(EscapeUtil.fieldKeyEncodePart(field.getName()), String.valueOf(newValue));
8787
else if (field.getType() == FieldDefinition.ColumnType.Date || field.getType() == FieldDefinition.ColumnType.DateAndTime || field.getType() == FieldDefinition.ColumnType.Time)
88-
setDateField(field.getLabel() == null ? field.getName() : field.getLabel(), (String) newValue);
88+
setDateField(EscapeUtil.fieldKeyEncodePart(field.getName()), (String) newValue);
8989
else if (field.getType() == FieldDefinition.ColumnType.Boolean)
9090
setBooleanField(EscapeUtil.fieldKeyEncodePart(field.getName()), (Boolean) newValue);
9191
else if (field.getType() == FieldDefinition.ColumnType.MultiLine)
@@ -151,9 +151,9 @@ public String getNumericField(String fieldKey)
151151
return elementCache().numericInput(fieldKey).get();
152152
}
153153

154-
public EntityBulkUpdateDialog setDateField(String fieldLabel, String dateString)
154+
public EntityBulkUpdateDialog setDateField(String fieldKey, String dateString)
155155
{
156-
enableAndWait(fieldLabel, elementCache().dateInput(fieldLabel)).set(dateString);
156+
enableAndWait(fieldKey, elementCache().dateInput(fieldKey)).set(dateString);
157157
return this;
158158
}
159159

@@ -360,10 +360,10 @@ public Input numericInput(String fieldKey)
360360
return new Input(inputEl, getDriver());
361361
}
362362

363-
public ReactDateTimePicker dateInput(String fieldLabel)
363+
public ReactDateTimePicker dateInput(String fieldKey)
364364
{
365365
return new ReactDateTimePicker.ReactDateTimeInputFinder(getDriver())
366-
.withInputId(EscapeUtil.fieldKeyEncodePart(fieldLabel)).waitFor(formRow(fieldLabel));
366+
.withInputId(fieldKey).waitFor(formRow(fieldKey));
367367
}
368368

369369
public FileAttachmentContainer fileUploadField(String fieldKey)

src/org/labkey/test/components/ui/grids/DetailTableEdit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public WebElement valueCellWithLabel(String label)
592592

593593
public WebElement valueCellWithName(String fieldName)
594594
{
595-
return Locator.tagWithAttribute("td", "data-fieldkey", EscapeUtil.fieldKeyEncodePart(fieldName).toLowerCase()).findElement(editPanel);
595+
return Locator.tagWithAttribute("td", "data-fieldkey", EscapeUtil.fieldKeyEncodePart(fieldName)).findElement(editPanel);
596596
}
597597

598598
public FileUploadField fileField(String label)

src/org/labkey/test/components/ui/grids/FieldSelectionDialog.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public String getActiveSelectedFieldLabel()
260260

261261
if(active.isDisplayed())
262262
{
263-
return getTextContent(Locator.tagWithClass("div", "field-name").findElement(active));
263+
return getTextContent(Locator.tagWithClass("div", "field-caption").findElement(active));
264264
}
265265
else
266266
{
@@ -601,7 +601,7 @@ protected class ElementCache extends ModalDialog.ElementCache
601601
protected WebElement selectedFieldsPanel = contentPanelLocator.index(1).findWhenNeeded(this);
602602

603603
// This is present to items in both panels.
604-
protected final Locator listItemName = Locator.tagWithClass("div", "field-name");
604+
protected final Locator listItemName = Locator.tagWithClass("div", "field-caption");
605605

606606
protected final WebElement undoEditsButton = Locator.tagWithText("span", "Undo edits")
607607
.refindWhenNeeded(this);
@@ -624,15 +624,15 @@ protected class ElementCache extends ModalDialog.ElementCache
624624
protected List<WebElement> getListItemElements(WebElement panel, String fieldLabel)
625625
{
626626
return Locator.tagWithClass("div", "list-group-item")
627-
.withDescendant(Locator.tagWithClass("div", "field-name").withText(fieldLabel))
627+
.withDescendant(Locator.tagWithClass("div", "field-caption").withText(fieldLabel))
628628
.findElements(panel);
629629
}
630630

631631
// Will get the first list item that matches the fieldLabel.
632632
protected WebElement getListItemElement(WebElement panel, String fieldLabel)
633633
{
634634
return Locator.tagWithClass("div", "list-group-item")
635-
.withDescendant(Locator.tagWithClass("div", "field-name").withText(fieldLabel))
635+
.withDescendant(Locator.tagWithClass("div", "field-caption").withText(fieldLabel))
636636
.findElement(panel);
637637
}
638638

0 commit comments

Comments
 (0)