@onehat/ui 0.4.43 → 0.4.45
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 +4 -1
- package/src/Components/Form/Field/Slider.js +2 -1
- package/src/Components/Form/Field/Tag/Tag.js +6 -0
- package/src/Components/Form/Form.js +1 -1
- package/src/Components/Hoc/withData.js +1 -2
- package/src/Components/Hoc/withFilters.js +1 -1
- package/src/Components/Hoc/withPresetButtons.js +2 -0
- package/src/Components/Window/UploadsDownloadsWindow.js +18 -19
- package/src/Functions/downloadWithFetch.js +13 -3
- /package/src/Data/{Hoc → hoc}/withRedux.js +0 -0
package/package.json
CHANGED
|
@@ -722,7 +722,7 @@ export const ComboComponent = forwardRef((props, ref) => {
|
|
|
722
722
|
// 'data',
|
|
723
723
|
'idIx',
|
|
724
724
|
'displayIx',
|
|
725
|
-
'value',
|
|
725
|
+
// 'value',
|
|
726
726
|
'disableView',
|
|
727
727
|
'disableCopy',
|
|
728
728
|
'disableDuplicate',
|
|
@@ -732,6 +732,9 @@ export const ComboComponent = forwardRef((props, ref) => {
|
|
|
732
732
|
'selectorSelectedField',
|
|
733
733
|
'usePermissions',
|
|
734
734
|
]);
|
|
735
|
+
if (!isInTag) {
|
|
736
|
+
gridProps.value = props.value;
|
|
737
|
+
}
|
|
735
738
|
if (!Repository) {
|
|
736
739
|
gridProps.data = filteredData;
|
|
737
740
|
}
|
|
@@ -148,6 +148,7 @@ function SliderElement(props) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
let className = `
|
|
151
|
+
Slider
|
|
151
152
|
w-full
|
|
152
153
|
items-center
|
|
153
154
|
`,
|
|
@@ -184,7 +185,7 @@ function SliderElement(props) {
|
|
|
184
185
|
tooltipPlacement={tooltipPlacement}
|
|
185
186
|
{...props._input}
|
|
186
187
|
/>
|
|
187
|
-
<HStack className="flex-1">
|
|
188
|
+
<HStack className="SliderContainer flex-1">
|
|
188
189
|
<Slider
|
|
189
190
|
{...testProps('slider')}
|
|
190
191
|
ref={props.outerRef}
|
|
@@ -38,6 +38,9 @@ function TagComponent(props) {
|
|
|
38
38
|
// withComponent
|
|
39
39
|
self,
|
|
40
40
|
|
|
41
|
+
// withFilters
|
|
42
|
+
isInFilter,
|
|
43
|
+
|
|
41
44
|
// withValue
|
|
42
45
|
value = [],
|
|
43
46
|
setValue,
|
|
@@ -246,6 +249,9 @@ function TagComponent(props) {
|
|
|
246
249
|
w-full
|
|
247
250
|
p-0
|
|
248
251
|
`;
|
|
252
|
+
if (isInFilter) {
|
|
253
|
+
className += ' max-w-[250px]';
|
|
254
|
+
}
|
|
249
255
|
if (props.className) {
|
|
250
256
|
className += ' ' + props.className;
|
|
251
257
|
}
|
|
@@ -307,7 +307,7 @@ export default function withFilters(WrappedComponent) {
|
|
|
307
307
|
placeholder={tooltip}
|
|
308
308
|
value={getFilterValue(field)}
|
|
309
309
|
onChangeValue={(value) => onFilterChangeValue(field, value)}
|
|
310
|
-
|
|
310
|
+
isInFilter={true}
|
|
311
311
|
minimizeForRow={true}
|
|
312
312
|
{...filterProps}
|
|
313
313
|
{...elementProps}
|
|
@@ -50,6 +50,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
50
50
|
useUploadDownload = false,
|
|
51
51
|
uploadHeaders,
|
|
52
52
|
uploadParams,
|
|
53
|
+
onUpload,
|
|
53
54
|
downloadHeaders,
|
|
54
55
|
downloadParams,
|
|
55
56
|
onChangeColumnsConfig,
|
|
@@ -369,6 +370,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
369
370
|
columnsConfig={props.columnsConfig}
|
|
370
371
|
uploadHeaders={uploadHeaders}
|
|
371
372
|
uploadParams={uploadParams}
|
|
373
|
+
onUpload={onUpload}
|
|
372
374
|
downloadHeaders={downloadHeaders}
|
|
373
375
|
downloadParams={downloadParams}
|
|
374
376
|
/>,
|
|
@@ -18,14 +18,14 @@ import Cookies from 'js-cookie';
|
|
|
18
18
|
import _ from 'lodash';
|
|
19
19
|
|
|
20
20
|
function UploadsDownloadsWindow(props) {
|
|
21
|
-
const
|
|
22
|
-
{
|
|
21
|
+
const {
|
|
23
22
|
Repository,
|
|
24
23
|
columnsConfig = [],
|
|
25
24
|
uploadHeaders,
|
|
26
25
|
downloadHeaders,
|
|
27
26
|
uploadParams = {},
|
|
28
27
|
downloadParams = {},
|
|
28
|
+
onUpload,
|
|
29
29
|
|
|
30
30
|
// withComponent
|
|
31
31
|
self,
|
|
@@ -45,10 +45,6 @@ function UploadsDownloadsWindow(props) {
|
|
|
45
45
|
|
|
46
46
|
const
|
|
47
47
|
baseURL = Repository.api.baseURL,
|
|
48
|
-
filters = Repository.filters.reduce((result, current) => {
|
|
49
|
-
result[current.name] = current.value;
|
|
50
|
-
return result;
|
|
51
|
-
}, {}),
|
|
52
48
|
columns = columnsConfig.map((column) => {
|
|
53
49
|
return column.fieldName;
|
|
54
50
|
}),
|
|
@@ -62,29 +58,29 @@ function UploadsDownloadsWindow(props) {
|
|
|
62
58
|
body: JSON.stringify({
|
|
63
59
|
download_token,
|
|
64
60
|
report_id: 1,
|
|
65
|
-
filters,
|
|
66
61
|
columns,
|
|
67
62
|
order,
|
|
68
63
|
model,
|
|
69
64
|
isTemplate,
|
|
65
|
+
...Repository._params,
|
|
70
66
|
...downloadParams,
|
|
71
67
|
}),
|
|
72
68
|
headers: _.merge({ 'Content-Type': 'application/json' }, Repository.headers, downloadHeaders),
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
};
|
|
70
|
+
downloadWithFetch(url, options);
|
|
71
|
+
const interval = setInterval(function() {
|
|
72
|
+
const cookie = Cookies.get(download_token);
|
|
73
|
+
if (win.window && cookie) {
|
|
74
|
+
clearInterval(interval);
|
|
75
|
+
Cookies.remove(download_token);
|
|
76
|
+
win.window.close();
|
|
77
|
+
}
|
|
78
|
+
}, 1000);
|
|
83
79
|
},
|
|
84
80
|
onDownloadTemplate = () => {
|
|
85
81
|
onDownload(true);
|
|
86
82
|
},
|
|
87
|
-
|
|
83
|
+
onUploadLocal = async () => {
|
|
88
84
|
const
|
|
89
85
|
url = Repository.api.baseURL + Repository.name + '/uploadBatch',
|
|
90
86
|
result = await Repository._send('POST', url, { importFile, ...uploadParams, }, uploadHeaders)
|
|
@@ -123,6 +119,9 @@ function UploadsDownloadsWindow(props) {
|
|
|
123
119
|
setImportFile(null);
|
|
124
120
|
self.formSetValue('file', null);
|
|
125
121
|
showInfo("Upload successful.\n");
|
|
122
|
+
if (onUpload) {
|
|
123
|
+
onUpload();
|
|
124
|
+
}
|
|
126
125
|
}
|
|
127
126
|
};
|
|
128
127
|
|
|
@@ -191,7 +190,7 @@ function UploadsDownloadsWindow(props) {
|
|
|
191
190
|
size: 'md',
|
|
192
191
|
},
|
|
193
192
|
isDisabled: !importFile,
|
|
194
|
-
onPress:
|
|
193
|
+
onPress: onUploadLocal,
|
|
195
194
|
},
|
|
196
195
|
{
|
|
197
196
|
type: 'Button',
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
const downloadWithFetch = (url, options = {}, win = null) => {
|
|
2
2
|
let obj = {};
|
|
3
3
|
fetch(url, options)
|
|
4
|
-
.then(
|
|
5
|
-
|
|
4
|
+
.then((res) => {
|
|
5
|
+
const contentDisposition = res.headers.get('Content-Disposition');
|
|
6
|
+
let filename = 'download';
|
|
7
|
+
if (contentDisposition && contentDisposition.indexOf('attachment') !== -1) {
|
|
8
|
+
const matches = /filename="([^"]*)"/.exec(contentDisposition);
|
|
9
|
+
if (matches != null && matches[1]) {
|
|
10
|
+
filename = matches[1];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return res.blob().then((blob) => ({ blob, filename }));
|
|
14
|
+
})
|
|
15
|
+
.then(({ blob, filename }) => {
|
|
6
16
|
// if (!win) {
|
|
7
17
|
// const
|
|
8
18
|
// winName = 'Download',
|
|
@@ -17,7 +27,7 @@ const downloadWithFetch = (url, options = {}, win = null) => {
|
|
|
17
27
|
// const link = win.document.createElement('a');
|
|
18
28
|
const link = document.createElement('a');
|
|
19
29
|
link.href = file;
|
|
20
|
-
|
|
30
|
+
link.download = filename; // Set the filename from the Content-Disposition header
|
|
21
31
|
link.target = "_blank";
|
|
22
32
|
link.click();
|
|
23
33
|
|
|
File without changes
|