@onehat/ui 0.3.236 → 0.3.237

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.236",
3
+ "version": "0.3.237",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -6,6 +6,7 @@ import {
6
6
  EDITOR_MODE__VIEW,
7
7
  EDITOR_MODE__ADD,
8
8
  EDITOR_MODE__EDIT,
9
+ EDITOR_TYPE__SIDE,
9
10
  } from '../../../Constants/Editor.js';
10
11
  import _ from 'lodash';
11
12
 
@@ -36,6 +37,7 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
36
37
  }
37
38
  return 'record' + (secondarySelection[0].displayValue ? ' "' + secondarySelection[0].displayValue + '"' : '') + '?';
38
39
  },
40
+ secondaryEditorType,
39
41
  secondaryOnAdd,
40
42
  secondaryOnChange, // any kind of crud change
41
43
  secondaryOnDelete,
@@ -428,23 +430,28 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
428
430
  calculateEditorMode = (secondaryIsIgnoreNextSelectionChange = false) => {
429
431
  // calculateEditorMode gets called only on selection changes
430
432
  let mode;
431
- if (secondaryIsIgnoreNextSelectionChange) {
432
- mode = secondaryEditorMode;
433
- if (!secondaryCanEditorViewOnly && secondaryUserCanEdit) {
434
- if (secondarySelection.length > 1) {
435
- if (!secondaryDisableEdit) {
436
- // For multiple entities selected, change it to edit multiple mode
437
- mode = EDITOR_MODE__EDIT;
438
- }
439
- } else if (secondarySelection.length === 1 && !secondarySelection[0].isDestroyed && secondarySelection[0].isPhantom) {
440
- if (!secondaryDisableAdd) {
441
- // When a phantom entity is selected, change it to add mode.
442
- mode = EDITOR_MODE__ADD;
433
+ if (secondaryEditorType === EDITOR_TYPE__SIDE && !_.isNil(UiGlobals.isSideEditorAlwaysEditMode) && UiGlobals.isSideEditorAlwaysEditMode) {
434
+ // special case: side editor is always edit mode
435
+ mode = EDITOR_MODE__EDIT;
436
+ } else {
437
+ if (secondaryIsIgnoreNextSelectionChange) {
438
+ mode = secondaryEditorMode;
439
+ if (!secondaryCanEditorViewOnly && secondaryUserCanEdit) {
440
+ if (secondarySelection.length > 1) {
441
+ if (!secondaryDisableEdit) {
442
+ // For multiple entities selected, change it to edit multiple mode
443
+ mode = EDITOR_MODE__EDIT;
444
+ }
445
+ } else if (secondarySelection.length === 1 && !secondarySelection[0].isDestroyed && secondarySelection[0].isPhantom) {
446
+ if (!secondaryDisableAdd) {
447
+ // When a phantom entity is selected, change it to add mode.
448
+ mode = EDITOR_MODE__ADD;
449
+ }
443
450
  }
444
451
  }
452
+ } else {
453
+ mode = secondarySelection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
445
454
  }
446
- } else {
447
- mode = secondarySelection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
448
455
  }
449
456
  return mode;
450
457
  },
@@ -8,8 +8,22 @@ import _ from 'lodash';
8
8
  // NOTE: This is a modified version of @onehat/ui/src/Hoc/withSideEditor
9
9
  // This HOC will eventually get out of sync with that one, and may need to be updated.
10
10
 
11
- export default function withSideEditor(WrappedComponent, isTree = false) {
12
- return withSecondaryEditor((props) => {
11
+
12
+ function withAdditionalProps(WrappedComponent) {
13
+ return (props) => {
14
+ // provide the editorType to withEditor
15
+ return <WrappedComponent
16
+ editorType={EDITOR_TYPE__SIDE}
17
+ {...props}
18
+ />;
19
+ };
20
+ }
21
+
22
+ // NOTE: Effectivtly, the HOC composition is:
23
+ // withAdditionalProps(withSecondaryEditor(withSecondarySideEditor))
24
+
25
+ export default function withSecondarySideEditor(WrappedComponent, isTree = false) {
26
+ return withAdditionalProps(withSecondaryEditor((props) => {
13
27
  const {
14
28
  SecondaryEditor,
15
29
  secondaryEditorProps = {},
@@ -46,5 +60,5 @@ export default function withSideEditor(WrappedComponent, isTree = false) {
46
60
  reference="secondaryEditor"
47
61
  />}
48
62
  />;
49
- });
63
+ }));
50
64
  }
@@ -13,8 +13,22 @@ import _ from 'lodash';
13
13
  // NOTE: This is a modified version of @onehat/ui/src/Hoc/withWindowedEditor
14
14
  // This HOC will eventually get out of sync with that one, and may need to be updated.
15
15
 
16
+
17
+ function withAdditionalProps(WrappedComponent) {
18
+ return (props) => {
19
+ // provide the editorType to withEditor
20
+ return <WrappedComponent
21
+ editorType={EDITOR_TYPE__WINDOWED}
22
+ {...props}
23
+ />;
24
+ };
25
+ }
26
+
27
+ // NOTE: Effectivtly, the HOC composition is:
28
+ // withAdditionalProps(withSecondaryEditor(withSecondaryWindowedEditor))
29
+
16
30
  export default function withSecondaryWindowedEditor(WrappedComponent, isTree = false) {
17
- return withSecondaryEditor((props) => {
31
+ return withAdditionalProps(withSecondaryEditor((props) => {
18
32
  const {
19
33
  secondaryIsEditorShown = false,
20
34
  secondarySetIsEditorShown,
@@ -67,5 +81,5 @@ export default function withSecondaryWindowedEditor(WrappedComponent, isTree = f
67
81
  />
68
82
  </Modal>}
69
83
  </>;
70
- }, isTree);
84
+ }, isTree));
71
85
  }