@onehat/ui 0.3.17 → 0.3.21
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/Form.js +8 -5
- package/src/Components/Grid/GridRow.js +32 -3
- package/src/Components/Hoc/withEditor.js +11 -5
- package/src/Components/Hoc/withFilters.js +14 -8
- package/src/Components/Hoc/withPresetButtons.js +2 -2
- package/src/Components/Icons/ChartPie.js +14 -0
- package/src/Components/Icons/Gears.js +14 -0
- package/src/Components/Viewer/TagViewer.js +28 -0
- package/src/Components/{Editor → Viewer}/Viewer.js +7 -3
- package/src/Components/index.js +2 -0
- package/src/PlatformImports/Web/Attachments.js +47 -33
package/package.json
CHANGED
|
@@ -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}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
VERTICAL,
|
|
9
9
|
} from '../../Constants/Directions.js';
|
|
10
|
+
import getComponentFromType from '../../Functions/getComponentFromType.js';
|
|
10
11
|
import UiGlobals from '../../UiGlobals.js';
|
|
11
12
|
import withDraggable from '../Hoc/withDraggable.js';
|
|
12
13
|
import AngleRight from '../Icons/AngleRight.js';
|
|
@@ -25,10 +26,17 @@ export default function GridRow(props) {
|
|
|
25
26
|
item,
|
|
26
27
|
isInlineEditorShown,
|
|
27
28
|
} = props,
|
|
28
|
-
styles = UiGlobals.styles
|
|
29
|
+
styles = UiGlobals.styles;
|
|
30
|
+
|
|
31
|
+
if (item.isDestroyed) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const
|
|
29
36
|
isPhantom = item.isPhantom,
|
|
30
37
|
hash = item?.hash || item;
|
|
31
38
|
|
|
39
|
+
|
|
32
40
|
return useMemo(() => {
|
|
33
41
|
const renderColumns = (item) => {
|
|
34
42
|
if (_.isArray(columnsConfig)) {
|
|
@@ -86,9 +94,30 @@ export default function GridRow(props) {
|
|
|
86
94
|
return <Row key={key} {...propsToPass} {...extraProps}>{config.renderer(item)}</Row>;
|
|
87
95
|
}
|
|
88
96
|
if (config.fieldName) {
|
|
89
|
-
if (item
|
|
90
|
-
const property = item.properties[config.fieldName];
|
|
97
|
+
if (item?.properties && item.properties[config.fieldName]) {
|
|
98
|
+
const property = item.properties[config.fieldName];
|
|
91
99
|
value = property.displayValue;
|
|
100
|
+
|
|
101
|
+
if (property?.viewerType?.type) {
|
|
102
|
+
const Element = getComponentFromType(property?.viewerType?.type);
|
|
103
|
+
return <Element
|
|
104
|
+
value={value}
|
|
105
|
+
key={key}
|
|
106
|
+
overflow="hidden"
|
|
107
|
+
textOverflow="ellipsis"
|
|
108
|
+
alignSelf="center"
|
|
109
|
+
style={{
|
|
110
|
+
userSelect: 'none',
|
|
111
|
+
}}
|
|
112
|
+
fontSize={styles.GRID_CELL_FONTSIZE}
|
|
113
|
+
px={styles.GRID_CELL_PX}
|
|
114
|
+
py={styles.GRID_CELL_PY}
|
|
115
|
+
numberOfLines={1}
|
|
116
|
+
ellipsizeMode="head"
|
|
117
|
+
{...propsToPass}
|
|
118
|
+
{...propsToPass}
|
|
119
|
+
/>;
|
|
120
|
+
}
|
|
92
121
|
} else if (item[config.fieldName]) {
|
|
93
122
|
value = item[config.fieldName];
|
|
94
123
|
} else if (fields) {
|
|
@@ -121,6 +121,9 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
onEdit = async () => {
|
|
124
|
+
if (_.isEmpty(selection) || (_.isArray(selection) && (selection.length > 1 || selection[0]?.isDestroyed))) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
124
127
|
if (getListeners().onBeforeEdit) {
|
|
125
128
|
const listenerResult = await getListeners().onBeforeEdit();
|
|
126
129
|
if (listenerResult === false) {
|
|
@@ -132,6 +135,9 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
132
135
|
setIsEditorShown(true);
|
|
133
136
|
},
|
|
134
137
|
onDelete = async (cb) => {
|
|
138
|
+
if (_.isEmpty(selection) || (_.isArray(selection) && (selection.length > 1 || selection[0]?.isDestroyed))) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
135
141
|
if (getListeners().onBeforeDelete) {
|
|
136
142
|
const listenerResult = await getListeners().onBeforeDelete();
|
|
137
143
|
if (listenerResult === false) {
|
|
@@ -165,7 +171,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
165
171
|
deleteRecord(cb);
|
|
166
172
|
} else {
|
|
167
173
|
const identifier = getRecordIdentifier(selection);
|
|
168
|
-
confirm('Are you sure you want to delete the ' + identifier, () => deleteRecord(cb));
|
|
174
|
+
confirm('Are you sure you want to delete the ' + identifier, () => deleteRecord(null, cb));
|
|
169
175
|
}
|
|
170
176
|
},
|
|
171
177
|
onMoveChildren = (cb) => {
|
|
@@ -268,7 +274,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
268
274
|
async function doIt() {
|
|
269
275
|
const
|
|
270
276
|
isSingle = selection.length === 1,
|
|
271
|
-
isPhantom = selection[0] && selection[0].isPhantom;
|
|
277
|
+
isPhantom = selection[0] && !selection[0]?.isDestroyed && selection[0].isPhantom;
|
|
272
278
|
if (isSingle && isPhantom) {
|
|
273
279
|
await deleteRecord();
|
|
274
280
|
}
|
|
@@ -301,7 +307,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
301
307
|
// For multiple entities selected, change it to edit multiple mode
|
|
302
308
|
mode = EDITOR_MODE__EDIT;
|
|
303
309
|
}
|
|
304
|
-
} else if (selection.length === 1 && selection[0].isPhantom) {
|
|
310
|
+
} else if (selection.length === 1 && !selection[0].isDestroyed && selection[0].isPhantom) {
|
|
305
311
|
if (!disableAdd) {
|
|
306
312
|
// When a phantom entity is selected, change it to add mode.
|
|
307
313
|
mode = EDITOR_MODE__ADD;
|
|
@@ -354,12 +360,12 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
354
360
|
setIsEditorShown={setIsEditorShown}
|
|
355
361
|
onAdd={(!userCanEdit || disableAdd) ? null : onAdd}
|
|
356
362
|
onEdit={(!userCanEdit || disableEdit) ? null : onEdit}
|
|
357
|
-
onDelete={(!userCanEdit || disableDelete
|
|
363
|
+
onDelete={(!userCanEdit || disableDelete) ? null : onDelete}
|
|
358
364
|
onView={viewRecord}
|
|
359
365
|
onDuplicate={duplicateRecord}
|
|
360
366
|
onEditorSave={onEditorSave}
|
|
361
367
|
onEditorCancel={onEditorCancel}
|
|
362
|
-
onEditorDelete={(!userCanEdit || disableDelete
|
|
368
|
+
onEditorDelete={(!userCanEdit || disableDelete) ? null : onEditorDelete}
|
|
363
369
|
onEditorClose={onEditorClose}
|
|
364
370
|
setWithEditListeners={setListeners}
|
|
365
371
|
isEditor={true}
|
|
@@ -80,13 +80,12 @@ export default function withFilters(WrappedComponent) {
|
|
|
80
80
|
if (propertyDef) {
|
|
81
81
|
title = propertyDef.title;
|
|
82
82
|
type = propertyDef.filterType;
|
|
83
|
-
} else {
|
|
84
|
-
if (!modelFilterTypes[field]) {
|
|
85
|
-
throw Error('not a propertyDef, and not an ancillaryFilter!');
|
|
86
|
-
}
|
|
83
|
+
} else if (modelAncillaryFilters[field]) {
|
|
87
84
|
const ancillaryFilter = modelFilterTypes[field];
|
|
88
85
|
title = ancillaryFilter.title;
|
|
89
86
|
type = FILTER_TYPE_ANCILLARY;
|
|
87
|
+
} else {
|
|
88
|
+
throw Error('not a propertyDef, and not an ancillaryFilter!');
|
|
90
89
|
}
|
|
91
90
|
formatted = {
|
|
92
91
|
field,
|
|
@@ -330,6 +329,7 @@ export default function withFilters(WrappedComponent) {
|
|
|
330
329
|
const {
|
|
331
330
|
field,
|
|
332
331
|
value,
|
|
332
|
+
type,
|
|
333
333
|
} = filter,
|
|
334
334
|
isFilterRange = getIsFilterRange(filter);
|
|
335
335
|
if (isFilterRange) {
|
|
@@ -345,8 +345,11 @@ export default function withFilters(WrappedComponent) {
|
|
|
345
345
|
newRepoFilters.push({ name: lowField, value: lowValue, });
|
|
346
346
|
}
|
|
347
347
|
} else {
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
const
|
|
349
|
+
isAncillary = type === FILTER_TYPE_ANCILLARY,
|
|
350
|
+
filterName = (isAncillary ? 'ancillary___' : '') + field;
|
|
351
|
+
newFilterNames.push(filterName);
|
|
352
|
+
newRepoFilters.push({ name: filterName, value, });
|
|
350
353
|
}
|
|
351
354
|
});
|
|
352
355
|
|
|
@@ -421,7 +424,7 @@ export default function withFilters(WrappedComponent) {
|
|
|
421
424
|
_.each(modalSlots, (field, ix) => {
|
|
422
425
|
|
|
423
426
|
// Create the data for the combobox. (i.e. List all the possible filters for this slot)
|
|
424
|
-
|
|
427
|
+
let data = [];
|
|
425
428
|
_.each(modelFilterTypes, (filterType, filterField) => {
|
|
426
429
|
if (inArray(filterField, usedFields) && field !== filterField) { // Show all filters not yet applied, but include the current filter
|
|
427
430
|
return; // skip, since it's already been used
|
|
@@ -430,7 +433,7 @@ export default function withFilters(WrappedComponent) {
|
|
|
430
433
|
// Is it an ancillary filter?
|
|
431
434
|
const isAncillary = _.isPlainObject(filterType) && filterType.isAncillary;
|
|
432
435
|
if (isAncillary) {
|
|
433
|
-
data.push([ filterField, filterType.title ]);
|
|
436
|
+
data.push([ filterField, filterType.title + ' •' ]);
|
|
434
437
|
return;
|
|
435
438
|
}
|
|
436
439
|
|
|
@@ -439,6 +442,9 @@ export default function withFilters(WrappedComponent) {
|
|
|
439
442
|
data.push([ filterField, propertyDef.title ]);
|
|
440
443
|
});
|
|
441
444
|
|
|
445
|
+
// sort by title
|
|
446
|
+
data = _.sortBy(data, [function(datum) { return datum[1]; }]);
|
|
447
|
+
|
|
442
448
|
const
|
|
443
449
|
ixPlusOne = (ix +1),
|
|
444
450
|
filterName = 'filter' + ixPlusOne;
|
|
@@ -143,7 +143,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
143
143
|
if (selectorId && !selectorSelected) {
|
|
144
144
|
isDisabled = true;
|
|
145
145
|
}
|
|
146
|
-
if (_.isEmpty(selection)) {
|
|
146
|
+
if (_.isEmpty(selection) || (_.isArray(selection) && selection.length > 1)) {
|
|
147
147
|
isDisabled = true;
|
|
148
148
|
}
|
|
149
149
|
break;
|
|
@@ -154,7 +154,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
154
154
|
if (selectorId && !selectorSelected) {
|
|
155
155
|
isDisabled = true;
|
|
156
156
|
}
|
|
157
|
-
if (_.isEmpty(selection) || selection.length > 1) {
|
|
157
|
+
if (_.isEmpty(selection) || (_.isArray(selection) && selection.length > 1)) {
|
|
158
158
|
isDisabled = true;
|
|
159
159
|
}
|
|
160
160
|
break;
|
|
@@ -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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Text,
|
|
3
|
+
} from 'native-base';
|
|
4
|
+
import UiGlobals from '../../UiGlobals.js';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
|
|
7
|
+
function TagViewer(props) {
|
|
8
|
+
const {
|
|
9
|
+
value,
|
|
10
|
+
} = props,
|
|
11
|
+
parsedValue = value ? JSON.parse(value) : null,
|
|
12
|
+
values = parsedValue ? _.map(parsedValue, (val) => {
|
|
13
|
+
const ret = val?.text;
|
|
14
|
+
return ret;
|
|
15
|
+
}).join(', ') : [],
|
|
16
|
+
styles = UiGlobals.styles;
|
|
17
|
+
|
|
18
|
+
return <Text
|
|
19
|
+
numberOfLines={1}
|
|
20
|
+
ellipsizeMode="head"
|
|
21
|
+
// fontSize={styles.FORM_TEXT_FONTSIZE}
|
|
22
|
+
// minHeight='40px'
|
|
23
|
+
// px={3}
|
|
24
|
+
// py={2}
|
|
25
|
+
{...props}
|
|
26
|
+
>{values}</Text>;
|
|
27
|
+
}
|
|
28
|
+
export default TagViewer;
|
|
@@ -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;
|
package/src/Components/index.js
CHANGED
|
@@ -38,6 +38,7 @@ import PlusMinusButton from './Buttons/PlusMinusButton.js';
|
|
|
38
38
|
import RadioGroup from './Form/Field/RadioGroup/RadioGroup.js';
|
|
39
39
|
import TabPanel from './Panel/TabPanel.js';
|
|
40
40
|
import Tag from './Form/Field/Combo/Tag.js';
|
|
41
|
+
import TagViewer from './Viewer/TagViewer.js';
|
|
41
42
|
import TextArea from './Form/Field/TextArea.js';
|
|
42
43
|
import Text from './Form/Field/Text.js';
|
|
43
44
|
import TimezonesCombo from './Form/Field/Combo/TimezonesCombo.js';
|
|
@@ -87,6 +88,7 @@ const components = {
|
|
|
87
88
|
RadioGroup,
|
|
88
89
|
TabPanel,
|
|
89
90
|
Tag,
|
|
91
|
+
TagViewer,
|
|
90
92
|
Text,
|
|
91
93
|
TextArea,
|
|
92
94
|
TimezonesCombo,
|
|
@@ -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;
|