@onehat/ui 0.4.30 → 0.4.32
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
|
@@ -65,6 +65,7 @@ export function ComboComponent(props) {
|
|
|
65
65
|
onGridAdd, // to hook into when menu adds (ComboEditor only)
|
|
66
66
|
onGridSave, // to hook into when menu saves (ComboEditor only)
|
|
67
67
|
onGridDelete, // to hook into when menu deletes (ComboEditor only)
|
|
68
|
+
onSubmit, // when Combo is used in a Tag, call this when the user submits the Combo value (i.e. presses Enter or clicks a row)
|
|
68
69
|
newEntityDisplayProperty,
|
|
69
70
|
testID,
|
|
70
71
|
|
|
@@ -252,6 +253,9 @@ export function ComboComponent(props) {
|
|
|
252
253
|
if (id !== value) {
|
|
253
254
|
setValue(id);
|
|
254
255
|
}
|
|
256
|
+
if (onSubmit) {
|
|
257
|
+
onSubmit(id);
|
|
258
|
+
}
|
|
255
259
|
hideMenu();
|
|
256
260
|
break;
|
|
257
261
|
case 'ArrowDown':
|
|
@@ -815,6 +819,9 @@ export function ComboComponent(props) {
|
|
|
815
819
|
hideMenu();
|
|
816
820
|
onInputFocus();
|
|
817
821
|
}
|
|
822
|
+
if (onSubmit) {
|
|
823
|
+
onSubmit(id);
|
|
824
|
+
}
|
|
818
825
|
}}
|
|
819
826
|
reference="grid"
|
|
820
827
|
parent={self}
|
|
@@ -50,13 +50,6 @@ function TagComponent(props) {
|
|
|
50
50
|
} = props,
|
|
51
51
|
styles = UiGlobals.styles,
|
|
52
52
|
valueRef = useRef(value),
|
|
53
|
-
ignoreNextComboValueChangeRef = useRef(false),
|
|
54
|
-
getIgnoreNextComboValueChange = () => {
|
|
55
|
-
return ignoreNextComboValueChangeRef.current;
|
|
56
|
-
},
|
|
57
|
-
setIgnoreNextComboValueChange = (bool) => {
|
|
58
|
-
ignoreNextComboValueChangeRef.current = bool;
|
|
59
|
-
},
|
|
60
53
|
onView = async (item, e) => {
|
|
61
54
|
const
|
|
62
55
|
id = item.id,
|
|
@@ -91,14 +84,9 @@ function TagComponent(props) {
|
|
|
91
84
|
});
|
|
92
85
|
},
|
|
93
86
|
clearComboValue = () => {
|
|
94
|
-
setIgnoreNextComboValueChange(true); // we're clearing out the value of the underlying Combo, so ignore it when this combo submits the new value change
|
|
95
87
|
self.children.combo.setValue(null);
|
|
96
88
|
},
|
|
97
89
|
onChangeComboValue = (comboValue) => {
|
|
98
|
-
if (getIgnoreNextComboValueChange()) {
|
|
99
|
-
setIgnoreNextComboValueChange(false);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
90
|
|
|
103
91
|
if (_.isNil(comboValue)) {
|
|
104
92
|
// NOTE: We *shouldn't* get here, but for some unknown reason, we *were* getting here on rare occasions.
|
|
@@ -309,21 +297,22 @@ function TagComponent(props) {
|
|
|
309
297
|
>
|
|
310
298
|
<HStack className={valueBoxesClassName}>{valueBoxes}</HStack>
|
|
311
299
|
|
|
312
|
-
{!isViewOnly &&
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
300
|
+
{!isViewOnly &&
|
|
301
|
+
<WhichCombo
|
|
302
|
+
Repository={props.Repository}
|
|
303
|
+
Editor={props.Editor}
|
|
304
|
+
onSubmit={onChangeComboValue}
|
|
305
|
+
parent={self}
|
|
306
|
+
reference="combo"
|
|
307
|
+
isInTag={true}
|
|
308
|
+
onGridAdd={onGridAdd}
|
|
309
|
+
onGridSave={onGridSave}
|
|
310
|
+
onGridDelete={onGridDelete}
|
|
311
|
+
tooltip={tooltip}
|
|
312
|
+
usePermissions={props.usePermissions}
|
|
313
|
+
{..._combo}
|
|
314
|
+
className={comboClassName}
|
|
315
|
+
/>}
|
|
327
316
|
</VStackNative>;
|
|
328
317
|
|
|
329
318
|
}
|
|
@@ -72,7 +72,8 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
72
72
|
disableCopy = !isGrid,
|
|
73
73
|
disableDuplicate = !isEditor,
|
|
74
74
|
disablePrint = !isGrid,
|
|
75
|
-
|
|
75
|
+
protectedValues, // records with these values cannot be edited or deleted
|
|
76
|
+
|
|
76
77
|
// withAlert
|
|
77
78
|
showInfo,
|
|
78
79
|
|
|
@@ -178,6 +179,25 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
178
179
|
}
|
|
179
180
|
return isDisabled;
|
|
180
181
|
},
|
|
182
|
+
isNoSelectorSelected = () => {
|
|
183
|
+
return selectorId && !selectorSelected;
|
|
184
|
+
},
|
|
185
|
+
isEmptySelection = () => {
|
|
186
|
+
return _.isEmpty(selection);
|
|
187
|
+
},
|
|
188
|
+
isMultiSelection = () => {
|
|
189
|
+
return _.isArray(selection) && selection.length > 1;
|
|
190
|
+
},
|
|
191
|
+
isProtectedValue = () => {
|
|
192
|
+
if (!protectedValues) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
const value = selection[0]?.id;
|
|
196
|
+
if (_.isNil(value)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
return inArray(value, protectedValues);
|
|
200
|
+
},
|
|
181
201
|
getPresetButtonProps = (type) => {
|
|
182
202
|
let key,
|
|
183
203
|
text,
|
|
@@ -190,10 +210,9 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
190
210
|
text = 'Add';
|
|
191
211
|
handler = (parent, e) => onAdd();
|
|
192
212
|
icon = Plus;
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (isTree && _.isEmpty(selection)) {
|
|
213
|
+
if (isNoSelectorSelected() ||
|
|
214
|
+
(isTree && isEmptySelection())
|
|
215
|
+
) {
|
|
197
216
|
isDisabled = true;
|
|
198
217
|
}
|
|
199
218
|
break;
|
|
@@ -202,13 +221,12 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
202
221
|
text = 'Edit';
|
|
203
222
|
handler = (parent, e) => onEdit();
|
|
204
223
|
icon = Edit;
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (canRecordBeEdited && !canRecordBeEdited(selection)) {
|
|
224
|
+
if (isNoSelectorSelected() ||
|
|
225
|
+
isEmptySelection() ||
|
|
226
|
+
isMultiSelection() ||
|
|
227
|
+
isProtectedValue() ||
|
|
228
|
+
(canRecordBeEdited && !canRecordBeEdited(selection))
|
|
229
|
+
) {
|
|
212
230
|
isDisabled = true;
|
|
213
231
|
}
|
|
214
232
|
break;
|
|
@@ -218,13 +236,12 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
218
236
|
handler = onDelete;
|
|
219
237
|
handler = (parent, e) => onDelete();
|
|
220
238
|
icon = Trash;
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (canRecordBeDeleted && !canRecordBeDeleted(selection)) {
|
|
239
|
+
if (isNoSelectorSelected() ||
|
|
240
|
+
isEmptySelection() ||
|
|
241
|
+
isMultiSelection() ||
|
|
242
|
+
isProtectedValue() ||
|
|
243
|
+
(canRecordBeEdited && !canRecordBeEdited(selection))
|
|
244
|
+
) {
|
|
228
245
|
isDisabled = true;
|
|
229
246
|
}
|
|
230
247
|
if (isTree) {
|
|
@@ -240,10 +257,10 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
240
257
|
handler = (parent, e) => onView();
|
|
241
258
|
icon = Eye;
|
|
242
259
|
isDisabled = !selection.length || selection.length !== 1;
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
260
|
+
if (isNoSelectorSelected() ||
|
|
261
|
+
isEmptySelection() ||
|
|
262
|
+
isMultiSelection()
|
|
263
|
+
) {
|
|
247
264
|
isDisabled = true;
|
|
248
265
|
}
|
|
249
266
|
break;
|
|
@@ -253,10 +270,9 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
253
270
|
handler = (parent, e) => onCopyToClipboard();
|
|
254
271
|
icon = Clipboard;
|
|
255
272
|
isDisabled = !selection.length;
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (_.isEmpty(selection)) {
|
|
273
|
+
if (isNoSelectorSelected() ||
|
|
274
|
+
isEmptySelection()
|
|
275
|
+
) {
|
|
260
276
|
isDisabled = true;
|
|
261
277
|
}
|
|
262
278
|
break;
|
|
@@ -266,13 +282,11 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
266
282
|
handler = (parent, e) => onDuplicate();
|
|
267
283
|
icon = Duplicate;
|
|
268
284
|
isDisabled = !selection.length || selection.length !== 1;
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
if (canRecordBeDuplicated && !canRecordBeDuplicated(selection)) {
|
|
285
|
+
if (isNoSelectorSelected() ||
|
|
286
|
+
isEmptySelection() ||
|
|
287
|
+
isMultiSelection() ||
|
|
288
|
+
(canRecordBeDuplicated && !canRecordBeDuplicated(selection))
|
|
289
|
+
) {
|
|
276
290
|
isDisabled = true;
|
|
277
291
|
}
|
|
278
292
|
break;
|