@onehat/ui 0.4.112 → 0.4.113

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.4.112",
3
+ "version": "0.4.113",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -28,6 +28,10 @@ const ButtonComponent = forwardRef((props, ref) => {
28
28
  ...propsToPass
29
29
  } = props;
30
30
 
31
+ if (propsToPass.handler) {
32
+ propsToPass.onPress = propsToPass.handler; // alias
33
+ }
34
+
31
35
  if (icon) {
32
36
  if (isValidElement(icon)) {
33
37
  if (_icon) {
@@ -38,6 +38,7 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
38
38
  secondaryDisableDelete = false,
39
39
  secondaryDisableDuplicate = false,
40
40
  secondaryDisableView = false,
41
+ secondaryWaitWhileSaving = false, // when true, show global wait modal while doEditorSave is in-flight
41
42
  secondaryUseRemoteDuplicate = false, // call specific copyToNew function on server, rather than simple duplicate on client
42
43
  secondaryGetRecordIdentifier = (secondarySelection) => {
43
44
  if (secondarySelection.length > 1) {
@@ -558,16 +559,24 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
558
559
  }
559
560
 
560
561
  setIsSaving(true);
562
+ if (secondaryWaitWhileSaving) {
563
+ setIsWaitModalShown(true);
564
+ }
561
565
  let success = true;
562
566
  const tempListener = (msg, data) => {
563
567
  success = { msg, data };
564
568
  };
565
569
 
566
- SecondaryRepository.on('error', tempListener); // add a temporary listener for the error event
567
- await SecondaryRepository.save(null, useStaged);
568
- SecondaryRepository.off('error', tempListener); // remove the temporary listener
569
-
570
- setIsSaving(false);
570
+ try {
571
+ SecondaryRepository.on('error', tempListener); // add a temporary listener for the error event
572
+ await SecondaryRepository.save(null, useStaged);
573
+ } finally {
574
+ SecondaryRepository.off('error', tempListener); // remove the temporary listener
575
+ setIsSaving(false);
576
+ if (secondaryWaitWhileSaving) {
577
+ setIsWaitModalShown(false);
578
+ }
579
+ }
571
580
 
572
581
  if (_.isBoolean(success) && success) {
573
582
  if (secondaryOnChange) {
@@ -39,6 +39,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
39
39
  enableMultiDelete = false, // deleting multiple records at once is opt-in only
40
40
  disableDuplicate = false,
41
41
  disableView = false,
42
+ waitWhileSaving = false, // when true, show global wait modal while doEditorSave is in-flight
42
43
  useRemoteDuplicate = false, // call specific copyToNew function on server, rather than simple duplicate on client
43
44
  getDuplicateValues, // fn(entity) to get default values for duplication
44
45
  getRecordIdentifier = (selection) => {
@@ -716,16 +717,24 @@ export default function withEditor(WrappedComponent, isTree = false) {
716
717
  }
717
718
 
718
719
  setIsSaving(true);
720
+ if (waitWhileSaving) {
721
+ setIsWaitModalShown(true);
722
+ }
719
723
  let success = true;
720
724
  const tempListener = (msg, data) => {
721
725
  success = false;
722
726
  };
723
727
 
724
- Repository.on('error', tempListener); // add a temporary listener for the error event
725
- await Repository.save(null, useStaged);
726
- Repository.off('error', tempListener); // remove the temporary listener
727
-
728
- setIsSaving(false);
728
+ try {
729
+ Repository.on('error', tempListener); // add a temporary listener for the error event
730
+ await Repository.save(null, useStaged);
731
+ } finally {
732
+ Repository.off('error', tempListener); // remove the temporary listener
733
+ setIsSaving(false);
734
+ if (waitWhileSaving) {
735
+ setIsWaitModalShown(false);
736
+ }
737
+ }
729
738
 
730
739
  if (_.isBoolean(success) && success) {
731
740
  if (onChange) {