@onehat/ui 0.3.252 → 0.3.253

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.252",
3
+ "version": "0.3.253",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -366,12 +366,11 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
366
366
  await SecondaryRepository.save(null, useStaged);
367
367
  success = true;
368
368
  } catch (e) {
369
- // alert(e.context);
370
- success = false;
369
+ success = e;
371
370
  }
372
371
  setIsSaving(false);
373
372
 
374
- if (success) {
373
+ if (_.isBoolean(success) && success) {
375
374
  if (secondaryOnChange) {
376
375
  secondaryOnChange(secondarySelection);
377
376
  }
@@ -476,7 +475,24 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
476
475
  return () => {};
477
476
  }
478
477
 
479
- function handleError(msg) {
478
+ function handleError(msg, data = null) {
479
+ if (data) {
480
+ if (_.isPlainObject(data)) {
481
+ for (let key in data) { if (data.hasOwnProperty(key)) {
482
+ const val1 = data[key];
483
+ if (_.isPlainObject(val1)) {
484
+ for (let key2 in val1) { if (val1.hasOwnProperty(key2)) {
485
+ const val2 = val1[key2];
486
+ msg += "\n" + val2;
487
+ } }
488
+ } else if (_.isString(data)) {
489
+ msg += "\n" + data;
490
+ }
491
+ } }
492
+ } else {
493
+ // not sure what to do with data!
494
+ }
495
+ }
480
496
  alert(msg);
481
497
  }
482
498
 
@@ -365,12 +365,11 @@ export default function withEditor(WrappedComponent, isTree = false) {
365
365
  await Repository.save(null, useStaged);
366
366
  success = true;
367
367
  } catch (e) {
368
- // alert(e.context);
369
- success = false;
368
+ success = e;
370
369
  }
371
370
  setIsSaving(false);
372
371
 
373
- if (success) {
372
+ if (_.isBoolean(success) && success) {
374
373
  if (onChange) {
375
374
  onChange(selection);
376
375
  }
@@ -485,7 +484,24 @@ export default function withEditor(WrappedComponent, isTree = false) {
485
484
  return () => {};
486
485
  }
487
486
 
488
- function handleError(msg) {
487
+ function handleError(msg, data = null) {
488
+ if (data) {
489
+ if (_.isPlainObject(data)) {
490
+ for (let key in data) { if (data.hasOwnProperty(key)) {
491
+ const val1 = data[key];
492
+ if (_.isPlainObject(val1)) {
493
+ for (let key2 in val1) { if (val1.hasOwnProperty(key2)) {
494
+ const val2 = val1[key2];
495
+ msg += "\n" + val2;
496
+ } }
497
+ } else if (_.isString(data)) {
498
+ msg += "\n" + data;
499
+ }
500
+ } }
501
+ } else {
502
+ // not sure what to do with data!
503
+ }
504
+ }
489
505
  alert(msg);
490
506
  }
491
507