@onehat/ui 0.4.105 → 0.4.106
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
|
@@ -969,6 +969,14 @@ function Form(props) {
|
|
|
969
969
|
buildAncillary = () => {
|
|
970
970
|
const
|
|
971
971
|
validAncillaryItems = _.filter(ancillaryItems, (item) => !!item), // filter out any null/undefined items
|
|
972
|
+
parentEditorModeRaw = getEditorMode?.() || props.editorMode || null,
|
|
973
|
+
parentEditorMode = parentEditorModeRaw === EDITOR_MODE__ADD
|
|
974
|
+
? EDITOR_MODE__EDIT
|
|
975
|
+
: parentEditorModeRaw,
|
|
976
|
+
normalizedParentEditorMode =
|
|
977
|
+
parentEditorMode === EDITOR_MODE__EDIT || parentEditorMode === EDITOR_MODE__VIEW
|
|
978
|
+
? parentEditorMode
|
|
979
|
+
: null,
|
|
972
980
|
components = [];
|
|
973
981
|
setAncillaryButtons([]);
|
|
974
982
|
if (validAncillaryItems.length) {
|
|
@@ -1011,6 +1019,8 @@ function Form(props) {
|
|
|
1011
1019
|
}
|
|
1012
1020
|
|
|
1013
1021
|
const
|
|
1022
|
+
ancillaryEditorMode = itemPropsToPass.editorMode ?? normalizedParentEditorMode,
|
|
1023
|
+
ancillaryInitialEditorMode = itemPropsToPass.initialEditorMode ?? ancillaryEditorMode ?? undefined,
|
|
1014
1024
|
Element = getComponentFromType(type),
|
|
1015
1025
|
element = <Element
|
|
1016
1026
|
{...testProps('ancillary-' + type)}
|
|
@@ -1020,6 +1030,8 @@ function Form(props) {
|
|
|
1020
1030
|
uniqueRepository={true}
|
|
1021
1031
|
parent={self}
|
|
1022
1032
|
{...itemPropsToPass}
|
|
1033
|
+
editorMode={ancillaryEditorMode}
|
|
1034
|
+
initialEditorMode={ancillaryInitialEditorMode}
|
|
1023
1035
|
/>;
|
|
1024
1036
|
if (title) {
|
|
1025
1037
|
if (record?.displayValue) {
|
|
@@ -57,6 +57,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
57
57
|
newEntityDisplayValue,
|
|
58
58
|
newEntityDisplayProperty, // in case the field to set for newEntityDisplayValue is different from model
|
|
59
59
|
defaultValues,
|
|
60
|
+
editorMode: parentEditorModeProp,
|
|
60
61
|
initialEditorMode = EDITOR_MODE__VIEW,
|
|
61
62
|
stayInEditModeOnSelectionChange = false,
|
|
62
63
|
inheritParentEditorMode = true,
|
|
@@ -174,7 +175,21 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
174
175
|
}
|
|
175
176
|
},
|
|
176
177
|
getParentEditorMode = () => {
|
|
177
|
-
|
|
178
|
+
const contextMode = parentEditorModeContext?.effectiveEditorMode || null;
|
|
179
|
+
if (contextMode) {
|
|
180
|
+
return contextMode;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Some modal implementations break React context boundaries. Fall back to
|
|
184
|
+
// an explicitly-passed parent mode so nested ancillary editors still inherit.
|
|
185
|
+
if (parentEditorModeProp === EDITOR_MODE__ADD) {
|
|
186
|
+
return EDITOR_MODE__EDIT;
|
|
187
|
+
}
|
|
188
|
+
if (parentEditorModeProp === EDITOR_MODE__EDIT || parentEditorModeProp === EDITOR_MODE__VIEW) {
|
|
189
|
+
return parentEditorModeProp;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return null;
|
|
178
193
|
},
|
|
179
194
|
getInheritedEditorMode = () => {
|
|
180
195
|
if (!inheritParentEditorMode) {
|
|
@@ -126,6 +126,11 @@ export default function MetersEditor(props) {
|
|
|
126
126
|
isEditable: false,
|
|
127
127
|
isEditingEnabledInPlainEditor: true,
|
|
128
128
|
},
|
|
129
|
+
{
|
|
130
|
+
name: 'meters__latest_meter_reading_date',
|
|
131
|
+
isEditable: false,
|
|
132
|
+
isEditingEnabledInPlainEditor: true,
|
|
133
|
+
},
|
|
129
134
|
...(includeExtendedCalculatedFields ? [
|
|
130
135
|
{
|
|
131
136
|
name: 'meters__latest_inspection_date',
|
|
@@ -18,6 +18,9 @@ import {
|
|
|
18
18
|
EDIT,
|
|
19
19
|
} from '../../Constants/Commands.js';
|
|
20
20
|
import {
|
|
21
|
+
EDITOR_MODE__ADD,
|
|
22
|
+
EDITOR_MODE__EDIT,
|
|
23
|
+
EDITOR_MODE__VIEW,
|
|
21
24
|
EDITOR_TYPE__SIDE,
|
|
22
25
|
EDITOR_TYPE__SMART,
|
|
23
26
|
} from '../../Constants/Editor.js';
|
|
@@ -69,6 +72,8 @@ function Viewer(props) {
|
|
|
69
72
|
|
|
70
73
|
// withEditor
|
|
71
74
|
editorType,
|
|
75
|
+
getEditorMode,
|
|
76
|
+
editorMode,
|
|
72
77
|
onEditMode,
|
|
73
78
|
onClose,
|
|
74
79
|
onDelete,
|
|
@@ -353,6 +358,14 @@ function Viewer(props) {
|
|
|
353
358
|
buildAncillary = () => {
|
|
354
359
|
const
|
|
355
360
|
validAncillaryItems = _.filter(ancillaryItems, (item) => !!item), // filter out any null/undefined items
|
|
361
|
+
parentEditorModeRaw = (getEditorMode && getEditorMode()) || editorMode || null,
|
|
362
|
+
parentEditorMode = parentEditorModeRaw === EDITOR_MODE__ADD
|
|
363
|
+
? EDITOR_MODE__EDIT
|
|
364
|
+
: parentEditorModeRaw,
|
|
365
|
+
normalizedParentEditorMode =
|
|
366
|
+
parentEditorMode === EDITOR_MODE__EDIT || parentEditorMode === EDITOR_MODE__VIEW
|
|
367
|
+
? parentEditorMode
|
|
368
|
+
: null,
|
|
356
369
|
components = [];
|
|
357
370
|
setAncillaryButtons([]);
|
|
358
371
|
if (validAncillaryItems.length) {
|
|
@@ -396,6 +409,8 @@ function Viewer(props) {
|
|
|
396
409
|
}
|
|
397
410
|
|
|
398
411
|
const
|
|
412
|
+
ancillaryEditorMode = itemPropsToPass.editorMode ?? normalizedParentEditorMode,
|
|
413
|
+
ancillaryInitialEditorMode = itemPropsToPass.initialEditorMode ?? ancillaryEditorMode ?? undefined,
|
|
399
414
|
Element = getComponentFromType(type),
|
|
400
415
|
element = <Element
|
|
401
416
|
{...testProps('ancillary-' + type)}
|
|
@@ -407,6 +422,8 @@ function Viewer(props) {
|
|
|
407
422
|
uniqueRepository={true}
|
|
408
423
|
parent={self}
|
|
409
424
|
{...itemPropsToPass}
|
|
425
|
+
editorMode={ancillaryEditorMode}
|
|
426
|
+
initialEditorMode={ancillaryInitialEditorMode}
|
|
410
427
|
className={className}
|
|
411
428
|
canRowsReorder={false}
|
|
412
429
|
/>;
|