@onehat/ui 0.3.35 → 0.3.36
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 +1 -1
- package/src/Components/Form/Field/Combo/Combo.js +8 -3
- package/src/Components/Form/Form.js +6 -2
- package/src/Components/Hoc/withData.js +25 -4
- package/src/Components/Hoc/withPdfButton.js +1 -0
- package/src/Components/Hoc/withSelection.js +1 -1
- package/src/Components/Panel/Panel.js +1 -1
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@ export function ComboComponent(props) {
|
|
|
38
38
|
hideMenuOnSelection = true,
|
|
39
39
|
_input = {},
|
|
40
40
|
isEditor = false,
|
|
41
|
+
isDisabled = false,
|
|
41
42
|
|
|
42
43
|
// withValue
|
|
43
44
|
value,
|
|
@@ -258,6 +259,10 @@ export function ComboComponent(props) {
|
|
|
258
259
|
},
|
|
259
260
|
searchForMatches = async (value) => {
|
|
260
261
|
|
|
262
|
+
if (_.isEmpty(value)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
261
266
|
let found;
|
|
262
267
|
if (Repository) {
|
|
263
268
|
|
|
@@ -275,9 +280,7 @@ export function ComboComponent(props) {
|
|
|
275
280
|
searchField = displayFieldName + ' LIKE';
|
|
276
281
|
}
|
|
277
282
|
|
|
278
|
-
|
|
279
|
-
value += '%';
|
|
280
|
-
}
|
|
283
|
+
value += '%';
|
|
281
284
|
|
|
282
285
|
await Repository.filter(searchField, value);
|
|
283
286
|
if (!this.isAutoLoad) {
|
|
@@ -408,6 +411,7 @@ export function ComboComponent(props) {
|
|
|
408
411
|
ref={inputRef}
|
|
409
412
|
value={textValue}
|
|
410
413
|
autoSubmit={true}
|
|
414
|
+
isDisabled={isDisabled}
|
|
411
415
|
onChangeValue={onInputChangeText}
|
|
412
416
|
onKeyPress={onInputKeyPress}
|
|
413
417
|
onBlur={onInputBlur}
|
|
@@ -453,6 +457,7 @@ export function ComboComponent(props) {
|
|
|
453
457
|
color: 'primary.800',
|
|
454
458
|
size: 'sm',
|
|
455
459
|
}}
|
|
460
|
+
isDisabled={isDisabled}
|
|
456
461
|
onPress={onTriggerPress}
|
|
457
462
|
onBlur={onTriggerBlur}
|
|
458
463
|
h="100%"
|
|
@@ -307,8 +307,12 @@ function Form(props) {
|
|
|
307
307
|
type = 'Text';
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
-
if (
|
|
311
|
-
editorTypeProps.autoLoad =
|
|
310
|
+
if (item.hasOwnProperty('autoLoad')) {
|
|
311
|
+
editorTypeProps.autoLoad = item.autoLoad;
|
|
312
|
+
} else {
|
|
313
|
+
if (type?.match && type.match(/Combo$/) && Repository?.isRemote && !Repository?.isLoaded) {
|
|
314
|
+
editorTypeProps.autoLoad = true;
|
|
315
|
+
}
|
|
312
316
|
}
|
|
313
317
|
const Element = getComponentFromType(type);
|
|
314
318
|
let children;
|
|
@@ -18,8 +18,9 @@ export default function withData(WrappedComponent) {
|
|
|
18
18
|
setRepository,
|
|
19
19
|
uniqueRepository = false,
|
|
20
20
|
model,
|
|
21
|
-
autoLoad
|
|
21
|
+
autoLoad, // bool
|
|
22
22
|
pageSize,
|
|
23
|
+
baseParams,
|
|
23
24
|
|
|
24
25
|
// For plain JS data
|
|
25
26
|
data,
|
|
@@ -46,11 +47,14 @@ export default function withData(WrappedComponent) {
|
|
|
46
47
|
return () => {};
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
let repositoryId;
|
|
51
|
+
|
|
49
52
|
(async () => {
|
|
50
53
|
let Repository;
|
|
51
54
|
if (uniqueRepository) {
|
|
52
55
|
const schema = oneHatData.getSchema(model);
|
|
53
56
|
Repository = await oneHatData.createRepository({ schema });
|
|
57
|
+
repositoryId = Repository.id;
|
|
54
58
|
} else {
|
|
55
59
|
Repository = oneHatData.getRepository(model);
|
|
56
60
|
}
|
|
@@ -59,8 +63,19 @@ export default function withData(WrappedComponent) {
|
|
|
59
63
|
Repository.setPageSize(pageSize);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
66
|
+
if (baseParams) {
|
|
67
|
+
Repository.setBaseParams(baseParams);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if (Repository && !Repository.isLoaded && Repository.isRemote && !Repository.isAutoLoad && !Repository.isLoading) {
|
|
72
|
+
let doAutoLoad = Repository.autoLoad;
|
|
73
|
+
if (!_.isNil(autoLoad)) { // prop can override schema setting for autoLoad
|
|
74
|
+
doAutoLoad = autoLoad;
|
|
75
|
+
}
|
|
76
|
+
if (doAutoLoad) {
|
|
77
|
+
await Repository.load();
|
|
78
|
+
}
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
setLocalRepository(Repository);
|
|
@@ -73,7 +88,13 @@ export default function withData(WrappedComponent) {
|
|
|
73
88
|
setIsReady(true);
|
|
74
89
|
})();
|
|
75
90
|
|
|
76
|
-
|
|
91
|
+
return () => {
|
|
92
|
+
if (repositoryId) {
|
|
93
|
+
oneHatData.deleteRepository(repositoryId);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}, []);
|
|
77
98
|
|
|
78
99
|
if (!isReady) {
|
|
79
100
|
return null;
|
|
@@ -281,7 +281,7 @@ export default function withSelection(WrappedComponent) {
|
|
|
281
281
|
(async () => {
|
|
282
282
|
|
|
283
283
|
if (usesWithValue && Repository?.isRemote
|
|
284
|
-
&& !Repository.isAutoLoad && !Repository.isLoaded && !Repository.isLoading) {
|
|
284
|
+
&& !Repository.isAutoLoad && !Repository.isLoaded && !Repository.isLoading && (!_.isNil(value) || !_.isEmpty(selection)) || autoSelectFirstItem) {
|
|
285
285
|
// on initialization, we can't conformSelectionToValue if the repository is not yet loaded,
|
|
286
286
|
// so first load repo, then conform to value
|
|
287
287
|
await Repository.load();
|
|
@@ -35,7 +35,7 @@ function Panel(props) {
|
|
|
35
35
|
onLayout = null,
|
|
36
36
|
|
|
37
37
|
// Header
|
|
38
|
-
title = UiGlobals.customInflect(Inflector.camel2words(Inflector.underscore(props.model))),
|
|
38
|
+
title = props.model ? UiGlobals.customInflect(Inflector.camel2words(Inflector.underscore(props.model))) : '',
|
|
39
39
|
showHeader = true,
|
|
40
40
|
header = null,
|
|
41
41
|
isClosable = false,
|