@fctc/widget-logic 2.5.0 → 2.5.2
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 +220 -3
- package/dist/hooks.d.ts +220 -3
- package/dist/hooks.js +0 -3
- package/dist/hooks.mjs +0 -3
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +68 -42
- package/dist/index.mjs +83 -53
- package/dist/widget.d.mts +1 -3
- package/dist/widget.d.ts +1 -3
- package/dist/widget.js +68 -191
- package/dist/widget.mjs +83 -202
- package/package.json +1 -1
- package/dist/use-view-v2-BWHqxo3S.d.mts +0 -222
- package/dist/use-view-v2-BWHqxo3S.d.ts +0 -222
package/dist/index.mjs
CHANGED
|
@@ -4610,9 +4610,6 @@ var useViewV2 = ({
|
|
|
4610
4610
|
}) => {
|
|
4611
4611
|
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
4612
4612
|
const viewParams = useMemo3(() => {
|
|
4613
|
-
if (!action) {
|
|
4614
|
-
return void 0;
|
|
4615
|
-
}
|
|
4616
4613
|
return {
|
|
4617
4614
|
model,
|
|
4618
4615
|
views,
|
|
@@ -5572,27 +5569,69 @@ var many2oneButtonController = (props) => {
|
|
|
5572
5569
|
};
|
|
5573
5570
|
|
|
5574
5571
|
// src/widget/basic/many2many-field/controller.ts
|
|
5575
|
-
import { useEffect as useEffect11, useState as useState8 } from "react";
|
|
5576
|
-
import {
|
|
5572
|
+
import { useEffect as useEffect11, useMemo as useMemo9, useState as useState8 } from "react";
|
|
5573
|
+
import {
|
|
5574
|
+
evalJSONContext as evalJSONContext4,
|
|
5575
|
+
evalJSONDomain as evalJSONDomain4,
|
|
5576
|
+
formatSortingString as formatSortingString2
|
|
5577
|
+
} from "@fctc/interface-logic/utils";
|
|
5577
5578
|
var many2manyFieldController = (props) => {
|
|
5578
|
-
const {
|
|
5579
|
+
const {
|
|
5580
|
+
relation,
|
|
5581
|
+
domain,
|
|
5582
|
+
context,
|
|
5583
|
+
options,
|
|
5584
|
+
tab,
|
|
5585
|
+
setSelectedRowKeys: setSelectedRowKeys2,
|
|
5586
|
+
groupByDomain,
|
|
5587
|
+
enabled: enabledCallAPI,
|
|
5588
|
+
actionData
|
|
5589
|
+
} = props;
|
|
5579
5590
|
const { env } = (0, provider_exports.useEnv)();
|
|
5580
|
-
const { useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
|
|
5591
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
|
|
5592
|
+
const [order, setOrder] = useState8();
|
|
5581
5593
|
const [page, setPage] = useState8(0);
|
|
5582
5594
|
const [domainMany2Many, setDomainMany2Many] = useState8(null);
|
|
5583
|
-
const
|
|
5595
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
5584
5596
|
const contextObject = {
|
|
5585
5597
|
...env.context,
|
|
5586
5598
|
...context || {}
|
|
5587
5599
|
};
|
|
5588
|
-
const
|
|
5589
|
-
model:
|
|
5600
|
+
const viewParams = {
|
|
5601
|
+
model: relation,
|
|
5590
5602
|
views: [
|
|
5591
5603
|
[false, "list"],
|
|
5592
5604
|
[false, "search"]
|
|
5593
5605
|
],
|
|
5594
5606
|
context: contextObject
|
|
5595
|
-
}
|
|
5607
|
+
};
|
|
5608
|
+
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5609
|
+
const baseModel = useMemo9(
|
|
5610
|
+
() => ({
|
|
5611
|
+
name: String(relation),
|
|
5612
|
+
view: viewResponse || {},
|
|
5613
|
+
actContext: contextObject,
|
|
5614
|
+
fields: [
|
|
5615
|
+
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
5616
|
+
...tab?.fields ? tab.fields : []
|
|
5617
|
+
]
|
|
5618
|
+
}),
|
|
5619
|
+
[relation, viewResponse]
|
|
5620
|
+
);
|
|
5621
|
+
const initModel = useModel();
|
|
5622
|
+
const modelInstance = useMemo9(() => {
|
|
5623
|
+
if (viewResponse) {
|
|
5624
|
+
return initModel.initModel(baseModel);
|
|
5625
|
+
}
|
|
5626
|
+
return null;
|
|
5627
|
+
}, [baseModel, viewResponse]);
|
|
5628
|
+
const specification = useMemo9(() => {
|
|
5629
|
+
if (modelInstance) {
|
|
5630
|
+
return modelInstance.getSpecification();
|
|
5631
|
+
}
|
|
5632
|
+
return null;
|
|
5633
|
+
}, [modelInstance]);
|
|
5634
|
+
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5596
5635
|
const optionsObject = tab?.options ? evalJSONContext4(tab?.options) : (options ? evalJSONContext4(options) : {}) || {};
|
|
5597
5636
|
const fetchData = async () => {
|
|
5598
5637
|
try {
|
|
@@ -5603,17 +5642,32 @@ var many2manyFieldController = (props) => {
|
|
|
5603
5642
|
console.log(err);
|
|
5604
5643
|
}
|
|
5605
5644
|
};
|
|
5645
|
+
const queryKey = [
|
|
5646
|
+
`view-${relation}`,
|
|
5647
|
+
specification,
|
|
5648
|
+
domainMany2Many,
|
|
5649
|
+
debouncedPage,
|
|
5650
|
+
groupByDomain,
|
|
5651
|
+
order
|
|
5652
|
+
];
|
|
5653
|
+
const data = {
|
|
5654
|
+
model: relation,
|
|
5655
|
+
specification,
|
|
5656
|
+
domain: domainMany2Many,
|
|
5657
|
+
offset: debouncedPage * 10,
|
|
5658
|
+
limit: 10,
|
|
5659
|
+
context: contextObject,
|
|
5660
|
+
fields: groupByDomain?.fields,
|
|
5661
|
+
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5662
|
+
sort: order ? order : default_order ? formatSortingString2(default_order) : ""
|
|
5663
|
+
};
|
|
5664
|
+
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5606
5665
|
const {
|
|
5607
5666
|
data: dataResponse,
|
|
5667
|
+
isLoading,
|
|
5608
5668
|
isFetched,
|
|
5609
|
-
isPlaceholderData
|
|
5610
|
-
|
|
5611
|
-
} = useListData({
|
|
5612
|
-
action,
|
|
5613
|
-
context,
|
|
5614
|
-
model: String(relation),
|
|
5615
|
-
viewData: viewResponse
|
|
5616
|
-
});
|
|
5669
|
+
isPlaceholderData
|
|
5670
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
5617
5671
|
useEffect11(() => {
|
|
5618
5672
|
if (viewResponse) {
|
|
5619
5673
|
fetchData();
|
|
@@ -5644,31 +5698,7 @@ var many2manyFieldController = (props) => {
|
|
|
5644
5698
|
)?.map((col) => ({ ...col.field })) ?? []
|
|
5645
5699
|
]
|
|
5646
5700
|
});
|
|
5647
|
-
const {
|
|
5648
|
-
refetch,
|
|
5649
|
-
data: dataFormViewResponse,
|
|
5650
|
-
isSuccess
|
|
5651
|
-
} = useGetFormView2({
|
|
5652
|
-
data: {
|
|
5653
|
-
id: null,
|
|
5654
|
-
model: relation ?? "",
|
|
5655
|
-
context: contextObject
|
|
5656
|
-
},
|
|
5657
|
-
queryKey: [`form-view-action-${relation}`],
|
|
5658
|
-
enabled: false
|
|
5659
|
-
});
|
|
5660
|
-
useEffect11(() => {
|
|
5661
|
-
if (isSuccess && dataFormViewResponse) {
|
|
5662
|
-
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
5663
|
-
window.location.href = `/form/menu?model=${relation}`;
|
|
5664
|
-
}
|
|
5665
|
-
}, [isSuccess]);
|
|
5666
5701
|
const handleCreateNewOnPage = async () => {
|
|
5667
|
-
try {
|
|
5668
|
-
refetch();
|
|
5669
|
-
} catch (error) {
|
|
5670
|
-
console.log(error);
|
|
5671
|
-
}
|
|
5672
5702
|
};
|
|
5673
5703
|
return {
|
|
5674
5704
|
handleCreateNewOnPage,
|
|
@@ -5691,7 +5721,7 @@ var many2manyFieldController = (props) => {
|
|
|
5691
5721
|
};
|
|
5692
5722
|
|
|
5693
5723
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5694
|
-
import { useMemo as
|
|
5724
|
+
import { useMemo as useMemo10 } from "react";
|
|
5695
5725
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
5696
5726
|
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
5697
5727
|
var many2manyTagsController = (props) => {
|
|
@@ -5709,7 +5739,7 @@ var many2manyTagsController = (props) => {
|
|
|
5709
5739
|
const { env } = (0, provider_exports.useEnv)();
|
|
5710
5740
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
5711
5741
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
5712
|
-
const domainObject =
|
|
5742
|
+
const domainObject = useMemo10(
|
|
5713
5743
|
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5714
5744
|
[domain, formValues]
|
|
5715
5745
|
);
|
|
@@ -6941,7 +6971,7 @@ var binaryFieldController = (props) => {
|
|
|
6941
6971
|
};
|
|
6942
6972
|
|
|
6943
6973
|
// src/widget/advance/table/table-head/controller.ts
|
|
6944
|
-
import { useMemo as
|
|
6974
|
+
import { useMemo as useMemo11, useRef as useRef5 } from "react";
|
|
6945
6975
|
var tableHeadController = (props) => {
|
|
6946
6976
|
const {
|
|
6947
6977
|
typeTable,
|
|
@@ -6954,19 +6984,19 @@ var tableHeadController = (props) => {
|
|
|
6954
6984
|
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
6955
6985
|
const selectedRowKeysRef = useRef5(recordIds);
|
|
6956
6986
|
const isGroupTable = typeTable === "group";
|
|
6957
|
-
const recordsCheckedGroup =
|
|
6987
|
+
const recordsCheckedGroup = useMemo11(() => {
|
|
6958
6988
|
if (!rows || !groupByList) return 0;
|
|
6959
6989
|
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6960
6990
|
return countSum(rows, groupBy);
|
|
6961
6991
|
}, [rows, groupByList]);
|
|
6962
|
-
const isAllGroupChecked =
|
|
6992
|
+
const isAllGroupChecked = useMemo11(() => {
|
|
6963
6993
|
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6964
6994
|
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6965
6995
|
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6966
6996
|
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6967
6997
|
return allGroupsSelected || allRecordsSelected;
|
|
6968
6998
|
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6969
|
-
const isAllNormalChecked =
|
|
6999
|
+
const isAllNormalChecked = useMemo11(() => {
|
|
6970
7000
|
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6971
7001
|
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6972
7002
|
(id) => rows.some((record) => record.id === id)
|
|
@@ -7096,7 +7126,7 @@ var tableController = ({ data }) => {
|
|
|
7096
7126
|
};
|
|
7097
7127
|
|
|
7098
7128
|
// src/widget/advance/table/table-group/controller.ts
|
|
7099
|
-
import { useEffect as useEffect14, useMemo as
|
|
7129
|
+
import { useEffect as useEffect14, useMemo as useMemo12, useState as useState14 } from "react";
|
|
7100
7130
|
import {
|
|
7101
7131
|
useAppSelector as useAppSelector2,
|
|
7102
7132
|
selectList
|
|
@@ -7124,7 +7154,7 @@ var tableGroupController = (props) => {
|
|
|
7124
7154
|
fromEnd: 1
|
|
7125
7155
|
});
|
|
7126
7156
|
const domain = row?.__domain;
|
|
7127
|
-
const processedData =
|
|
7157
|
+
const processedData = useMemo12(() => {
|
|
7128
7158
|
const calculateColSpanEmpty = () => {
|
|
7129
7159
|
const startIndex = columns.findIndex(
|
|
7130
7160
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -7139,7 +7169,7 @@ var tableGroupController = (props) => {
|
|
|
7139
7169
|
};
|
|
7140
7170
|
return calculateColSpanEmpty();
|
|
7141
7171
|
}, [columns, row]);
|
|
7142
|
-
const shouldFetchData =
|
|
7172
|
+
const shouldFetchData = useMemo12(() => {
|
|
7143
7173
|
return !!isShowGroup;
|
|
7144
7174
|
}, [isShowGroup]);
|
|
7145
7175
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -7341,7 +7371,7 @@ var searchController = ({
|
|
|
7341
7371
|
const formatDomain = () => {
|
|
7342
7372
|
if (domainAction) {
|
|
7343
7373
|
const domain2 = [];
|
|
7344
|
-
if (domainAction
|
|
7374
|
+
if (Array.isArray(domainAction) && domainAction.length > 0) {
|
|
7345
7375
|
if (Object.keys(searchMap).some((key) => !key.includes(SearchType.GROUP))) {
|
|
7346
7376
|
domain2.push("&");
|
|
7347
7377
|
}
|
package/dist/widget.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
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';
|
|
5
4
|
import moment from 'moment';
|
|
6
5
|
import '@fctc/interface-logic/types';
|
|
7
|
-
import '@tanstack/query-core';
|
|
8
6
|
|
|
9
7
|
type TStatus = 'normal' | 'done' | 'blocked';
|
|
10
8
|
interface TStatusDropdownFieldProps extends IInputFieldProps {
|
|
@@ -85,7 +83,7 @@ declare const many2manyFieldController: (props: IMany2ManyControllerProps) => {
|
|
|
85
83
|
isPlaceholderData: boolean;
|
|
86
84
|
setPage: react.Dispatch<react.SetStateAction<number>>;
|
|
87
85
|
page: number;
|
|
88
|
-
viewData:
|
|
86
|
+
viewData: any;
|
|
89
87
|
domain: any;
|
|
90
88
|
setDomain: react.Dispatch<any>;
|
|
91
89
|
searchController: {
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
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';
|
|
5
4
|
import moment from 'moment';
|
|
6
5
|
import '@fctc/interface-logic/types';
|
|
7
|
-
import '@tanstack/query-core';
|
|
8
6
|
|
|
9
7
|
type TStatus = 'normal' | 'done' | 'blocked';
|
|
10
8
|
interface TStatusDropdownFieldProps extends IInputFieldProps {
|
|
@@ -85,7 +83,7 @@ declare const many2manyFieldController: (props: IMany2ManyControllerProps) => {
|
|
|
85
83
|
isPlaceholderData: boolean;
|
|
86
84
|
setPage: react.Dispatch<react.SetStateAction<number>>;
|
|
87
85
|
page: number;
|
|
88
|
-
viewData:
|
|
86
|
+
viewData: any;
|
|
89
87
|
domain: any;
|
|
90
88
|
setDomain: react.Dispatch<any>;
|
|
91
89
|
searchController: {
|
package/dist/widget.js
CHANGED
|
@@ -4320,34 +4320,6 @@ __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
|
-
};
|
|
4351
4323
|
|
|
4352
4324
|
// src/hooks/core/use-company.ts
|
|
4353
4325
|
var import_react_query3 = require("@tanstack/react-query");
|
|
@@ -4363,47 +4335,12 @@ var AppProviderInitialValue = {
|
|
|
4363
4335
|
view: {}
|
|
4364
4336
|
};
|
|
4365
4337
|
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
|
-
};
|
|
4373
4338
|
|
|
4374
4339
|
// src/hooks/core/use-config.ts
|
|
4375
4340
|
var import_react10 = require("react");
|
|
4376
4341
|
|
|
4377
4342
|
// src/hooks/core/use-get-specification.ts
|
|
4378
4343
|
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
|
-
};
|
|
4407
4344
|
|
|
4408
4345
|
// src/hooks/core/use-list-data.ts
|
|
4409
4346
|
var import_react15 = require("react");
|
|
@@ -4493,95 +4430,6 @@ var useGetRowIds = (tableRef) => {
|
|
|
4493
4430
|
return { rowIds, refresh: updateVisibleRowIds };
|
|
4494
4431
|
};
|
|
4495
4432
|
|
|
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
|
-
|
|
4585
4433
|
// src/store.ts
|
|
4586
4434
|
var store_exports = {};
|
|
4587
4435
|
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
@@ -4797,24 +4645,62 @@ var many2oneButtonController = (props) => {
|
|
|
4797
4645
|
var import_react17 = require("react");
|
|
4798
4646
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
4799
4647
|
var many2manyFieldController = (props) => {
|
|
4800
|
-
const {
|
|
4648
|
+
const {
|
|
4649
|
+
relation,
|
|
4650
|
+
domain,
|
|
4651
|
+
context,
|
|
4652
|
+
options,
|
|
4653
|
+
tab,
|
|
4654
|
+
setSelectedRowKeys: setSelectedRowKeys2,
|
|
4655
|
+
groupByDomain,
|
|
4656
|
+
enabled: enabledCallAPI,
|
|
4657
|
+
actionData
|
|
4658
|
+
} = props;
|
|
4801
4659
|
const { env } = (0, provider_exports.useEnv)();
|
|
4802
|
-
const { useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
|
|
4660
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
|
|
4661
|
+
const [order, setOrder] = (0, import_react17.useState)();
|
|
4803
4662
|
const [page, setPage] = (0, import_react17.useState)(0);
|
|
4804
4663
|
const [domainMany2Many, setDomainMany2Many] = (0, import_react17.useState)(null);
|
|
4805
|
-
const
|
|
4664
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
4806
4665
|
const contextObject = {
|
|
4807
4666
|
...env.context,
|
|
4808
4667
|
...context || {}
|
|
4809
4668
|
};
|
|
4810
|
-
const
|
|
4811
|
-
model:
|
|
4669
|
+
const viewParams = {
|
|
4670
|
+
model: relation,
|
|
4812
4671
|
views: [
|
|
4813
4672
|
[false, "list"],
|
|
4814
4673
|
[false, "search"]
|
|
4815
4674
|
],
|
|
4816
4675
|
context: contextObject
|
|
4817
|
-
}
|
|
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;
|
|
4818
4704
|
const optionsObject = tab?.options ? (0, import_utils8.evalJSONContext)(tab?.options) : (options ? (0, import_utils8.evalJSONContext)(options) : {}) || {};
|
|
4819
4705
|
const fetchData = async () => {
|
|
4820
4706
|
try {
|
|
@@ -4825,17 +4711,32 @@ var many2manyFieldController = (props) => {
|
|
|
4825
4711
|
console.log(err);
|
|
4826
4712
|
}
|
|
4827
4713
|
};
|
|
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;
|
|
4828
4734
|
const {
|
|
4829
4735
|
data: dataResponse,
|
|
4736
|
+
isLoading,
|
|
4830
4737
|
isFetched,
|
|
4831
|
-
isPlaceholderData
|
|
4832
|
-
|
|
4833
|
-
} = useListData({
|
|
4834
|
-
action,
|
|
4835
|
-
context,
|
|
4836
|
-
model: String(relation),
|
|
4837
|
-
viewData: viewResponse
|
|
4838
|
-
});
|
|
4738
|
+
isPlaceholderData
|
|
4739
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
4839
4740
|
(0, import_react17.useEffect)(() => {
|
|
4840
4741
|
if (viewResponse) {
|
|
4841
4742
|
fetchData();
|
|
@@ -4866,31 +4767,7 @@ var many2manyFieldController = (props) => {
|
|
|
4866
4767
|
)?.map((col) => ({ ...col.field })) ?? []
|
|
4867
4768
|
]
|
|
4868
4769
|
});
|
|
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]);
|
|
4888
4770
|
const handleCreateNewOnPage = async () => {
|
|
4889
|
-
try {
|
|
4890
|
-
refetch();
|
|
4891
|
-
} catch (error) {
|
|
4892
|
-
console.log(error);
|
|
4893
|
-
}
|
|
4894
4771
|
};
|
|
4895
4772
|
return {
|
|
4896
4773
|
handleCreateNewOnPage,
|
|
@@ -6555,7 +6432,7 @@ var searchController = ({
|
|
|
6555
6432
|
const formatDomain = () => {
|
|
6556
6433
|
if (domainAction) {
|
|
6557
6434
|
const domain2 = [];
|
|
6558
|
-
if (domainAction
|
|
6435
|
+
if (Array.isArray(domainAction) && domainAction.length > 0) {
|
|
6559
6436
|
if (Object.keys(searchMap).some((key) => !key.includes(import_constants3.SearchType.GROUP))) {
|
|
6560
6437
|
domain2.push("&");
|
|
6561
6438
|
}
|