@evoke-platform/ui-components 1.6.0-dev.3 → 1.6.0-dev.30
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/dist/published/components/core/SwipeableDrawer/SwipeableDrawer.d.ts +4 -0
- package/dist/published/components/core/SwipeableDrawer/SwipeableDrawer.js +8 -0
- package/dist/published/components/core/SwipeableDrawer/index.d.ts +3 -0
- package/dist/published/components/core/SwipeableDrawer/index.js +3 -0
- package/dist/published/components/core/index.d.ts +1 -0
- package/dist/published/components/core/index.js +1 -0
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +1 -1
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +45 -5
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +8 -1
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +2 -2
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +87 -57
- package/dist/published/components/custom/Form/tests/Form.test.js +1 -1
- package/dist/published/components/custom/Form/utils.js +6 -0
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +3 -3
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +6 -3
- package/dist/published/components/custom/FormField/Select/Select.js +17 -5
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +13 -3
- package/dist/published/components/custom/FormV2/FormRenderer.d.ts +19 -0
- package/dist/published/components/custom/FormV2/FormRenderer.js +183 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.js +131 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.d.ts +19 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.js +106 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.d.ts +24 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.js +100 -0
- package/dist/published/components/custom/FormV2/components/FormContext.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormContext.js +8 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.js +50 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.d.ts +14 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.js +88 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.js +140 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.js +233 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.d.ts +40 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.js +95 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +526 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.js +93 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.js +113 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.js +179 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.js +108 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.js +129 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.d.ts +15 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.js +226 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.js +439 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.d.ts +29 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.js +74 -0
- package/dist/published/components/custom/FormV2/components/FormSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormSections.js +104 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.d.ts +2 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.js +209 -0
- package/dist/published/components/custom/FormV2/components/TabNav.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/TabNav.js +23 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.d.ts +3 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.js +176 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.js +45 -0
- package/dist/published/components/custom/FormV2/components/types.d.ts +122 -0
- package/dist/published/components/custom/FormV2/components/types.js +1 -0
- package/dist/published/components/custom/FormV2/components/utils.d.ts +47 -0
- package/dist/published/components/custom/FormV2/components/utils.js +434 -0
- package/dist/published/components/custom/FormV2/index.d.ts +1 -0
- package/dist/published/components/custom/FormV2/index.js +1 -0
- package/dist/published/components/custom/HistoryLog/HistoryData.d.ts +1 -0
- package/dist/published/components/custom/HistoryLog/HistoryData.js +14 -6
- package/dist/published/components/custom/HistoryLog/HistoryLoading.d.ts +4 -1
- package/dist/published/components/custom/HistoryLog/HistoryLoading.js +14 -8
- package/dist/published/components/custom/HistoryLog/index.d.ts +2 -0
- package/dist/published/components/custom/HistoryLog/index.js +4 -4
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.d.ts +33 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.js +140 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.d.ts +1 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.js +100 -0
- package/dist/published/components/custom/ResponsiveOverflow/index.d.ts +4 -0
- package/dist/published/components/custom/ResponsiveOverflow/index.js +3 -0
- package/dist/published/components/custom/index.d.ts +2 -0
- package/dist/published/components/custom/index.js +2 -0
- package/dist/published/components/custom/util.d.ts +1 -0
- package/dist/published/components/custom/util.js +28 -0
- package/dist/published/index.d.ts +1 -1
- package/dist/published/index.js +1 -1
- package/dist/published/stories/ResponsiveOverflow.stories.d.ts +8 -0
- package/dist/published/stories/ResponsiveOverflow.stories.js +91 -0
- package/dist/published/theme/hooks.d.ts +7 -0
- package/dist/published/theme/hooks.js +9 -0
- package/package.json +6 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useApiServices } from '@evoke-platform/context';
|
|
2
|
+
import { ExpandMore } from '@mui/icons-material';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
import { useFormContext } from '../../../../../theme/hooks';
|
|
5
|
+
import { Autocomplete, Paper, TextField, Typography } from '../../../../core';
|
|
6
|
+
import { getPrefixedUrl, isOptionEqualToValue } from '../utils';
|
|
7
|
+
const UserProperty = (props) => {
|
|
8
|
+
const { id, handleChange, error, value, fieldHeight, readOnly, hasDescription } = props;
|
|
9
|
+
const { fetchedOptions, setFetchedOptions } = useFormContext();
|
|
10
|
+
const [loadingOptions, setLoadingOptions] = useState(false);
|
|
11
|
+
const apiServices = useApiServices();
|
|
12
|
+
const [options, setOptions] = useState(fetchedOptions[`${id}Options`] || []);
|
|
13
|
+
const [openOptions, setOpenOptions] = useState(false);
|
|
14
|
+
const [users, setUsers] = useState();
|
|
15
|
+
const [userValue, setUserValue] = useState();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (value && typeof value == 'object' && 'name' in value && 'id' in value) {
|
|
18
|
+
setUserValue({ label: value.name, value: value.id });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
setUserValue(undefined);
|
|
22
|
+
}
|
|
23
|
+
}, [value]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!fetchedOptions[`${id}Options`]) {
|
|
26
|
+
setLoadingOptions(true);
|
|
27
|
+
apiServices.get(getPrefixedUrl(`/users`), (error, userList) => {
|
|
28
|
+
setUsers(userList);
|
|
29
|
+
setOptions((userList ?? []).map((user) => ({
|
|
30
|
+
label: user.name,
|
|
31
|
+
value: user.id,
|
|
32
|
+
})));
|
|
33
|
+
setFetchedOptions({
|
|
34
|
+
[`${id}Options`]: (userList ?? []).map((user) => ({
|
|
35
|
+
label: user.name,
|
|
36
|
+
value: user.id,
|
|
37
|
+
})),
|
|
38
|
+
});
|
|
39
|
+
setLoadingOptions(false);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [id]);
|
|
43
|
+
function handleChangeUserProperty(id, value) {
|
|
44
|
+
const updatedValue = typeof value.value === 'string' ? { name: value.label, id: value.value } : undefined;
|
|
45
|
+
handleChange(id, updatedValue);
|
|
46
|
+
}
|
|
47
|
+
return (options && (React.createElement(Autocomplete, { id: id, fullWidth: true, open: openOptions, popupIcon: userValue || readOnly ? '' : React.createElement(ExpandMore, null), PaperComponent: ({ children }) => {
|
|
48
|
+
return (React.createElement(Paper, { sx: {
|
|
49
|
+
borderRadius: '12px',
|
|
50
|
+
boxShadow: '0px 24px 48px 0px rgba(145, 158, 171, 0.2)',
|
|
51
|
+
'& .MuiAutocomplete-listbox': {
|
|
52
|
+
maxHeight: '25vh',
|
|
53
|
+
},
|
|
54
|
+
'& .MuiAutocomplete-noOptions': {
|
|
55
|
+
fontFamily: 'sans-serif',
|
|
56
|
+
fontSize: '14px',
|
|
57
|
+
paddingLeft: '24px',
|
|
58
|
+
color: 'rgba(145, 158, 171, 1)',
|
|
59
|
+
},
|
|
60
|
+
'& .MuiAutocomplete-loading': {
|
|
61
|
+
fontFamily: 'sans-serif',
|
|
62
|
+
fontSize: '14px',
|
|
63
|
+
paddingLeft: '24px',
|
|
64
|
+
color: 'rgba(145, 158, 171, 1)',
|
|
65
|
+
},
|
|
66
|
+
} }, children));
|
|
67
|
+
}, sx: {
|
|
68
|
+
'& button.MuiButtonBase-root': {
|
|
69
|
+
...(!loadingOptions && value ? { visibility: 'visible' } : {}),
|
|
70
|
+
},
|
|
71
|
+
'.MuiAutocomplete-clearIndicator': {
|
|
72
|
+
...(!value ? { display: 'none' } : undefined),
|
|
73
|
+
},
|
|
74
|
+
}, noOptionsText: 'No options available', renderOption: (props, option) => {
|
|
75
|
+
return (React.createElement("li", { ...props, key: option.id },
|
|
76
|
+
React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } },
|
|
77
|
+
option.label,
|
|
78
|
+
" ",
|
|
79
|
+
'',
|
|
80
|
+
users?.find((user) => option.value === user.id)?.status === 'Inactive' ? (React.createElement("span", null, "(Inactive)")) : (''))));
|
|
81
|
+
}, onOpen: () => {
|
|
82
|
+
setOpenOptions(true);
|
|
83
|
+
}, onClose: () => setOpenOptions(false), value: userValue ?? '', options: options, getOptionLabel: (option) => {
|
|
84
|
+
if (typeof option === 'string') {
|
|
85
|
+
return options.find((o) => o.value === option)?.label ?? '';
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
{
|
|
89
|
+
if (users?.find((user) => option.value === user.id)?.status === 'Inactive') {
|
|
90
|
+
return option.label + ' (Inactive)';
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return option.label ?? '';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, onKeyDownCapture: (e) => {
|
|
98
|
+
// prevents keyboard trap
|
|
99
|
+
if (e.key === 'Tab') {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (value) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
}
|
|
105
|
+
}, loading: loadingOptions, isOptionEqualToValue: isOptionEqualToValue, onChange: (event, value) => {
|
|
106
|
+
handleChangeUserProperty(id, value);
|
|
107
|
+
}, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: !readOnly ? 'Select' : undefined, readOnly: !loadingOptions && !value && readOnly, inputProps: {
|
|
108
|
+
...params.inputProps,
|
|
109
|
+
...(hasDescription ? { 'aria-describedby': `${id}-description` } : undefined),
|
|
110
|
+
}, sx: {
|
|
111
|
+
...(!loadingOptions && value
|
|
112
|
+
? {
|
|
113
|
+
'.MuiOutlinedInput-root': {
|
|
114
|
+
background: 'white',
|
|
115
|
+
border: 'auto',
|
|
116
|
+
},
|
|
117
|
+
'& fieldset': { borderColor: 'auto' },
|
|
118
|
+
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
119
|
+
border: 'auto',
|
|
120
|
+
},
|
|
121
|
+
caretColor: 'white',
|
|
122
|
+
'& svg': {
|
|
123
|
+
display: readOnly ? 'none' : 'block',
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
: {}),
|
|
127
|
+
} })), size: fieldHeight ?? 'medium', readOnly: readOnly, error: error })));
|
|
128
|
+
};
|
|
129
|
+
export default UserProperty;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Obj, ObjectInstance, TableViewLayout } from '@evoke-platform/context';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BaseProps } from '../../types';
|
|
4
|
+
export type InstanceLookUpProps = BaseProps & {
|
|
5
|
+
object: Obj;
|
|
6
|
+
instanceId?: string;
|
|
7
|
+
setSelectedInstance: (selectedInstance: ObjectInstance) => void;
|
|
8
|
+
setRelationType: (relationType: 'new' | 'existing') => void;
|
|
9
|
+
mode: 'default' | 'existingOnly';
|
|
10
|
+
nestedFieldsView?: boolean;
|
|
11
|
+
filter?: Record<string, unknown>;
|
|
12
|
+
layout?: TableViewLayout;
|
|
13
|
+
};
|
|
14
|
+
declare const InstanceLookup: (props: InstanceLookUpProps) => React.JSX.Element;
|
|
15
|
+
export default InstanceLookup;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { useApiServices } from '@evoke-platform/context';
|
|
2
|
+
import { Clear, Search } from '@mui/icons-material';
|
|
3
|
+
import { debounce, get, startCase } from 'lodash';
|
|
4
|
+
import { DateTime } from 'luxon';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import { Button, IconButton, InputAdornment, TextField, Typography, } from '../../../../../core';
|
|
7
|
+
import { Box, Grid } from '../../../../../layout';
|
|
8
|
+
import BuilderGrid from '../../../../BuilderGrid';
|
|
9
|
+
import { getPrefixedUrl } from '../../utils';
|
|
10
|
+
const SearchField = (props) => {
|
|
11
|
+
const { searchableColumns, filter, setFilter, searchString, setSearchString } = props;
|
|
12
|
+
const clearSearch = () => {
|
|
13
|
+
setSearchString('');
|
|
14
|
+
setFilter(undefined);
|
|
15
|
+
};
|
|
16
|
+
const handleSearch = async (e) => {
|
|
17
|
+
const searchProperties = searchableColumns.map((column) => {
|
|
18
|
+
const columnId = column.id;
|
|
19
|
+
return {
|
|
20
|
+
[columnId]: {
|
|
21
|
+
like: e.target.value,
|
|
22
|
+
options: 'i',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
if (e.target.value.trim() === '' || !e.target.value) {
|
|
27
|
+
clearSearch();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setSearchString(e.target.value);
|
|
31
|
+
setFilter({
|
|
32
|
+
...filter,
|
|
33
|
+
where: {
|
|
34
|
+
or: searchProperties,
|
|
35
|
+
},
|
|
36
|
+
limit: 100,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (React.createElement(TextField, { autoFocus: true, placeholder: "Search", value: searchString, onChange: (e) => handleSearch(e), size: "medium", fullWidth: true, sx: { marginBottom: '15px', marginTop: '15px' }, InputProps: {
|
|
41
|
+
endAdornment: (React.createElement(InputAdornment, { position: "end" },
|
|
42
|
+
React.createElement(IconButton, { sx: {
|
|
43
|
+
visibility: searchString.length > 0 ? 'visible' : 'hidden',
|
|
44
|
+
}, onClick: () => clearSearch() },
|
|
45
|
+
React.createElement(Clear, { sx: {
|
|
46
|
+
fontSize: '22px',
|
|
47
|
+
} })))),
|
|
48
|
+
startAdornment: (React.createElement(InputAdornment, { position: "start" },
|
|
49
|
+
React.createElement(Search, { sx: { fontSize: '22px', color: '#637381' } }))),
|
|
50
|
+
} }));
|
|
51
|
+
};
|
|
52
|
+
const InstanceLookup = (props) => {
|
|
53
|
+
const { object, setSelectedInstance, setRelationType, filter: criteriaFilter, mode, nestedFieldsView, layout, } = props;
|
|
54
|
+
const [rows, setRows] = useState([]);
|
|
55
|
+
const [loading, setLoading] = useState(false);
|
|
56
|
+
const [filter, setFilter] = useState();
|
|
57
|
+
const [searchString, setSearchString] = useState('');
|
|
58
|
+
const [searchableColumns] = useState(object.properties?.filter((property) => property.searchable) ?? []);
|
|
59
|
+
const apiServices = useApiServices();
|
|
60
|
+
const retrieveColumns = (tableViewLayout) => {
|
|
61
|
+
let columns = [];
|
|
62
|
+
if (tableViewLayout?.properties) {
|
|
63
|
+
for (const prop of tableViewLayout.properties) {
|
|
64
|
+
const propertyId = prop.id.split('.')[0];
|
|
65
|
+
const property = object.properties?.find((p) => p.id === propertyId);
|
|
66
|
+
if (property) {
|
|
67
|
+
if (property.type === 'address') {
|
|
68
|
+
columns.push({
|
|
69
|
+
field: prop.id,
|
|
70
|
+
headerName: `${property.name} - ${startCase(prop.id.split('.')[1])}`,
|
|
71
|
+
type: 'string',
|
|
72
|
+
flex: 1,
|
|
73
|
+
valueGetter: (params) => {
|
|
74
|
+
return get(params.row, prop.id) ?? '';
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else if (property.type === 'object' || property.type === 'user') {
|
|
79
|
+
columns.push({
|
|
80
|
+
field: prop.id,
|
|
81
|
+
headerName: property.name,
|
|
82
|
+
type: 'string',
|
|
83
|
+
flex: 1,
|
|
84
|
+
valueGetter: (params) => {
|
|
85
|
+
return (get(params.row, !prop.id.includes('.') ? `${prop.id}.name` : prop.id) ?? '');
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else if (property.type === 'document') {
|
|
90
|
+
columns.push({
|
|
91
|
+
field: prop.id,
|
|
92
|
+
headerName: property.name,
|
|
93
|
+
type: 'string',
|
|
94
|
+
flex: 1,
|
|
95
|
+
valueGetter: (params) => {
|
|
96
|
+
const row = params.row;
|
|
97
|
+
return (row[prop.id]?.map((v) => v.name).join(', ') ??
|
|
98
|
+
'');
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (property.type === 'date') {
|
|
103
|
+
columns.push({
|
|
104
|
+
field: prop.id,
|
|
105
|
+
headerName: property.name,
|
|
106
|
+
type: 'string',
|
|
107
|
+
flex: 1,
|
|
108
|
+
valueFormatter: (params) => {
|
|
109
|
+
if (!params.value) {
|
|
110
|
+
return params.value;
|
|
111
|
+
}
|
|
112
|
+
// The value should really be typed as string | undefined so once asserted as defined
|
|
113
|
+
// the value must be a string.
|
|
114
|
+
return DateTime.fromISO(params.value).toLocaleString(DateTime.DATE_SHORT);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else if (property.type === 'date-time') {
|
|
119
|
+
columns.push({
|
|
120
|
+
field: prop.id,
|
|
121
|
+
headerName: property.name,
|
|
122
|
+
type: 'string',
|
|
123
|
+
flex: 1,
|
|
124
|
+
valueFormatter: (params) => {
|
|
125
|
+
if (!params.value) {
|
|
126
|
+
return params.value;
|
|
127
|
+
}
|
|
128
|
+
// The value should really be typed as string | undefined so once asserted as defined
|
|
129
|
+
// the value must be a string.
|
|
130
|
+
return DateTime.fromISO(params.value).toLocaleString(DateTime.DATETIME_SHORT);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else if (property.type === 'time') {
|
|
135
|
+
columns.push({
|
|
136
|
+
field: prop.id,
|
|
137
|
+
headerName: property.name,
|
|
138
|
+
type: 'string',
|
|
139
|
+
flex: 1,
|
|
140
|
+
valueFormatter: (params) => {
|
|
141
|
+
if (!params.value) {
|
|
142
|
+
return params.value;
|
|
143
|
+
}
|
|
144
|
+
// The value should really be typed as string | undefined so once asserted as defined
|
|
145
|
+
// the value must be a string.
|
|
146
|
+
return DateTime.fromISO(params.value).toLocaleString(DateTime.TIME_SIMPLE);
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
columns.push({
|
|
152
|
+
field: prop.id,
|
|
153
|
+
headerName: property.name,
|
|
154
|
+
type: 'string',
|
|
155
|
+
flex: 1,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const name = object.properties?.find((property) => property.id == 'name');
|
|
163
|
+
columns = [{ field: 'name', headerName: name?.name ?? 'Name', type: 'string', flex: 1 }];
|
|
164
|
+
}
|
|
165
|
+
return columns;
|
|
166
|
+
};
|
|
167
|
+
function fetchObjectInstance() {
|
|
168
|
+
setLoading(true);
|
|
169
|
+
const combinedFilter = {
|
|
170
|
+
...criteriaFilter,
|
|
171
|
+
...filter,
|
|
172
|
+
where: criteriaFilter?.where
|
|
173
|
+
? {
|
|
174
|
+
and: [criteriaFilter.where, filter?.where],
|
|
175
|
+
}
|
|
176
|
+
: filter?.where,
|
|
177
|
+
};
|
|
178
|
+
apiServices.get(getPrefixedUrl(`/objects/${object.id}/instances`), { params: { filter: JSON.stringify(combinedFilter) } }, (error, objectInstances) => {
|
|
179
|
+
if (error) {
|
|
180
|
+
console.error(error);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
!!objectInstances && setRows(objectInstances);
|
|
184
|
+
}
|
|
185
|
+
setLoading(false);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
if (filter || searchString.length) {
|
|
190
|
+
debounce(() => fetchObjectInstance(), 500)();
|
|
191
|
+
}
|
|
192
|
+
else if (searchString === '') {
|
|
193
|
+
setRows([]);
|
|
194
|
+
}
|
|
195
|
+
}, [filter, searchString.length]);
|
|
196
|
+
return (React.createElement(Grid, { container: true, sx: { paddingBottom: '30px' } },
|
|
197
|
+
React.createElement(Grid, { item: true, xs: 12 }, searchableColumns.length ? (React.createElement(SearchField, { searchString: searchString, setSearchString: setSearchString, filter: filter, setFilter: setFilter, searchableColumns: searchableColumns })) : (React.createElement(Typography, { sx: { fontSize: '16px', fontWeight: '700' } }, "There are no searchable properties configured for this object"))),
|
|
198
|
+
React.createElement(BuilderGrid, { item: 'instances', rows: rows, columns: retrieveColumns(layout), onRowClick: (params) => setSelectedInstance(params.row), initialSort: {
|
|
199
|
+
field: object.viewLayout?.table?.sort?.colId ?? 'name',
|
|
200
|
+
sort: object.viewLayout?.table?.sort?.sort ?? 'asc',
|
|
201
|
+
}, sx: {
|
|
202
|
+
height: '360px',
|
|
203
|
+
width: '100%',
|
|
204
|
+
}, hideToolbar: true, loading: loading, hideEmptyContent: true, localeText: {
|
|
205
|
+
noRowsLabel: searchString.length > 0
|
|
206
|
+
? `No Results Found. Refine your search ${mode !== 'existingOnly' ? 'or create a new record.' : '.'}`
|
|
207
|
+
: 'Search to view results',
|
|
208
|
+
}, noRowsOverlay: React.createElement(Box, { sx: { height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' } }, searchString.length > 0 ? (React.createElement(React.Fragment, null,
|
|
209
|
+
React.createElement(Box, null,
|
|
210
|
+
React.createElement(Typography, { sx: {
|
|
211
|
+
fontSize: '14px',
|
|
212
|
+
fontWeight: 700,
|
|
213
|
+
textAlign: 'center',
|
|
214
|
+
} }, "No Results Found"),
|
|
215
|
+
React.createElement(Typography, { sx: {
|
|
216
|
+
fontSize: '14px',
|
|
217
|
+
textAlign: 'center',
|
|
218
|
+
} },
|
|
219
|
+
"Refine your search",
|
|
220
|
+
!nestedFieldsView && mode !== 'existingOnly' && (React.createElement(React.Fragment, null,
|
|
221
|
+
' or ',
|
|
222
|
+
React.createElement(Button, { variant: "text", onClick: () => setRelationType('new'), sx: {
|
|
223
|
+
padding: '3px 5px',
|
|
224
|
+
} }, "enter a new record"))))))) : (React.createElement(Typography, { sx: { fontSize: '16px' } }, "Search to view results"))) })));
|
|
225
|
+
};
|
|
226
|
+
export default InstanceLookup;
|