@onehat/ui 0.3.273 → 0.3.274

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.3.273",
3
+ "version": "0.3.274",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -58,6 +58,7 @@ export function ComboComponent(props) {
58
58
  onGridSave, // to hook into when menu saves (ComboEditor only)
59
59
  onGridDelete, // to hook into when menu deletes (ComboEditor only)
60
60
  newEntityDisplayProperty,
61
+ testID,
61
62
 
62
63
  // withComponent
63
64
  self,
@@ -361,7 +362,7 @@ export function ComboComponent(props) {
361
362
  menuRef.current === relatedTarget ||
362
363
  menuRef.current?.contains(relatedTarget);
363
364
  },
364
- getFilterName = () => {
365
+ getFilterName = (isId) => {
365
366
  // Only used for remote repositories
366
367
  // Gets the filter name of the query, which becomes the condition sent to server
367
368
  let filterName = FILTER_NAME;
@@ -372,7 +373,10 @@ export function ComboComponent(props) {
372
373
  displayFieldDef = schema.getPropertyDefinition(displayFieldName);
373
374
 
374
375
  // Verify displayField is a real field
375
- if (!displayFieldDef.isVirtual) {
376
+ if (isId) {
377
+ const idFieldName = schema.model.idProperty;
378
+ filterName = idFieldName;
379
+ } else if (!displayFieldDef.isVirtual) {
376
380
  filterName = displayFieldName + ' LIKE';
377
381
  }
378
382
  }
@@ -418,10 +422,13 @@ export function ComboComponent(props) {
418
422
  }
419
423
 
420
424
  // Set filter
421
- const filterName = getFilterName();
425
+ const
426
+ idRegex = /^id:(.*)$/,
427
+ isId = _.isString(value) && !!value.match(idRegex),
428
+ filterName = getFilterName(isId);
422
429
  if (Repository.isRemote) {
423
430
  // remote
424
- const filterValue = _.isEmpty(value) ? null : value + '%';
431
+ const filterValue = _.isEmpty(value) ? null : (isId ? value.match(idRegex)[1] : value + '%');
425
432
  await Repository.filter(filterName, filterValue);
426
433
  if (!Repository.isAutoLoad) {
427
434
  await Repository.reload();
@@ -958,7 +965,7 @@ export function ComboComponent(props) {
958
965
  if (isRendered && additionalButtons?.length && containerWidth < 500) {
959
966
  // be responsive for small screen sizes and bump additionalButtons to the next line
960
967
  assembledComponents =
961
- <Column>
968
+ <Column testID={testID}>
962
969
  <Row {...refProps} justifyContent="center" alignItems="center" flex={1} h="100%">
963
970
  {xButton}
964
971
  {eyeButton}
@@ -971,7 +978,7 @@ export function ComboComponent(props) {
971
978
  </Column>;
972
979
  } else {
973
980
  assembledComponents =
974
- <Row {...refProps} justifyContent="center" alignItems="center" flex={1} h="100%" onLayout={onLayout}>
981
+ <Row testID={testID} {...refProps} justifyContent="center" alignItems="center" flex={1} h="100%" onLayout={onLayout}>
975
982
  {xButton}
976
983
  {eyeButton}
977
984
  {inputAndTrigger}