@headless-adminapp/app 1.5.2 → 1.5.7
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/board/types.d.ts +1 -1
- package/builders/CommandBuilder/ViewCommandBuilder.d.ts +2 -1
- package/builders/utils.d.ts +3 -3
- package/builders/utils.js +0 -1
- package/dataform/utils/saveRecord.js +10 -9
- package/datagrid/DataGridProvider/DataResolver.d.ts +1 -2
- package/datagrid/DataGridProvider/DataResolver.js +9 -8
- package/datagrid/DataGridProvider/index.d.ts +2 -2
- package/datagrid/DataGridProvider/useGridCellRangeResolver.d.ts +1 -1
- package/datagrid/context.d.ts +5 -5
- package/datagrid/hooks/useGridSelection.d.ts +2 -1
- package/datagrid/hooks/useGridSorting.d.ts +1 -1
- package/datagrid/hooks/useGridSorting.js +0 -1
- package/datagrid/hooks/useMainGridCommands.d.ts +3 -2
- package/datagrid/hooks/useMainGridCommands.js +2 -1
- package/datagrid/hooks/useOpenRecord.js +3 -2
- package/package.json +2 -2
- package/quickcreate/hooks/useFormSave.js +3 -2
- package/recordset/hooks/useRecordSetResult.js +2 -1
- package/transport/InMemoryDataService/index.js +2 -1
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
package/board/types.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface BoardConfig<S extends SchemaAttributes = SchemaAttributes> {
|
|
|
38
38
|
title: string;
|
|
39
39
|
description: string;
|
|
40
40
|
schema: Schema<S>;
|
|
41
|
-
sorting: SortingState<S
|
|
41
|
+
sorting: SortingState<Extract<keyof S, string>>;
|
|
42
42
|
projection: {
|
|
43
43
|
columns: Array<keyof S>;
|
|
44
44
|
expand?: Partial<Record<keyof S, string[]>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EntityMainGridCommandContext, EntityMainGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import type { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
3
|
import type { Localized } from '@headless-adminapp/core/types';
|
|
3
4
|
import type { Icon } from '@headless-adminapp/icons';
|
|
4
5
|
export declare namespace EnabledRules {
|
|
@@ -79,7 +80,7 @@ export declare namespace ViewCommandBuilder {
|
|
|
79
80
|
};
|
|
80
81
|
}): EntityMainGridCommandItemExperience;
|
|
81
82
|
}
|
|
82
|
-
export declare function exportRecordsToExcel(context: EntityMainGridCommandContext): Promise<void>;
|
|
83
|
+
export declare function exportRecordsToExcel<S extends SchemaAttributes = SchemaAttributes>(context: EntityMainGridCommandContext<S>): Promise<void>;
|
|
83
84
|
export declare function exportRecordsToCSV(context: EntityMainGridCommandContext): Promise<void>;
|
|
84
85
|
export declare function processDeleteRecordRequest(context: EntityMainGridCommandContext, { stringSet, localizedStringSet, }: {
|
|
85
86
|
stringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
|
package/builders/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Locale } from '@headless-adminapp/core/experience/locale';
|
|
2
2
|
import type { ColumnCondition, SortingState, View } from '@headless-adminapp/core/experience/view';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
4
4
|
import type { ISchemaStore } from '@headless-adminapp/core/store';
|
|
5
5
|
import type { Filter, IDataService } from '@headless-adminapp/core/transport';
|
|
6
6
|
import type { TransformedViewColumn } from '../datagrid';
|
|
@@ -24,7 +24,7 @@ export declare function retriveRecords<S extends SchemaAttributes = SchemaAttrib
|
|
|
24
24
|
extraFilter?: Filter;
|
|
25
25
|
columnFilters?: Partial<Record<string, ColumnCondition>>;
|
|
26
26
|
schemaStore: ISchemaStore;
|
|
27
|
-
sorting: SortingState<S
|
|
27
|
+
sorting: SortingState<Extract<keyof S, string>>;
|
|
28
28
|
skip: number;
|
|
29
29
|
limit: number;
|
|
30
|
-
}): Promise<import("@headless-adminapp/core/transport").RetriveRecordsResult<
|
|
30
|
+
}): Promise<import("@headless-adminapp/core/transport").RetriveRecordsResult<S>>;
|
package/builders/utils.js
CHANGED
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getModifiedValues = getModifiedValues;
|
|
4
4
|
exports.saveRecord = saveRecord;
|
|
5
5
|
exports.saveEditableGridControl = saveEditableGridControl;
|
|
6
|
-
const utils_1 = require("
|
|
6
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
7
|
+
const utils_2 = require("../DataFormProvider/utils");
|
|
7
8
|
function getModifiedValues(
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
10
|
initialValues,
|
|
@@ -47,8 +48,8 @@ function generateSubgridUpdateOperation({ recordId, control, schemaStore, values
|
|
|
47
48
|
const newRows = gridRows.filter((x) => !x[gridSchema.idAttribute]);
|
|
48
49
|
const updatedRows = gridRows.filter((x) => x[gridSchema.idAttribute]);
|
|
49
50
|
const deletedIds = initialGridRows
|
|
50
|
-
?.map((x) =>
|
|
51
|
-
.filter((id) => !gridRows.find((x) =>
|
|
51
|
+
?.map((x) => (0, utils_1.getRecordId)(gridSchema, x))
|
|
52
|
+
.filter((id) => !gridRows.find((x) => (0, utils_1.getRecordId)(gridSchema, x) === id));
|
|
52
53
|
for (const row of newRows) {
|
|
53
54
|
operations.push({
|
|
54
55
|
type: 'create',
|
|
@@ -63,7 +64,7 @@ function generateSubgridUpdateOperation({ recordId, control, schemaStore, values
|
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
for (const row of updatedRows) {
|
|
66
|
-
const initialRow = initialGridRows.find((x) =>
|
|
67
|
+
const initialRow = initialGridRows.find((x) => (0, utils_1.getRecordId)(gridSchema, x) === (0, utils_1.getRecordId)(gridSchema, row));
|
|
67
68
|
if (!initialRow) {
|
|
68
69
|
throw new Error('Initial row not found');
|
|
69
70
|
}
|
|
@@ -75,7 +76,7 @@ function generateSubgridUpdateOperation({ recordId, control, schemaStore, values
|
|
|
75
76
|
type: 'update',
|
|
76
77
|
logicalName: control.logicalName,
|
|
77
78
|
data: modifiedRow,
|
|
78
|
-
id:
|
|
79
|
+
id: (0, utils_1.getRecordId)(gridSchema, row),
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
for (const id of deletedIds) {
|
|
@@ -88,7 +89,7 @@ function generateSubgridUpdateOperation({ recordId, control, schemaStore, values
|
|
|
88
89
|
return operations;
|
|
89
90
|
}
|
|
90
91
|
async function createRecord({ values, form, schema, dataService, }) {
|
|
91
|
-
const controls = (0,
|
|
92
|
+
const controls = (0, utils_2.getControls)(form);
|
|
92
93
|
const editableGridControls = controls.filter((control) => control.type === 'editablegrid' && control.alias);
|
|
93
94
|
const result = await dataService.createRecord(schema.logicalName, values);
|
|
94
95
|
const recordId = result.id;
|
|
@@ -107,7 +108,7 @@ async function createRecord({ values, form, schema, dataService, }) {
|
|
|
107
108
|
return recordId;
|
|
108
109
|
}
|
|
109
110
|
async function updateRecord({ recordId, values, form, schema, dataService, initialValues, schemaStore, }) {
|
|
110
|
-
const controls = (0,
|
|
111
|
+
const controls = (0, utils_2.getControls)(form);
|
|
111
112
|
const editableGridControls = controls.filter((control) => control.type === 'editablegrid' && control.alias);
|
|
112
113
|
const modifiedValues = getModifiedValues(initialValues, values, editableGridControls.map((x) => x.alias));
|
|
113
114
|
const operations = [];
|
|
@@ -148,9 +149,9 @@ async function updateRecord({ recordId, values, form, schema, dataService, initi
|
|
|
148
149
|
async function saveRecord({ values, form, schema, dataService, initialValues, record, schemaStore, }) {
|
|
149
150
|
let recordId;
|
|
150
151
|
if (record) {
|
|
151
|
-
recordId = record
|
|
152
|
+
const recordId = (0, utils_1.getRecordId)(schema, record);
|
|
152
153
|
const updateResult = await updateRecord({
|
|
153
|
-
recordId,
|
|
154
|
+
recordId: recordId,
|
|
154
155
|
values,
|
|
155
156
|
form,
|
|
156
157
|
schema,
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function DataResolver<S extends SchemaAttributes = SchemaAttributes>(): null;
|
|
1
|
+
export declare function DataResolver(): null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataResolver = DataResolver;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const auth_1 = require("../../auth");
|
|
6
7
|
const hooks_1 = require("../../hooks");
|
|
@@ -12,7 +13,7 @@ const context_2 = require("../context");
|
|
|
12
13
|
const hooks_2 = require("../hooks");
|
|
13
14
|
const useGridDisabled_1 = require("../hooks/useGridDisabled");
|
|
14
15
|
const useQuickFilter_1 = require("../hooks/useQuickFilter");
|
|
15
|
-
const
|
|
16
|
+
const utils_2 = require("./utils");
|
|
16
17
|
function DataResolver() {
|
|
17
18
|
const schema = (0, hooks_2.useDataGridSchema)();
|
|
18
19
|
const view = (0, hooks_2.useSelectedView)();
|
|
@@ -33,14 +34,14 @@ function DataResolver() {
|
|
|
33
34
|
const [search] = (0, useDebouncedValue_1.useDebouncedValue)(searchText, 500);
|
|
34
35
|
const isMobile = (0, hooks_1.useIsMobile)();
|
|
35
36
|
const columns = (0, react_1.useMemo)(() => isMobile
|
|
36
|
-
? (0,
|
|
37
|
-
: (0,
|
|
37
|
+
? (0, utils_2.collectCardColumns)({ cardView: view.experience.card, schema })
|
|
38
|
+
: (0, utils_2.collectGridColumns)({
|
|
38
39
|
gridColumns,
|
|
39
40
|
schema,
|
|
40
41
|
}), [isMobile, view.experience.card, schema, gridColumns]);
|
|
41
42
|
const expand = (0, react_1.useMemo)(() => isMobile
|
|
42
|
-
? (0,
|
|
43
|
-
: (0,
|
|
43
|
+
? (0, utils_2.collectCardExpandedKeys)({ cardView: view.experience.card })
|
|
44
|
+
: (0, utils_2.collectExpandedKeys)(gridColumns), [gridColumns, isMobile, view.experience.card]);
|
|
44
45
|
const quickFilterResults = (0, react_1.useMemo)(() => {
|
|
45
46
|
if (!quickFilter) {
|
|
46
47
|
return null;
|
|
@@ -51,7 +52,7 @@ function DataResolver() {
|
|
|
51
52
|
return quickFilter.resolver(quickFilterValues, authSession);
|
|
52
53
|
}, [authSession, quickFilter, quickFilterValues]);
|
|
53
54
|
const filter = (0, react_1.useMemo)(() => {
|
|
54
|
-
return (0,
|
|
55
|
+
return (0, utils_2.mergeConditions)(schema, view.experience.filter, extraFilter, quickFilterResults, columnFilters, schemaStore);
|
|
55
56
|
}, [
|
|
56
57
|
columnFilters,
|
|
57
58
|
extraFilter,
|
|
@@ -85,12 +86,12 @@ function DataResolver() {
|
|
|
85
86
|
});
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
|
-
const selectedIds = selectedIdsRef.current.filter((x) => data.records.some((y) =>
|
|
89
|
+
const selectedIds = selectedIdsRef.current.filter((x) => data.records.some((y) => (0, utils_1.getRecordId)(schema, y) === x));
|
|
89
90
|
setState({
|
|
90
91
|
data,
|
|
91
92
|
selectedIds,
|
|
92
93
|
});
|
|
93
|
-
}, [data, setState, schema
|
|
94
|
+
}, [data, setState, schema]);
|
|
94
95
|
(0, react_1.useEffect)(() => {
|
|
95
96
|
setState({
|
|
96
97
|
dataState: {
|
|
@@ -4,7 +4,7 @@ import type { EntityMainGridCommandContext, EntitySubGridCommandContext, View }
|
|
|
4
4
|
import type { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
5
5
|
import type { Filter } from '@headless-adminapp/core/transport';
|
|
6
6
|
import { type PropsWithChildren } from 'react';
|
|
7
|
-
export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext
|
|
7
|
+
export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>> {
|
|
8
8
|
schema: Schema<S>;
|
|
9
9
|
views: LocalizedDataLookup[];
|
|
10
10
|
view: View<S>;
|
|
@@ -21,4 +21,4 @@ export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttrib
|
|
|
21
21
|
maxRecords?: number;
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
}
|
|
24
|
-
export declare function DataGridProvider<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext
|
|
24
|
+
export declare function DataGridProvider<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>>(props: PropsWithChildren<DataGridProviderProps<S, CommandContext>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,4 +2,4 @@ import { type MutableValue } from '@headless-adminapp/app/mutable';
|
|
|
2
2
|
import type { EntityMainGridCommandContext, EntitySubGridCommandContext } from '@headless-adminapp/core/experience/view';
|
|
3
3
|
import type { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
4
4
|
import type { GridContextState } from '../context';
|
|
5
|
-
export declare function useGridCellRangeResolver<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext
|
|
5
|
+
export declare function useGridCellRangeResolver<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>>(context: MutableValue<GridContextState<S, CommandContext>>): void;
|
package/datagrid/context.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { LocalizedDataLookup } from '@headless-adminapp/core/attributes';
|
|
1
|
+
import type { Id, LocalizedDataLookup } from '@headless-adminapp/core/attributes';
|
|
2
2
|
import type { CommandItemExperience } from '@headless-adminapp/core/experience/command';
|
|
3
3
|
import type { ColumnCondition, EntityMainGridCommandContext, EntitySubGridCommandContext, SortingState, View } from '@headless-adminapp/core/experience/view';
|
|
4
4
|
import { type TransformedViewColumn } from '@headless-adminapp/core/experience/view/ViewColumn';
|
|
5
5
|
import type { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
6
6
|
import type { Filter, RetriveRecordsResult } from '@headless-adminapp/core/transport';
|
|
7
7
|
export { type TransformedViewColumn } from '@headless-adminapp/core/experience/view/ViewColumn';
|
|
8
|
-
export interface GridContextState<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext
|
|
8
|
+
export interface GridContextState<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext<S> | EntitySubGridCommandContext = EntityMainGridCommandContext<S>> {
|
|
9
9
|
schema: Schema<S>;
|
|
10
10
|
view: View<S>;
|
|
11
11
|
viewLookup: LocalizedDataLookup[];
|
|
@@ -22,9 +22,9 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
|
|
|
22
22
|
columns: TransformedViewColumn<S>[];
|
|
23
23
|
searchText: string;
|
|
24
24
|
columnFilters: Partial<Record<keyof S, ColumnCondition>>;
|
|
25
|
-
sorting: SortingState<S
|
|
25
|
+
sorting: SortingState<Extract<keyof S, string>>;
|
|
26
26
|
quickFilterValues: Record<string, unknown>;
|
|
27
|
-
selectedIds:
|
|
27
|
+
selectedIds: Id[];
|
|
28
28
|
cellSelectionRange?: CellSelectionRange | null;
|
|
29
29
|
data: RetriveRecordsResult<InferredSchemaType<S>> | null;
|
|
30
30
|
dataState: {
|
|
@@ -36,7 +36,7 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
|
|
|
36
36
|
isSubGrid: boolean;
|
|
37
37
|
allowViewSelection: boolean;
|
|
38
38
|
}
|
|
39
|
-
export declare const GridContext: import("react").Context<import("../mutable/context").ContextValue<GridContextState<SchemaAttributes, EntityMainGridCommandContext
|
|
39
|
+
export declare const GridContext: import("react").Context<import("../mutable/context").ContextValue<GridContextState<SchemaAttributes, EntityMainGridCommandContext<SchemaAttributes>>>>;
|
|
40
40
|
export interface CellSelectionRange {
|
|
41
41
|
start: {
|
|
42
42
|
row: number;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Id } from '@headless-adminapp/core';
|
|
2
|
+
export declare function useGridSelection(): readonly [Id[], (selectedIds: Id[] | ((previousIds: Id[]) => Id[])) => void];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SortingState } from '@headless-adminapp/core/experience/view';
|
|
2
2
|
import type { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
-
export declare function useGridSorting<S extends SchemaAttributes = SchemaAttributes>(): readonly [SortingState<
|
|
3
|
+
export declare function useGridSorting<S extends SchemaAttributes = SchemaAttributes>(): readonly [SortingState<Extract<keyof S, string>>, (value: SortingState<Extract<keyof S, string>>) => void];
|
|
@@ -8,7 +8,6 @@ function useGridSorting() {
|
|
|
8
8
|
const sorting = (0, context_1.useContextSelector)(context_2.GridContext, (state) => state.sorting);
|
|
9
9
|
const setValue = (0, context_1.useContextSetValue)(context_2.GridContext);
|
|
10
10
|
const setSorting = (0, react_1.useCallback)((value) => {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
11
|
setValue({ sorting: value });
|
|
13
12
|
}, [setValue]);
|
|
14
13
|
return [sorting, setSorting];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { EntityMainGridCommandContext } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import type { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
3
|
import type { CommandItemState, MenuItemCommandState, UtilityContextState } from '../../command/types';
|
|
3
4
|
export declare function useUtility(): UtilityContextState;
|
|
4
|
-
export declare function useGridControlContext(): EntityMainGridCommandContext['primaryControl'];
|
|
5
|
-
export declare function useMainGridCommandHandlerContext(): EntityMainGridCommandContext
|
|
5
|
+
export declare function useGridControlContext<S extends SchemaAttributes = SchemaAttributes>(): EntityMainGridCommandContext<S>['primaryControl'];
|
|
6
|
+
export declare function useMainGridCommandHandlerContext<S extends SchemaAttributes = SchemaAttributes>(): EntityMainGridCommandContext<S>;
|
|
6
7
|
export declare function useMainGridCommands(): CommandItemState[][];
|
|
7
8
|
export declare function useMainGridContextCommands(): MenuItemCommandState[][];
|
|
@@ -7,6 +7,7 @@ exports.useMainGridCommands = useMainGridCommands;
|
|
|
7
7
|
exports.useMainGridContextCommands = useMainGridContextCommands;
|
|
8
8
|
const app_1 = require("@headless-adminapp/app/app");
|
|
9
9
|
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
10
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
10
11
|
const react_1 = require("react");
|
|
11
12
|
const command_1 = require("../../command");
|
|
12
13
|
const hooks_1 = require("../../dialog/hooks");
|
|
@@ -63,7 +64,7 @@ function useGridControlContext() {
|
|
|
63
64
|
return obj;
|
|
64
65
|
}, [selectedIds]);
|
|
65
66
|
const selectedRecords = (0, react_1.useMemo)(() => {
|
|
66
|
-
return (data?.records ?? []).filter((record) => selectedIdsObj[record
|
|
67
|
+
return (data?.records ?? []).filter((record) => selectedIdsObj[(0, utils_1.getRecordId)(schema, record)]);
|
|
67
68
|
}, [data, schema, selectedIdsObj]);
|
|
68
69
|
return (0, react_1.useMemo)(() => ({
|
|
69
70
|
data,
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useOpenRecord = useOpenRecord;
|
|
4
4
|
const route_1 = require("@headless-adminapp/app/route");
|
|
5
5
|
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
6
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
6
7
|
const react_1 = require("react");
|
|
7
8
|
const useGridData_1 = require("./useGridData");
|
|
8
9
|
const useGridSchema_1 = require("./useGridSchema");
|
|
@@ -23,12 +24,12 @@ function useOpenRecord() {
|
|
|
23
24
|
state: {
|
|
24
25
|
navigator: logicalName === schema.logicalName
|
|
25
26
|
? {
|
|
26
|
-
ids: dataRef.current?.records.map((x) =>
|
|
27
|
+
ids: dataRef.current?.records.map((x) => (0, utils_1.getRecordId)(schema, x)) ?? [],
|
|
27
28
|
visible: false,
|
|
28
29
|
logicalName: schema.logicalName,
|
|
29
30
|
}
|
|
30
31
|
: null,
|
|
31
32
|
},
|
|
32
33
|
});
|
|
33
|
-
}, [routeResolver, router, schema
|
|
34
|
+
}, [routeResolver, router, schema]);
|
|
34
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"uuid": "11.0.3",
|
|
39
39
|
"yup": "^1.4.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "85010c33721181b76d6973993ce504e3c5d54aef"
|
|
42
42
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFormSave = useFormSave;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
4
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -48,8 +49,8 @@ function useFormSave() {
|
|
|
48
49
|
schema.avatarAttribute,
|
|
49
50
|
].filter(Boolean));
|
|
50
51
|
saveResult = {
|
|
51
|
-
id:
|
|
52
|
-
name:
|
|
52
|
+
id: (0, utils_1.getRecordId)(schema, record),
|
|
53
|
+
name: (0, utils_1.getRecordPrimaryName)(schema, record),
|
|
53
54
|
avatar: schema.avatarAttribute
|
|
54
55
|
? record[schema.avatarAttribute]
|
|
55
56
|
: undefined,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRecordSetResult = useRecordSetResult;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
4
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
6
|
const lodash_1 = require("lodash");
|
|
6
7
|
const react_1 = require("react");
|
|
@@ -55,7 +56,7 @@ function useRecordSetResult() {
|
|
|
55
56
|
sort: [],
|
|
56
57
|
limit: context.ids.length,
|
|
57
58
|
});
|
|
58
|
-
const sortedData = (0, lodash_1.sortBy)(result.records, (x) => context.ids.indexOf(
|
|
59
|
+
const sortedData = (0, lodash_1.sortBy)(result.records, (x) => context.ids.indexOf((0, utils_1.getRecordId)(schema, x)));
|
|
59
60
|
return sortedData;
|
|
60
61
|
},
|
|
61
62
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InMemoryDataService = void 0;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/transport/utils");
|
|
4
5
|
class InMemoryDataService {
|
|
5
6
|
options;
|
|
6
7
|
// , IActionService, IReportService
|
|
@@ -24,7 +25,7 @@ class InMemoryDataService {
|
|
|
24
25
|
const schema = this.getSchema(logicalName);
|
|
25
26
|
const records = this.getCollection(logicalName);
|
|
26
27
|
const record = records.find((record) => {
|
|
27
|
-
return
|
|
28
|
+
return (0, utils_1.getRecordId)(schema, record) === id;
|
|
28
29
|
});
|
|
29
30
|
if (!record) {
|
|
30
31
|
throw new Error(`Record with id ${id} not found`);
|
|
@@ -6,7 +6,7 @@ interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
|
6
6
|
schema: Schema<S>;
|
|
7
7
|
search?: string;
|
|
8
8
|
filter?: Filter | null;
|
|
9
|
-
sorting?: SortingState<S
|
|
9
|
+
sorting?: SortingState<Extract<keyof S, string>>;
|
|
10
10
|
columns: (keyof S)[];
|
|
11
11
|
expand?: Partial<Record<string, string[]>>;
|
|
12
12
|
maxRecords?: number;
|