@onehat/ui 0.4.35 → 0.4.37
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 +5 -1
- package/src/Components/Form/Field/Tag/Tag.js +1 -0
- package/src/Components/Form/Form.js +31 -21
- package/src/Components/Hoc/withModal.js +5 -5
- package/src/Components/Report/Report.js +2 -3
- package/src/Components/Viewer/Viewer.js +6 -1
- package/src/Functions/buildAdditionalButtons.js +0 -1
- package/src/PlatformImports/Web/Attachments.js +22 -15
package/package.json
CHANGED
|
@@ -56,6 +56,7 @@ export function ComboComponent(props) {
|
|
|
56
56
|
isDisabled = false,
|
|
57
57
|
isInTag = false,
|
|
58
58
|
minimizeForRow = false,
|
|
59
|
+
reloadOnTrigger = false,
|
|
59
60
|
menuHeight,
|
|
60
61
|
tooltipPlacement = 'bottom',
|
|
61
62
|
placeholder,
|
|
@@ -308,11 +309,14 @@ export function ComboComponent(props) {
|
|
|
308
309
|
resetTextInputValue();
|
|
309
310
|
hideMenu();
|
|
310
311
|
},
|
|
311
|
-
onTriggerPress = (e) => {
|
|
312
|
+
onTriggerPress = async (e) => {
|
|
312
313
|
if (!isRendered) {
|
|
313
314
|
return;
|
|
314
315
|
}
|
|
315
316
|
clearGridFilters();
|
|
317
|
+
if (reloadOnTrigger && Repository) {
|
|
318
|
+
await Repository.reload();
|
|
319
|
+
}
|
|
316
320
|
if (isMenuShown) {
|
|
317
321
|
hideMenu();
|
|
318
322
|
} else {
|
|
@@ -80,6 +80,7 @@ function Form(props) {
|
|
|
80
80
|
checkIsEditingDisabled = true,
|
|
81
81
|
disableLabels = false,
|
|
82
82
|
disableDirtyIcon = false,
|
|
83
|
+
alwaysShowCancelButton = false,
|
|
83
84
|
onBack,
|
|
84
85
|
onReset,
|
|
85
86
|
onInit,
|
|
@@ -567,7 +568,7 @@ function Form(props) {
|
|
|
567
568
|
return buildFromItem(item, ix, {...defaults, ...itemDefaults});
|
|
568
569
|
});
|
|
569
570
|
|
|
570
|
-
let elementClassName = 'Form-ElementFromItem';
|
|
571
|
+
let elementClassName = 'Form-ElementFromItem gap-2';
|
|
571
572
|
const defaultsClassName = defaults.className;
|
|
572
573
|
if (defaultsClassName) {
|
|
573
574
|
elementClassName += ' ' + defaultsClassName;
|
|
@@ -785,7 +786,7 @@ function Form(props) {
|
|
|
785
786
|
if (item.additionalEditButtons) {
|
|
786
787
|
const buttons = buildAdditionalButtons(item.additionalEditButtons, self, { fieldState, formSetValue, formGetValues, formState });
|
|
787
788
|
if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
|
|
788
|
-
element = <HStack className="Form-HStack5 flex-1 flex-wrap items-center">
|
|
789
|
+
element = <HStack className="Form-HStack5 flex-1 flex-wrap items-center gap-2">
|
|
789
790
|
{element}
|
|
790
791
|
{buttons}
|
|
791
792
|
</HStack>;
|
|
@@ -1147,7 +1148,7 @@ function Form(props) {
|
|
|
1147
1148
|
</Toolbar>;
|
|
1148
1149
|
}
|
|
1149
1150
|
if (getEditorMode() === EDITOR_MODE__EDIT && !_.isEmpty(additionalButtons)) {
|
|
1150
|
-
formButtons.push(<Toolbar key="additionalButtonsToolbar" className="justify-end flex-wrap">
|
|
1151
|
+
formButtons.push(<Toolbar key="additionalButtonsToolbar" className="justify-end flex-wrap gap-2">
|
|
1151
1152
|
{additionalButtons}
|
|
1152
1153
|
</Toolbar>)
|
|
1153
1154
|
}
|
|
@@ -1170,27 +1171,31 @@ function Form(props) {
|
|
|
1170
1171
|
showResetBtn = true;
|
|
1171
1172
|
}
|
|
1172
1173
|
// determine whether we should show the close or cancel button
|
|
1173
|
-
if (
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
// }
|
|
1180
|
-
if (formState.isDirty || isPhantom) {
|
|
1181
|
-
if (isSingle && onCancel) {
|
|
1182
|
-
showCancelBtn = true;
|
|
1183
|
-
}
|
|
1174
|
+
if (alwaysShowCancelButton) {
|
|
1175
|
+
showCancelBtn = true;
|
|
1176
|
+
} else {
|
|
1177
|
+
if (editorType !== EDITOR_TYPE__SIDE) {
|
|
1178
|
+
if (isEditorViewOnly) {
|
|
1179
|
+
showCloseBtn = true;
|
|
1184
1180
|
} else {
|
|
1185
|
-
if (
|
|
1186
|
-
|
|
1181
|
+
// if (editorType === EDITOR_TYPE__WINDOWED && onCancel) {
|
|
1182
|
+
// showCancelBtn = true;
|
|
1183
|
+
// }
|
|
1184
|
+
if (formState.isDirty || isPhantom) {
|
|
1185
|
+
if (isSingle && onCancel) {
|
|
1186
|
+
showCancelBtn = true;
|
|
1187
|
+
}
|
|
1188
|
+
} else {
|
|
1189
|
+
if (onClose) {
|
|
1190
|
+
showCloseBtn = true;
|
|
1191
|
+
}
|
|
1187
1192
|
}
|
|
1188
1193
|
}
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
+
} else {
|
|
1195
|
+
// side editor only
|
|
1196
|
+
if (isPhantom && isSingle && onCancel) {
|
|
1197
|
+
showCancelBtn = true;
|
|
1198
|
+
}
|
|
1194
1199
|
}
|
|
1195
1200
|
}
|
|
1196
1201
|
if (!isEditorViewOnly && onSave) {
|
|
@@ -1267,11 +1272,16 @@ function Form(props) {
|
|
|
1267
1272
|
/>}
|
|
1268
1273
|
|
|
1269
1274
|
{additionalFooterButtons && _.map(additionalFooterButtons, (props) => {
|
|
1275
|
+
let isDisabled = false;
|
|
1276
|
+
if (props.disableOnInvalid) {
|
|
1277
|
+
isDisabled = !formState.isValid;
|
|
1278
|
+
}
|
|
1270
1279
|
return <Button
|
|
1271
1280
|
{...testProps('additionalFooterBtn-' + props.key)}
|
|
1272
1281
|
{...props}
|
|
1273
1282
|
onPress={(e) => handleSubmit(props.onPress, onSubmitError)(e)}
|
|
1274
1283
|
text={props.text}
|
|
1284
|
+
isDisabled={isDisabled}
|
|
1275
1285
|
/>;
|
|
1276
1286
|
})}
|
|
1277
1287
|
</>;
|
|
@@ -33,6 +33,7 @@ export default function withModal(WrappedComponent) {
|
|
|
33
33
|
[okBtnLabel, setOkBtnLabel] = useState(),
|
|
34
34
|
[onYes, setOnYes] = useState(),
|
|
35
35
|
[onNo, setOnNo] = useState(),
|
|
36
|
+
[onCancel, setOnCancel] = useState(),
|
|
36
37
|
[customButtons, setCustomButtons] = useState(),
|
|
37
38
|
[body, setBody] = useState(),
|
|
38
39
|
[whichModal, setWhichModal] = useState(),
|
|
@@ -40,9 +41,6 @@ export default function withModal(WrappedComponent) {
|
|
|
40
41
|
autoFocusRef = useRef(null),
|
|
41
42
|
cancelRef = useRef(null),
|
|
42
43
|
[windowWidth, windowHeight] = useAdjustedWindowSize(w, h),
|
|
43
|
-
onCancel = () => {
|
|
44
|
-
hideModal();
|
|
45
|
-
},
|
|
46
44
|
hideModal = () => {
|
|
47
45
|
setIsModalShown(false);
|
|
48
46
|
},
|
|
@@ -52,6 +50,7 @@ export default function withModal(WrappedComponent) {
|
|
|
52
50
|
body = null,
|
|
53
51
|
canClose = false,
|
|
54
52
|
includeCancel = false,
|
|
53
|
+
onCancel = null,
|
|
55
54
|
onOk = null,
|
|
56
55
|
okBtnLabel = null,
|
|
57
56
|
onYes = null,
|
|
@@ -76,6 +75,7 @@ export default function withModal(WrappedComponent) {
|
|
|
76
75
|
setBody(body);
|
|
77
76
|
setCanClose(canClose);
|
|
78
77
|
setIncludeCancel(includeCancel);
|
|
78
|
+
setOnCancel(() => onCancel);
|
|
79
79
|
setOnOk(onOk ? () => onOk : null);
|
|
80
80
|
setOkBtnLabel(okBtnLabel || 'OK');
|
|
81
81
|
setOnYes(onYes ? () => onYes : null);
|
|
@@ -101,7 +101,7 @@ export default function withModal(WrappedComponent) {
|
|
|
101
101
|
buttons.push(<Button
|
|
102
102
|
{...testProps('cancelBtn')}
|
|
103
103
|
key="cancelBtn"
|
|
104
|
-
onPress={onCancel}
|
|
104
|
+
onPress={onCancel || hideModal}
|
|
105
105
|
colorScheme="coolGray"
|
|
106
106
|
ref={cancelRef}
|
|
107
107
|
className="mr-2"
|
|
@@ -180,7 +180,7 @@ export default function withModal(WrappedComponent) {
|
|
|
180
180
|
{...props}
|
|
181
181
|
disableWithModal={false}
|
|
182
182
|
showModal={showModal}
|
|
183
|
-
hideModal={onCancel}
|
|
183
|
+
hideModal={onCancel || hideModal}
|
|
184
184
|
updateModalBody={updateModalBody}
|
|
185
185
|
isModalShown={isModalShown}
|
|
186
186
|
whichModal={whichModal}
|
|
@@ -33,12 +33,9 @@ function Report(props) {
|
|
|
33
33
|
title,
|
|
34
34
|
description,
|
|
35
35
|
reportId,
|
|
36
|
-
// icon,
|
|
37
36
|
disablePdf = false,
|
|
38
37
|
disableExcel = false,
|
|
39
|
-
includePresets = false,
|
|
40
38
|
showReportHeaders = true,
|
|
41
|
-
h = '300px',
|
|
42
39
|
} = props,
|
|
43
40
|
buttons = [];
|
|
44
41
|
|
|
@@ -68,6 +65,7 @@ function Report(props) {
|
|
|
68
65
|
reportType: REPORT_TYPES__EXCEL,
|
|
69
66
|
showReportHeaders,
|
|
70
67
|
}),
|
|
68
|
+
disabledOnInvalid: true,
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
if (!disablePdf) {
|
|
@@ -82,6 +80,7 @@ function Report(props) {
|
|
|
82
80
|
reportType: REPORT_TYPES__PDF,
|
|
83
81
|
showReportHeaders,
|
|
84
82
|
}),
|
|
83
|
+
disableOnInvalid: true,
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
86
|
return <VStackNative
|
|
@@ -234,7 +234,12 @@ function Viewer(props) {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
let elementClassName =
|
|
237
|
+
let elementClassName = `
|
|
238
|
+
Viewer-field
|
|
239
|
+
basis-auto
|
|
240
|
+
grow
|
|
241
|
+
shrink
|
|
242
|
+
`;
|
|
238
243
|
const defaultsClassName = defaults.className;
|
|
239
244
|
if (defaultsClassName) {
|
|
240
245
|
elementClassName += ' ' + defaultsClassName;
|
|
@@ -45,17 +45,16 @@ function FileCardCustom(props) {
|
|
|
45
45
|
uploadStatus,
|
|
46
46
|
} = props,
|
|
47
47
|
isDownloading = uploadStatus && inArray(uploadStatus, ['preparing', 'uploading', 'success']);
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
);
|
|
48
|
+
return <Pressable
|
|
49
|
+
onPress={() => {
|
|
50
|
+
downloadInBackground(downloadUrl);
|
|
51
|
+
}}
|
|
52
|
+
className="px-3 py-1 items-center flex-row rounded-[5px] border border-primary.700"
|
|
53
|
+
>
|
|
54
|
+
{isDownloading && <Spinner className="mr-2" />}
|
|
55
|
+
<Text>{filename}</Text>
|
|
56
|
+
{onDelete && <IconButton ml={1} icon={Xmark} onPress={() => onDelete(id)} />}
|
|
57
|
+
</Pressable>;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
|
|
@@ -183,8 +182,9 @@ function AttachmentsElement(props) {
|
|
|
183
182
|
}
|
|
184
183
|
},
|
|
185
184
|
onFileDelete = (id) => {
|
|
185
|
+
const file = _.find(files, { id });
|
|
186
186
|
if (confirmBeforeDelete) {
|
|
187
|
-
confirm('Are you sure you want to delete the file?', () => doDelete(id));
|
|
187
|
+
confirm('Are you sure you want to delete the file "' + file.name + '"?', () => doDelete(id));
|
|
188
188
|
} else {
|
|
189
189
|
doDelete(id);
|
|
190
190
|
}
|
|
@@ -282,12 +282,19 @@ function AttachmentsElement(props) {
|
|
|
282
282
|
if (canCrud) {
|
|
283
283
|
_fileMosaic.onDelete = onFileDelete;
|
|
284
284
|
}
|
|
285
|
-
let className =
|
|
285
|
+
let className = `
|
|
286
|
+
AttachmentsElement
|
|
287
|
+
w-full
|
|
288
|
+
h-full
|
|
289
|
+
p-1
|
|
290
|
+
rounded-[5px]
|
|
291
|
+
`;
|
|
286
292
|
if (props.className) {
|
|
287
293
|
className += ' ' + props.className;
|
|
288
294
|
}
|
|
289
295
|
let content = <VStack className={className}>
|
|
290
|
-
<HStack className="flex-wrap">
|
|
296
|
+
<HStack className="AttachmentsElement-HStack flex-wrap">
|
|
297
|
+
{files.length === 0 && <Text className="text-grey-600 italic">No files</Text>}
|
|
291
298
|
{files.map((file) => {
|
|
292
299
|
return <Box
|
|
293
300
|
key={file.id}
|
|
@@ -312,7 +319,7 @@ function AttachmentsElement(props) {
|
|
|
312
319
|
{Repository.total <= collapsedMax ? null :
|
|
313
320
|
<Button
|
|
314
321
|
onPress={toggleShowAll}
|
|
315
|
-
className="mt-2"
|
|
322
|
+
className="AttachmentsElement-toggleShowAll mt-2"
|
|
316
323
|
text={'Show ' + (showAll ? ' Less' : ' All ' + Repository.total)}
|
|
317
324
|
_text={{
|
|
318
325
|
className: `
|