@fctc/widget-logic 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +149 -160
- package/dist/index.mjs +142 -162
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/widget.d.mts +58 -19
- package/dist/widget.d.ts +58 -19
- package/dist/widget.js +149 -160
- package/dist/widget.mjs +142 -162
- 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,15 +5256,14 @@ 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
|
-
const { useGetSelection:
|
|
5266
|
+
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
5267
5267
|
const data = {
|
|
5268
5268
|
model: relation,
|
|
5269
5269
|
domain: domainObject,
|
|
@@ -5279,7 +5279,7 @@ var many2oneFieldController = (props) => {
|
|
|
5279
5279
|
data: dataOfSelection,
|
|
5280
5280
|
refetch,
|
|
5281
5281
|
isFetching
|
|
5282
|
-
} =
|
|
5282
|
+
} = useGetSelection3({
|
|
5283
5283
|
data,
|
|
5284
5284
|
queryKey,
|
|
5285
5285
|
enabled: false
|
|
@@ -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
|
-
|
|
5452
|
-
sessionStorageUtils
|
|
5446
|
+
enabled: enabledCallAPI,
|
|
5447
|
+
actionData
|
|
5453
5448
|
} = 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
5449
|
const { env } = (0, provider_exports.useEnv)();
|
|
5461
5450
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5451
|
+
const [order, setOrder] = (0, import_react15.useState)();
|
|
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 =
|
|
5523
|
+
const enabled = enabledCallAPI && !!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,73 +5532,58 @@ 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
|
-
setIsLoadedData(false);
|
|
5558
5538
|
};
|
|
5559
5539
|
}, [viewResponse]);
|
|
5560
|
-
const { rows, columns, typeTable } = tableController({
|
|
5540
|
+
const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
|
|
5561
5541
|
data: {
|
|
5562
|
-
fields:
|
|
5542
|
+
fields: viewResponse?.views?.list?.fields,
|
|
5563
5543
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
5564
5544
|
dataModel: viewResponse?.models?.[String(relation)],
|
|
5565
|
-
context:
|
|
5545
|
+
context: contextObject,
|
|
5566
5546
|
typeTable: dataResponse?.groups ? "group" : "list"
|
|
5567
5547
|
}
|
|
5568
5548
|
});
|
|
5569
|
-
const
|
|
5570
|
-
|
|
5571
|
-
model: relation,
|
|
5572
|
-
context
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
data: dataFormView,
|
|
5580
|
-
queryKey: [`form-view-action-${relation}`],
|
|
5581
|
-
enabled: false
|
|
5549
|
+
const searchControllers = searchController({
|
|
5550
|
+
viewData: viewResponse,
|
|
5551
|
+
model: relation ?? "",
|
|
5552
|
+
context: contextObject,
|
|
5553
|
+
domain,
|
|
5554
|
+
fieldsList: [
|
|
5555
|
+
...columns?.filter(
|
|
5556
|
+
(col) => col?.field?.type_co === "field" && col?.optional !== "hide"
|
|
5557
|
+
)?.map((col) => ({ ...col.field })) ?? []
|
|
5558
|
+
]
|
|
5582
5559
|
});
|
|
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
|
-
(0, import_react15.useEffect)(() => {
|
|
5590
|
-
if (domainMany2Many && !isLoadedData) {
|
|
5591
|
-
setIsLoadedData(true);
|
|
5592
|
-
}
|
|
5593
|
-
}, [domainMany2Many]);
|
|
5594
5560
|
const handleCreateNewOnPage = async () => {
|
|
5595
|
-
try {
|
|
5596
|
-
refetch();
|
|
5597
|
-
} catch (error) {
|
|
5598
|
-
console.log(error);
|
|
5599
|
-
}
|
|
5600
5561
|
};
|
|
5601
5562
|
return {
|
|
5602
5563
|
handleCreateNewOnPage,
|
|
5603
5564
|
optionsObject,
|
|
5565
|
+
totalRows: dataResponse?.length ?? 0,
|
|
5604
5566
|
rows,
|
|
5605
5567
|
columns,
|
|
5568
|
+
onToggleColumnOptional,
|
|
5606
5569
|
typeTable,
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
isPlaceholderData
|
|
5570
|
+
isLoading,
|
|
5571
|
+
isFetched,
|
|
5572
|
+
isPlaceholderData,
|
|
5573
|
+
setPage,
|
|
5574
|
+
page,
|
|
5575
|
+
viewData: viewResponse,
|
|
5576
|
+
domain: domainMany2Many,
|
|
5577
|
+
setDomain: setDomainMany2Many,
|
|
5578
|
+
searchController: searchControllers
|
|
5610
5579
|
};
|
|
5611
5580
|
};
|
|
5612
5581
|
|
|
5613
5582
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5614
5583
|
var import_react16 = require("react");
|
|
5615
5584
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5585
|
+
var import_environment7 = require("@fctc/interface-logic/environment");
|
|
5586
|
+
var import_hooks14 = require("@fctc/interface-logic/hooks");
|
|
5616
5587
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5617
5588
|
var many2manyTagsController = (props) => {
|
|
5618
5589
|
const {
|
|
@@ -5624,8 +5595,7 @@ var many2manyTagsController = (props) => {
|
|
|
5624
5595
|
placeholderNoOption
|
|
5625
5596
|
} = props;
|
|
5626
5597
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5627
|
-
const
|
|
5628
|
-
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5598
|
+
const env = (0, import_environment7.getEnv)();
|
|
5629
5599
|
const addtionalFields = optionsFields ? (0, import_utils7.evalJSONContext)(optionsFields) : null;
|
|
5630
5600
|
const domainObject = (0, import_react16.useMemo)(
|
|
5631
5601
|
() => (0, import_utils7.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
@@ -5644,7 +5614,7 @@ var many2manyTagsController = (props) => {
|
|
|
5644
5614
|
enabled: true,
|
|
5645
5615
|
context: env.context
|
|
5646
5616
|
};
|
|
5647
|
-
const { data: dataOfSelection } =
|
|
5617
|
+
const { data: dataOfSelection } = (0, import_hooks14.useGetSelection)({
|
|
5648
5618
|
data,
|
|
5649
5619
|
queryKey: [`data_${relation}`, domainObject]
|
|
5650
5620
|
});
|
|
@@ -5664,6 +5634,7 @@ var many2manyTagsController = (props) => {
|
|
|
5664
5634
|
options,
|
|
5665
5635
|
customNoOptionsMessage,
|
|
5666
5636
|
tranfer,
|
|
5637
|
+
dataOfSelection,
|
|
5667
5638
|
isUser
|
|
5668
5639
|
};
|
|
5669
5640
|
};
|
|
@@ -5672,7 +5643,7 @@ var many2manyTagsController = (props) => {
|
|
|
5672
5643
|
var import_react17 = require("react");
|
|
5673
5644
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5674
5645
|
var durationController = (props) => {
|
|
5675
|
-
const { relation, domain, formValues, name, id, model, onRefetch
|
|
5646
|
+
const { relation, domain, formValues, name, id, model, onRefetch } = props;
|
|
5676
5647
|
const specification = {
|
|
5677
5648
|
id: 0,
|
|
5678
5649
|
name: "",
|
|
@@ -5696,11 +5667,7 @@ var durationController = (props) => {
|
|
|
5696
5667
|
},
|
|
5697
5668
|
sort: ""
|
|
5698
5669
|
};
|
|
5699
|
-
const { data: dataResponse } = useGetListData3(
|
|
5700
|
-
listDataProps,
|
|
5701
|
-
queryKey,
|
|
5702
|
-
enabled
|
|
5703
|
-
);
|
|
5670
|
+
const { data: dataResponse } = useGetListData3(listDataProps, queryKey);
|
|
5704
5671
|
const { mutate: fetchChangeStatus } = useChangeStatus();
|
|
5705
5672
|
const handleClick = async (stage_id) => {
|
|
5706
5673
|
setDisabled(true);
|
|
@@ -5736,18 +5703,32 @@ var durationController = (props) => {
|
|
|
5736
5703
|
};
|
|
5737
5704
|
|
|
5738
5705
|
// src/widget/basic/priority-field/controller.ts
|
|
5706
|
+
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
5739
5707
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5740
5708
|
var priorityFieldController = (props) => {
|
|
5741
|
-
const {
|
|
5709
|
+
const {
|
|
5710
|
+
value,
|
|
5711
|
+
isForm,
|
|
5712
|
+
name,
|
|
5713
|
+
methods,
|
|
5714
|
+
onChange,
|
|
5715
|
+
model,
|
|
5716
|
+
selection,
|
|
5717
|
+
id,
|
|
5718
|
+
actionData,
|
|
5719
|
+
viewData,
|
|
5720
|
+
context
|
|
5721
|
+
} = props;
|
|
5742
5722
|
const _context = { ...(0, import_utils9.evalJSONContext)(actionData?.context) };
|
|
5743
5723
|
const contextObject = { ...context, ..._context };
|
|
5744
|
-
const
|
|
5745
|
-
const
|
|
5724
|
+
const defaultPriority = parseInt(value) + 1;
|
|
5725
|
+
const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
|
|
5726
|
+
const { mutateAsync: fetchSave } = (0, import_hooks15.useSave)();
|
|
5746
5727
|
const savePriorities = async ({
|
|
5747
|
-
value,
|
|
5728
|
+
value: value2,
|
|
5748
5729
|
resetPriority
|
|
5749
5730
|
}) => {
|
|
5750
|
-
const priorityValue =
|
|
5731
|
+
const priorityValue = value2 <= 0 ? 0 : value2 - 1;
|
|
5751
5732
|
try {
|
|
5752
5733
|
fetchSave({
|
|
5753
5734
|
ids: id ? [id] : [],
|
|
@@ -5765,7 +5746,14 @@ var priorityFieldController = (props) => {
|
|
|
5765
5746
|
}
|
|
5766
5747
|
};
|
|
5767
5748
|
return {
|
|
5768
|
-
|
|
5749
|
+
selection,
|
|
5750
|
+
isForm,
|
|
5751
|
+
methods,
|
|
5752
|
+
defaultPriority,
|
|
5753
|
+
savePriorities,
|
|
5754
|
+
label,
|
|
5755
|
+
id,
|
|
5756
|
+
onChange
|
|
5769
5757
|
};
|
|
5770
5758
|
};
|
|
5771
5759
|
|
|
@@ -6728,11 +6716,11 @@ var import_utils11 = require("@fctc/interface-logic/utils");
|
|
|
6728
6716
|
var colorFieldController = (props) => {
|
|
6729
6717
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6730
6718
|
const { env } = (0, provider_exports.useEnv)();
|
|
6731
|
-
const { useSave:
|
|
6719
|
+
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
6732
6720
|
const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) || {} };
|
|
6733
6721
|
const contextObject = { ...env.context, ..._context };
|
|
6734
6722
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6735
|
-
const { mutate: onSave } =
|
|
6723
|
+
const { mutate: onSave } = useSave3();
|
|
6736
6724
|
const savePickColor = async (colorObject) => {
|
|
6737
6725
|
const { id } = colorObject;
|
|
6738
6726
|
if (value === id) return;
|
|
@@ -6855,20 +6843,20 @@ var binaryFieldController = (props) => {
|
|
|
6855
6843
|
};
|
|
6856
6844
|
|
|
6857
6845
|
// src/widget/advance/table/table-body/controller.ts
|
|
6858
|
-
var
|
|
6846
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6859
6847
|
var import_react21 = require("react");
|
|
6860
6848
|
var tableBodyController = (props) => {
|
|
6861
6849
|
const {
|
|
6862
6850
|
checkedAll,
|
|
6863
6851
|
checkboxRef,
|
|
6864
6852
|
setIsAutoSelect,
|
|
6853
|
+
selectedRowKeys,
|
|
6865
6854
|
row,
|
|
6866
6855
|
isAutoSelect,
|
|
6867
6856
|
selectedRowKeysRef,
|
|
6868
6857
|
onClickRow
|
|
6869
6858
|
} = props;
|
|
6870
|
-
const appDispatch = (0,
|
|
6871
|
-
const { selectedRowKeys } = (0, import_store9.useAppSelector)(import_store9.selectList);
|
|
6859
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
6872
6860
|
const checked = (0, import_react21.useMemo)(() => {
|
|
6873
6861
|
if (!row?.id) return false;
|
|
6874
6862
|
if (selectedRowKeys?.includes(row.id)) {
|
|
@@ -6884,7 +6872,8 @@ var tableBodyController = (props) => {
|
|
|
6884
6872
|
return;
|
|
6885
6873
|
}
|
|
6886
6874
|
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6887
|
-
|
|
6875
|
+
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6876
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6888
6877
|
};
|
|
6889
6878
|
const handleClickRow = (col, row2) => {
|
|
6890
6879
|
onClickRow(col, row2);
|
|
@@ -6897,13 +6886,13 @@ var tableBodyController = (props) => {
|
|
|
6897
6886
|
(id) => id !== row.id
|
|
6898
6887
|
);
|
|
6899
6888
|
selectedRowKeysRef.current = filtered;
|
|
6900
|
-
appDispatch((0,
|
|
6889
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(filtered));
|
|
6901
6890
|
} else {
|
|
6902
6891
|
const unique = Array.from(
|
|
6903
6892
|
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6904
6893
|
);
|
|
6905
6894
|
selectedRowKeysRef.current = unique;
|
|
6906
|
-
appDispatch((0,
|
|
6895
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(unique));
|
|
6907
6896
|
}
|
|
6908
6897
|
}
|
|
6909
6898
|
}, [isAutoSelect]);
|
|
@@ -6921,35 +6910,35 @@ var tableBodyController = (props) => {
|
|
|
6921
6910
|
};
|
|
6922
6911
|
|
|
6923
6912
|
// src/widget/advance/table/table-head/controller.ts
|
|
6924
|
-
var
|
|
6913
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6925
6914
|
var tableHeadController = (props) => {
|
|
6926
6915
|
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6927
|
-
const appDispatch = (0,
|
|
6928
|
-
const { groupByDomain } = (0,
|
|
6916
|
+
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6917
|
+
const { groupByDomain } = (0, import_store9.useAppSelector)(import_store9.selectSearch);
|
|
6929
6918
|
const handleCheckBoxAll = (event) => {
|
|
6930
6919
|
if (event?.target?.checked && typeTable === "list") {
|
|
6931
6920
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6932
|
-
appDispatch((0,
|
|
6921
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(allRowKeys));
|
|
6933
6922
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6934
6923
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6935
6924
|
const ids = Array.from(rowsIDs)?.map(
|
|
6936
6925
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6937
6926
|
);
|
|
6938
6927
|
if (ids?.length > 0) {
|
|
6939
|
-
appDispatch((0,
|
|
6928
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(ids));
|
|
6940
6929
|
} else {
|
|
6941
6930
|
const sum = countSum(
|
|
6942
6931
|
rows,
|
|
6943
6932
|
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6944
6933
|
);
|
|
6945
6934
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6946
|
-
appDispatch((0,
|
|
6935
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(keys));
|
|
6947
6936
|
}
|
|
6948
6937
|
if (selectedRowKeysRef) {
|
|
6949
6938
|
selectedRowKeysRef.current = [];
|
|
6950
6939
|
}
|
|
6951
6940
|
} else {
|
|
6952
|
-
appDispatch((0,
|
|
6941
|
+
appDispatch((0, import_store9.setSelectedRowKeys)([]));
|
|
6953
6942
|
}
|
|
6954
6943
|
};
|
|
6955
6944
|
return {
|
|
@@ -6959,7 +6948,7 @@ var tableHeadController = (props) => {
|
|
|
6959
6948
|
|
|
6960
6949
|
// src/widget/advance/table/table-view/controller.ts
|
|
6961
6950
|
var import_react22 = require("react");
|
|
6962
|
-
var
|
|
6951
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
6963
6952
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6964
6953
|
var tableController = ({ data }) => {
|
|
6965
6954
|
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
@@ -7038,8 +7027,8 @@ var tableController = ({ data }) => {
|
|
|
7038
7027
|
|
|
7039
7028
|
// src/widget/advance/table/table-group/controller.ts
|
|
7040
7029
|
var import_react23 = require("react");
|
|
7041
|
-
var
|
|
7042
|
-
var
|
|
7030
|
+
var import_hooks16 = require("@fctc/interface-logic/hooks");
|
|
7031
|
+
var import_store11 = require("@fctc/interface-logic/store");
|
|
7043
7032
|
|
|
7044
7033
|
// src/environment.ts
|
|
7045
7034
|
var environment_exports = {};
|
|
@@ -7067,10 +7056,10 @@ var tableGroupController = (props) => {
|
|
|
7067
7056
|
selectedRowKeysRef
|
|
7068
7057
|
} = props;
|
|
7069
7058
|
const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
|
|
7070
|
-
const { groupByDomain, selectedTags } = (0,
|
|
7071
|
-
const { selectedRowKeys } = (0,
|
|
7072
|
-
const appDispatch = (0,
|
|
7073
|
-
const { toDataJS } = (0,
|
|
7059
|
+
const { groupByDomain, selectedTags } = (0, import_store11.useAppSelector)(import_store11.selectSearch);
|
|
7060
|
+
const { selectedRowKeys } = (0, import_store11.useAppSelector)(import_store11.selectList);
|
|
7061
|
+
const appDispatch = (0, import_store11.useAppDispatch)();
|
|
7062
|
+
const { toDataJS } = (0, import_hooks16.useOdooDataTransform)();
|
|
7074
7063
|
const initVal = toDataJS(row, viewData, model);
|
|
7075
7064
|
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
7076
7065
|
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
@@ -7117,7 +7106,7 @@ var tableGroupController = (props) => {
|
|
|
7117
7106
|
isPlaceholderData,
|
|
7118
7107
|
isLoading,
|
|
7119
7108
|
isFetching
|
|
7120
|
-
} = (0,
|
|
7109
|
+
} = (0, import_hooks16.useGetListData)(listDataProps, queryKey, enabled);
|
|
7121
7110
|
const {
|
|
7122
7111
|
columns: columnsGroup,
|
|
7123
7112
|
rows: rowsGroup,
|
|
@@ -7155,14 +7144,14 @@ var tableGroupController = (props) => {
|
|
|
7155
7144
|
const filteredIds = selectedRowKeys.filter(
|
|
7156
7145
|
(id) => !ids.includes(id)
|
|
7157
7146
|
);
|
|
7158
|
-
appDispatch((0,
|
|
7147
|
+
appDispatch((0, import_store11.setSelectedRowKeys)(filteredIds));
|
|
7159
7148
|
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
7160
7149
|
const clonedKeys = [...selectedRowKeys];
|
|
7161
|
-
appDispatch((0,
|
|
7162
|
-
setTimeout(() => appDispatch((0,
|
|
7150
|
+
appDispatch((0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
7151
|
+
setTimeout(() => appDispatch((0, import_store11.setSelectedRowKeys)(clonedKeys)), 500);
|
|
7163
7152
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7164
7153
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7165
|
-
appDispatch((0,
|
|
7154
|
+
appDispatch((0, import_store11.setSelectedRowKeys)(filteredKeys));
|
|
7166
7155
|
}
|
|
7167
7156
|
toggleShowGroup();
|
|
7168
7157
|
};
|
|
@@ -7171,8 +7160,8 @@ var tableGroupController = (props) => {
|
|
|
7171
7160
|
return;
|
|
7172
7161
|
}
|
|
7173
7162
|
const clonedKeys = [...selectedRowKeys];
|
|
7174
|
-
(0,
|
|
7175
|
-
setTimeout(() => (0,
|
|
7163
|
+
(0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
7164
|
+
setTimeout(() => (0, import_store11.setSelectedRowKeys)(clonedKeys), 500);
|
|
7176
7165
|
}, [isQueryFetched]);
|
|
7177
7166
|
return {
|
|
7178
7167
|
handleExpandChildGroup,
|
|
@@ -7212,20 +7201,21 @@ var import_moment2 = __toESM(require_moment());
|
|
|
7212
7201
|
var import_react24 = require("react");
|
|
7213
7202
|
var searchController = ({
|
|
7214
7203
|
viewData,
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
searchMap
|
|
7204
|
+
model,
|
|
7205
|
+
domain,
|
|
7206
|
+
context,
|
|
7207
|
+
fieldsList
|
|
7220
7208
|
}) => {
|
|
7209
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
7221
7210
|
const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
|
|
7222
7211
|
const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
|
|
7223
7212
|
const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
|
|
7224
7213
|
const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
|
|
7225
7214
|
const [searchString, setSearchString] = (0, import_react24.useState)("");
|
|
7226
|
-
const
|
|
7227
|
-
const
|
|
7228
|
-
const
|
|
7215
|
+
const [searchMap, setSearchMap] = (0, import_react24.useState)({});
|
|
7216
|
+
const actionContext = typeof context === "string" ? (0, import_utils14.evalJSONContext)(context) : context;
|
|
7217
|
+
const contextSearch = { ...env.context, ...actionContext };
|
|
7218
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils14.evalJSONDomain)(domain, contextSearch) : [];
|
|
7229
7219
|
const clearSearch = () => {
|
|
7230
7220
|
setFilterBy([]);
|
|
7231
7221
|
setGroupBy([]);
|
|
@@ -7270,9 +7260,8 @@ var searchController = ({
|
|
|
7270
7260
|
}
|
|
7271
7261
|
};
|
|
7272
7262
|
(0, import_react24.useEffect)(() => {
|
|
7273
|
-
clearSearch();
|
|
7274
7263
|
fetchData();
|
|
7275
|
-
}, [
|
|
7264
|
+
}, [model, viewData]);
|
|
7276
7265
|
const onChangeSearchInput = (search_string) => {
|
|
7277
7266
|
setSearchString(search_string);
|
|
7278
7267
|
};
|
|
@@ -7309,27 +7298,27 @@ var searchController = ({
|
|
|
7309
7298
|
};
|
|
7310
7299
|
const formatDomain = () => {
|
|
7311
7300
|
if (domainAction) {
|
|
7312
|
-
const
|
|
7301
|
+
const domain2 = [];
|
|
7313
7302
|
if (domainAction?.length > 0) {
|
|
7314
|
-
if (Object.keys(searchMap).
|
|
7315
|
-
|
|
7303
|
+
if (Object.keys(searchMap).some((key) => !key.includes(import_constants5.SearchType.GROUP))) {
|
|
7304
|
+
domain2.push("&");
|
|
7316
7305
|
}
|
|
7317
7306
|
domainAction.forEach((domainItem) => {
|
|
7318
|
-
|
|
7307
|
+
domain2.push(domainItem);
|
|
7319
7308
|
});
|
|
7320
7309
|
}
|
|
7321
7310
|
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
7322
7311
|
if (!key?.includes(import_constants5.SearchType.GROUP)) {
|
|
7323
7312
|
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
7324
|
-
|
|
7313
|
+
domain2.push("&");
|
|
7325
7314
|
}
|
|
7326
7315
|
const valuesOfKey = searchMap[key];
|
|
7327
7316
|
valuesOfKey.forEach((value, index) => {
|
|
7328
7317
|
if (index < valuesOfKey.length - 1) {
|
|
7329
|
-
|
|
7318
|
+
domain2.push("|");
|
|
7330
7319
|
}
|
|
7331
7320
|
if (value.domain) {
|
|
7332
|
-
|
|
7321
|
+
domain2.push(...value.domain);
|
|
7333
7322
|
return;
|
|
7334
7323
|
}
|
|
7335
7324
|
let valueDomainItem = value?.value;
|
|
@@ -7345,11 +7334,11 @@ var searchController = ({
|
|
|
7345
7334
|
}
|
|
7346
7335
|
}
|
|
7347
7336
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
7348
|
-
|
|
7337
|
+
domain2.push([value.name, operator, valueDomainItem]);
|
|
7349
7338
|
});
|
|
7350
7339
|
}
|
|
7351
7340
|
});
|
|
7352
|
-
return [...
|
|
7341
|
+
return [...domain2];
|
|
7353
7342
|
}
|
|
7354
7343
|
};
|
|
7355
7344
|
const setTagSearch = (0, import_react24.useCallback)(
|
|
@@ -7380,16 +7369,16 @@ var searchController = ({
|
|
|
7380
7369
|
const contexts = [];
|
|
7381
7370
|
let groupValues = [];
|
|
7382
7371
|
objValues?.forEach((objValue) => {
|
|
7383
|
-
const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7372
|
+
const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7384
7373
|
const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
|
|
7385
7374
|
contexts.push(
|
|
7386
|
-
...Array.isArray(
|
|
7375
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
|
|
7387
7376
|
);
|
|
7388
7377
|
groupValues[indexAppend] = {
|
|
7389
7378
|
contexts: [
|
|
7390
|
-
...Array.isArray(
|
|
7379
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
|
|
7391
7380
|
group_by: item
|
|
7392
|
-
})) : [
|
|
7381
|
+
})) : [context2]
|
|
7393
7382
|
],
|
|
7394
7383
|
strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
|
|
7395
7384
|
};
|
|
@@ -7416,39 +7405,38 @@ var searchController = ({
|
|
|
7416
7405
|
[searchMap]
|
|
7417
7406
|
);
|
|
7418
7407
|
(0, import_react24.useEffect)(() => {
|
|
7419
|
-
setSelectedTags(null);
|
|
7420
7408
|
setTagSearch(searchMap);
|
|
7421
7409
|
}, [searchMap]);
|
|
7422
7410
|
const handleAddTagSearch = (tag) => {
|
|
7423
7411
|
const {
|
|
7424
|
-
domain,
|
|
7412
|
+
domain: domain2,
|
|
7425
7413
|
groupIndex,
|
|
7426
7414
|
value,
|
|
7427
7415
|
type,
|
|
7428
7416
|
title,
|
|
7429
|
-
context,
|
|
7417
|
+
context: context2,
|
|
7430
7418
|
active,
|
|
7431
7419
|
dataIndex
|
|
7432
7420
|
} = tag;
|
|
7433
|
-
const domainFormat = new import_utils14.domainHelper.Domain(
|
|
7421
|
+
const domainFormat = new import_utils14.domainHelper.Domain(domain2);
|
|
7434
7422
|
if (type === import_constants5.SearchType.FILTER) {
|
|
7435
7423
|
addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
|
|
7436
7424
|
...tag,
|
|
7437
|
-
domain:
|
|
7425
|
+
domain: domain2 ? domainFormat.toList(context2) : null
|
|
7438
7426
|
});
|
|
7439
7427
|
} else if (type === import_constants5.SearchType.SEARCH) {
|
|
7440
7428
|
addSearchItems(`${import_constants5.SearchType.SEARCH}_${String(dataIndex)}`, {
|
|
7441
7429
|
...tag,
|
|
7442
|
-
domain:
|
|
7443
|
-
...
|
|
7430
|
+
domain: domain2 ? domainFormat.toList({
|
|
7431
|
+
...context2,
|
|
7444
7432
|
self: value
|
|
7445
7433
|
}) : null
|
|
7446
7434
|
});
|
|
7447
7435
|
} else if (type === import_constants5.SearchType.GROUP) {
|
|
7448
7436
|
addSearchItems(`${import_constants5.SearchType.GROUP}`, {
|
|
7449
7437
|
...tag,
|
|
7450
|
-
domain:
|
|
7451
|
-
context,
|
|
7438
|
+
domain: domain2 ? domainFormat.toList({
|
|
7439
|
+
context: context2,
|
|
7452
7440
|
self: value
|
|
7453
7441
|
}) : null
|
|
7454
7442
|
});
|
|
@@ -7468,7 +7456,8 @@ var searchController = ({
|
|
|
7468
7456
|
removeSearchItems,
|
|
7469
7457
|
onSearchString: onChangeSearchInput,
|
|
7470
7458
|
handleAddTagSearch,
|
|
7471
|
-
domain: formatDomain()
|
|
7459
|
+
domain: formatDomain(),
|
|
7460
|
+
context: contextSearch
|
|
7472
7461
|
};
|
|
7473
7462
|
};
|
|
7474
7463
|
|