@fctc/widget-logic 2.0.8 → 2.0.10
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 +12 -1
- package/dist/hooks.d.ts +12 -1
- package/dist/hooks.js +179 -6
- package/dist/hooks.mjs +179 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +256 -310
- package/dist/index.mjs +229 -292
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/widget.d.mts +46 -34
- package/dist/widget.d.ts +46 -34
- package/dist/widget.js +246 -302
- package/dist/widget.mjs +223 -287
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4068,7 +4068,6 @@ __export(index_exports, {
|
|
|
4068
4068
|
searchController: () => searchController,
|
|
4069
4069
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4070
4070
|
statusDropdownController: () => statusDropdownController,
|
|
4071
|
-
tableBodyController: () => tableBodyController,
|
|
4072
4071
|
tableController: () => tableController,
|
|
4073
4072
|
tableGroupController: () => tableGroupController,
|
|
4074
4073
|
tableHeadController: () => tableHeadController,
|
|
@@ -4082,6 +4081,7 @@ __export(index_exports, {
|
|
|
4082
4081
|
useGetRowIds: () => useGetRowIds,
|
|
4083
4082
|
useListData: () => useListData,
|
|
4084
4083
|
useMenu: () => useMenu,
|
|
4084
|
+
useMenuItem: () => useMenuItem,
|
|
4085
4085
|
useProfile: () => useProfile,
|
|
4086
4086
|
useSelectionState: () => useSelectionState,
|
|
4087
4087
|
useStorageState: () => useStorageState,
|
|
@@ -4103,6 +4103,7 @@ __export(hooks_exports, {
|
|
|
4103
4103
|
useDetail: () => useDetail,
|
|
4104
4104
|
useListData: () => useListData,
|
|
4105
4105
|
useMenu: () => useMenu,
|
|
4106
|
+
useMenuItem: () => useMenuItem,
|
|
4106
4107
|
useProfile: () => useProfile,
|
|
4107
4108
|
useUser: () => useUser,
|
|
4108
4109
|
useViewV2: () => useViewV2
|
|
@@ -4862,8 +4863,69 @@ var useAppProvider = () => {
|
|
|
4862
4863
|
return context;
|
|
4863
4864
|
};
|
|
4864
4865
|
|
|
4865
|
-
// src/hooks/
|
|
4866
|
+
// src/hooks/core/use-menu-item.tsx
|
|
4867
|
+
var import_environment5 = require("@fctc/interface-logic/environment");
|
|
4868
|
+
var import_hooks9 = require("@fctc/interface-logic/hooks");
|
|
4866
4869
|
var import_react11 = require("react");
|
|
4870
|
+
|
|
4871
|
+
// src/utils.ts
|
|
4872
|
+
var utils_exports = {};
|
|
4873
|
+
__export(utils_exports, {
|
|
4874
|
+
API_APP_URL: () => API_APP_URL,
|
|
4875
|
+
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
4876
|
+
STORAGES: () => STORAGES,
|
|
4877
|
+
combineContexts: () => combineContexts,
|
|
4878
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
4879
|
+
countSum: () => countSum,
|
|
4880
|
+
getDateRange: () => getDateRange,
|
|
4881
|
+
languages: () => languages,
|
|
4882
|
+
mergeButtons: () => mergeButtons,
|
|
4883
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
4884
|
+
useGetRowIds: () => useGetRowIds,
|
|
4885
|
+
useSelectionState: () => useSelectionState,
|
|
4886
|
+
useStorageState: () => useStorageState
|
|
4887
|
+
});
|
|
4888
|
+
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
4889
|
+
|
|
4890
|
+
// src/hooks/core/use-menu-item.tsx
|
|
4891
|
+
var useMenuItem = (props) => {
|
|
4892
|
+
const { menu, activeMenuId } = props;
|
|
4893
|
+
const model = menu?.action?.res_model;
|
|
4894
|
+
const aid = menu?.action?.id?.id;
|
|
4895
|
+
const id = menu?.id;
|
|
4896
|
+
const context = (0, import_environment5.getEnv)().context;
|
|
4897
|
+
const queryActionDetail = (0, import_hooks9.useGetActionDetail)({
|
|
4898
|
+
aid,
|
|
4899
|
+
id,
|
|
4900
|
+
model,
|
|
4901
|
+
context,
|
|
4902
|
+
enabled: true,
|
|
4903
|
+
queryKey: [`action-${aid}`]
|
|
4904
|
+
}).data;
|
|
4905
|
+
const [path, setPath] = (0, import_react11.useState)("");
|
|
4906
|
+
const handleClick = () => {
|
|
4907
|
+
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
4908
|
+
return;
|
|
4909
|
+
}
|
|
4910
|
+
const hasListView = queryActionDetail.views.some(
|
|
4911
|
+
([id2, type]) => type === "list"
|
|
4912
|
+
);
|
|
4913
|
+
const viewType = hasListView ? "list" : "form";
|
|
4914
|
+
const isAccountPayment = menu?.action?.res_model === "account.payment" && menu?.action?.id?.id === 1551;
|
|
4915
|
+
const isConvertCurrencyMenu = menu?.action?.res_model === "currency.convert" && menu?.action?.id?.id === 1562;
|
|
4916
|
+
const path2 = (0, utils_exports.formatUrlPath)({
|
|
4917
|
+
viewType,
|
|
4918
|
+
actionPath: isConvertCurrencyMenu ? "menu" : isAccountPayment ? "menu" : menu?.action?.path || "menu",
|
|
4919
|
+
aid: menu?.action?.id?.id,
|
|
4920
|
+
model: queryActionDetail.res_model
|
|
4921
|
+
});
|
|
4922
|
+
setPath(path2);
|
|
4923
|
+
};
|
|
4924
|
+
return { handleClick, path, queryActionDetail };
|
|
4925
|
+
};
|
|
4926
|
+
|
|
4927
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4928
|
+
var import_react12 = require("react");
|
|
4867
4929
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4868
4930
|
var useClickOutside = ({
|
|
4869
4931
|
handler,
|
|
@@ -4871,8 +4933,8 @@ var useClickOutside = ({
|
|
|
4871
4933
|
nodes = [],
|
|
4872
4934
|
refs
|
|
4873
4935
|
}) => {
|
|
4874
|
-
const ref = (0,
|
|
4875
|
-
(0,
|
|
4936
|
+
const ref = (0, import_react12.useRef)(null);
|
|
4937
|
+
(0, import_react12.useEffect)(() => {
|
|
4876
4938
|
const listener = (event) => {
|
|
4877
4939
|
const { target } = event;
|
|
4878
4940
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4894,10 +4956,10 @@ var useClickOutside = ({
|
|
|
4894
4956
|
};
|
|
4895
4957
|
|
|
4896
4958
|
// src/hooks/utils/use-debounce.ts
|
|
4897
|
-
var
|
|
4959
|
+
var import_react13 = require("react");
|
|
4898
4960
|
function useDebounce(value, delay) {
|
|
4899
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4900
|
-
(0,
|
|
4961
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react13.useState)(value);
|
|
4962
|
+
(0, import_react13.useEffect)(() => {
|
|
4901
4963
|
const handler = setTimeout(() => {
|
|
4902
4964
|
setDebouncedValue(value);
|
|
4903
4965
|
}, delay);
|
|
@@ -5152,20 +5214,20 @@ var ChevronBottomIcon = ({
|
|
|
5152
5214
|
};
|
|
5153
5215
|
|
|
5154
5216
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
5155
|
-
var
|
|
5156
|
-
var
|
|
5157
|
-
var
|
|
5217
|
+
var import_react14 = require("react");
|
|
5218
|
+
var import_environment6 = require("@fctc/interface-logic/environment");
|
|
5219
|
+
var import_hooks11 = require("@fctc/interface-logic/hooks");
|
|
5158
5220
|
var statusDropdownController = (props) => {
|
|
5159
5221
|
const { selection, isForm, id, model, name, state, onRefetch } = props;
|
|
5160
|
-
const env = (0,
|
|
5222
|
+
const env = (0, import_environment6.getEnv)();
|
|
5161
5223
|
const colors = {
|
|
5162
5224
|
normal: "bg-[#e9ecef]",
|
|
5163
5225
|
done: "bg-primary",
|
|
5164
5226
|
blocked: "bg-red-500"
|
|
5165
5227
|
};
|
|
5166
|
-
const [isOpen, setIsOpen] = (0,
|
|
5167
|
-
const buttonRef = (0,
|
|
5168
|
-
(0,
|
|
5228
|
+
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
5229
|
+
const buttonRef = (0, import_react14.useRef)(null);
|
|
5230
|
+
(0, import_react14.useEffect)(() => {
|
|
5169
5231
|
const handleClickOutside = (event) => {
|
|
5170
5232
|
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
5171
5233
|
setIsOpen(false);
|
|
@@ -5176,7 +5238,7 @@ var statusDropdownController = (props) => {
|
|
|
5176
5238
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
5177
5239
|
};
|
|
5178
5240
|
}, []);
|
|
5179
|
-
const { mutate: onSave } = (0,
|
|
5241
|
+
const { mutate: onSave } = (0, import_hooks11.useSave)();
|
|
5180
5242
|
const handleClick = async (status) => {
|
|
5181
5243
|
setIsOpen(!isOpen);
|
|
5182
5244
|
onSave(
|
|
@@ -5206,26 +5268,7 @@ var statusDropdownController = (props) => {
|
|
|
5206
5268
|
};
|
|
5207
5269
|
|
|
5208
5270
|
// src/widget/basic/many2one-field/controller.ts
|
|
5209
|
-
var
|
|
5210
|
-
|
|
5211
|
-
// src/utils.ts
|
|
5212
|
-
var utils_exports = {};
|
|
5213
|
-
__export(utils_exports, {
|
|
5214
|
-
API_APP_URL: () => API_APP_URL,
|
|
5215
|
-
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
5216
|
-
STORAGES: () => STORAGES,
|
|
5217
|
-
combineContexts: () => combineContexts,
|
|
5218
|
-
convertFieldsToArray: () => convertFieldsToArray,
|
|
5219
|
-
countSum: () => countSum,
|
|
5220
|
-
getDateRange: () => getDateRange,
|
|
5221
|
-
languages: () => languages,
|
|
5222
|
-
mergeButtons: () => mergeButtons,
|
|
5223
|
-
setStorageItemAsync: () => setStorageItemAsync,
|
|
5224
|
-
useGetRowIds: () => useGetRowIds,
|
|
5225
|
-
useSelectionState: () => useSelectionState,
|
|
5226
|
-
useStorageState: () => useStorageState
|
|
5227
|
-
});
|
|
5228
|
-
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
5271
|
+
var import_react15 = require("react");
|
|
5229
5272
|
|
|
5230
5273
|
// src/provider.ts
|
|
5231
5274
|
var provider_exports = {};
|
|
@@ -5246,22 +5289,22 @@ var many2oneFieldController = (props) => {
|
|
|
5246
5289
|
options: fieldOptions,
|
|
5247
5290
|
showDetail
|
|
5248
5291
|
} = props;
|
|
5249
|
-
const
|
|
5250
|
-
const [
|
|
5292
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
5293
|
+
const [options, setOptions] = (0, import_react15.useState)([]);
|
|
5294
|
+
const [inputValue, setInputValue] = (0, import_react15.useState)("");
|
|
5251
5295
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
5252
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
5253
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
5254
|
-
const [domainModal, setDomainModal] = (0,
|
|
5255
|
-
const [domainObject, setDomainObject] = (0,
|
|
5296
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react15.useState)(false);
|
|
5297
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react15.useState)(null);
|
|
5298
|
+
const [domainModal, setDomainModal] = (0, import_react15.useState)(null);
|
|
5299
|
+
const [domainObject, setDomainObject] = (0, import_react15.useState)(null);
|
|
5256
5300
|
const actionData = sessionStorageUtils.getActionData();
|
|
5257
5301
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5258
|
-
const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
|
|
5259
5302
|
const initValue = methods?.getValues(name);
|
|
5260
5303
|
const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
|
|
5261
5304
|
const contextObject = {
|
|
5262
5305
|
...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
|
|
5263
5306
|
...fieldContext,
|
|
5264
|
-
...context
|
|
5307
|
+
...env?.context
|
|
5265
5308
|
};
|
|
5266
5309
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5267
5310
|
const data = {
|
|
@@ -5284,18 +5327,18 @@ var many2oneFieldController = (props) => {
|
|
|
5284
5327
|
queryKey,
|
|
5285
5328
|
enabled: false
|
|
5286
5329
|
});
|
|
5287
|
-
const selectOptions = (0,
|
|
5330
|
+
const selectOptions = (0, import_react15.useMemo)(() => {
|
|
5288
5331
|
return dataOfSelection?.records?.map((val) => ({
|
|
5289
5332
|
value: val?.id,
|
|
5290
5333
|
label: val?.display_name || val?.name
|
|
5291
5334
|
})) || [];
|
|
5292
5335
|
}, [dataOfSelection]);
|
|
5293
|
-
(0,
|
|
5336
|
+
(0, import_react15.useEffect)(() => {
|
|
5294
5337
|
setOptions(selectOptions);
|
|
5295
5338
|
setDomainModal(domainObject);
|
|
5296
5339
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5297
5340
|
}, [selectOptions]);
|
|
5298
|
-
(0,
|
|
5341
|
+
(0, import_react15.useEffect)(() => {
|
|
5299
5342
|
setDomainObject(
|
|
5300
5343
|
(0, utils_exports.evalJSONDomain)(
|
|
5301
5344
|
domain,
|
|
@@ -5303,7 +5346,7 @@ var many2oneFieldController = (props) => {
|
|
|
5303
5346
|
)
|
|
5304
5347
|
);
|
|
5305
5348
|
}, [domain, formValues]);
|
|
5306
|
-
(0,
|
|
5349
|
+
(0, import_react15.useEffect)(() => {
|
|
5307
5350
|
if (!propValue && tempSelectedOption) {
|
|
5308
5351
|
methods.setValue(name, null);
|
|
5309
5352
|
setTempSelectedOption(null);
|
|
@@ -5314,10 +5357,10 @@ var many2oneFieldController = (props) => {
|
|
|
5314
5357
|
});
|
|
5315
5358
|
}
|
|
5316
5359
|
}, [propValue]);
|
|
5317
|
-
const fetchMoreOptions = (0,
|
|
5360
|
+
const fetchMoreOptions = (0, import_react15.useCallback)(() => {
|
|
5318
5361
|
refetch();
|
|
5319
5362
|
}, [refetch]);
|
|
5320
|
-
(0,
|
|
5363
|
+
(0, import_react15.useEffect)(() => {
|
|
5321
5364
|
if (debouncedInputValue) {
|
|
5322
5365
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5323
5366
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5332,7 +5375,7 @@ var many2oneFieldController = (props) => {
|
|
|
5332
5375
|
}, 50);
|
|
5333
5376
|
}
|
|
5334
5377
|
}, [debouncedInputValue]);
|
|
5335
|
-
const handleChooseRecord = (0,
|
|
5378
|
+
const handleChooseRecord = (0, import_react15.useCallback)(
|
|
5336
5379
|
(idRecord) => {
|
|
5337
5380
|
const newOption = options.find(
|
|
5338
5381
|
(option) => option.value === idRecord
|
|
@@ -5357,8 +5400,8 @@ var many2oneFieldController = (props) => {
|
|
|
5357
5400
|
},
|
|
5358
5401
|
[options, methods, name, onChange]
|
|
5359
5402
|
);
|
|
5360
|
-
const handleClose = (0,
|
|
5361
|
-
const handleSelectChange = (0,
|
|
5403
|
+
const handleClose = (0, import_react15.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5404
|
+
const handleSelectChange = (0, import_react15.useCallback)(
|
|
5362
5405
|
(selectedOption) => {
|
|
5363
5406
|
if (!selectedOption) {
|
|
5364
5407
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5405,20 +5448,20 @@ var many2oneFieldController = (props) => {
|
|
|
5405
5448
|
};
|
|
5406
5449
|
|
|
5407
5450
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
5408
|
-
var
|
|
5409
|
-
var
|
|
5410
|
-
var
|
|
5451
|
+
var import_environment7 = require("@fctc/interface-logic/environment");
|
|
5452
|
+
var import_hooks13 = require("@fctc/interface-logic/hooks");
|
|
5453
|
+
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5411
5454
|
var many2oneButtonController = (props) => {
|
|
5412
5455
|
const { domain, methods, relation } = props;
|
|
5413
5456
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
5414
|
-
const env = (0,
|
|
5415
|
-
const domainObject = (0,
|
|
5457
|
+
const env = (0, import_environment7.getEnv)();
|
|
5458
|
+
const domainObject = (0, import_utils6.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
5416
5459
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
5417
|
-
const { data: dataOfSelection } = (0,
|
|
5460
|
+
const { data: dataOfSelection } = (0, import_hooks13.useGetSelection)({
|
|
5418
5461
|
data: {
|
|
5419
5462
|
model: relation ?? "",
|
|
5420
5463
|
domain: domainObject,
|
|
5421
|
-
context: { ...env.context, ...(0,
|
|
5464
|
+
context: { ...env.context, ...(0, import_utils6.evalJSONContext)(actionData?.context) }
|
|
5422
5465
|
},
|
|
5423
5466
|
queryKey: [`data_${relation}`, domainObject]
|
|
5424
5467
|
});
|
|
@@ -5432,91 +5475,77 @@ var many2oneButtonController = (props) => {
|
|
|
5432
5475
|
};
|
|
5433
5476
|
|
|
5434
5477
|
// src/widget/basic/many2many-field/controller.ts
|
|
5435
|
-
var
|
|
5436
|
-
var
|
|
5437
|
-
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5478
|
+
var import_react16 = require("react");
|
|
5479
|
+
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5438
5480
|
var many2manyFieldController = (props) => {
|
|
5439
5481
|
const {
|
|
5440
5482
|
relation,
|
|
5441
5483
|
domain,
|
|
5442
5484
|
context,
|
|
5485
|
+
options,
|
|
5443
5486
|
tab,
|
|
5444
|
-
|
|
5445
|
-
aid,
|
|
5446
|
-
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5447
|
-
fields,
|
|
5448
|
-
setFields,
|
|
5487
|
+
setSelectedRowKeys: setSelectedRowKeys3,
|
|
5449
5488
|
groupByDomain,
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
sessionStorageUtils
|
|
5489
|
+
enabled: enabledCallAPI,
|
|
5490
|
+
actionData
|
|
5453
5491
|
} = 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
5492
|
const { env } = (0, provider_exports.useEnv)();
|
|
5461
5493
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5494
|
+
const [order, setOrder] = (0, import_react16.useState)();
|
|
5495
|
+
const [page, setPage] = (0, import_react16.useState)(0);
|
|
5496
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(null);
|
|
5497
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
5498
|
+
const contextObject = {
|
|
5499
|
+
...env.context,
|
|
5500
|
+
...context || {}
|
|
5501
|
+
};
|
|
5462
5502
|
const viewParams = {
|
|
5463
5503
|
model: relation,
|
|
5464
5504
|
views: [
|
|
5465
5505
|
[false, "list"],
|
|
5466
5506
|
[false, "search"]
|
|
5467
5507
|
],
|
|
5468
|
-
context
|
|
5508
|
+
context: contextObject
|
|
5469
5509
|
};
|
|
5470
|
-
const { data: viewResponse } = useGetView2(viewParams,
|
|
5471
|
-
const baseModel = (0,
|
|
5510
|
+
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5511
|
+
const baseModel = (0, import_react16.useMemo)(
|
|
5472
5512
|
() => ({
|
|
5473
5513
|
name: String(relation),
|
|
5474
5514
|
view: viewResponse || {},
|
|
5475
|
-
actContext:
|
|
5515
|
+
actContext: contextObject,
|
|
5476
5516
|
fields: [
|
|
5477
5517
|
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
5478
5518
|
...tab?.fields ? tab.fields : []
|
|
5479
5519
|
]
|
|
5480
5520
|
}),
|
|
5481
|
-
[
|
|
5521
|
+
[relation, viewResponse]
|
|
5482
5522
|
);
|
|
5483
5523
|
const initModel = (0, hooks_exports.useModel)();
|
|
5484
|
-
const modelInstance = (0,
|
|
5524
|
+
const modelInstance = (0, import_react16.useMemo)(() => {
|
|
5485
5525
|
if (viewResponse) {
|
|
5486
5526
|
return initModel.initModel(baseModel);
|
|
5487
5527
|
}
|
|
5488
5528
|
return null;
|
|
5489
5529
|
}, [baseModel, viewResponse]);
|
|
5490
|
-
const specification = (0,
|
|
5530
|
+
const specification = (0, import_react16.useMemo)(() => {
|
|
5491
5531
|
if (modelInstance) {
|
|
5492
5532
|
return modelInstance.getSpecification();
|
|
5493
5533
|
}
|
|
5494
5534
|
return null;
|
|
5495
5535
|
}, [modelInstance]);
|
|
5496
5536
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5497
|
-
const optionsObject = tab?.options ? (0,
|
|
5537
|
+
const optionsObject = tab?.options ? (0, import_utils7.evalJSONContext)(tab?.options) : (options ? (0, import_utils7.evalJSONContext)(options) : {}) || {};
|
|
5498
5538
|
const fetchData = async () => {
|
|
5499
5539
|
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));
|
|
5540
|
+
const domainParse = typeof domain === "string" ? (0, import_utils7.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5541
|
+
setDomainMany2Many(domainParse);
|
|
5542
|
+
setPage(0);
|
|
5514
5543
|
} catch (err) {
|
|
5515
5544
|
console.log(err);
|
|
5516
5545
|
}
|
|
5517
5546
|
};
|
|
5518
5547
|
const queryKey = [
|
|
5519
|
-
`view-${relation}
|
|
5548
|
+
`view-${relation}`,
|
|
5520
5549
|
specification,
|
|
5521
5550
|
domainMany2Many,
|
|
5522
5551
|
debouncedPage,
|
|
@@ -5529,91 +5558,74 @@ var many2manyFieldController = (props) => {
|
|
|
5529
5558
|
domain: domainMany2Many,
|
|
5530
5559
|
offset: debouncedPage * 10,
|
|
5531
5560
|
limit: 10,
|
|
5532
|
-
context,
|
|
5561
|
+
context: contextObject,
|
|
5533
5562
|
fields: groupByDomain?.fields,
|
|
5534
5563
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5535
|
-
sort: order ? order : default_order ? (0,
|
|
5564
|
+
sort: order ? order : default_order ? (0, import_utils7.formatSortingString)(default_order) : ""
|
|
5536
5565
|
};
|
|
5537
|
-
const enabled =
|
|
5566
|
+
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5538
5567
|
const {
|
|
5539
5568
|
data: dataResponse,
|
|
5540
|
-
isLoading
|
|
5541
|
-
isFetched
|
|
5569
|
+
isLoading,
|
|
5570
|
+
isFetched,
|
|
5542
5571
|
isPlaceholderData
|
|
5543
5572
|
} = useGetListData3(data, queryKey, enabled);
|
|
5544
|
-
(0,
|
|
5573
|
+
(0, import_react16.useEffect)(() => {
|
|
5545
5574
|
if (viewResponse) {
|
|
5546
5575
|
fetchData();
|
|
5547
5576
|
}
|
|
5548
5577
|
return () => {
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
...prevFields,
|
|
5552
|
-
[`${aid}_${relation}_popupmany2many`]: null
|
|
5553
|
-
}));
|
|
5554
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5555
|
-
setSelectedRowKeys4([]);
|
|
5578
|
+
setPage(0);
|
|
5579
|
+
setSelectedRowKeys3([]);
|
|
5556
5580
|
setDomainMany2Many(null);
|
|
5557
|
-
setIsLoadedData(false);
|
|
5558
5581
|
};
|
|
5559
5582
|
}, [viewResponse]);
|
|
5560
|
-
const { rows, columns, typeTable } = tableController({
|
|
5583
|
+
const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
|
|
5561
5584
|
data: {
|
|
5562
|
-
fields:
|
|
5585
|
+
fields: viewResponse?.views?.list?.fields,
|
|
5563
5586
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
5564
5587
|
dataModel: viewResponse?.models?.[String(relation)],
|
|
5565
|
-
context:
|
|
5588
|
+
context: contextObject,
|
|
5566
5589
|
typeTable: dataResponse?.groups ? "group" : "list"
|
|
5567
5590
|
}
|
|
5568
5591
|
});
|
|
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
|
|
5592
|
+
const searchControllers = searchController({
|
|
5593
|
+
viewData: viewResponse,
|
|
5594
|
+
model: relation ?? "",
|
|
5595
|
+
context: contextObject,
|
|
5596
|
+
domain,
|
|
5597
|
+
fieldsList: [
|
|
5598
|
+
...columns?.filter(
|
|
5599
|
+
(col) => col?.field?.type_co === "field" && col?.optional !== "hide"
|
|
5600
|
+
)?.map((col) => ({ ...col.field })) ?? []
|
|
5601
|
+
]
|
|
5582
5602
|
});
|
|
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
5603
|
const handleCreateNewOnPage = async () => {
|
|
5595
|
-
try {
|
|
5596
|
-
refetch();
|
|
5597
|
-
} catch (error) {
|
|
5598
|
-
console.log(error);
|
|
5599
|
-
}
|
|
5600
5604
|
};
|
|
5601
5605
|
return {
|
|
5602
5606
|
handleCreateNewOnPage,
|
|
5603
5607
|
optionsObject,
|
|
5608
|
+
totalRows: dataResponse?.length ?? 0,
|
|
5604
5609
|
rows,
|
|
5605
5610
|
columns,
|
|
5611
|
+
onToggleColumnOptional,
|
|
5606
5612
|
typeTable,
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
isPlaceholderData
|
|
5613
|
+
isLoading,
|
|
5614
|
+
isFetched,
|
|
5615
|
+
isPlaceholderData,
|
|
5616
|
+
setPage,
|
|
5617
|
+
page,
|
|
5618
|
+
viewData: viewResponse,
|
|
5619
|
+
domain: domainMany2Many,
|
|
5620
|
+
setDomain: setDomainMany2Many,
|
|
5621
|
+
searchController: searchControllers
|
|
5610
5622
|
};
|
|
5611
5623
|
};
|
|
5612
5624
|
|
|
5613
5625
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5614
|
-
var
|
|
5626
|
+
var import_react17 = require("react");
|
|
5615
5627
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5616
|
-
var
|
|
5628
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5617
5629
|
var many2manyTagsController = (props) => {
|
|
5618
5630
|
const {
|
|
5619
5631
|
relation,
|
|
@@ -5626,9 +5638,9 @@ var many2manyTagsController = (props) => {
|
|
|
5626
5638
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5627
5639
|
const { env } = (0, provider_exports.useEnv)();
|
|
5628
5640
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5629
|
-
const addtionalFields = optionsFields ? (0,
|
|
5630
|
-
const domainObject = (0,
|
|
5631
|
-
() => (0,
|
|
5641
|
+
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5642
|
+
const domainObject = (0, import_react17.useMemo)(
|
|
5643
|
+
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5632
5644
|
[domain, formValues]
|
|
5633
5645
|
);
|
|
5634
5646
|
const data = {
|
|
@@ -5669,8 +5681,8 @@ var many2manyTagsController = (props) => {
|
|
|
5669
5681
|
};
|
|
5670
5682
|
|
|
5671
5683
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5672
|
-
var
|
|
5673
|
-
var
|
|
5684
|
+
var import_react18 = require("react");
|
|
5685
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5674
5686
|
var durationController = (props) => {
|
|
5675
5687
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
5676
5688
|
const specification = {
|
|
@@ -5680,13 +5692,13 @@ var durationController = (props) => {
|
|
|
5680
5692
|
};
|
|
5681
5693
|
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5682
5694
|
const { env } = (0, provider_exports.useEnv)();
|
|
5683
|
-
const [disabled, setDisabled] = (0,
|
|
5684
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5695
|
+
const [disabled, setDisabled] = (0, import_react18.useState)(false);
|
|
5696
|
+
const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
|
|
5685
5697
|
const queryKey = [`data-status-duration`, specification];
|
|
5686
5698
|
const listDataProps = {
|
|
5687
5699
|
model: relation,
|
|
5688
5700
|
specification,
|
|
5689
|
-
domain: (0,
|
|
5701
|
+
domain: (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5690
5702
|
limit: 10,
|
|
5691
5703
|
offset: 0,
|
|
5692
5704
|
fields: "",
|
|
@@ -5736,10 +5748,10 @@ var durationController = (props) => {
|
|
|
5736
5748
|
};
|
|
5737
5749
|
|
|
5738
5750
|
// src/widget/basic/priority-field/controller.ts
|
|
5739
|
-
var
|
|
5751
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5740
5752
|
var priorityFieldController = (props) => {
|
|
5741
5753
|
const { name, model, id, actionData, context, onChange } = props;
|
|
5742
|
-
const _context = { ...(0,
|
|
5754
|
+
const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
|
|
5743
5755
|
const contextObject = { ...context, ..._context };
|
|
5744
5756
|
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
5745
5757
|
const { mutateAsync: fetchSave } = useSave2();
|
|
@@ -5770,10 +5782,10 @@ var priorityFieldController = (props) => {
|
|
|
5770
5782
|
};
|
|
5771
5783
|
|
|
5772
5784
|
// src/widget/basic/download-file-field/controller.ts
|
|
5773
|
-
var
|
|
5785
|
+
var import_react19 = require("react");
|
|
5774
5786
|
var downloadFileController = () => {
|
|
5775
|
-
const inputId = (0,
|
|
5776
|
-
const [file, setFile] = (0,
|
|
5787
|
+
const inputId = (0, import_react19.useId)();
|
|
5788
|
+
const [file, setFile] = (0, import_react19.useState)(null);
|
|
5777
5789
|
const handleFileChange = (e) => {
|
|
5778
5790
|
setFile(e.target.files[0]);
|
|
5779
5791
|
};
|
|
@@ -6705,13 +6717,13 @@ var dateFieldController = (props) => {
|
|
|
6705
6717
|
};
|
|
6706
6718
|
|
|
6707
6719
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6708
|
-
var
|
|
6709
|
-
var
|
|
6720
|
+
var import_react20 = require("react");
|
|
6721
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6710
6722
|
var copyLinkButtonController = (props) => {
|
|
6711
6723
|
const { value, defaultValue } = props;
|
|
6712
|
-
const [isCopied, setIsCopied] = (0,
|
|
6724
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
6713
6725
|
const handleCopyToClipboard = async (value2) => {
|
|
6714
|
-
await (0,
|
|
6726
|
+
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6715
6727
|
setIsCopied(true);
|
|
6716
6728
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6717
6729
|
};
|
|
@@ -6724,12 +6736,12 @@ var copyLinkButtonController = (props) => {
|
|
|
6724
6736
|
};
|
|
6725
6737
|
|
|
6726
6738
|
// src/widget/basic/color-field/color-controller.ts
|
|
6727
|
-
var
|
|
6739
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
6728
6740
|
var colorFieldController = (props) => {
|
|
6729
6741
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6730
6742
|
const { env } = (0, provider_exports.useEnv)();
|
|
6731
6743
|
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
6732
|
-
const _context = { ...(0,
|
|
6744
|
+
const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) || {} };
|
|
6733
6745
|
const contextObject = { ...env.context, ..._context };
|
|
6734
6746
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6735
6747
|
const { mutate: onSave } = useSave2();
|
|
@@ -6757,16 +6769,16 @@ var colorFieldController = (props) => {
|
|
|
6757
6769
|
};
|
|
6758
6770
|
|
|
6759
6771
|
// src/widget/basic/binary-field/controller.ts
|
|
6760
|
-
var
|
|
6761
|
-
var
|
|
6772
|
+
var import_react21 = require("react");
|
|
6773
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6762
6774
|
var binaryFieldController = (props) => {
|
|
6763
6775
|
const { name, methods, readonly = false, value } = props;
|
|
6764
|
-
const inputId = (0,
|
|
6765
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6766
|
-
const [initialImage, setInitialImage] = (0,
|
|
6767
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6776
|
+
const inputId = (0, import_react21.useId)();
|
|
6777
|
+
const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
|
|
6778
|
+
const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
|
|
6779
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
|
|
6768
6780
|
const { setValue } = methods;
|
|
6769
|
-
const binaryRef = (0,
|
|
6781
|
+
const binaryRef = (0, import_react21.useRef)(null);
|
|
6770
6782
|
const convertUrlToBase64 = async (url) => {
|
|
6771
6783
|
try {
|
|
6772
6784
|
const response = await fetch(url);
|
|
@@ -6815,11 +6827,11 @@ var binaryFieldController = (props) => {
|
|
|
6815
6827
|
};
|
|
6816
6828
|
const checkIsImageLink = (url) => {
|
|
6817
6829
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6818
|
-
return imageExtensions.test(url) || (0,
|
|
6830
|
+
return imageExtensions.test(url) || (0, import_utils13.isBase64Image)(url) || isBlobUrl(url);
|
|
6819
6831
|
};
|
|
6820
6832
|
const getImageBase64WithMimeType = (base64) => {
|
|
6821
6833
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6822
|
-
if ((0,
|
|
6834
|
+
if ((0, import_utils13.isBase64Image)(base64)) return base64;
|
|
6823
6835
|
let mimeType = null;
|
|
6824
6836
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6825
6837
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6828,14 +6840,14 @@ var binaryFieldController = (props) => {
|
|
|
6828
6840
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6829
6841
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6830
6842
|
};
|
|
6831
|
-
(0,
|
|
6843
|
+
(0, import_react21.useEffect)(() => {
|
|
6832
6844
|
return () => {
|
|
6833
6845
|
if (selectedImage) {
|
|
6834
6846
|
URL.revokeObjectURL(selectedImage);
|
|
6835
6847
|
}
|
|
6836
6848
|
};
|
|
6837
6849
|
}, [selectedImage]);
|
|
6838
|
-
(0,
|
|
6850
|
+
(0, import_react21.useEffect)(() => {
|
|
6839
6851
|
if (binaryRef.current) {
|
|
6840
6852
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6841
6853
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6854,102 +6866,36 @@ var binaryFieldController = (props) => {
|
|
|
6854
6866
|
};
|
|
6855
6867
|
};
|
|
6856
6868
|
|
|
6857
|
-
// src/widget/advance/table/table-body/controller.ts
|
|
6858
|
-
var import_store9 = require("@fctc/interface-logic/store");
|
|
6859
|
-
var import_react21 = require("react");
|
|
6860
|
-
var tableBodyController = (props) => {
|
|
6861
|
-
const {
|
|
6862
|
-
checkedAll,
|
|
6863
|
-
checkboxRef,
|
|
6864
|
-
setIsAutoSelect,
|
|
6865
|
-
row,
|
|
6866
|
-
isAutoSelect,
|
|
6867
|
-
selectedRowKeysRef,
|
|
6868
|
-
onClickRow
|
|
6869
|
-
} = props;
|
|
6870
|
-
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6871
|
-
const { selectedRowKeys } = (0, import_store9.useAppSelector)(import_store9.selectList);
|
|
6872
|
-
const checked = (0, import_react21.useMemo)(() => {
|
|
6873
|
-
if (!row?.id) return false;
|
|
6874
|
-
if (selectedRowKeys?.includes(row.id)) {
|
|
6875
|
-
return true;
|
|
6876
|
-
}
|
|
6877
|
-
return checkedAll;
|
|
6878
|
-
}, [row?.id, selectedRowKeys, checkedAll]);
|
|
6879
|
-
const handleCheckBoxSingle = (event) => {
|
|
6880
|
-
event.stopPropagation();
|
|
6881
|
-
if (checkedAll) {
|
|
6882
|
-
checkboxRef.current = "uncheck";
|
|
6883
|
-
setIsAutoSelect(true);
|
|
6884
|
-
return;
|
|
6885
|
-
}
|
|
6886
|
-
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6887
|
-
appDispatch((0, import_store9.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6888
|
-
};
|
|
6889
|
-
const handleClickRow = (col, row2) => {
|
|
6890
|
-
onClickRow(col, row2);
|
|
6891
|
-
};
|
|
6892
|
-
(0, import_react21.useEffect)(() => {
|
|
6893
|
-
if (!row?.id) return;
|
|
6894
|
-
if (isAutoSelect) {
|
|
6895
|
-
if (checkboxRef?.current === "uncheck") {
|
|
6896
|
-
const filtered = selectedRowKeysRef.current.filter(
|
|
6897
|
-
(id) => id !== row.id
|
|
6898
|
-
);
|
|
6899
|
-
selectedRowKeysRef.current = filtered;
|
|
6900
|
-
appDispatch((0, import_store9.setSelectedRowKeys)(filtered));
|
|
6901
|
-
} else {
|
|
6902
|
-
const unique = Array.from(
|
|
6903
|
-
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6904
|
-
);
|
|
6905
|
-
selectedRowKeysRef.current = unique;
|
|
6906
|
-
appDispatch((0, import_store9.setSelectedRowKeys)(unique));
|
|
6907
|
-
}
|
|
6908
|
-
}
|
|
6909
|
-
}, [isAutoSelect]);
|
|
6910
|
-
(0, import_react21.useEffect)(() => {
|
|
6911
|
-
if (!checkedAll) {
|
|
6912
|
-
checkboxRef.current = "enabled";
|
|
6913
|
-
false;
|
|
6914
|
-
}
|
|
6915
|
-
}, [checkedAll]);
|
|
6916
|
-
return {
|
|
6917
|
-
handleCheckBoxSingle,
|
|
6918
|
-
checked,
|
|
6919
|
-
handleClickRow
|
|
6920
|
-
};
|
|
6921
|
-
};
|
|
6922
|
-
|
|
6923
6869
|
// src/widget/advance/table/table-head/controller.ts
|
|
6924
|
-
var
|
|
6870
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6925
6871
|
var tableHeadController = (props) => {
|
|
6926
6872
|
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6927
|
-
const appDispatch = (0,
|
|
6928
|
-
const { groupByDomain } = (0,
|
|
6873
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
6874
|
+
const { groupByDomain } = (0, import_store8.useAppSelector)(import_store8.selectSearch);
|
|
6929
6875
|
const handleCheckBoxAll = (event) => {
|
|
6930
6876
|
if (event?.target?.checked && typeTable === "list") {
|
|
6931
6877
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6932
|
-
appDispatch((0,
|
|
6878
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(allRowKeys));
|
|
6933
6879
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6934
6880
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6935
6881
|
const ids = Array.from(rowsIDs)?.map(
|
|
6936
6882
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6937
6883
|
);
|
|
6938
6884
|
if (ids?.length > 0) {
|
|
6939
|
-
appDispatch((0,
|
|
6885
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(ids));
|
|
6940
6886
|
} else {
|
|
6941
6887
|
const sum = countSum(
|
|
6942
6888
|
rows,
|
|
6943
6889
|
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6944
6890
|
);
|
|
6945
6891
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6946
|
-
appDispatch((0,
|
|
6892
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(keys));
|
|
6947
6893
|
}
|
|
6948
6894
|
if (selectedRowKeysRef) {
|
|
6949
6895
|
selectedRowKeysRef.current = [];
|
|
6950
6896
|
}
|
|
6951
6897
|
} else {
|
|
6952
|
-
appDispatch((0,
|
|
6898
|
+
appDispatch((0, import_store8.setSelectedRowKeys)([]));
|
|
6953
6899
|
}
|
|
6954
6900
|
};
|
|
6955
6901
|
return {
|
|
@@ -6959,8 +6905,8 @@ var tableHeadController = (props) => {
|
|
|
6959
6905
|
|
|
6960
6906
|
// src/widget/advance/table/table-view/controller.ts
|
|
6961
6907
|
var import_react22 = require("react");
|
|
6962
|
-
var
|
|
6963
|
-
var
|
|
6908
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6909
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6964
6910
|
var tableController = ({ data }) => {
|
|
6965
6911
|
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
6966
6912
|
const [columns, setColumns] = (0, import_react22.useState)([]);
|
|
@@ -6998,7 +6944,7 @@ var tableController = ({ data }) => {
|
|
|
6998
6944
|
let cols = [];
|
|
6999
6945
|
try {
|
|
7000
6946
|
cols = mergeFields?.filter((item) => {
|
|
7001
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6947
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_utils14.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_utils14.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
7002
6948
|
})?.map((field) => {
|
|
7003
6949
|
return {
|
|
7004
6950
|
name: field?.name,
|
|
@@ -7038,8 +6984,8 @@ var tableController = ({ data }) => {
|
|
|
7038
6984
|
|
|
7039
6985
|
// src/widget/advance/table/table-group/controller.ts
|
|
7040
6986
|
var import_react23 = require("react");
|
|
7041
|
-
var
|
|
7042
|
-
var
|
|
6987
|
+
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
6988
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
7043
6989
|
|
|
7044
6990
|
// src/environment.ts
|
|
7045
6991
|
var environment_exports = {};
|
|
@@ -7067,10 +7013,10 @@ var tableGroupController = (props) => {
|
|
|
7067
7013
|
selectedRowKeysRef
|
|
7068
7014
|
} = props;
|
|
7069
7015
|
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,
|
|
7016
|
+
const { groupByDomain, selectedTags } = (0, import_store10.useAppSelector)(import_store10.selectSearch);
|
|
7017
|
+
const { selectedRowKeys } = (0, import_store10.useAppSelector)(import_store10.selectList);
|
|
7018
|
+
const appDispatch = (0, import_store10.useAppDispatch)();
|
|
7019
|
+
const { toDataJS } = (0, import_hooks15.useOdooDataTransform)();
|
|
7074
7020
|
const initVal = toDataJS(row, viewData, model);
|
|
7075
7021
|
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
7076
7022
|
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
@@ -7117,7 +7063,7 @@ var tableGroupController = (props) => {
|
|
|
7117
7063
|
isPlaceholderData,
|
|
7118
7064
|
isLoading,
|
|
7119
7065
|
isFetching
|
|
7120
|
-
} = (0,
|
|
7066
|
+
} = (0, import_hooks15.useGetListData)(listDataProps, queryKey, enabled);
|
|
7121
7067
|
const {
|
|
7122
7068
|
columns: columnsGroup,
|
|
7123
7069
|
rows: rowsGroup,
|
|
@@ -7155,14 +7101,14 @@ var tableGroupController = (props) => {
|
|
|
7155
7101
|
const filteredIds = selectedRowKeys.filter(
|
|
7156
7102
|
(id) => !ids.includes(id)
|
|
7157
7103
|
);
|
|
7158
|
-
appDispatch((0,
|
|
7104
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(filteredIds));
|
|
7159
7105
|
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
7160
7106
|
const clonedKeys = [...selectedRowKeys];
|
|
7161
|
-
appDispatch((0,
|
|
7162
|
-
setTimeout(() => appDispatch((0,
|
|
7107
|
+
appDispatch((0, import_store10.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
7108
|
+
setTimeout(() => appDispatch((0, import_store10.setSelectedRowKeys)(clonedKeys)), 500);
|
|
7163
7109
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7164
7110
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7165
|
-
appDispatch((0,
|
|
7111
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(filteredKeys));
|
|
7166
7112
|
}
|
|
7167
7113
|
toggleShowGroup();
|
|
7168
7114
|
};
|
|
@@ -7171,8 +7117,8 @@ var tableGroupController = (props) => {
|
|
|
7171
7117
|
return;
|
|
7172
7118
|
}
|
|
7173
7119
|
const clonedKeys = [...selectedRowKeys];
|
|
7174
|
-
(0,
|
|
7175
|
-
setTimeout(() => (0,
|
|
7120
|
+
(0, import_store10.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
7121
|
+
setTimeout(() => (0, import_store10.setSelectedRowKeys)(clonedKeys), 500);
|
|
7176
7122
|
}, [isQueryFetched]);
|
|
7177
7123
|
return {
|
|
7178
7124
|
handleExpandChildGroup,
|
|
@@ -7207,25 +7153,26 @@ var tableGroupController = (props) => {
|
|
|
7207
7153
|
|
|
7208
7154
|
// src/widget/advance/search/controller.ts
|
|
7209
7155
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
7210
|
-
var
|
|
7156
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
7211
7157
|
var import_moment2 = __toESM(require_moment());
|
|
7212
7158
|
var import_react24 = require("react");
|
|
7213
7159
|
var searchController = ({
|
|
7214
7160
|
viewData,
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
searchMap
|
|
7161
|
+
model,
|
|
7162
|
+
domain,
|
|
7163
|
+
context,
|
|
7164
|
+
fieldsList
|
|
7220
7165
|
}) => {
|
|
7166
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
7221
7167
|
const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
|
|
7222
7168
|
const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
|
|
7223
7169
|
const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
|
|
7224
7170
|
const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
|
|
7225
7171
|
const [searchString, setSearchString] = (0, import_react24.useState)("");
|
|
7226
|
-
const
|
|
7227
|
-
const
|
|
7228
|
-
const
|
|
7172
|
+
const [searchMap, setSearchMap] = (0, import_react24.useState)({});
|
|
7173
|
+
const actionContext = typeof context === "string" ? (0, import_utils15.evalJSONContext)(context) : context;
|
|
7174
|
+
const contextSearch = { ...env.context, ...actionContext };
|
|
7175
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils15.evalJSONDomain)(domain, contextSearch) : [];
|
|
7229
7176
|
const clearSearch = () => {
|
|
7230
7177
|
setFilterBy([]);
|
|
7231
7178
|
setGroupBy([]);
|
|
@@ -7240,7 +7187,7 @@ var searchController = ({
|
|
|
7240
7187
|
const dataModel = viewData?.models?.[model];
|
|
7241
7188
|
const searchViews = viewData?.views?.search;
|
|
7242
7189
|
const searchByItems = searchViews?.search_by?.filter(
|
|
7243
|
-
(item) => !
|
|
7190
|
+
(item) => !import_utils15.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
7244
7191
|
)?.map(
|
|
7245
7192
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
7246
7193
|
dataIndex: index,
|
|
@@ -7253,10 +7200,10 @@ var searchController = ({
|
|
|
7253
7200
|
})
|
|
7254
7201
|
);
|
|
7255
7202
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
7256
|
-
return !
|
|
7203
|
+
return !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
7257
7204
|
})?.map((item) => ({ ...item, active: false }));
|
|
7258
7205
|
const groupByItems = searchViews?.group_by.filter(
|
|
7259
|
-
(item) => !
|
|
7206
|
+
(item) => !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
7260
7207
|
).map((item) => ({
|
|
7261
7208
|
...item,
|
|
7262
7209
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -7270,9 +7217,8 @@ var searchController = ({
|
|
|
7270
7217
|
}
|
|
7271
7218
|
};
|
|
7272
7219
|
(0, import_react24.useEffect)(() => {
|
|
7273
|
-
clearSearch();
|
|
7274
7220
|
fetchData();
|
|
7275
|
-
}, [
|
|
7221
|
+
}, [model, viewData]);
|
|
7276
7222
|
const onChangeSearchInput = (search_string) => {
|
|
7277
7223
|
setSearchString(search_string);
|
|
7278
7224
|
};
|
|
@@ -7309,47 +7255,47 @@ var searchController = ({
|
|
|
7309
7255
|
};
|
|
7310
7256
|
const formatDomain = () => {
|
|
7311
7257
|
if (domainAction) {
|
|
7312
|
-
const
|
|
7258
|
+
const domain2 = [];
|
|
7313
7259
|
if (domainAction?.length > 0) {
|
|
7314
|
-
if (Object.keys(searchMap).
|
|
7315
|
-
|
|
7260
|
+
if (Object.keys(searchMap).some((key) => !key.includes(import_constants5.SearchType.GROUP))) {
|
|
7261
|
+
domain2.push("&");
|
|
7316
7262
|
}
|
|
7317
7263
|
domainAction.forEach((domainItem) => {
|
|
7318
|
-
|
|
7264
|
+
domain2.push(domainItem);
|
|
7319
7265
|
});
|
|
7320
7266
|
}
|
|
7321
7267
|
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
7322
7268
|
if (!key?.includes(import_constants5.SearchType.GROUP)) {
|
|
7323
7269
|
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
7324
|
-
|
|
7270
|
+
domain2.push("&");
|
|
7325
7271
|
}
|
|
7326
7272
|
const valuesOfKey = searchMap[key];
|
|
7327
7273
|
valuesOfKey.forEach((value, index) => {
|
|
7328
7274
|
if (index < valuesOfKey.length - 1) {
|
|
7329
|
-
|
|
7275
|
+
domain2.push("|");
|
|
7330
7276
|
}
|
|
7331
7277
|
if (value.domain) {
|
|
7332
|
-
|
|
7278
|
+
domain2.push(...value.domain);
|
|
7333
7279
|
return;
|
|
7334
7280
|
}
|
|
7335
7281
|
let valueDomainItem = value?.value;
|
|
7336
7282
|
if (value?.modelType === "date") {
|
|
7337
|
-
valueDomainItem = (0,
|
|
7283
|
+
valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value);
|
|
7338
7284
|
} else if (value?.modelType === "datetime") {
|
|
7339
7285
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7340
|
-
const parsedDate = (0,
|
|
7286
|
+
const parsedDate = (0, import_utils15.validateAndParseDate)(value?.value, true);
|
|
7341
7287
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7342
7288
|
valueDomainItem = hasTime ? (0, import_moment2.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment2.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
7343
7289
|
} else {
|
|
7344
|
-
valueDomainItem = (0,
|
|
7290
|
+
valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value, true);
|
|
7345
7291
|
}
|
|
7346
7292
|
}
|
|
7347
7293
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
7348
|
-
|
|
7294
|
+
domain2.push([value.name, operator, valueDomainItem]);
|
|
7349
7295
|
});
|
|
7350
7296
|
}
|
|
7351
7297
|
});
|
|
7352
|
-
return [...
|
|
7298
|
+
return [...domain2];
|
|
7353
7299
|
}
|
|
7354
7300
|
};
|
|
7355
7301
|
const setTagSearch = (0, import_react24.useCallback)(
|
|
@@ -7380,16 +7326,16 @@ var searchController = ({
|
|
|
7380
7326
|
const contexts = [];
|
|
7381
7327
|
let groupValues = [];
|
|
7382
7328
|
objValues?.forEach((objValue) => {
|
|
7383
|
-
const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7329
|
+
const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7384
7330
|
const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
|
|
7385
7331
|
contexts.push(
|
|
7386
|
-
...Array.isArray(
|
|
7332
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
|
|
7387
7333
|
);
|
|
7388
7334
|
groupValues[indexAppend] = {
|
|
7389
7335
|
contexts: [
|
|
7390
|
-
...Array.isArray(
|
|
7336
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
|
|
7391
7337
|
group_by: item
|
|
7392
|
-
})) : [
|
|
7338
|
+
})) : [context2]
|
|
7393
7339
|
],
|
|
7394
7340
|
strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
|
|
7395
7341
|
};
|
|
@@ -7416,39 +7362,38 @@ var searchController = ({
|
|
|
7416
7362
|
[searchMap]
|
|
7417
7363
|
);
|
|
7418
7364
|
(0, import_react24.useEffect)(() => {
|
|
7419
|
-
setSelectedTags(null);
|
|
7420
7365
|
setTagSearch(searchMap);
|
|
7421
7366
|
}, [searchMap]);
|
|
7422
7367
|
const handleAddTagSearch = (tag) => {
|
|
7423
7368
|
const {
|
|
7424
|
-
domain,
|
|
7369
|
+
domain: domain2,
|
|
7425
7370
|
groupIndex,
|
|
7426
7371
|
value,
|
|
7427
7372
|
type,
|
|
7428
7373
|
title,
|
|
7429
|
-
context,
|
|
7374
|
+
context: context2,
|
|
7430
7375
|
active,
|
|
7431
7376
|
dataIndex
|
|
7432
7377
|
} = tag;
|
|
7433
|
-
const domainFormat = new
|
|
7378
|
+
const domainFormat = new import_utils15.domainHelper.Domain(domain2);
|
|
7434
7379
|
if (type === import_constants5.SearchType.FILTER) {
|
|
7435
7380
|
addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
|
|
7436
7381
|
...tag,
|
|
7437
|
-
domain:
|
|
7382
|
+
domain: domain2 ? domainFormat.toList(context2) : null
|
|
7438
7383
|
});
|
|
7439
7384
|
} else if (type === import_constants5.SearchType.SEARCH) {
|
|
7440
7385
|
addSearchItems(`${import_constants5.SearchType.SEARCH}_${String(dataIndex)}`, {
|
|
7441
7386
|
...tag,
|
|
7442
|
-
domain:
|
|
7443
|
-
...
|
|
7387
|
+
domain: domain2 ? domainFormat.toList({
|
|
7388
|
+
...context2,
|
|
7444
7389
|
self: value
|
|
7445
7390
|
}) : null
|
|
7446
7391
|
});
|
|
7447
7392
|
} else if (type === import_constants5.SearchType.GROUP) {
|
|
7448
7393
|
addSearchItems(`${import_constants5.SearchType.GROUP}`, {
|
|
7449
7394
|
...tag,
|
|
7450
|
-
domain:
|
|
7451
|
-
context,
|
|
7395
|
+
domain: domain2 ? domainFormat.toList({
|
|
7396
|
+
context: context2,
|
|
7452
7397
|
self: value
|
|
7453
7398
|
}) : null
|
|
7454
7399
|
});
|
|
@@ -7468,7 +7413,8 @@ var searchController = ({
|
|
|
7468
7413
|
removeSearchItems,
|
|
7469
7414
|
onSearchString: onChangeSearchInput,
|
|
7470
7415
|
handleAddTagSearch,
|
|
7471
|
-
domain: formatDomain()
|
|
7416
|
+
domain: formatDomain(),
|
|
7417
|
+
context: contextSearch
|
|
7472
7418
|
};
|
|
7473
7419
|
};
|
|
7474
7420
|
|
|
@@ -7533,7 +7479,6 @@ __reExport(index_exports, types_exports, module.exports);
|
|
|
7533
7479
|
searchController,
|
|
7534
7480
|
setStorageItemAsync,
|
|
7535
7481
|
statusDropdownController,
|
|
7536
|
-
tableBodyController,
|
|
7537
7482
|
tableController,
|
|
7538
7483
|
tableGroupController,
|
|
7539
7484
|
tableHeadController,
|
|
@@ -7547,6 +7492,7 @@ __reExport(index_exports, types_exports, module.exports);
|
|
|
7547
7492
|
useGetRowIds,
|
|
7548
7493
|
useListData,
|
|
7549
7494
|
useMenu,
|
|
7495
|
+
useMenuItem,
|
|
7550
7496
|
useProfile,
|
|
7551
7497
|
useSelectionState,
|
|
7552
7498
|
useStorageState,
|