@onehat/ui 0.2.39 → 0.2.40
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,8 +1,8 @@
|
|
|
1
1
|
import { useState, } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
EDITOR_MODE__VIEW,
|
|
4
|
+
EDITOR_MODE__ADD,
|
|
5
|
+
EDITOR_MODE__EDIT,
|
|
6
6
|
} from '../../Constants/Editor.js';
|
|
7
7
|
import _ from 'lodash';
|
|
8
8
|
|
|
@@ -38,7 +38,7 @@ export default function withEditor(WrappedComponent) {
|
|
|
38
38
|
[currentRecord, setCurrentRecord] = useState(null),
|
|
39
39
|
[isEditorShown, setIsEditorShown] = useState(false),
|
|
40
40
|
[isEditorViewOnly, setIsEditorViewOnly] = useState(false),
|
|
41
|
-
[
|
|
41
|
+
[editorMode, setEditorMode] = useState(EDITOR_MODE__VIEW),
|
|
42
42
|
addRecord = async () => {
|
|
43
43
|
if (!userCanEdit) {
|
|
44
44
|
return;
|
|
@@ -48,7 +48,7 @@ export default function withEditor(WrappedComponent) {
|
|
|
48
48
|
entity = await Repository.add(defaultValues, false, true, true);
|
|
49
49
|
setSelection([entity]);
|
|
50
50
|
setIsEditorViewOnly(false);
|
|
51
|
-
|
|
51
|
+
setEditorMode(EDITOR_MODE__ADD);
|
|
52
52
|
setIsEditorShown(true);
|
|
53
53
|
},
|
|
54
54
|
editRecord = () => {
|
|
@@ -56,7 +56,7 @@ export default function withEditor(WrappedComponent) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
setIsEditorViewOnly(false);
|
|
59
|
-
|
|
59
|
+
setEditorMode(EDITOR_MODE__EDIT);
|
|
60
60
|
setIsEditorShown(true);
|
|
61
61
|
},
|
|
62
62
|
deleteRecord = (e) => {
|
|
@@ -88,7 +88,7 @@ export default function withEditor(WrappedComponent) {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
setIsEditorViewOnly(true);
|
|
91
|
-
|
|
91
|
+
setEditorMode(EDITOR_MODE__VIEW);
|
|
92
92
|
setIsEditorShown(true);
|
|
93
93
|
},
|
|
94
94
|
duplicateRecord = async () => {
|
|
@@ -147,7 +147,8 @@ export default function withEditor(WrappedComponent) {
|
|
|
147
147
|
setCurrentRecord={setCurrentRecord}
|
|
148
148
|
isEditorShown={isEditorShown}
|
|
149
149
|
isEditorViewOnly={isEditorViewOnly}
|
|
150
|
-
|
|
150
|
+
editorMode={editorMode}
|
|
151
|
+
setEditorMode={setEditorMode}
|
|
151
152
|
setIsEditorShown={setIsEditorShown}
|
|
152
153
|
onAdd={addRecord}
|
|
153
154
|
onEdit={editRecord}
|
package/src/Constants/Editor.js
CHANGED
|
@@ -3,6 +3,6 @@ export const EDITOR_TYPE__WINDOWED = 'EDITOR_TYPE__WINDOWED';
|
|
|
3
3
|
export const EDITOR_TYPE__SIDE = 'EDITOR_TYPE__SIDE';
|
|
4
4
|
export const EDITOR_TYPE__SMART = 'EDITOR_TYPE__SMART';
|
|
5
5
|
export const EDITOR_TYPE__PLAIN = 'EDITOR_TYPE__PLAIN';
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
6
|
+
export const EDITOR_MODE__VIEW = 'EDITOR_MODE__VIEW';
|
|
7
|
+
export const EDITOR_MODE__ADD = 'EDITOR_MODE__ADD';
|
|
8
|
+
export const EDITOR_MODE__EDIT = 'EDITOR_MODE__EDIT';
|