@fctc/widget-logic 1.9.3 → 1.9.5
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/index.js +58 -98
- package/dist/index.mjs +48 -93
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/widget.d.mts +7 -8
- package/dist/widget.d.ts +7 -8
- package/dist/widget.js +58 -98
- package/dist/widget.mjs +48 -93
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5246,6 +5246,7 @@ var many2oneFieldController = (props) => {
|
|
|
5246
5246
|
options: fieldOptions,
|
|
5247
5247
|
showDetail
|
|
5248
5248
|
} = props;
|
|
5249
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
5249
5250
|
const [options, setOptions] = (0, import_react14.useState)([]);
|
|
5250
5251
|
const [inputValue, setInputValue] = (0, import_react14.useState)("");
|
|
5251
5252
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
@@ -5255,13 +5256,12 @@ var many2oneFieldController = (props) => {
|
|
|
5255
5256
|
const [domainObject, setDomainObject] = (0, import_react14.useState)(null);
|
|
5256
5257
|
const actionData = sessionStorageUtils.getActionData();
|
|
5257
5258
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5258
|
-
const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
|
|
5259
5259
|
const initValue = methods?.getValues(name);
|
|
5260
5260
|
const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
|
|
5261
5261
|
const contextObject = {
|
|
5262
5262
|
...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
|
|
5263
5263
|
...fieldContext,
|
|
5264
|
-
...context
|
|
5264
|
+
...env?.context
|
|
5265
5265
|
};
|
|
5266
5266
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
5267
5267
|
const data = {
|
|
@@ -5433,52 +5433,49 @@ var many2oneButtonController = (props) => {
|
|
|
5433
5433
|
|
|
5434
5434
|
// src/widget/basic/many2many-field/controller.ts
|
|
5435
5435
|
var import_react15 = require("react");
|
|
5436
|
-
var import_store8 = require("@fctc/interface-logic/store");
|
|
5437
5436
|
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5438
5437
|
var many2manyFieldController = (props) => {
|
|
5439
5438
|
const {
|
|
5440
5439
|
relation,
|
|
5441
5440
|
domain,
|
|
5442
5441
|
context,
|
|
5442
|
+
options,
|
|
5443
5443
|
tab,
|
|
5444
|
-
model,
|
|
5445
|
-
aid,
|
|
5446
5444
|
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5447
|
-
fields,
|
|
5448
|
-
setFields,
|
|
5449
5445
|
groupByDomain,
|
|
5450
|
-
|
|
5451
|
-
options,
|
|
5452
|
-
sessionStorageUtils
|
|
5446
|
+
enabled: enabledCallAPI
|
|
5453
5447
|
} = props;
|
|
5454
|
-
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
5455
|
-
const actionData = sessionStorageUtils.getActionData();
|
|
5456
|
-
const [debouncedPage] = useDebounce(page, 500);
|
|
5457
|
-
const [order, setOrder] = (0, import_react15.useState)();
|
|
5458
|
-
const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
|
|
5459
|
-
const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(domain);
|
|
5460
5448
|
const { env } = (0, provider_exports.useEnv)();
|
|
5461
5449
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5450
|
+
const [order, setOrder] = (0, import_react15.useState)();
|
|
5451
|
+
const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
|
|
5452
|
+
const [page, setPage] = (0, import_react15.useState)(0);
|
|
5453
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(null);
|
|
5454
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
5455
|
+
const contextObject = {
|
|
5456
|
+
...env.context,
|
|
5457
|
+
...context || {}
|
|
5458
|
+
};
|
|
5462
5459
|
const viewParams = {
|
|
5463
5460
|
model: relation,
|
|
5464
5461
|
views: [
|
|
5465
5462
|
[false, "list"],
|
|
5466
5463
|
[false, "search"]
|
|
5467
5464
|
],
|
|
5468
|
-
context
|
|
5465
|
+
context: contextObject
|
|
5469
5466
|
};
|
|
5470
|
-
const { data: viewResponse } = useGetView2(viewParams,
|
|
5467
|
+
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5471
5468
|
const baseModel = (0, import_react15.useMemo)(
|
|
5472
5469
|
() => ({
|
|
5473
5470
|
name: String(relation),
|
|
5474
5471
|
view: viewResponse || {},
|
|
5475
|
-
actContext:
|
|
5472
|
+
actContext: contextObject,
|
|
5476
5473
|
fields: [
|
|
5477
5474
|
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
5478
5475
|
...tab?.fields ? tab.fields : []
|
|
5479
5476
|
]
|
|
5480
5477
|
}),
|
|
5481
|
-
[
|
|
5478
|
+
[relation, viewResponse]
|
|
5482
5479
|
);
|
|
5483
5480
|
const initModel = (0, hooks_exports.useModel)();
|
|
5484
5481
|
const modelInstance = (0, import_react15.useMemo)(() => {
|
|
@@ -5497,26 +5494,15 @@ var many2manyFieldController = (props) => {
|
|
|
5497
5494
|
const optionsObject = tab?.options ? (0, import_utils6.evalJSONContext)(tab?.options) : (options ? (0, import_utils6.evalJSONContext)(options) : {}) || {};
|
|
5498
5495
|
const fetchData = async () => {
|
|
5499
5496
|
try {
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
5504
|
-
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
5505
|
-
...field
|
|
5506
|
-
}));
|
|
5507
|
-
if (!fields?.[`${aid}_${relation}_popupmany2many`] && modalData) {
|
|
5508
|
-
setFields({
|
|
5509
|
-
...fields,
|
|
5510
|
-
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
5511
|
-
});
|
|
5512
|
-
}
|
|
5513
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5497
|
+
const domainParse = typeof domain === "string" ? (0, import_utils6.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5498
|
+
setDomainMany2Many(domainParse);
|
|
5499
|
+
setPage(0);
|
|
5514
5500
|
} catch (err) {
|
|
5515
5501
|
console.log(err);
|
|
5516
5502
|
}
|
|
5517
5503
|
};
|
|
5518
5504
|
const queryKey = [
|
|
5519
|
-
`view-${relation}
|
|
5505
|
+
`view-${relation}`,
|
|
5520
5506
|
specification,
|
|
5521
5507
|
domainMany2Many,
|
|
5522
5508
|
debouncedPage,
|
|
@@ -5529,16 +5515,16 @@ var many2manyFieldController = (props) => {
|
|
|
5529
5515
|
domain: domainMany2Many,
|
|
5530
5516
|
offset: debouncedPage * 10,
|
|
5531
5517
|
limit: 10,
|
|
5532
|
-
context,
|
|
5518
|
+
context: contextObject,
|
|
5533
5519
|
fields: groupByDomain?.fields,
|
|
5534
5520
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5535
5521
|
sort: order ? order : default_order ? (0, import_utils6.formatSortingString)(default_order) : ""
|
|
5536
5522
|
};
|
|
5537
|
-
const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5523
|
+
const enabled = enabledCallAPI && isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5538
5524
|
const {
|
|
5539
5525
|
data: dataResponse,
|
|
5540
|
-
isLoading
|
|
5541
|
-
isFetched
|
|
5526
|
+
isLoading,
|
|
5527
|
+
isFetched,
|
|
5542
5528
|
isPlaceholderData
|
|
5543
5529
|
} = useGetListData3(data, queryKey, enabled);
|
|
5544
5530
|
(0, import_react15.useEffect)(() => {
|
|
@@ -5546,12 +5532,7 @@ var many2manyFieldController = (props) => {
|
|
|
5546
5532
|
fetchData();
|
|
5547
5533
|
}
|
|
5548
5534
|
return () => {
|
|
5549
|
-
|
|
5550
|
-
setFields((prevFields) => ({
|
|
5551
|
-
...prevFields,
|
|
5552
|
-
[`${aid}_${relation}_popupmany2many`]: null
|
|
5553
|
-
}));
|
|
5554
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5535
|
+
setPage(0);
|
|
5555
5536
|
setSelectedRowKeys4([]);
|
|
5556
5537
|
setDomainMany2Many(null);
|
|
5557
5538
|
setIsLoadedData(false);
|
|
@@ -5559,44 +5540,19 @@ var many2manyFieldController = (props) => {
|
|
|
5559
5540
|
}, [viewResponse]);
|
|
5560
5541
|
const { rows, columns, typeTable } = tableController({
|
|
5561
5542
|
data: {
|
|
5562
|
-
fields:
|
|
5543
|
+
fields: viewResponse?.views?.list?.fields,
|
|
5563
5544
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
5564
5545
|
dataModel: viewResponse?.models?.[String(relation)],
|
|
5565
|
-
context:
|
|
5546
|
+
context: contextObject,
|
|
5566
5547
|
typeTable: dataResponse?.groups ? "group" : "list"
|
|
5567
5548
|
}
|
|
5568
5549
|
});
|
|
5569
|
-
const dataFormView = {
|
|
5570
|
-
id: null,
|
|
5571
|
-
model: relation,
|
|
5572
|
-
context
|
|
5573
|
-
};
|
|
5574
|
-
const {
|
|
5575
|
-
refetch,
|
|
5576
|
-
data: dataFormViewResponse,
|
|
5577
|
-
isSuccess
|
|
5578
|
-
} = useGetFormView({
|
|
5579
|
-
data: dataFormView,
|
|
5580
|
-
queryKey: [`form-view-action-${relation}`],
|
|
5581
|
-
enabled: false
|
|
5582
|
-
});
|
|
5583
|
-
(0, import_react15.useEffect)(() => {
|
|
5584
|
-
if (isSuccess && dataFormViewResponse) {
|
|
5585
|
-
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
5586
|
-
window.location.href = `/form/menu?model=${relation}`;
|
|
5587
|
-
}
|
|
5588
|
-
}, [isSuccess]);
|
|
5589
5550
|
(0, import_react15.useEffect)(() => {
|
|
5590
5551
|
if (domainMany2Many && !isLoadedData) {
|
|
5591
5552
|
setIsLoadedData(true);
|
|
5592
5553
|
}
|
|
5593
5554
|
}, [domainMany2Many]);
|
|
5594
5555
|
const handleCreateNewOnPage = async () => {
|
|
5595
|
-
try {
|
|
5596
|
-
refetch();
|
|
5597
|
-
} catch (error) {
|
|
5598
|
-
console.log(error);
|
|
5599
|
-
}
|
|
5600
5556
|
};
|
|
5601
5557
|
return {
|
|
5602
5558
|
handleCreateNewOnPage,
|
|
@@ -5604,9 +5560,13 @@ var many2manyFieldController = (props) => {
|
|
|
5604
5560
|
rows,
|
|
5605
5561
|
columns,
|
|
5606
5562
|
typeTable,
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
isPlaceholderData
|
|
5563
|
+
isLoading,
|
|
5564
|
+
isFetched,
|
|
5565
|
+
isPlaceholderData,
|
|
5566
|
+
setPage,
|
|
5567
|
+
page,
|
|
5568
|
+
domain: domainMany2Many,
|
|
5569
|
+
setDomain: setDomainMany2Many
|
|
5610
5570
|
};
|
|
5611
5571
|
};
|
|
5612
5572
|
|
|
@@ -6874,7 +6834,7 @@ var binaryFieldController = (props) => {
|
|
|
6874
6834
|
};
|
|
6875
6835
|
|
|
6876
6836
|
// src/widget/advance/table/table-body/controller.ts
|
|
6877
|
-
var
|
|
6837
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6878
6838
|
var import_react21 = require("react");
|
|
6879
6839
|
var tableBodyController = (props) => {
|
|
6880
6840
|
const {
|
|
@@ -6887,7 +6847,7 @@ var tableBodyController = (props) => {
|
|
|
6887
6847
|
selectedRowKeysRef,
|
|
6888
6848
|
onClickRow
|
|
6889
6849
|
} = props;
|
|
6890
|
-
const appDispatch = (0,
|
|
6850
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
6891
6851
|
const checked = (0, import_react21.useMemo)(() => {
|
|
6892
6852
|
if (!row?.id) return false;
|
|
6893
6853
|
if (selectedRowKeys?.includes(row.id)) {
|
|
@@ -6904,7 +6864,7 @@ var tableBodyController = (props) => {
|
|
|
6904
6864
|
}
|
|
6905
6865
|
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6906
6866
|
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6907
|
-
appDispatch((0,
|
|
6867
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6908
6868
|
};
|
|
6909
6869
|
const handleClickRow = (col, row2) => {
|
|
6910
6870
|
onClickRow(col, row2);
|
|
@@ -6917,13 +6877,13 @@ var tableBodyController = (props) => {
|
|
|
6917
6877
|
(id) => id !== row.id
|
|
6918
6878
|
);
|
|
6919
6879
|
selectedRowKeysRef.current = filtered;
|
|
6920
|
-
appDispatch((0,
|
|
6880
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(filtered));
|
|
6921
6881
|
} else {
|
|
6922
6882
|
const unique = Array.from(
|
|
6923
6883
|
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6924
6884
|
);
|
|
6925
6885
|
selectedRowKeysRef.current = unique;
|
|
6926
|
-
appDispatch((0,
|
|
6886
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(unique));
|
|
6927
6887
|
}
|
|
6928
6888
|
}
|
|
6929
6889
|
}, [isAutoSelect]);
|
|
@@ -6941,35 +6901,35 @@ var tableBodyController = (props) => {
|
|
|
6941
6901
|
};
|
|
6942
6902
|
|
|
6943
6903
|
// src/widget/advance/table/table-head/controller.ts
|
|
6944
|
-
var
|
|
6904
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6945
6905
|
var tableHeadController = (props) => {
|
|
6946
6906
|
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6947
|
-
const appDispatch = (0,
|
|
6948
|
-
const { groupByDomain } = (0,
|
|
6907
|
+
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6908
|
+
const { groupByDomain } = (0, import_store9.useAppSelector)(import_store9.selectSearch);
|
|
6949
6909
|
const handleCheckBoxAll = (event) => {
|
|
6950
6910
|
if (event?.target?.checked && typeTable === "list") {
|
|
6951
6911
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6952
|
-
appDispatch((0,
|
|
6912
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(allRowKeys));
|
|
6953
6913
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6954
6914
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6955
6915
|
const ids = Array.from(rowsIDs)?.map(
|
|
6956
6916
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6957
6917
|
);
|
|
6958
6918
|
if (ids?.length > 0) {
|
|
6959
|
-
appDispatch((0,
|
|
6919
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(ids));
|
|
6960
6920
|
} else {
|
|
6961
6921
|
const sum = countSum(
|
|
6962
6922
|
rows,
|
|
6963
6923
|
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6964
6924
|
);
|
|
6965
6925
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6966
|
-
appDispatch((0,
|
|
6926
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(keys));
|
|
6967
6927
|
}
|
|
6968
6928
|
if (selectedRowKeysRef) {
|
|
6969
6929
|
selectedRowKeysRef.current = [];
|
|
6970
6930
|
}
|
|
6971
6931
|
} else {
|
|
6972
|
-
appDispatch((0,
|
|
6932
|
+
appDispatch((0, import_store9.setSelectedRowKeys)([]));
|
|
6973
6933
|
}
|
|
6974
6934
|
};
|
|
6975
6935
|
return {
|
|
@@ -6979,7 +6939,7 @@ var tableHeadController = (props) => {
|
|
|
6979
6939
|
|
|
6980
6940
|
// src/widget/advance/table/table-view/controller.ts
|
|
6981
6941
|
var import_react22 = require("react");
|
|
6982
|
-
var
|
|
6942
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
6983
6943
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6984
6944
|
var tableController = ({ data }) => {
|
|
6985
6945
|
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
@@ -7059,7 +7019,7 @@ var tableController = ({ data }) => {
|
|
|
7059
7019
|
// src/widget/advance/table/table-group/controller.ts
|
|
7060
7020
|
var import_react23 = require("react");
|
|
7061
7021
|
var import_hooks16 = require("@fctc/interface-logic/hooks");
|
|
7062
|
-
var
|
|
7022
|
+
var import_store11 = require("@fctc/interface-logic/store");
|
|
7063
7023
|
|
|
7064
7024
|
// src/environment.ts
|
|
7065
7025
|
var environment_exports = {};
|
|
@@ -7087,9 +7047,9 @@ var tableGroupController = (props) => {
|
|
|
7087
7047
|
selectedRowKeysRef
|
|
7088
7048
|
} = props;
|
|
7089
7049
|
const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
|
|
7090
|
-
const { groupByDomain, selectedTags } = (0,
|
|
7091
|
-
const { selectedRowKeys } = (0,
|
|
7092
|
-
const appDispatch = (0,
|
|
7050
|
+
const { groupByDomain, selectedTags } = (0, import_store11.useAppSelector)(import_store11.selectSearch);
|
|
7051
|
+
const { selectedRowKeys } = (0, import_store11.useAppSelector)(import_store11.selectList);
|
|
7052
|
+
const appDispatch = (0, import_store11.useAppDispatch)();
|
|
7093
7053
|
const { toDataJS } = (0, import_hooks16.useOdooDataTransform)();
|
|
7094
7054
|
const initVal = toDataJS(row, viewData, model);
|
|
7095
7055
|
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
@@ -7175,14 +7135,14 @@ var tableGroupController = (props) => {
|
|
|
7175
7135
|
const filteredIds = selectedRowKeys.filter(
|
|
7176
7136
|
(id) => !ids.includes(id)
|
|
7177
7137
|
);
|
|
7178
|
-
appDispatch((0,
|
|
7138
|
+
appDispatch((0, import_store11.setSelectedRowKeys)(filteredIds));
|
|
7179
7139
|
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
7180
7140
|
const clonedKeys = [...selectedRowKeys];
|
|
7181
|
-
appDispatch((0,
|
|
7182
|
-
setTimeout(() => appDispatch((0,
|
|
7141
|
+
appDispatch((0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
7142
|
+
setTimeout(() => appDispatch((0, import_store11.setSelectedRowKeys)(clonedKeys)), 500);
|
|
7183
7143
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7184
7144
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7185
|
-
appDispatch((0,
|
|
7145
|
+
appDispatch((0, import_store11.setSelectedRowKeys)(filteredKeys));
|
|
7186
7146
|
}
|
|
7187
7147
|
toggleShowGroup();
|
|
7188
7148
|
};
|
|
@@ -7191,8 +7151,8 @@ var tableGroupController = (props) => {
|
|
|
7191
7151
|
return;
|
|
7192
7152
|
}
|
|
7193
7153
|
const clonedKeys = [...selectedRowKeys];
|
|
7194
|
-
(0,
|
|
7195
|
-
setTimeout(() => (0,
|
|
7154
|
+
(0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
7155
|
+
setTimeout(() => (0, import_store11.setSelectedRowKeys)(clonedKeys), 500);
|
|
7196
7156
|
}, [isQueryFetched]);
|
|
7197
7157
|
return {
|
|
7198
7158
|
handleExpandChildGroup,
|