drf-react-by-schema 0.17.7 → 0.17.9
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/api.d.ts +2 -33
- package/dist/components/DataGridBySchemaEditable.d.ts +2 -1
- package/dist/components/DataGridBySchemaEditable.js +13 -5
- package/dist/components/DataTotals.d.ts +1 -2
- package/dist/components/DataTotalsServer.d.ts +1 -1
- package/dist/components/DataTotalsServer.js +3 -5
- package/dist/components/GenericModelList.d.ts +3 -3
- package/dist/components/GenericModelList.js +2 -2
- package/dist/components/GenericRelatedModelList.d.ts +1 -2
- package/dist/components/GenericRelatedModelList.js +2 -2
- package/dist/context/APIWrapper.js +10 -0
- package/dist/context/APIWrapperContext.d.ts +4 -4
- package/dist/context/APIWrapperContext.js +1 -0
- package/dist/utils.d.ts +41 -2
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AxiosError } from 'axios';
|
|
2
2
|
import { serverEndPointType } from './context/DRFReactBySchemaContext';
|
|
3
|
-
import { Item, SchemaType,
|
|
4
|
-
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid';
|
|
5
|
-
import { AlertColor } from '@mui/material/Alert';
|
|
3
|
+
import { Item, SchemaType, DataSchemaColumnsType, ItemSchemaColumnsType, Id, TargetApiParams, TargetApiPostParams, GetGenericModelListProps } from './utils';
|
|
6
4
|
interface TargetApiParamsOptionalId {
|
|
7
5
|
path: string;
|
|
8
6
|
serverEndPoint: serverEndPointType | null;
|
|
@@ -20,7 +18,7 @@ export declare const getRawData: ({ path, serverEndPoint, }: {
|
|
|
20
18
|
*/
|
|
21
19
|
export declare const updateData: ({ path, serverEndPoint, data, id }: TargetApiParams) => Promise<Item>;
|
|
22
20
|
export declare const partialUpdateData: ({ path, serverEndPoint, data, id }: TargetApiParams) => Promise<Item>;
|
|
23
|
-
export declare const createData: ({ path, serverEndPoint, data }:
|
|
21
|
+
export declare const createData: ({ path, serverEndPoint, data }: TargetApiPostParams) => Promise<Item>;
|
|
24
22
|
export declare const deleteData: (path: string, serverEndPoint: serverEndPointType | null, id: Id) => Promise<true | AxiosError<unknown, any>>;
|
|
25
23
|
export declare const createOrUpdateData: ({ path, serverEndPoint, data, id, }: TargetApiParamsOptionalId) => Promise<Item>;
|
|
26
24
|
export declare const updateDataBySchema: ({ model, modelObjectId, serverEndPoint, data, schema, path, }: {
|
|
@@ -48,35 +46,6 @@ export declare const setAuthToken: (token: string | null) => void;
|
|
|
48
46
|
export declare const isLoggedIn: (serverEndPoint: serverEndPointType | null) => Promise<false | Item>;
|
|
49
47
|
export declare const getSignUpOptions: (serverEndPoint: serverEndPointType | null) => Promise<SchemaType | AxiosError<unknown, any>>;
|
|
50
48
|
export declare const signUp: (data: Item, serverEndPoint: serverEndPointType | null) => Promise<Item>;
|
|
51
|
-
export interface GetGenericModelListProps {
|
|
52
|
-
model: string;
|
|
53
|
-
serverEndPoint: serverEndPointType | null;
|
|
54
|
-
id?: Id;
|
|
55
|
-
relatedModel?: string;
|
|
56
|
-
relatedModelId?: Id;
|
|
57
|
-
columnFields: string[];
|
|
58
|
-
hiddenFields?: string[];
|
|
59
|
-
creatableFields?: string[];
|
|
60
|
-
disabledFields?: string[];
|
|
61
|
-
isInBatches?: boolean;
|
|
62
|
-
loadedSchema?: SchemaType | boolean;
|
|
63
|
-
loadedModelOptions?: modelOptionsType | boolean;
|
|
64
|
-
page?: number;
|
|
65
|
-
filter?: GridFilterModel;
|
|
66
|
-
queryParams?: string[];
|
|
67
|
-
sort?: GridSortModel;
|
|
68
|
-
sumRows?: SumRowsType;
|
|
69
|
-
}
|
|
70
|
-
export interface SumRowsType {
|
|
71
|
-
rows: SumRowsItem[];
|
|
72
|
-
severity?: AlertColor;
|
|
73
|
-
}
|
|
74
|
-
interface SumRowsItem {
|
|
75
|
-
field: string;
|
|
76
|
-
prefix?: string;
|
|
77
|
-
suffix?: string;
|
|
78
|
-
isCount?: boolean;
|
|
79
|
-
}
|
|
80
49
|
export declare const getGenericModelList: ({ model, serverEndPoint, id, relatedModel, relatedModelId, columnFields, hiddenFields, creatableFields, disabledFields, isInBatches, loadedSchema, loadedModelOptions, page, filter, queryParams, sort, sumRows, }: GetGenericModelListProps) => Promise<false | DataSchemaColumnsType>;
|
|
81
50
|
export declare const getGenericModel: ({ model, serverEndPoint, id, relatedModel, relatedModelId, }: {
|
|
82
51
|
model: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { GridRowId, GridRenderCellParams } from '@mui/x-data-grid';
|
|
3
3
|
import { SxProps } from '@mui/material';
|
|
4
|
-
import { Item, SchemaType, Id, GridEnrichedBySchemaColDef, PaginationModel, ActionType, OnSelectActions, OptionsAC, FormFieldLayout } from '../utils';
|
|
4
|
+
import { Item, SchemaType, Id, GridEnrichedBySchemaColDef, PaginationModel, ActionType, OnSelectActions, OptionsAC, FormFieldLayout, CustomAction } from '../utils';
|
|
5
5
|
import { OnEditModelType } from '../context/APIWrapperContext';
|
|
6
6
|
interface DataGridBySchemaEditableProps {
|
|
7
7
|
schema: SchemaType;
|
|
@@ -44,6 +44,7 @@ interface DataGridBySchemaEditableProps {
|
|
|
44
44
|
hideToolbarComponent?: boolean;
|
|
45
45
|
tableAutoHeight?: boolean;
|
|
46
46
|
actions?: Partial<ActionType>[];
|
|
47
|
+
customActions?: CustomAction[];
|
|
47
48
|
optionsAC?: OptionsAC;
|
|
48
49
|
}
|
|
49
50
|
declare const DataGridBySchemaEditable: React.ForwardRefExoticComponent<DataGridBySchemaEditableProps & React.RefAttributes<unknown>>;
|
|
@@ -63,7 +63,7 @@ const BooleanInputCell_1 = require("./DataGridBySchemaEditable/BooleanInputCell"
|
|
|
63
63
|
const FooterToolbar_1 = require("./DataGridBySchemaEditable/FooterToolbar");
|
|
64
64
|
const ConfirmDialog_1 = require("./DataGridBySchemaEditable/ConfirmDialog");
|
|
65
65
|
const APIWrapperContext_1 = require("../context/APIWrapperContext");
|
|
66
|
-
const DataGridBySchemaEditable = (0, react_1.forwardRef)(({ schema, data, rowCount = 0, columns, model, name = Math.floor(Math.random() * 1000000).toString(), indexField = 'nome', addExistingModel, indexFieldMinWidth = 350, indexFieldBasePath = '', indexFieldViewBasePath, stateToLink = {}, minWidth = 80, loading, modelParent, modelParentId, customColumnOperations, customFieldFormLayouts, customLinkDestination, LinkComponent, onProcessRow, onDataChange, onEditModel, isEditable = false, hasBulkSelect = false, onSelectActions, isAutoHeight = false, defaultValues = {}, hideFooterPagination = false, setVisibleRows, paginationModel = undefined, setPaginationModel = undefined, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions = ['editInline', 'remove'], optionsAC: optionsACExternal, }, ref) => {
|
|
66
|
+
const DataGridBySchemaEditable = (0, react_1.forwardRef)(({ schema, data, rowCount = 0, columns, model, name = Math.floor(Math.random() * 1000000).toString(), indexField = 'nome', addExistingModel, indexFieldMinWidth = 350, indexFieldBasePath = '', indexFieldViewBasePath, stateToLink = {}, minWidth = 80, loading, modelParent, modelParentId, customColumnOperations, customFieldFormLayouts, customLinkDestination, LinkComponent, onProcessRow, onDataChange, onEditModel, isEditable = false, hasBulkSelect = false, onSelectActions, isAutoHeight = false, defaultValues = {}, hideFooterPagination = false, setVisibleRows, paginationModel = undefined, setPaginationModel = undefined, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions = ['editInline', 'remove'], customActions, optionsAC: optionsACExternal, }, ref) => {
|
|
67
67
|
const { serverEndPoint } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
68
68
|
const apiContext = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
69
69
|
const initialSnackBar = {
|
|
@@ -205,6 +205,13 @@ const DataGridBySchemaEditable = (0, react_1.forwardRef)(({ schema, data, rowCou
|
|
|
205
205
|
break;
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
|
+
// React.ReactElement<any, string | React.JSXElementConstructor<any>>
|
|
209
|
+
// React.ReactElement<any, string | React.JSXElementConstructor<any>>
|
|
210
|
+
if (customActions) {
|
|
211
|
+
customActions.map((customAction) => {
|
|
212
|
+
actionItems.push(react_1.default.createElement(x_data_grid_1.GridActionsCellItem, { key: `${customAction.key}_${id}`, icon: customAction.icon, label: customAction.label, onClick: () => customAction.handleClick(dataGrid.data.find((row) => row.id === id)), onResize: () => null, onResizeCapture: () => null, showInMenu: false, placeholder: '' }));
|
|
213
|
+
});
|
|
214
|
+
}
|
|
208
215
|
return actionItems;
|
|
209
216
|
},
|
|
210
217
|
});
|
|
@@ -576,10 +583,11 @@ const DataGridBySchemaEditable = (0, react_1.forwardRef)(({ schema, data, rowCou
|
|
|
576
583
|
});
|
|
577
584
|
}, [data]);
|
|
578
585
|
(0, react_1.useEffect)(() => {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
586
|
+
// I don't undedrstand why I had this. I'm commenting out....
|
|
587
|
+
// if (optionsAC.current) {
|
|
588
|
+
// initColumns();
|
|
589
|
+
// return;
|
|
590
|
+
// }
|
|
583
591
|
updateOptionsAC().then(() => {
|
|
584
592
|
initColumns();
|
|
585
593
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { GridRowId } from '@mui/x-data-grid';
|
|
3
|
-
import { Item } from '../utils';
|
|
4
|
-
import { SumRowsType } from '../api';
|
|
3
|
+
import { Item, SumRowsType } from '../utils';
|
|
5
4
|
interface DataTotalsProps {
|
|
6
5
|
data?: Item[];
|
|
7
6
|
sumRows?: SumRowsType;
|
|
@@ -8,11 +8,9 @@ const Alert_1 = __importDefault(require("@mui/material/Alert"));
|
|
|
8
8
|
const List_1 = __importDefault(require("@mui/material/List"));
|
|
9
9
|
const ListItem_1 = __importDefault(require("@mui/material/ListItem"));
|
|
10
10
|
const react_number_format_1 = require("react-number-format");
|
|
11
|
-
;
|
|
12
11
|
const DataTotalsServer = ({ sumRows, totals }) => {
|
|
13
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, sumRows && sumRows.rows.length > 0 &&
|
|
14
|
-
react_1.default.createElement(
|
|
15
|
-
react_1.default.createElement(
|
|
16
|
-
react_1.default.createElement(react_number_format_1.NumericFormat, { value: totals ? totals[`${row.field}_total`] : 0, thousandSeparator: '.', decimalSeparator: ',', displayType: 'text', decimalScale: row.isCount ? 0 : 2, fixedDecimalScale: true, prefix: row.prefix, suffix: row.suffix }))))))));
|
|
12
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, sumRows && sumRows.rows.length > 0 && (react_1.default.createElement(Alert_1.default, { severity: sumRows.severity || 'info' },
|
|
13
|
+
react_1.default.createElement(List_1.default, { dense: true }, sumRows.rows.map((row) => (react_1.default.createElement(ListItem_1.default, { key: `sumRows_${row.field}` },
|
|
14
|
+
react_1.default.createElement(react_number_format_1.NumericFormat, { value: totals ? totals[`${row.field}_total`] : 0, thousandSeparator: ".", decimalSeparator: ",", displayType: 'text', decimalScale: row.isCount ? 0 : 2, fixedDecimalScale: true, prefix: row.prefix, suffix: row.suffix })))))))));
|
|
17
15
|
};
|
|
18
16
|
exports.default = DataTotalsServer;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { GridFilterModel, GridRenderCellParams } from '@mui/x-data-grid';
|
|
3
|
-
import { GridEnrichedBySchemaColDef, ActionType, Item, OnSelectActions, OptionsAC, FormFieldLayout } from '../utils';
|
|
4
|
-
import { SumRowsType } from '../api';
|
|
3
|
+
import { GridEnrichedBySchemaColDef, ActionType, Item, OnSelectActions, OptionsAC, FormFieldLayout, CustomAction, SumRowsType } from '../utils';
|
|
5
4
|
interface GenericModelListProps {
|
|
6
5
|
model: string;
|
|
7
6
|
columnFields: string[];
|
|
@@ -33,9 +32,10 @@ interface GenericModelListProps {
|
|
|
33
32
|
hideToolbarComponent?: boolean;
|
|
34
33
|
tableAutoHeight?: boolean;
|
|
35
34
|
actions?: Partial<ActionType>[];
|
|
35
|
+
customActions?: CustomAction[];
|
|
36
36
|
optionsAC?: OptionsAC;
|
|
37
37
|
defaultValues?: Item;
|
|
38
38
|
disableScreenLoading?: boolean;
|
|
39
39
|
}
|
|
40
|
-
declare const GenericModelList: ({ model, columnFields, hiddenFields, creatableFields, disabledFields, minWidthFields, indexField, indexFieldBasePath, indexFieldViewBasePath, addExistingModel, onProcessRow, reloadAfterRowUpdate, customColumnOperations, customFieldFormLayouts, customLinkDestination, isEditable, hasBulkSelect, onSelectActions, sumRows, isAutoHeight, forceReload, LinkComponent, hasHeader, paginationMode, defaultFilter, queryParams, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions, optionsAC, defaultValues, disableScreenLoading, }: GenericModelListProps) => React.JSX.Element;
|
|
40
|
+
declare const GenericModelList: ({ model, columnFields, hiddenFields, creatableFields, disabledFields, minWidthFields, indexField, indexFieldBasePath, indexFieldViewBasePath, addExistingModel, onProcessRow, reloadAfterRowUpdate, customColumnOperations, customFieldFormLayouts, customLinkDestination, isEditable, hasBulkSelect, onSelectActions, sumRows, isAutoHeight, forceReload, LinkComponent, hasHeader, paginationMode, defaultFilter, queryParams, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions, customActions, optionsAC, defaultValues, disableScreenLoading, }: GenericModelListProps) => React.JSX.Element;
|
|
41
41
|
export default GenericModelList;
|
|
@@ -50,7 +50,7 @@ const utils_1 = require("../utils");
|
|
|
50
50
|
const api_1 = require("../api");
|
|
51
51
|
const DRFReactBySchemaContext_1 = require("../context/DRFReactBySchemaContext");
|
|
52
52
|
const APIWrapperContext_1 = require("../context/APIWrapperContext");
|
|
53
|
-
const GenericModelList = ({ model, columnFields, hiddenFields = [], creatableFields, disabledFields, minWidthFields, indexField, indexFieldBasePath, indexFieldViewBasePath, addExistingModel, onProcessRow, reloadAfterRowUpdate, customColumnOperations, customFieldFormLayouts, customLinkDestination, isEditable, hasBulkSelect = false, onSelectActions, sumRows, isAutoHeight = true, forceReload = false, LinkComponent = null, hasHeader = false, paginationMode = 'client', defaultFilter, queryParams, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions, optionsAC, defaultValues, disableScreenLoading, }) => {
|
|
53
|
+
const GenericModelList = ({ model, columnFields, hiddenFields = [], creatableFields, disabledFields, minWidthFields, indexField, indexFieldBasePath, indexFieldViewBasePath, addExistingModel, onProcessRow, reloadAfterRowUpdate, customColumnOperations, customFieldFormLayouts, customLinkDestination, isEditable, hasBulkSelect = false, onSelectActions, sumRows, isAutoHeight = true, forceReload = false, LinkComponent = null, hasHeader = false, paginationMode = 'client', defaultFilter, queryParams, hideFooterComponent, hideToolbarComponent, tableAutoHeight, actions, customActions, optionsAC, defaultValues, disableScreenLoading, }) => {
|
|
54
54
|
const { serverEndPoint, isInBatches, firstBatchLength } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
55
55
|
const { onEditModel } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
56
56
|
const [data, setData] = (0, react_1.useState)(false);
|
|
@@ -151,7 +151,7 @@ const GenericModelList = ({ model, columnFields, hiddenFields = [], creatableFie
|
|
|
151
151
|
react_1.default.createElement(LinkComponent, { to: `novo` },
|
|
152
152
|
react_1.default.createElement(Button_1.default, { variant: "contained", size: "medium", sx: { alignSelf: 'stretch' }, startIcon: react_1.default.createElement(AddCircleOutline_1.default, null) }, "Adicionar")))))),
|
|
153
153
|
react_1.default.createElement(Box_1.default, { sx: tableAutoHeight ? {} : styles_1.Layout.dataGridWithTabs },
|
|
154
|
-
react_1.default.createElement(DataGridBySchemaEditable_1.default, { data: data.data, columns: data.columns, schema: data.schema || {}, model: model, loading: loading, indexField: indexField, indexFieldBasePath: indexFieldBasePath, indexFieldViewBasePath: indexFieldViewBasePath, addExistingModel: addExistingModel, isEditable: isEditable, hasBulkSelect: hasBulkSelect, onSelectActions: onSelectActions, onEditModel: onEditModel, isAutoHeight: isAutoHeight, tableAutoHeight: tableAutoHeight, customColumnOperations: finalCustomColumnOperations, customFieldFormLayouts: customFieldFormLayouts, setVisibleRows: setVisibleRows, hideFooterPagination: hideFooterPagination, hideFooterComponent: hideFooterComponent, hideToolbarComponent: hideToolbarComponent, customLinkDestination: customLinkDestination, actions: actions, optionsAC: optionsAC, defaultValues: defaultValues, onProcessRow: onProcessRow, onDataChange: (newData) => {
|
|
154
|
+
react_1.default.createElement(DataGridBySchemaEditable_1.default, { data: data.data, columns: data.columns, schema: data.schema || {}, model: model, loading: loading, indexField: indexField, indexFieldBasePath: indexFieldBasePath, indexFieldViewBasePath: indexFieldViewBasePath, addExistingModel: addExistingModel, isEditable: isEditable, hasBulkSelect: hasBulkSelect, onSelectActions: onSelectActions, onEditModel: onEditModel, isAutoHeight: isAutoHeight, tableAutoHeight: tableAutoHeight, customColumnOperations: finalCustomColumnOperations, customFieldFormLayouts: customFieldFormLayouts, setVisibleRows: setVisibleRows, hideFooterPagination: hideFooterPagination, hideFooterComponent: hideFooterComponent, hideToolbarComponent: hideToolbarComponent, customLinkDestination: customLinkDestination, actions: actions, customActions: customActions, optionsAC: optionsAC, defaultValues: defaultValues, onProcessRow: onProcessRow, onDataChange: (newData) => {
|
|
155
155
|
if (reloadAfterRowUpdate) {
|
|
156
156
|
loadObjectList();
|
|
157
157
|
return;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { GridFilterModel } from '@mui/x-data-grid';
|
|
3
|
-
import { ActionType, GridEnrichedBySchemaColDef, Id, Item, OnSelectActions, OptionsAC } from '../utils';
|
|
4
|
-
import { SumRowsType } from '../api';
|
|
3
|
+
import { ActionType, GridEnrichedBySchemaColDef, Id, Item, OnSelectActions, OptionsAC, SumRowsType } from '../utils';
|
|
5
4
|
interface GenericRelatedModelListProps {
|
|
6
5
|
model: string;
|
|
7
6
|
id: Id;
|
|
@@ -49,9 +49,9 @@ const APIWrapperContext_1 = require("../context/APIWrapperContext");
|
|
|
49
49
|
const utils_1 = require("../utils");
|
|
50
50
|
const api_1 = require("../api");
|
|
51
51
|
const styles_1 = require("../styles");
|
|
52
|
-
const ContentTable = ({ data, relatedModel, model, loading, id, indexField, indexFieldBasePath, indexFieldViewBasePath, addExistingModel, isEditable, onEditModel, finalCustomColumnOperations, setVisibleRows, isAutoHeight, hideFooterPagination, hideFooterComponent, hideToolbarComponent, onProcessRow, onDataChange, sumRows, visibleRows, paginationMode = 'client', paginationModel, setPaginationModel, hasBulkSelect, onSelectActions, tableAutoHeight, actions, optionsAC, defaultValues, LinkComponent, }) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
52
|
+
const ContentTable = ({ data, relatedModel, model, loading, id, indexField, indexFieldBasePath, indexFieldViewBasePath, addExistingModel, isEditable, onEditModel, finalCustomColumnOperations, setVisibleRows, isAutoHeight, hideFooterPagination, hideFooterComponent, hideToolbarComponent, onProcessRow, onDataChange, sumRows, visibleRows, paginationMode = 'client', paginationModel, setPaginationModel, hasBulkSelect, onSelectActions, tableAutoHeight, actions, customActions, optionsAC, defaultValues, LinkComponent, }) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
53
53
|
data.columns ? (react_1.default.createElement(Box_1.default, { sx: tableAutoHeight ? {} : styles_1.Layout.dataGridFixedHeight },
|
|
54
|
-
react_1.default.createElement(DataGridBySchemaEditable_1.default, { data: data.data, columns: data.columns, schema: data.schema, model: relatedModel, modelParent: model, modelParentId: id, loading: loading, indexField: indexField, indexFieldBasePath: indexFieldBasePath, indexFieldViewBasePath: indexFieldViewBasePath, addExistingModel: addExistingModel, isEditable: isEditable, hasBulkSelect: hasBulkSelect, onSelectActions: onSelectActions, onEditModel: onEditModel, isAutoHeight: isAutoHeight, tableAutoHeight: tableAutoHeight, customColumnOperations: finalCustomColumnOperations, setVisibleRows: setVisibleRows, hideFooterPagination: hideFooterPagination, hideFooterComponent: hideFooterComponent, hideToolbarComponent: hideToolbarComponent, actions: actions, optionsAC: optionsAC, defaultValues: defaultValues, onProcessRow: onProcessRow, onDataChange: onDataChange, paginationModel: paginationMode === 'server' ? paginationModel : undefined, setPaginationModel: paginationMode === 'server' ? setPaginationModel : undefined, rowCount: paginationMode === 'client'
|
|
54
|
+
react_1.default.createElement(DataGridBySchemaEditable_1.default, { data: data.data, columns: data.columns, schema: data.schema, model: relatedModel, modelParent: model, modelParentId: id, loading: loading, indexField: indexField, indexFieldBasePath: indexFieldBasePath, indexFieldViewBasePath: indexFieldViewBasePath, addExistingModel: addExistingModel, isEditable: isEditable, hasBulkSelect: hasBulkSelect, onSelectActions: onSelectActions, onEditModel: onEditModel, isAutoHeight: isAutoHeight, tableAutoHeight: tableAutoHeight, customColumnOperations: finalCustomColumnOperations, setVisibleRows: setVisibleRows, hideFooterPagination: hideFooterPagination, hideFooterComponent: hideFooterComponent, hideToolbarComponent: hideToolbarComponent, actions: actions, customActions: customActions, optionsAC: optionsAC, defaultValues: defaultValues, onProcessRow: onProcessRow, onDataChange: onDataChange, paginationModel: paginationMode === 'server' ? paginationModel : undefined, setPaginationModel: paginationMode === 'server' ? setPaginationModel : undefined, rowCount: paginationMode === 'client'
|
|
55
55
|
? undefined
|
|
56
56
|
: typeof data.rowCount !== undefined
|
|
57
57
|
? data.rowCount
|
|
@@ -459,6 +459,15 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
459
459
|
return response;
|
|
460
460
|
});
|
|
461
461
|
}
|
|
462
|
+
function postData(params) {
|
|
463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
464
|
+
const response = yield (0, api_1.createData)(Object.assign(Object.assign({}, params), { serverEndPoint }));
|
|
465
|
+
if ('isAxiosError' in response) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
return response;
|
|
469
|
+
});
|
|
470
|
+
}
|
|
462
471
|
return (react_1.default.createElement(APIWrapperContext_1.APIWrapperContext.Provider, { value: {
|
|
463
472
|
usuaria,
|
|
464
473
|
updateUsuaria,
|
|
@@ -483,6 +492,7 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
483
492
|
loginByPayload: localLoginByPayload,
|
|
484
493
|
getSignUpOptions: localGetSignupOptions,
|
|
485
494
|
signUp: localSignUp,
|
|
495
|
+
postData: postData,
|
|
486
496
|
// Remove after integrating new "onEditModel" to package:
|
|
487
497
|
serverEndPoint,
|
|
488
498
|
editModel,
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { FieldValues, SubmitHandler, UseFormGetValues, UseFormSetValue } from 'react-hook-form';
|
|
3
3
|
import { AlertColor, AlertPropsColorOverrides } from '@mui/material/Alert';
|
|
4
4
|
import { OverridableStringUnion } from '@mui/types';
|
|
5
|
-
import { ItemSchemaColumnsType, Id, Item, SchemaType, DataSchemaColumnsType, OnSuccessEvent, OptionsAC, GenericValue,
|
|
6
|
-
import { GetGenericModelListProps } from '../api';
|
|
5
|
+
import { ItemSchemaColumnsType, Id, Item, SchemaType, DataSchemaColumnsType, OnSuccessEvent, OptionsAC, GenericValue, FormFieldLayout, TargetApiParamsLocal, GetGenericModelListPropsLocal } from '../utils';
|
|
7
6
|
import { serverEndPointType } from './DRFReactBySchemaContext';
|
|
8
7
|
export interface LoadSinglePageDataProps {
|
|
9
8
|
model: string;
|
|
@@ -84,14 +83,15 @@ export interface APIWrapperContextType {
|
|
|
84
83
|
setDialog: (x: Partial<DialogType>) => void;
|
|
85
84
|
getRawData: (route: string) => Promise<GenericValue>;
|
|
86
85
|
getAutoComplete: (model: string) => Promise<false | Item[]>;
|
|
87
|
-
getGenericModelList: (x:
|
|
86
|
+
getGenericModelList: (x: GetGenericModelListPropsLocal) => Promise<false | DataSchemaColumnsType>;
|
|
88
87
|
getAllModels: () => Promise<Item[]>;
|
|
89
88
|
loginByPayload: (payload: Item) => Promise<boolean>;
|
|
90
89
|
getSignUpOptions: () => Promise<false | SchemaType>;
|
|
91
90
|
signUp: (data: Item) => Promise<false | Item>;
|
|
91
|
+
postData: (params: TargetApiParamsLocal) => Promise<false | Item>;
|
|
92
92
|
serverEndPoint: serverEndPointType;
|
|
93
93
|
editModel: React.MutableRefObject<Item>;
|
|
94
|
-
updateModel: (p:
|
|
94
|
+
updateModel: (p: TargetApiParamsLocal) => Promise<false | Item>;
|
|
95
95
|
populateOptionsAC: (optionsACModels: string[]) => void;
|
|
96
96
|
}
|
|
97
97
|
export declare const APIWrapperContext: React.Context<APIWrapperContextType>;
|
|
@@ -38,6 +38,7 @@ exports.APIWrapperContext = react_1.default.createContext({
|
|
|
38
38
|
loginByPayload: () => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
39
39
|
getSignUpOptions: () => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
40
40
|
signUp: () => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
41
|
+
postData: () => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
41
42
|
// Remove after integrating new "onEditModel" to package:
|
|
42
43
|
serverEndPoint: { url: '', apiTokenUrl: '' },
|
|
43
44
|
editModel: { current: {} },
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import * as Yup from 'yup';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
3
|
import { GridActionsColDef, GridColDef, GridFilterModel, GridSortModel } from '@mui/x-data-grid';
|
|
4
4
|
import { Control, FieldValues, UseFormGetValues, UseFormSetValue } from 'react-hook-form';
|
|
5
|
-
import { AutocompleteRenderOptionState, SxProps } from '@mui/material';
|
|
5
|
+
import { AlertColor, AutocompleteRenderOptionState, SxProps } from '@mui/material';
|
|
6
6
|
import { OnEditModelType } from './context/APIWrapperContext';
|
|
7
7
|
import { serverEndPointType } from './context/DRFReactBySchemaContext';
|
|
8
8
|
import { DateView } from '@mui/x-date-pickers';
|
|
@@ -183,6 +183,12 @@ export declare const slugToCamelCase: (str: string) => string;
|
|
|
183
183
|
export declare const slugify: (text: string | null) => string;
|
|
184
184
|
export declare function mergeFilterItems(defaultFilter: GridFilterModel | undefined, filter: GridFilterModel | undefined): GridFilterModel | undefined;
|
|
185
185
|
export type ActionType = 'editInline' | 'remove' | 'edit' | 'view';
|
|
186
|
+
export interface CustomAction {
|
|
187
|
+
key: string;
|
|
188
|
+
icon: ReactElement;
|
|
189
|
+
label: string;
|
|
190
|
+
handleClick: (item: Item | undefined) => undefined;
|
|
191
|
+
}
|
|
186
192
|
export type BulkUpdateData = (newData: Item[]) => Promise<{
|
|
187
193
|
id: Id;
|
|
188
194
|
success: boolean;
|
|
@@ -243,4 +249,37 @@ export interface TargetApiParams {
|
|
|
243
249
|
data: Item;
|
|
244
250
|
id: Id;
|
|
245
251
|
}
|
|
252
|
+
export type TargetApiParamsLocal = Omit<TargetApiParams, 'serverEndPoint'>;
|
|
253
|
+
export type TargetApiPostParams = Omit<TargetApiParams, 'id'>;
|
|
254
|
+
export type TargetApiPostParamsLocal = Omit<TargetApiPostParams, 'serverEndPoint'>;
|
|
255
|
+
export interface SumRowsType {
|
|
256
|
+
rows: SumRowsItem[];
|
|
257
|
+
severity?: AlertColor;
|
|
258
|
+
}
|
|
259
|
+
interface SumRowsItem {
|
|
260
|
+
field: string;
|
|
261
|
+
prefix?: string;
|
|
262
|
+
suffix?: string;
|
|
263
|
+
isCount?: boolean;
|
|
264
|
+
}
|
|
265
|
+
export interface GetGenericModelListProps {
|
|
266
|
+
model: string;
|
|
267
|
+
serverEndPoint: serverEndPointType | null;
|
|
268
|
+
id?: Id;
|
|
269
|
+
relatedModel?: string;
|
|
270
|
+
relatedModelId?: Id;
|
|
271
|
+
columnFields: string[];
|
|
272
|
+
hiddenFields?: string[];
|
|
273
|
+
creatableFields?: string[];
|
|
274
|
+
disabledFields?: string[];
|
|
275
|
+
isInBatches?: boolean;
|
|
276
|
+
loadedSchema?: SchemaType | boolean;
|
|
277
|
+
loadedModelOptions?: modelOptionsType | boolean;
|
|
278
|
+
page?: number;
|
|
279
|
+
filter?: GridFilterModel;
|
|
280
|
+
queryParams?: string[];
|
|
281
|
+
sort?: GridSortModel;
|
|
282
|
+
sumRows?: SumRowsType;
|
|
283
|
+
}
|
|
284
|
+
export type GetGenericModelListPropsLocal = Omit<GetGenericModelListProps, 'serverEndPoint'>;
|
|
246
285
|
export {};
|
package/package.json
CHANGED