@onehat/ui 0.3.188 → 0.3.190

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.188",
3
+ "version": "0.3.190",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -745,15 +745,15 @@ export function ComboComponent(props) {
745
745
  }
746
746
 
747
747
  }}
748
- onAdd={(entity) => {
749
- if (entity?.id !== value && !isInTag) {
748
+ onAdd={(selection) => {
749
+ const entity = selection[0];
750
+ if (entity.id !== value && !isInTag) {
750
751
  // Select it and set the value of the combo.
751
- setGridSelection([entity]);
752
- const id = entity.id;
753
- setValue(id);
752
+ setGridSelection(selection);
753
+ setValue(entity.id);
754
754
  }
755
755
  if (onGridAdd) {
756
- onGridAdd([entity]);
756
+ onGridAdd(selection);
757
757
  }
758
758
  }}
759
759
  onSave={(selection) => {
@@ -761,9 +761,8 @@ export function ComboComponent(props) {
761
761
  if (entity?.id !== value && !isInTag) { // Tag doesn't use value, so don't do this comparison in the Tag
762
762
  // Either a phantom record was just solidified into a real record, or a new (non-phantom) record was added.
763
763
  // Select it and set the value of the combo.
764
- setGridSelection([entity]);
765
- const id = entity.id;
766
- setValue(id);
764
+ setGridSelection(selection);
765
+ setValue(entity.id);
767
766
  }
768
767
  if (onGridSave) {
769
768
  onGridSave(selection);
@@ -33,7 +33,6 @@ export default function withEditor(WrappedComponent, isTree = false) {
33
33
  }
34
34
  return 'record' + (selection[0].displayValue ? ' "' + selection[0].displayValue + '"' : '') + '?';
35
35
  },
36
- record,
37
36
  onAdd,
38
37
  onChange, // any kind of crud change
39
38
  onDelete,
@@ -313,12 +312,10 @@ export default function withEditor(WrappedComponent, isTree = false) {
313
312
  },
314
313
  doEditorSave = async (data, e) => {
315
314
  // NOTE: The Form submits onSave for both adds (when not isAutoSsave) and edits.
316
- const
317
- what = record || selection,
318
- isSingle = what.length === 1;
315
+ const isSingle = selection.length === 1;
319
316
  if (isSingle) {
320
317
  // just update this one entity
321
- what[0].setValues(data);
318
+ selection[0].setValues(data);
322
319
 
323
320
  } else if (selection.length > 1) {
324
321
  // Edit multiple entities
@@ -327,7 +324,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
327
324
  const propertyNames = Object.getOwnPropertyNames(data);
328
325
  _.each(propertyNames, (propertyName) => {
329
326
  if (!_.isNil(data[propertyName])) {
330
- _.each(what, (rec) => {
327
+ _.each(selection, (rec) => {
331
328
  rec[propertyName] = data[propertyName]
332
329
  });
333
330
  }
@@ -335,7 +332,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
335
332
  }
336
333
 
337
334
  if (getListeners().onBeforeSave) {
338
- const listenerResult = await getListeners().onBeforeSave(what);
335
+ const listenerResult = await getListeners().onBeforeSave(selection);
339
336
  if (listenerResult === false) {
340
337
  return;
341
338
  }
@@ -354,23 +351,23 @@ export default function withEditor(WrappedComponent, isTree = false) {
354
351
 
355
352
  if (success) {
356
353
  if (onChange) {
357
- onChange(what);
354
+ onChange(selection);
358
355
  }
359
356
  if (editorMode === EDITOR_MODE__ADD) {
360
357
  if (onAdd) {
361
- await onAdd(what);
358
+ await onAdd(selection);
362
359
  }
363
360
  if (getListeners().onAfterAdd) {
364
- await getListeners().onAfterAdd(what);
361
+ await getListeners().onAfterAdd(selection);
365
362
  }
366
363
  setIsAdding(false);
367
364
  setEditorMode(EDITOR_MODE__EDIT);
368
365
  } else if (editorMode === EDITOR_MODE__EDIT) {
369
366
  if (getListeners().onAfterEdit) {
370
- await getListeners().onAfterEdit(what);
367
+ await getListeners().onAfterEdit(selection);
371
368
  }
372
369
  if (onSave) {
373
- onSave(what);
370
+ onSave(selection);
374
371
  }
375
372
  }
376
373
  // setIsEditorShown(false);