@onehat/ui 0.3.235 → 0.3.236

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.235",
3
+ "version": "0.3.236",
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 UiGlobals from '../../UiGlobals.js';
11
12
  import _ from 'lodash';
@@ -34,6 +35,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
34
35
  }
35
36
  return 'record' + (selection[0].displayValue ? ' "' + selection[0].displayValue + '"' : '') + '?';
36
37
  },
38
+ editorType,
37
39
  onAdd,
38
40
  onChange, // any kind of crud change
39
41
  onDelete,
@@ -437,23 +439,28 @@ export default function withEditor(WrappedComponent, isTree = false) {
437
439
 
438
440
  // calculateEditorMode gets called only on selection changes
439
441
  let mode;
440
- if (isIgnoreNextSelectionChange) {
441
- mode = editorMode;
442
- if (!canEditorViewOnly && userCanEdit) {
443
- if (selection.length > 1) {
444
- if (!disableEdit) {
445
- // For multiple entities selected, change it to edit multiple mode
446
- mode = EDITOR_MODE__EDIT;
447
- }
448
- } else if (selection.length === 1 && !selection[0].isDestroyed && selection[0].isPhantom) {
449
- if (!disableAdd) {
450
- // When a phantom entity is selected, change it to add mode.
451
- mode = EDITOR_MODE__ADD;
442
+ if (editorType === EDITOR_TYPE__SIDE && !_.isNil(UiGlobals.isSideEditorAlwaysEditMode) && UiGlobals.isSideEditorAlwaysEditMode) {
443
+ // special case: side editor is always edit mode
444
+ mode = EDITOR_MODE__EDIT;
445
+ } else {
446
+ if (isIgnoreNextSelectionChange) {
447
+ mode = editorMode;
448
+ if (!canEditorViewOnly && userCanEdit) {
449
+ if (selection.length > 1) {
450
+ if (!disableEdit) {
451
+ // For multiple entities selected, change it to edit multiple mode
452
+ mode = EDITOR_MODE__EDIT;
453
+ }
454
+ } else if (selection.length === 1 && !selection[0].isDestroyed && selection[0].isPhantom) {
455
+ if (!disableAdd) {
456
+ // When a phantom entity is selected, change it to add mode.
457
+ mode = EDITOR_MODE__ADD;
458
+ }
452
459
  }
453
460
  }
461
+ } else {
462
+ mode = selection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
454
463
  }
455
- } else {
456
- mode = selection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
457
464
  }
458
465
  return mode;
459
466
  },
@@ -18,8 +18,23 @@ import Form from '../Form/Form.js';
18
18
  import withEditor from './withEditor.js';
19
19
  import _ from 'lodash';
20
20
 
21
+
22
+
23
+ function withAdditionalProps(WrappedComponent) {
24
+ return (props) => {
25
+ // provide the editorType to withEditor
26
+ return <WrappedComponent
27
+ editorType={EDITOR_TYPE__INLINE}
28
+ {...props}
29
+ />;
30
+ };
31
+ }
32
+
33
+ // NOTE: Effectivtly, the HOC composition is:
34
+ // withAdditionalProps(withEditor(withWindowedEditor))
35
+
21
36
  export default function withInlineEditor(WrappedComponent) {
22
- return withEditor((props) => {
37
+ return withAdditionalProps(withEditor((props) => {
23
38
  const {
24
39
  editorType,
25
40
  isEditorShown = false,
@@ -147,5 +162,5 @@ export default function withInlineEditor(WrappedComponent) {
147
162
  inlineEditor={inlineEditor}
148
163
  isInlineEditorShown={isEditorShown}
149
164
  />;
150
- });
165
+ }));
151
166
  }
@@ -6,8 +6,21 @@ import withEditor from './withEditor.js';
6
6
  import _ from 'lodash';
7
7
 
8
8
 
9
+ function withAdditionalProps(WrappedComponent) {
10
+ return (props) => {
11
+ // provide the editorType to withEditor
12
+ return <WrappedComponent
13
+ editorType={EDITOR_TYPE__SIDE}
14
+ {...props}
15
+ />;
16
+ };
17
+ }
18
+
19
+ // NOTE: Effectivtly, the HOC composition is:
20
+ // withAdditionalProps(withEditor(withSideEditor))
21
+
9
22
  export default function withSideEditor(WrappedComponent, isTree = false) {
10
- return withEditor((props) => {
23
+ return withAdditionalProps(withEditor((props) => {
11
24
  const {
12
25
  Editor,
13
26
  editorProps = {},
@@ -44,5 +57,5 @@ export default function withSideEditor(WrappedComponent, isTree = false) {
44
57
  reference="editor"
45
58
  />}
46
59
  />;
47
- });
60
+ }));
48
61
  }
@@ -25,8 +25,24 @@ import _ from 'lodash';
25
25
  // then switch position to absolute, draggable area would be header of panel
26
26
  // const DraggableColumn = withAdditionalProps(withDraggable(Column));
27
27
 
28
+
29
+
30
+
31
+ function withAdditionalProps(WrappedComponent) {
32
+ return (props) => {
33
+ // provide the editorType to withEditor
34
+ return <WrappedComponent
35
+ editorType={EDITOR_TYPE__WINDOWED}
36
+ {...props}
37
+ />;
38
+ };
39
+ }
40
+
41
+ // NOTE: Effectivtly, the HOC composition is:
42
+ // withAdditionalProps(withEditor(withWindowedEditor))
43
+
28
44
  export default function withWindowedEditor(WrappedComponent, isTree = false) {
29
- return withEditor((props) => {
45
+ return withAdditionalProps(withEditor((props) => {
30
46
  const {
31
47
  isEditorShown = false,
32
48
  setIsEditorShown,
@@ -65,5 +81,5 @@ export default function withWindowedEditor(WrappedComponent, isTree = false) {
65
81
  />
66
82
  </Modal>}
67
83
  </>;
68
- }, isTree);
84
+ }, isTree));
69
85
  }