@fctc/widget-logic 2.4.9 → 2.5.0
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/hooks.d.mts +3 -220
- package/dist/hooks.d.ts +3 -220
- package/dist/hooks.js +5 -1
- package/dist/hooks.mjs +5 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +43 -69
- package/dist/index.mjs +54 -84
- package/dist/use-view-v2-BWHqxo3S.d.mts +222 -0
- package/dist/use-view-v2-BWHqxo3S.d.ts +222 -0
- package/dist/widget.d.mts +3 -1
- package/dist/widget.d.ts +3 -1
- package/dist/widget.js +190 -68
- package/dist/widget.mjs +201 -83
- package/package.json +96 -96
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
2
|
+
|
|
3
|
+
declare const useCallAction: () => readonly [ActionResult | undefined, ({ aid, }: {
|
|
4
|
+
aid: number;
|
|
5
|
+
actionType?: string;
|
|
6
|
+
}) => Promise<ActionResult | undefined>];
|
|
7
|
+
type useCallActionType = ReturnType<typeof useCallAction>;
|
|
8
|
+
type ActionResultType = useCallActionType[0];
|
|
9
|
+
interface ActionResult {
|
|
10
|
+
id?: number;
|
|
11
|
+
name?: string;
|
|
12
|
+
type?: 'ir.actions.act_window' | string;
|
|
13
|
+
xml_id?: string;
|
|
14
|
+
path?: false | string;
|
|
15
|
+
help?: string;
|
|
16
|
+
binding_model_id?: false | number;
|
|
17
|
+
binding_type?: 'action' | string;
|
|
18
|
+
binding_view_types?: string;
|
|
19
|
+
display_name?: string;
|
|
20
|
+
view_id?: false | number;
|
|
21
|
+
domain?: false | any[];
|
|
22
|
+
context?: string;
|
|
23
|
+
res_id?: number;
|
|
24
|
+
res_model?: string;
|
|
25
|
+
target?: 'current' | 'new' | string;
|
|
26
|
+
view_mode?: string;
|
|
27
|
+
mobile_view_mode?: string;
|
|
28
|
+
views?: [number, string][];
|
|
29
|
+
limit?: number;
|
|
30
|
+
groups_id?: number[];
|
|
31
|
+
search_view_id?: [number, string];
|
|
32
|
+
embedded_action_ids?: number[];
|
|
33
|
+
filter?: false | any;
|
|
34
|
+
url?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare const useViewV2: ({ action, context, aid, views, model, }: {
|
|
38
|
+
action?: ActionResultType;
|
|
39
|
+
context: any;
|
|
40
|
+
aid?: any;
|
|
41
|
+
views?: any;
|
|
42
|
+
model?: string;
|
|
43
|
+
}) => {
|
|
44
|
+
context: any;
|
|
45
|
+
data: ViewResponse;
|
|
46
|
+
error: Error;
|
|
47
|
+
isError: true;
|
|
48
|
+
isPending: false;
|
|
49
|
+
isLoading: false;
|
|
50
|
+
isLoadingError: false;
|
|
51
|
+
isRefetchError: true;
|
|
52
|
+
isSuccess: false;
|
|
53
|
+
isPlaceholderData: false;
|
|
54
|
+
status: "error";
|
|
55
|
+
dataUpdatedAt: number;
|
|
56
|
+
errorUpdatedAt: number;
|
|
57
|
+
failureCount: number;
|
|
58
|
+
failureReason: Error | null;
|
|
59
|
+
errorUpdateCount: number;
|
|
60
|
+
isFetched: boolean;
|
|
61
|
+
isFetchedAfterMount: boolean;
|
|
62
|
+
isFetching: boolean;
|
|
63
|
+
isInitialLoading: boolean;
|
|
64
|
+
isPaused: boolean;
|
|
65
|
+
isRefetching: boolean;
|
|
66
|
+
isStale: boolean;
|
|
67
|
+
isEnabled: boolean;
|
|
68
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ViewResponse, Error>>;
|
|
69
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
70
|
+
promise: Promise<ViewResponse>;
|
|
71
|
+
} | {
|
|
72
|
+
context: any;
|
|
73
|
+
data: ViewResponse;
|
|
74
|
+
error: null;
|
|
75
|
+
isError: false;
|
|
76
|
+
isPending: false;
|
|
77
|
+
isLoading: false;
|
|
78
|
+
isLoadingError: false;
|
|
79
|
+
isRefetchError: false;
|
|
80
|
+
isSuccess: true;
|
|
81
|
+
isPlaceholderData: false;
|
|
82
|
+
status: "success";
|
|
83
|
+
dataUpdatedAt: number;
|
|
84
|
+
errorUpdatedAt: number;
|
|
85
|
+
failureCount: number;
|
|
86
|
+
failureReason: Error | null;
|
|
87
|
+
errorUpdateCount: number;
|
|
88
|
+
isFetched: boolean;
|
|
89
|
+
isFetchedAfterMount: boolean;
|
|
90
|
+
isFetching: boolean;
|
|
91
|
+
isInitialLoading: boolean;
|
|
92
|
+
isPaused: boolean;
|
|
93
|
+
isRefetching: boolean;
|
|
94
|
+
isStale: boolean;
|
|
95
|
+
isEnabled: boolean;
|
|
96
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ViewResponse, Error>>;
|
|
97
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
98
|
+
promise: Promise<ViewResponse>;
|
|
99
|
+
} | {
|
|
100
|
+
context: any;
|
|
101
|
+
data: undefined;
|
|
102
|
+
error: Error;
|
|
103
|
+
isError: true;
|
|
104
|
+
isPending: false;
|
|
105
|
+
isLoading: false;
|
|
106
|
+
isLoadingError: true;
|
|
107
|
+
isRefetchError: false;
|
|
108
|
+
isSuccess: false;
|
|
109
|
+
isPlaceholderData: false;
|
|
110
|
+
status: "error";
|
|
111
|
+
dataUpdatedAt: number;
|
|
112
|
+
errorUpdatedAt: number;
|
|
113
|
+
failureCount: number;
|
|
114
|
+
failureReason: Error | null;
|
|
115
|
+
errorUpdateCount: number;
|
|
116
|
+
isFetched: boolean;
|
|
117
|
+
isFetchedAfterMount: boolean;
|
|
118
|
+
isFetching: boolean;
|
|
119
|
+
isInitialLoading: boolean;
|
|
120
|
+
isPaused: boolean;
|
|
121
|
+
isRefetching: boolean;
|
|
122
|
+
isStale: boolean;
|
|
123
|
+
isEnabled: boolean;
|
|
124
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ViewResponse, Error>>;
|
|
125
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
126
|
+
promise: Promise<ViewResponse>;
|
|
127
|
+
} | {
|
|
128
|
+
context: any;
|
|
129
|
+
data: undefined;
|
|
130
|
+
error: null;
|
|
131
|
+
isError: false;
|
|
132
|
+
isPending: true;
|
|
133
|
+
isLoading: true;
|
|
134
|
+
isLoadingError: false;
|
|
135
|
+
isRefetchError: false;
|
|
136
|
+
isSuccess: false;
|
|
137
|
+
isPlaceholderData: false;
|
|
138
|
+
status: "pending";
|
|
139
|
+
dataUpdatedAt: number;
|
|
140
|
+
errorUpdatedAt: number;
|
|
141
|
+
failureCount: number;
|
|
142
|
+
failureReason: Error | null;
|
|
143
|
+
errorUpdateCount: number;
|
|
144
|
+
isFetched: boolean;
|
|
145
|
+
isFetchedAfterMount: boolean;
|
|
146
|
+
isFetching: boolean;
|
|
147
|
+
isInitialLoading: boolean;
|
|
148
|
+
isPaused: boolean;
|
|
149
|
+
isRefetching: boolean;
|
|
150
|
+
isStale: boolean;
|
|
151
|
+
isEnabled: boolean;
|
|
152
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ViewResponse, Error>>;
|
|
153
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
154
|
+
promise: Promise<ViewResponse>;
|
|
155
|
+
} | {
|
|
156
|
+
context: any;
|
|
157
|
+
data: undefined;
|
|
158
|
+
error: null;
|
|
159
|
+
isError: false;
|
|
160
|
+
isPending: true;
|
|
161
|
+
isLoadingError: false;
|
|
162
|
+
isRefetchError: false;
|
|
163
|
+
isSuccess: false;
|
|
164
|
+
isPlaceholderData: false;
|
|
165
|
+
status: "pending";
|
|
166
|
+
dataUpdatedAt: number;
|
|
167
|
+
errorUpdatedAt: number;
|
|
168
|
+
failureCount: number;
|
|
169
|
+
failureReason: Error | null;
|
|
170
|
+
errorUpdateCount: number;
|
|
171
|
+
isFetched: boolean;
|
|
172
|
+
isFetchedAfterMount: boolean;
|
|
173
|
+
isFetching: boolean;
|
|
174
|
+
isLoading: boolean;
|
|
175
|
+
isInitialLoading: boolean;
|
|
176
|
+
isPaused: boolean;
|
|
177
|
+
isRefetching: boolean;
|
|
178
|
+
isStale: boolean;
|
|
179
|
+
isEnabled: boolean;
|
|
180
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ViewResponse, Error>>;
|
|
181
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
182
|
+
promise: Promise<ViewResponse>;
|
|
183
|
+
} | {
|
|
184
|
+
context: any;
|
|
185
|
+
data: ViewResponse;
|
|
186
|
+
isError: false;
|
|
187
|
+
error: null;
|
|
188
|
+
isPending: false;
|
|
189
|
+
isLoading: false;
|
|
190
|
+
isLoadingError: false;
|
|
191
|
+
isRefetchError: false;
|
|
192
|
+
isSuccess: true;
|
|
193
|
+
isPlaceholderData: true;
|
|
194
|
+
status: "success";
|
|
195
|
+
dataUpdatedAt: number;
|
|
196
|
+
errorUpdatedAt: number;
|
|
197
|
+
failureCount: number;
|
|
198
|
+
failureReason: Error | null;
|
|
199
|
+
errorUpdateCount: number;
|
|
200
|
+
isFetched: boolean;
|
|
201
|
+
isFetchedAfterMount: boolean;
|
|
202
|
+
isFetching: boolean;
|
|
203
|
+
isInitialLoading: boolean;
|
|
204
|
+
isPaused: boolean;
|
|
205
|
+
isRefetching: boolean;
|
|
206
|
+
isStale: boolean;
|
|
207
|
+
isEnabled: boolean;
|
|
208
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ViewResponse, Error>>;
|
|
209
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
210
|
+
promise: Promise<ViewResponse>;
|
|
211
|
+
};
|
|
212
|
+
type useViewV2Type = ReturnType<typeof useViewV2>;
|
|
213
|
+
type ViewResponse = {
|
|
214
|
+
models: {
|
|
215
|
+
[key: string]: any;
|
|
216
|
+
};
|
|
217
|
+
views: {
|
|
218
|
+
[key: string]: any;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export { type ActionResultType as A, type ViewResponse as V, type useCallActionType as a, useViewV2 as b, type useViewV2Type as c, useCallAction as u };
|
package/dist/widget.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ChangeEvent } from 'react';
|
|
3
3
|
import { IInputFieldProps } from './types.mjs';
|
|
4
|
+
import { V as ViewResponse } from './use-view-v2-BWHqxo3S.mjs';
|
|
4
5
|
import moment from 'moment';
|
|
5
6
|
import '@fctc/interface-logic/types';
|
|
7
|
+
import '@tanstack/query-core';
|
|
6
8
|
|
|
7
9
|
type TStatus = 'normal' | 'done' | 'blocked';
|
|
8
10
|
interface TStatusDropdownFieldProps extends IInputFieldProps {
|
|
@@ -83,7 +85,7 @@ declare const many2manyFieldController: (props: IMany2ManyControllerProps) => {
|
|
|
83
85
|
isPlaceholderData: boolean;
|
|
84
86
|
setPage: react.Dispatch<react.SetStateAction<number>>;
|
|
85
87
|
page: number;
|
|
86
|
-
viewData:
|
|
88
|
+
viewData: ViewResponse | undefined;
|
|
87
89
|
domain: any;
|
|
88
90
|
setDomain: react.Dispatch<any>;
|
|
89
91
|
searchController: {
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ChangeEvent } from 'react';
|
|
3
3
|
import { IInputFieldProps } from './types.js';
|
|
4
|
+
import { V as ViewResponse } from './use-view-v2-BWHqxo3S.js';
|
|
4
5
|
import moment from 'moment';
|
|
5
6
|
import '@fctc/interface-logic/types';
|
|
7
|
+
import '@tanstack/query-core';
|
|
6
8
|
|
|
7
9
|
type TStatus = 'normal' | 'done' | 'blocked';
|
|
8
10
|
interface TStatusDropdownFieldProps extends IInputFieldProps {
|
|
@@ -83,7 +85,7 @@ declare const many2manyFieldController: (props: IMany2ManyControllerProps) => {
|
|
|
83
85
|
isPlaceholderData: boolean;
|
|
84
86
|
setPage: react.Dispatch<react.SetStateAction<number>>;
|
|
85
87
|
page: number;
|
|
86
|
-
viewData:
|
|
88
|
+
viewData: ViewResponse | undefined;
|
|
87
89
|
domain: any;
|
|
88
90
|
setDomain: react.Dispatch<any>;
|
|
89
91
|
searchController: {
|
package/dist/widget.js
CHANGED
|
@@ -4320,6 +4320,34 @@ __reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
|
4320
4320
|
|
|
4321
4321
|
// src/hooks/core/use-view-v2.ts
|
|
4322
4322
|
var import_react7 = require("react");
|
|
4323
|
+
var useViewV2 = ({
|
|
4324
|
+
action,
|
|
4325
|
+
context,
|
|
4326
|
+
aid,
|
|
4327
|
+
views,
|
|
4328
|
+
model
|
|
4329
|
+
}) => {
|
|
4330
|
+
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
4331
|
+
const viewParams = (0, import_react7.useMemo)(() => {
|
|
4332
|
+
if (!action) {
|
|
4333
|
+
return void 0;
|
|
4334
|
+
}
|
|
4335
|
+
return {
|
|
4336
|
+
model,
|
|
4337
|
+
views,
|
|
4338
|
+
context,
|
|
4339
|
+
id: isNaN(Number(aid)) ? action?.id : aid
|
|
4340
|
+
};
|
|
4341
|
+
}, [action, context, aid]);
|
|
4342
|
+
const view = useGetView2(
|
|
4343
|
+
viewParams || {},
|
|
4344
|
+
!!viewParams
|
|
4345
|
+
);
|
|
4346
|
+
return {
|
|
4347
|
+
...view,
|
|
4348
|
+
context
|
|
4349
|
+
};
|
|
4350
|
+
};
|
|
4323
4351
|
|
|
4324
4352
|
// src/hooks/core/use-company.ts
|
|
4325
4353
|
var import_react_query3 = require("@tanstack/react-query");
|
|
@@ -4335,12 +4363,47 @@ var AppProviderInitialValue = {
|
|
|
4335
4363
|
view: {}
|
|
4336
4364
|
};
|
|
4337
4365
|
var ReactContext = (0, import_react9.createContext)(AppProviderInitialValue);
|
|
4366
|
+
var useAppProvider = () => {
|
|
4367
|
+
const context = (0, import_react9.useContext)(ReactContext);
|
|
4368
|
+
if (!context) {
|
|
4369
|
+
return AppProviderInitialValue;
|
|
4370
|
+
}
|
|
4371
|
+
return context;
|
|
4372
|
+
};
|
|
4338
4373
|
|
|
4339
4374
|
// src/hooks/core/use-config.ts
|
|
4340
4375
|
var import_react10 = require("react");
|
|
4341
4376
|
|
|
4342
4377
|
// src/hooks/core/use-get-specification.ts
|
|
4343
4378
|
var import_react11 = require("react");
|
|
4379
|
+
var useGetSpecification = ({
|
|
4380
|
+
model,
|
|
4381
|
+
viewData,
|
|
4382
|
+
fields
|
|
4383
|
+
}) => {
|
|
4384
|
+
const baseModel = (0, import_react11.useMemo)(
|
|
4385
|
+
() => ({
|
|
4386
|
+
name: String(model),
|
|
4387
|
+
view: viewData || {},
|
|
4388
|
+
fields
|
|
4389
|
+
}),
|
|
4390
|
+
[model, viewData]
|
|
4391
|
+
);
|
|
4392
|
+
const initModel = (0, import_hooks3.useModel)();
|
|
4393
|
+
const modelInstance = (0, import_react11.useMemo)(() => {
|
|
4394
|
+
if (viewData) {
|
|
4395
|
+
return initModel.initModel(baseModel);
|
|
4396
|
+
}
|
|
4397
|
+
return null;
|
|
4398
|
+
}, [baseModel, viewData]);
|
|
4399
|
+
const specification = (0, import_react11.useMemo)(() => {
|
|
4400
|
+
if (modelInstance) {
|
|
4401
|
+
return modelInstance.getSpecification();
|
|
4402
|
+
}
|
|
4403
|
+
return null;
|
|
4404
|
+
}, [modelInstance]);
|
|
4405
|
+
return { specification };
|
|
4406
|
+
};
|
|
4344
4407
|
|
|
4345
4408
|
// src/hooks/core/use-list-data.ts
|
|
4346
4409
|
var import_react15 = require("react");
|
|
@@ -4430,6 +4493,95 @@ var useGetRowIds = (tableRef) => {
|
|
|
4430
4493
|
return { rowIds, refresh: updateVisibleRowIds };
|
|
4431
4494
|
};
|
|
4432
4495
|
|
|
4496
|
+
// src/hooks/core/use-list-data.ts
|
|
4497
|
+
var useListData = ({
|
|
4498
|
+
action,
|
|
4499
|
+
context,
|
|
4500
|
+
viewData,
|
|
4501
|
+
model
|
|
4502
|
+
}) => {
|
|
4503
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
4504
|
+
const [page, setPage] = (0, import_react15.useState)(0);
|
|
4505
|
+
const [pageLimit, setPageLimit] = (0, import_react15.useState)(10);
|
|
4506
|
+
const [groupByList, setGroupByList] = (0, import_react15.useState)(null);
|
|
4507
|
+
const [domain, setDomain] = (0, import_react15.useState)(null);
|
|
4508
|
+
const [order, setOrder] = (0, import_react15.useState)("");
|
|
4509
|
+
const [mode, setMode] = (0, import_react15.useState)("month");
|
|
4510
|
+
const [type, setType] = (0, import_react15.useState)("list");
|
|
4511
|
+
const [currentDate, setCurrentDate] = (0, import_react15.useState)(/* @__PURE__ */ new Date());
|
|
4512
|
+
const [selectedRowKeys, setSelectedRowKeys2] = (0, import_react15.useState)([]);
|
|
4513
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
4514
|
+
const [debouncedDomain] = useDebounce(domain, 500);
|
|
4515
|
+
const { specification } = useGetSpecification({
|
|
4516
|
+
model,
|
|
4517
|
+
viewData,
|
|
4518
|
+
fields: viewData?.views?.list?.fields
|
|
4519
|
+
});
|
|
4520
|
+
const listDataProps = (0, import_react15.useMemo)(() => {
|
|
4521
|
+
if (!viewData || !action || !context) {
|
|
4522
|
+
return null;
|
|
4523
|
+
}
|
|
4524
|
+
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils4.evalJSONDomain)(action?.domain, context) : [];
|
|
4525
|
+
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
4526
|
+
const offset = debouncedPage * pageLimit;
|
|
4527
|
+
const fields = type === "calendar" ? convertFieldsToArray(viewData?.views?.calendar?.fields) || [] : typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
4528
|
+
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
4529
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils4.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
4530
|
+
return {
|
|
4531
|
+
model: action.res_model,
|
|
4532
|
+
specification,
|
|
4533
|
+
domain: domainParse,
|
|
4534
|
+
limit,
|
|
4535
|
+
offset,
|
|
4536
|
+
fields,
|
|
4537
|
+
groupby,
|
|
4538
|
+
context,
|
|
4539
|
+
sort,
|
|
4540
|
+
type
|
|
4541
|
+
};
|
|
4542
|
+
}, [
|
|
4543
|
+
action,
|
|
4544
|
+
context,
|
|
4545
|
+
currentDate,
|
|
4546
|
+
groupByList,
|
|
4547
|
+
mode,
|
|
4548
|
+
order,
|
|
4549
|
+
debouncedPage,
|
|
4550
|
+
pageLimit,
|
|
4551
|
+
type,
|
|
4552
|
+
debouncedDomain
|
|
4553
|
+
]);
|
|
4554
|
+
const list = useGetListData2(
|
|
4555
|
+
listDataProps,
|
|
4556
|
+
[listDataProps],
|
|
4557
|
+
!!listDataProps && !!specification && !(0, import_utils4.isObjectEmpty)(specification)
|
|
4558
|
+
);
|
|
4559
|
+
return {
|
|
4560
|
+
...list,
|
|
4561
|
+
state: {
|
|
4562
|
+
specification,
|
|
4563
|
+
type,
|
|
4564
|
+
page,
|
|
4565
|
+
mode,
|
|
4566
|
+
order,
|
|
4567
|
+
domain: listDataProps?.domain,
|
|
4568
|
+
pageLimit,
|
|
4569
|
+
groupByList,
|
|
4570
|
+
currentDate,
|
|
4571
|
+
selectedRowKeys,
|
|
4572
|
+
setType,
|
|
4573
|
+
setMode,
|
|
4574
|
+
setPage,
|
|
4575
|
+
setOrder,
|
|
4576
|
+
setDomain,
|
|
4577
|
+
setPageLimit,
|
|
4578
|
+
setGroupByList,
|
|
4579
|
+
setCurrentDate,
|
|
4580
|
+
setSelectedRowKeys: setSelectedRowKeys2
|
|
4581
|
+
}
|
|
4582
|
+
};
|
|
4583
|
+
};
|
|
4584
|
+
|
|
4433
4585
|
// src/store.ts
|
|
4434
4586
|
var store_exports = {};
|
|
4435
4587
|
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
@@ -4645,62 +4797,24 @@ var many2oneButtonController = (props) => {
|
|
|
4645
4797
|
var import_react17 = require("react");
|
|
4646
4798
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
4647
4799
|
var many2manyFieldController = (props) => {
|
|
4648
|
-
const {
|
|
4649
|
-
relation,
|
|
4650
|
-
domain,
|
|
4651
|
-
context,
|
|
4652
|
-
options,
|
|
4653
|
-
tab,
|
|
4654
|
-
setSelectedRowKeys: setSelectedRowKeys2,
|
|
4655
|
-
groupByDomain,
|
|
4656
|
-
enabled: enabledCallAPI,
|
|
4657
|
-
actionData
|
|
4658
|
-
} = props;
|
|
4800
|
+
const { relation, domain, context, options, tab, setSelectedRowKeys: setSelectedRowKeys2 } = props;
|
|
4659
4801
|
const { env } = (0, provider_exports.useEnv)();
|
|
4660
|
-
const {
|
|
4661
|
-
const [order, setOrder] = (0, import_react17.useState)();
|
|
4802
|
+
const { useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
|
|
4662
4803
|
const [page, setPage] = (0, import_react17.useState)(0);
|
|
4663
4804
|
const [domainMany2Many, setDomainMany2Many] = (0, import_react17.useState)(null);
|
|
4664
|
-
const
|
|
4805
|
+
const { action } = useAppProvider();
|
|
4665
4806
|
const contextObject = {
|
|
4666
4807
|
...env.context,
|
|
4667
4808
|
...context || {}
|
|
4668
4809
|
};
|
|
4669
|
-
const
|
|
4670
|
-
model: relation,
|
|
4810
|
+
const { data: viewResponse } = useViewV2({
|
|
4811
|
+
model: String(relation),
|
|
4671
4812
|
views: [
|
|
4672
4813
|
[false, "list"],
|
|
4673
4814
|
[false, "search"]
|
|
4674
4815
|
],
|
|
4675
4816
|
context: contextObject
|
|
4676
|
-
};
|
|
4677
|
-
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
4678
|
-
const baseModel = (0, import_react17.useMemo)(
|
|
4679
|
-
() => ({
|
|
4680
|
-
name: String(relation),
|
|
4681
|
-
view: viewResponse || {},
|
|
4682
|
-
actContext: contextObject,
|
|
4683
|
-
fields: [
|
|
4684
|
-
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
4685
|
-
...tab?.fields ? tab.fields : []
|
|
4686
|
-
]
|
|
4687
|
-
}),
|
|
4688
|
-
[relation, viewResponse]
|
|
4689
|
-
);
|
|
4690
|
-
const initModel = (0, import_hooks3.useModel)();
|
|
4691
|
-
const modelInstance = (0, import_react17.useMemo)(() => {
|
|
4692
|
-
if (viewResponse) {
|
|
4693
|
-
return initModel.initModel(baseModel);
|
|
4694
|
-
}
|
|
4695
|
-
return null;
|
|
4696
|
-
}, [baseModel, viewResponse]);
|
|
4697
|
-
const specification = (0, import_react17.useMemo)(() => {
|
|
4698
|
-
if (modelInstance) {
|
|
4699
|
-
return modelInstance.getSpecification();
|
|
4700
|
-
}
|
|
4701
|
-
return null;
|
|
4702
|
-
}, [modelInstance]);
|
|
4703
|
-
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
4817
|
+
});
|
|
4704
4818
|
const optionsObject = tab?.options ? (0, import_utils8.evalJSONContext)(tab?.options) : (options ? (0, import_utils8.evalJSONContext)(options) : {}) || {};
|
|
4705
4819
|
const fetchData = async () => {
|
|
4706
4820
|
try {
|
|
@@ -4711,32 +4825,17 @@ var many2manyFieldController = (props) => {
|
|
|
4711
4825
|
console.log(err);
|
|
4712
4826
|
}
|
|
4713
4827
|
};
|
|
4714
|
-
const queryKey = [
|
|
4715
|
-
`view-${relation}`,
|
|
4716
|
-
specification,
|
|
4717
|
-
domainMany2Many,
|
|
4718
|
-
debouncedPage,
|
|
4719
|
-
groupByDomain,
|
|
4720
|
-
order
|
|
4721
|
-
];
|
|
4722
|
-
const data = {
|
|
4723
|
-
model: relation,
|
|
4724
|
-
specification,
|
|
4725
|
-
domain: domainMany2Many,
|
|
4726
|
-
offset: debouncedPage * 10,
|
|
4727
|
-
limit: 10,
|
|
4728
|
-
context: contextObject,
|
|
4729
|
-
fields: groupByDomain?.fields,
|
|
4730
|
-
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
4731
|
-
sort: order ? order : default_order ? (0, import_utils8.formatSortingString)(default_order) : ""
|
|
4732
|
-
};
|
|
4733
|
-
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
4734
4828
|
const {
|
|
4735
4829
|
data: dataResponse,
|
|
4736
|
-
isLoading,
|
|
4737
4830
|
isFetched,
|
|
4738
|
-
isPlaceholderData
|
|
4739
|
-
|
|
4831
|
+
isPlaceholderData,
|
|
4832
|
+
isLoading
|
|
4833
|
+
} = useListData({
|
|
4834
|
+
action,
|
|
4835
|
+
context,
|
|
4836
|
+
model: String(relation),
|
|
4837
|
+
viewData: viewResponse
|
|
4838
|
+
});
|
|
4740
4839
|
(0, import_react17.useEffect)(() => {
|
|
4741
4840
|
if (viewResponse) {
|
|
4742
4841
|
fetchData();
|
|
@@ -4767,7 +4866,31 @@ var many2manyFieldController = (props) => {
|
|
|
4767
4866
|
)?.map((col) => ({ ...col.field })) ?? []
|
|
4768
4867
|
]
|
|
4769
4868
|
});
|
|
4869
|
+
const {
|
|
4870
|
+
refetch,
|
|
4871
|
+
data: dataFormViewResponse,
|
|
4872
|
+
isSuccess
|
|
4873
|
+
} = useGetFormView2({
|
|
4874
|
+
data: {
|
|
4875
|
+
id: null,
|
|
4876
|
+
model: relation ?? "",
|
|
4877
|
+
context: contextObject
|
|
4878
|
+
},
|
|
4879
|
+
queryKey: [`form-view-action-${relation}`],
|
|
4880
|
+
enabled: false
|
|
4881
|
+
});
|
|
4882
|
+
(0, import_react17.useEffect)(() => {
|
|
4883
|
+
if (isSuccess && dataFormViewResponse) {
|
|
4884
|
+
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
4885
|
+
window.location.href = `/form/menu?model=${relation}`;
|
|
4886
|
+
}
|
|
4887
|
+
}, [isSuccess]);
|
|
4770
4888
|
const handleCreateNewOnPage = async () => {
|
|
4889
|
+
try {
|
|
4890
|
+
refetch();
|
|
4891
|
+
} catch (error) {
|
|
4892
|
+
console.log(error);
|
|
4893
|
+
}
|
|
4771
4894
|
};
|
|
4772
4895
|
return {
|
|
4773
4896
|
handleCreateNewOnPage,
|
|
@@ -6298,7 +6421,6 @@ var tableGroupController = (props) => {
|
|
|
6298
6421
|
setSelectedRowKeys2([...clonedKeys, -1]);
|
|
6299
6422
|
setTimeout(() => setSelectedRowKeys2(clonedKeys), 500);
|
|
6300
6423
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6301
|
-
console.log("abc");
|
|
6302
6424
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6303
6425
|
setSelectedRowKeys2(filteredKeys);
|
|
6304
6426
|
}
|