@onehat/ui 0.3.17 → 0.3.18
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
|
@@ -37,19 +37,23 @@ export default function Viewer(props) {
|
|
|
37
37
|
onClose,
|
|
38
38
|
onDelete,
|
|
39
39
|
} = props,
|
|
40
|
+
isMultiple = _.isArray(record),
|
|
40
41
|
isSideEditor = editorType === EDITOR_TYPE__SIDE,
|
|
41
42
|
styles = UiGlobals.styles,
|
|
42
43
|
flex = props.flex || 1,
|
|
43
44
|
buildAncillary = () => {
|
|
44
|
-
|
|
45
|
+
const components = [];
|
|
45
46
|
if (ancillaryItems.length) {
|
|
46
|
-
|
|
47
|
+
_.each(ancillaryItems, (item, ix) => {
|
|
47
48
|
let {
|
|
48
49
|
type,
|
|
49
50
|
title = null,
|
|
50
51
|
selectorId = null,
|
|
51
52
|
...propsToPass
|
|
52
53
|
} = item;
|
|
54
|
+
if (isMultiple && type !== 'Attachments') {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
53
57
|
if (!propsToPass.h) {
|
|
54
58
|
propsToPass.h = 400;
|
|
55
59
|
}
|
|
@@ -70,7 +74,7 @@ export default function Viewer(props) {
|
|
|
70
74
|
fontWeight="bold"
|
|
71
75
|
>{title}</Text>;
|
|
72
76
|
}
|
|
73
|
-
|
|
77
|
+
components.push(<Column key={'ancillary-' + ix} my={5}>{title}{element}</Column>);
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
80
|
return components;
|
|
@@ -421,15 +421,18 @@ function Form(props) {
|
|
|
421
421
|
/>;
|
|
422
422
|
},
|
|
423
423
|
buildAncillary = () => {
|
|
424
|
-
|
|
424
|
+
const components = [];
|
|
425
425
|
if (ancillaryItems.length) {
|
|
426
|
-
|
|
426
|
+
_.each(ancillaryItems, (item, ix) => {
|
|
427
427
|
let {
|
|
428
428
|
type,
|
|
429
429
|
title = null,
|
|
430
430
|
selectorId,
|
|
431
431
|
...propsToPass
|
|
432
432
|
} = item;
|
|
433
|
+
if (isMultiple && type !== 'Attachments') {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
433
436
|
if (!propsToPass.h) {
|
|
434
437
|
propsToPass.h = 400;
|
|
435
438
|
}
|
|
@@ -448,7 +451,7 @@ function Form(props) {
|
|
|
448
451
|
fontWeight="bold"
|
|
449
452
|
>{title}</Text>;
|
|
450
453
|
}
|
|
451
|
-
|
|
454
|
+
components.push(<Column key={'ancillary-' + ix} mx={2} my={5}>{title}{element}</Column>);
|
|
452
455
|
});
|
|
453
456
|
}
|
|
454
457
|
return components;
|
|
@@ -607,7 +610,7 @@ function Form(props) {
|
|
|
607
610
|
{editor}
|
|
608
611
|
|
|
609
612
|
<Footer justifyContent="flex-end" {...footerProps} {...savingProps}>
|
|
610
|
-
{onDelete && editorMode === EDITOR_MODE__EDIT &&
|
|
613
|
+
{onDelete && editorMode === EDITOR_MODE__EDIT && isSingle &&
|
|
611
614
|
<Row flex={1} justifyContent="flex-start">
|
|
612
615
|
<Button
|
|
613
616
|
key="deleteBtn"
|
|
@@ -631,7 +634,7 @@ function Form(props) {
|
|
|
631
634
|
}}
|
|
632
635
|
icon={<Rotate color="#fff" />}
|
|
633
636
|
/>}
|
|
634
|
-
{!isEditorViewOnly && onCancel && <Button
|
|
637
|
+
{!isEditorViewOnly && isSingle && onCancel && <Button
|
|
635
638
|
key="cancelBtn"
|
|
636
639
|
variant="ghost"
|
|
637
640
|
onPress={onCancel}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import Svg, { Path } from "react-native-svg"
|
|
4
|
+
import { Icon } from 'native-base';
|
|
5
|
+
|
|
6
|
+
function SvgComponent(props) {
|
|
7
|
+
return (
|
|
8
|
+
<Icon xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" {...props}>
|
|
9
|
+
<Path d="M304 240V16.6c0-9 7-16.6 16-16.6 123.7 0 224 100.3 224 224 0 9-7.6 16-16.6 16H304zM32 272c0-121.3 90.1-221.7 207-237.7 9.2-1.3 17 6.1 17 15.4V288l156.5 156.5c6.7 6.7 6.2 17.7-1.5 23.1-39.2 28-87.2 44.4-139 44.4-132.5 0-240-107.4-240-240zm526.4 16c9.3 0 16.6 7.8 15.4 17-7.7 55.9-34.6 105.6-73.9 142.3-6 5.6-15.4 5.2-21.2-.7L320 288h238.4z" />
|
|
10
|
+
</Icon>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default SvgComponent
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import Svg, { Path } from "react-native-svg"
|
|
4
|
+
import { Icon } from 'native-base';
|
|
5
|
+
|
|
6
|
+
function SvgComponent(props) {
|
|
7
|
+
return (
|
|
8
|
+
<Icon xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" {...props}>
|
|
9
|
+
<Path d="M308.5 135.3c7.1-6.3 9.9-16.2 6.2-25-2.3-5.3-4.8-10.5-7.6-15.5l-3.1-5.4c-3-5-6.3-9.9-9.8-14.6-5.7-7.6-15.7-10.1-24.7-7.1L241.3 77c-10.7-8.8-23-16-36.2-20.9l-6.1-29c-1.9-9.3-9.1-16.7-18.5-17.8-6.6-.9-13.3-1.3-20.1-1.3h-.7c-6.8 0-13.5.4-20.1 1.2-9.4 1.1-16.6 8.6-18.5 17.8L115 56.1c-13.3 5-25.5 12.1-36.2 20.9l-28.3-9.2c-9-3-19-.5-24.7 7.1-3.5 4.7-6.8 9.6-9.9 14.6l-3 5.3c-2.8 5-5.3 10.2-7.6 15.6-3.7 8.7-.9 18.6 6.2 25l22.2 19.8c-1.1 6.7-1.7 13.7-1.7 20.8s.6 14.1 1.7 20.9l-22.2 19.8c-7.1 6.3-9.9 16.2-6.2 25 2.3 5.3 4.8 10.5 7.6 15.6l3 5.2c3 5.1 6.3 9.9 9.9 14.6 5.7 7.6 15.7 10.1 24.7 7.1l28.2-9.3c10.7 8.8 23 16 36.2 20.9l6.1 29.1c1.9 9.3 9.1 16.7 18.5 17.8 6.7.8 13.5 1.2 20.4 1.2s13.7-.4 20.4-1.2c9.4-1.1 16.6-8.6 18.5-17.8l6.1-29.1c13.3-5 25.5-12.1 36.2-20.9l28.2 9.3c9 3 19 .5 24.7-7.1 3.5-4.7 6.8-9.5 9.8-14.6l3.1-5.4c2.8-5 5.3-10.2 7.6-15.5 3.7-8.7.9-18.6-6.2-25l-22.2-19.8c1.1-6.8 1.7-13.8 1.7-20.9s-.6-14.1-1.7-20.9l22.2-19.8zM112 176a48 48 0 1196 0 48 48 0 11-96 0zm392.7 324.5c6.3 7.1 16.2 9.9 25 6.2 5.3-2.3 10.5-4.8 15.5-7.6l5.4-3.1c5-3 9.9-6.3 14.6-9.8 7.6-5.7 10.1-15.7 7.1-24.7l-9.3-28.2c8.8-10.7 16-23 20.9-36.2L613 391c9.3-1.9 16.7-9.1 17.8-18.5.8-6.7 1.2-13.5 1.2-20.4s-.4-13.7-1.2-20.4c-1.1-9.4-8.6-16.6-17.8-18.5l-29.1-6.2c-5-13.3-12.1-25.5-20.9-36.2l9.3-28.2c3-9 .5-19-7.1-24.7-4.7-3.5-9.6-6.8-14.6-9.9l-5.3-3c-5-2.8-10.2-5.3-15.6-7.6-8.7-3.7-18.6-.9-25 6.2l-19.8 22.2c-6.8-1.1-13.8-1.7-20.9-1.7s-14.1.6-20.9 1.7l-19.8-22.2c-6.3-7.1-16.2-9.9-25-6.2-5.3 2.3-10.5 4.8-15.6 7.6l-5.2 3c-5.1 3-9.9 6.3-14.6 9.9-7.6 5.7-10.1 15.7-7.1 24.7l9.3 28.2c-8.8 10.7-16 23-20.9 36.2l-29.1 6c-9.3 1.9-16.7 9.1-17.8 18.5-.8 6.7-1.2 13.5-1.2 20.4s.4 13.7 1.2 20.4c1.1 9.4 8.6 16.6 17.8 18.5l29.1 6.1c5 13.3 12.1 25.5 20.9 36.2l-9.3 28.2c-3 9-.5 19 7.1 24.7 4.7 3.5 9.5 6.8 14.6 9.8l5.4 3.1c5 2.8 10.2 5.3 15.5 7.6 8.7 3.7 18.6.9 25-6.2l19.8-22.2c6.8 1.1 13.8 1.7 20.9 1.7s14.1-.6 20.9-1.7l19.8 22.2zM464 304a48 48 0 110 96 48 48 0 110-96z" />
|
|
10
|
+
</Icon>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default SvgComponent
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect, } from 'react';
|
|
1
|
+
import { useState, useEffect, useRef, } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
Button,
|
|
@@ -49,8 +49,9 @@ function AttachmentsElement(props) {
|
|
|
49
49
|
|
|
50
50
|
} = props,
|
|
51
51
|
styles = UiGlobals.styles,
|
|
52
|
-
model = selectorSelected?.repository?.name,
|
|
53
|
-
|
|
52
|
+
model = _.isArray(selectorSelected) && selectorSelected[0] ? selectorSelected[0].repository?.name : selectorSelected?.repository?.name,
|
|
53
|
+
modelidCalc = _.isArray(selectorSelected) ? _.map(selectorSelected, (entity) => entity.id) : selectorSelected?.id,
|
|
54
|
+
modelid = useRef(modelidCalc),
|
|
54
55
|
[isReady, setIsReady] = useState(false),
|
|
55
56
|
[isUploading, setIsUploading] = useState(false),
|
|
56
57
|
[showAll, setShowAll] = useState(false),
|
|
@@ -78,6 +79,9 @@ function AttachmentsElement(props) {
|
|
|
78
79
|
});
|
|
79
80
|
setFiles(files);
|
|
80
81
|
},
|
|
82
|
+
clearFiles = () => {
|
|
83
|
+
setFiles([]);
|
|
84
|
+
},
|
|
81
85
|
toggleShowAll = () => {
|
|
82
86
|
setShowAll(!showAll);
|
|
83
87
|
},
|
|
@@ -86,7 +90,7 @@ function AttachmentsElement(props) {
|
|
|
86
90
|
_.each(files, (file) => {
|
|
87
91
|
file.extraUploadData = {
|
|
88
92
|
model,
|
|
89
|
-
modelid,
|
|
93
|
+
modelid: modelid.current,
|
|
90
94
|
};
|
|
91
95
|
});
|
|
92
96
|
},
|
|
@@ -112,6 +116,10 @@ function AttachmentsElement(props) {
|
|
|
112
116
|
Repository.deleteById(id);
|
|
113
117
|
};
|
|
114
118
|
|
|
119
|
+
if (!_.isEqual(modelidCalc, modelid.current)) {
|
|
120
|
+
modelid.current = modelidCalc;
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
useEffect(() => {
|
|
116
124
|
|
|
117
125
|
if (!model) {
|
|
@@ -120,37 +128,43 @@ function AttachmentsElement(props) {
|
|
|
120
128
|
|
|
121
129
|
(async () => {
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
if (!_.isArray(modelid.current)) {
|
|
132
|
+
|
|
133
|
+
// Load Repository
|
|
134
|
+
const filters = [
|
|
135
|
+
{
|
|
136
|
+
name: 'model',
|
|
137
|
+
value: model,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'modelid',
|
|
141
|
+
value: modelid.current,
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
if (accept) {
|
|
145
|
+
let name,
|
|
146
|
+
mimetypes;
|
|
147
|
+
if (_.isString(accept)) {
|
|
148
|
+
name = 'mimetype LIKE';
|
|
149
|
+
mimetypes = accept.replace('*', '%');
|
|
150
|
+
} else if (_.isArray(accept)) {
|
|
151
|
+
name = 'mimetype IN';
|
|
152
|
+
mimetypes = accept;
|
|
153
|
+
}
|
|
154
|
+
filters.push({
|
|
155
|
+
name,
|
|
156
|
+
value: mimetypes,
|
|
157
|
+
});
|
|
143
158
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
159
|
+
Repository.filter(filters);
|
|
160
|
+
Repository.setPageSize(showAll ? EXPANDED_MAX : COLLAPSED_MAX);
|
|
161
|
+
await Repository.load();
|
|
162
|
+
|
|
163
|
+
buildFiles();
|
|
164
|
+
} else {
|
|
165
|
+
clearFiles();
|
|
148
166
|
}
|
|
149
|
-
Repository.filter(filters);
|
|
150
|
-
Repository.setPageSize(showAll ? EXPANDED_MAX : COLLAPSED_MAX);
|
|
151
|
-
await Repository.load();
|
|
152
167
|
|
|
153
|
-
buildFiles();
|
|
154
168
|
|
|
155
169
|
if (!isReady) {
|
|
156
170
|
setIsReady(true);
|
|
@@ -162,7 +176,7 @@ function AttachmentsElement(props) {
|
|
|
162
176
|
return () => {
|
|
163
177
|
Repository.off('load', buildFiles);
|
|
164
178
|
};
|
|
165
|
-
}, [model, modelid, showAll]);
|
|
179
|
+
}, [model, modelid.current, showAll]);
|
|
166
180
|
|
|
167
181
|
if (!isReady) {
|
|
168
182
|
return null;
|