@fctc/widget-logic 1.8.4 → 1.8.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 +36 -149
- package/dist/index.mjs +42 -160
- package/dist/widget.d.mts +1 -1
- package/dist/widget.d.ts +1 -1
- package/dist/widget.js +30 -149
- package/dist/widget.mjs +35 -160
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -6167,35 +6167,22 @@ var tableGroupController = (props) => {
|
|
|
6167
6167
|
// src/widget/advance/search/controller.ts
|
|
6168
6168
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
6169
6169
|
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
6170
|
-
var import_moment = __toESM(require_moment());
|
|
6171
6170
|
var import_react18 = require("react");
|
|
6172
|
-
|
|
6173
|
-
// src/provider.ts
|
|
6174
|
-
var provider_exports = {};
|
|
6175
|
-
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
6176
|
-
|
|
6177
|
-
// src/widget/advance/search/controller.ts
|
|
6178
6171
|
var searchController = ({
|
|
6179
6172
|
viewData,
|
|
6180
6173
|
actionData,
|
|
6181
6174
|
fieldsList,
|
|
6182
|
-
|
|
6175
|
+
contextSearch,
|
|
6176
|
+
setSearchMap,
|
|
6177
|
+
searchMap
|
|
6183
6178
|
}) => {
|
|
6184
|
-
const { env } = (0, provider_exports.useEnv)();
|
|
6185
|
-
const { context } = actionData || {};
|
|
6186
|
-
const actionContext = typeof context === "string" ? (0, import_utils6.evalJSONContext)(context) : context;
|
|
6187
|
-
const contextSearch = { ...env.context, ...actionContext };
|
|
6188
6179
|
const [filterBy, setFilterBy] = (0, import_react18.useState)(null);
|
|
6189
6180
|
const [searchBy, setSearchBy] = (0, import_react18.useState)(null);
|
|
6190
6181
|
const [groupBy, setGroupBy] = (0, import_react18.useState)(null);
|
|
6191
6182
|
const [selectedTags, setSelectedTags] = (0, import_react18.useState)(null);
|
|
6192
6183
|
const [searchString, setSearchString] = (0, import_react18.useState)("");
|
|
6193
|
-
const [searchMap, setSearchMap] = (0, import_react18.useState)({});
|
|
6194
|
-
const [isReadyFormatDomain, setIsReadyFormatDomain] = (0, import_react18.useState)(false);
|
|
6195
|
-
const [didInit, setDidInit] = (0, import_react18.useState)(false);
|
|
6196
6184
|
const aid = actionData?.id;
|
|
6197
6185
|
const model = actionData?.res_model;
|
|
6198
|
-
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils6.evalJSONDomain)(actionData?.domain, contextSearch) : [];
|
|
6199
6186
|
const clearSearch = () => {
|
|
6200
6187
|
setFilterBy([]);
|
|
6201
6188
|
setGroupBy([]);
|
|
@@ -6305,16 +6292,16 @@ var searchController = ({
|
|
|
6305
6292
|
const contexts = [];
|
|
6306
6293
|
let groupValues = [];
|
|
6307
6294
|
objValues?.forEach((objValue) => {
|
|
6308
|
-
const { context
|
|
6295
|
+
const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
6309
6296
|
const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
|
|
6310
6297
|
contexts.push(
|
|
6311
|
-
...Array.isArray(
|
|
6298
|
+
...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({ group_by: item })) : [context]
|
|
6312
6299
|
);
|
|
6313
6300
|
groupValues[indexAppend] = {
|
|
6314
6301
|
contexts: [
|
|
6315
|
-
...Array.isArray(
|
|
6302
|
+
...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({
|
|
6316
6303
|
group_by: item
|
|
6317
|
-
})) : [
|
|
6304
|
+
})) : [context]
|
|
6318
6305
|
],
|
|
6319
6306
|
strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
|
|
6320
6307
|
};
|
|
@@ -6344,51 +6331,6 @@ var searchController = ({
|
|
|
6344
6331
|
setSelectedTags(null);
|
|
6345
6332
|
setTagSearch(searchMap);
|
|
6346
6333
|
}, [searchMap]);
|
|
6347
|
-
const formatDomain = () => {
|
|
6348
|
-
if (domainAction) {
|
|
6349
|
-
const domain = [];
|
|
6350
|
-
if (domainAction?.length > 0) {
|
|
6351
|
-
if (Object.keys(searchMap).length > 0) {
|
|
6352
|
-
domain.push("&");
|
|
6353
|
-
}
|
|
6354
|
-
domainAction.forEach((domainItem) => {
|
|
6355
|
-
domain.push(domainItem);
|
|
6356
|
-
});
|
|
6357
|
-
}
|
|
6358
|
-
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
6359
|
-
if (!key?.includes(import_constants3.SearchType.GROUP)) {
|
|
6360
|
-
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
6361
|
-
domain.push("&");
|
|
6362
|
-
}
|
|
6363
|
-
const valuesOfKey = searchMap[key];
|
|
6364
|
-
valuesOfKey.forEach((value, index) => {
|
|
6365
|
-
if (index < valuesOfKey.length - 1) {
|
|
6366
|
-
domain.push("|");
|
|
6367
|
-
}
|
|
6368
|
-
if (value.domain) {
|
|
6369
|
-
domain.push(...value.domain);
|
|
6370
|
-
return;
|
|
6371
|
-
}
|
|
6372
|
-
let valueDomainItem = value?.value;
|
|
6373
|
-
if (value?.modelType === "date") {
|
|
6374
|
-
valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value);
|
|
6375
|
-
} else if (value?.modelType === "datetime") {
|
|
6376
|
-
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6377
|
-
const parsedDate = (0, import_utils6.validateAndParseDate)(value?.value, true);
|
|
6378
|
-
const hasTime = (0, import_moment.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6379
|
-
valueDomainItem = hasTime ? (0, import_moment.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
6380
|
-
} else {
|
|
6381
|
-
valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value, true);
|
|
6382
|
-
}
|
|
6383
|
-
}
|
|
6384
|
-
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
6385
|
-
domain.push([value.name, operator, valueDomainItem]);
|
|
6386
|
-
});
|
|
6387
|
-
}
|
|
6388
|
-
});
|
|
6389
|
-
return [...domain];
|
|
6390
|
-
}
|
|
6391
|
-
};
|
|
6392
6334
|
const handleAddTagSearch = (tag) => {
|
|
6393
6335
|
const {
|
|
6394
6336
|
domain,
|
|
@@ -6396,7 +6338,7 @@ var searchController = ({
|
|
|
6396
6338
|
value,
|
|
6397
6339
|
type,
|
|
6398
6340
|
title,
|
|
6399
|
-
context
|
|
6341
|
+
context,
|
|
6400
6342
|
active,
|
|
6401
6343
|
dataIndex
|
|
6402
6344
|
} = tag;
|
|
@@ -6404,13 +6346,13 @@ var searchController = ({
|
|
|
6404
6346
|
if (type === import_constants3.SearchType.FILTER) {
|
|
6405
6347
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
6406
6348
|
...tag,
|
|
6407
|
-
domain: domain ? domainFormat.toList(
|
|
6349
|
+
domain: domain ? domainFormat.toList(context) : null
|
|
6408
6350
|
});
|
|
6409
6351
|
} else if (type === import_constants3.SearchType.SEARCH) {
|
|
6410
6352
|
addSearchItems(`${import_constants3.SearchType.SEARCH}_${String(dataIndex)}`, {
|
|
6411
6353
|
...tag,
|
|
6412
6354
|
domain: domain ? domainFormat.toList({
|
|
6413
|
-
...
|
|
6355
|
+
...context,
|
|
6414
6356
|
self: value
|
|
6415
6357
|
}) : null
|
|
6416
6358
|
});
|
|
@@ -6418,73 +6360,12 @@ var searchController = ({
|
|
|
6418
6360
|
addSearchItems(`${import_constants3.SearchType.GROUP}`, {
|
|
6419
6361
|
...tag,
|
|
6420
6362
|
domain: domain ? domainFormat.toList({
|
|
6421
|
-
context
|
|
6363
|
+
context,
|
|
6422
6364
|
self: value
|
|
6423
6365
|
}) : null
|
|
6424
6366
|
});
|
|
6425
6367
|
}
|
|
6426
6368
|
};
|
|
6427
|
-
(0, import_react18.useEffect)(() => {
|
|
6428
|
-
if (isReadyFormatDomain) {
|
|
6429
|
-
(0, store_exports.setPage)(0);
|
|
6430
|
-
(0, store_exports.setSelectedRowKeys)([]);
|
|
6431
|
-
const containSearchFilter = selectedTags?.length > 0 && selectedTags?.find(
|
|
6432
|
-
(item) => item?.type === import_constants3.SearchType.FILTER || item?.type === import_constants3.SearchType.SEARCH || item?.type === import_constants3.SearchType.GROUP
|
|
6433
|
-
);
|
|
6434
|
-
if (containSearchFilter || Array.isArray(selectedTags) && selectedTags?.length === 0) {
|
|
6435
|
-
setDomain(formatDomain());
|
|
6436
|
-
}
|
|
6437
|
-
}
|
|
6438
|
-
return () => {
|
|
6439
|
-
setDidInit(false);
|
|
6440
|
-
setIsReadyFormatDomain(false);
|
|
6441
|
-
};
|
|
6442
|
-
}, [selectedTags, isReadyFormatDomain]);
|
|
6443
|
-
(0, import_react18.useEffect)(() => {
|
|
6444
|
-
if (didInit || selectedTags?.length > 0 || !fieldsList || fieldsList?.length === 0)
|
|
6445
|
-
return;
|
|
6446
|
-
const searchDefaults = Object.entries(actionContext || {}).filter(
|
|
6447
|
-
([key]) => key.startsWith("search_default_")
|
|
6448
|
-
);
|
|
6449
|
-
const hasGroupBy = viewData?.views?.search?.filters_by?.length > 0;
|
|
6450
|
-
if (searchDefaults.length === 0 && !hasGroupBy) {
|
|
6451
|
-
setIsReadyFormatDomain(true);
|
|
6452
|
-
setDidInit(true);
|
|
6453
|
-
return;
|
|
6454
|
-
}
|
|
6455
|
-
const updatedFilter = filterBy?.map((item) => {
|
|
6456
|
-
const matched = searchDefaults.find(
|
|
6457
|
-
([key]) => key.split("search_default_")[1] === item.name
|
|
6458
|
-
);
|
|
6459
|
-
if (matched && !item.active) {
|
|
6460
|
-
handleAddTagSearch?.({
|
|
6461
|
-
name: item?.name,
|
|
6462
|
-
value: item?.string ?? item?.help,
|
|
6463
|
-
domain: item?.domain,
|
|
6464
|
-
groupIndex: item?.group_index,
|
|
6465
|
-
type: import_constants3.SearchType.FILTER
|
|
6466
|
-
});
|
|
6467
|
-
return { ...item, active: true };
|
|
6468
|
-
}
|
|
6469
|
-
return item;
|
|
6470
|
-
});
|
|
6471
|
-
if (updatedFilter) setFilterBy(updatedFilter);
|
|
6472
|
-
if (hasGroupBy) {
|
|
6473
|
-
viewData?.views?.search?.filters_by?.forEach((item, idx) => {
|
|
6474
|
-
const groupCtx = (0, import_utils6.evalJSONContext)(item?.context);
|
|
6475
|
-
handleAddTagSearch?.({
|
|
6476
|
-
name: item?.name,
|
|
6477
|
-
value: item?.display_name,
|
|
6478
|
-
type: import_constants3.SearchType.GROUP,
|
|
6479
|
-
context: groupCtx,
|
|
6480
|
-
groupIndex: idx,
|
|
6481
|
-
isDefault: true
|
|
6482
|
-
});
|
|
6483
|
-
});
|
|
6484
|
-
setDidInit(true);
|
|
6485
|
-
}
|
|
6486
|
-
setIsReadyFormatDomain(true);
|
|
6487
|
-
}, [aid, fieldsList]);
|
|
6488
6369
|
return {
|
|
6489
6370
|
groupBy,
|
|
6490
6371
|
searchBy,
|
|
@@ -6504,7 +6385,7 @@ var searchController = ({
|
|
|
6504
6385
|
|
|
6505
6386
|
// src/widget/basic/many2many-field/controller.ts
|
|
6506
6387
|
var import_environment8 = require("@fctc/interface-logic/environment");
|
|
6507
|
-
var
|
|
6388
|
+
var import_store12 = require("@fctc/interface-logic/store");
|
|
6508
6389
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
6509
6390
|
var many2manyFieldController = (props) => {
|
|
6510
6391
|
const {
|
|
@@ -6514,7 +6395,7 @@ var many2manyFieldController = (props) => {
|
|
|
6514
6395
|
tab,
|
|
6515
6396
|
model,
|
|
6516
6397
|
aid,
|
|
6517
|
-
setSelectedRowKeys:
|
|
6398
|
+
setSelectedRowKeys: setSelectedRowKeys4,
|
|
6518
6399
|
fields,
|
|
6519
6400
|
setFields,
|
|
6520
6401
|
groupByDomain,
|
|
@@ -6522,14 +6403,14 @@ var many2manyFieldController = (props) => {
|
|
|
6522
6403
|
options,
|
|
6523
6404
|
sessionStorageUtils
|
|
6524
6405
|
} = props;
|
|
6525
|
-
const appDispatch = (0,
|
|
6406
|
+
const appDispatch = (0, import_store12.useAppDispatch)();
|
|
6526
6407
|
const actionData = sessionStorageUtils.getActionData();
|
|
6527
6408
|
const [debouncedPage] = useDebounce(page, 500);
|
|
6528
6409
|
const [order, setOrder] = (0, import_react19.useState)();
|
|
6529
6410
|
const [isLoadedData, setIsLoadedData] = (0, import_react19.useState)(false);
|
|
6530
6411
|
const [domainMany2Many, setDomainMany2Many] = (0, import_react19.useState)(domain);
|
|
6531
6412
|
const env = (0, import_environment8.getEnv)();
|
|
6532
|
-
const { selectedTags } = (0,
|
|
6413
|
+
const { selectedTags } = (0, import_store12.useAppSelector)(import_store12.selectSearch);
|
|
6533
6414
|
const viewParams = {
|
|
6534
6415
|
model: relation,
|
|
6535
6416
|
views: [
|
|
@@ -6572,8 +6453,8 @@ var many2manyFieldController = (props) => {
|
|
|
6572
6453
|
const fetchData = async () => {
|
|
6573
6454
|
try {
|
|
6574
6455
|
setDomainMany2Many(domain);
|
|
6575
|
-
appDispatch((0,
|
|
6576
|
-
appDispatch((0,
|
|
6456
|
+
appDispatch((0, import_store12.setFirstDomain)(domain));
|
|
6457
|
+
appDispatch((0, import_store12.setViewDataStore)(viewResponse));
|
|
6577
6458
|
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
6578
6459
|
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
6579
6460
|
...field
|
|
@@ -6584,7 +6465,7 @@ var many2manyFieldController = (props) => {
|
|
|
6584
6465
|
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
6585
6466
|
});
|
|
6586
6467
|
}
|
|
6587
|
-
appDispatch((0,
|
|
6468
|
+
appDispatch((0, import_store12.setPage)(0));
|
|
6588
6469
|
} catch (err) {
|
|
6589
6470
|
console.log(err);
|
|
6590
6471
|
}
|
|
@@ -6620,13 +6501,13 @@ var many2manyFieldController = (props) => {
|
|
|
6620
6501
|
fetchData();
|
|
6621
6502
|
}
|
|
6622
6503
|
return () => {
|
|
6623
|
-
appDispatch((0,
|
|
6504
|
+
appDispatch((0, import_store12.setGroupByDomain)(null));
|
|
6624
6505
|
setFields((prevFields) => ({
|
|
6625
6506
|
...prevFields,
|
|
6626
6507
|
[`${aid}_${relation}_popupmany2many`]: null
|
|
6627
6508
|
}));
|
|
6628
|
-
appDispatch((0,
|
|
6629
|
-
|
|
6509
|
+
appDispatch((0, import_store12.setPage)(0));
|
|
6510
|
+
setSelectedRowKeys4([]);
|
|
6630
6511
|
setDomainMany2Many(null);
|
|
6631
6512
|
setIsLoadedData(false);
|
|
6632
6513
|
};
|
|
@@ -6738,7 +6619,7 @@ var many2manyTagsController = (props) => {
|
|
|
6738
6619
|
// src/widget/basic/status-bar-field/controller.ts
|
|
6739
6620
|
var import_react21 = require("react");
|
|
6740
6621
|
var import_hooks16 = require("@fctc/interface-logic/hooks");
|
|
6741
|
-
var
|
|
6622
|
+
var import_store13 = require("@fctc/interface-logic/store");
|
|
6742
6623
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
6743
6624
|
var durationController = (props) => {
|
|
6744
6625
|
const {
|
|
@@ -6758,7 +6639,7 @@ var durationController = (props) => {
|
|
|
6758
6639
|
};
|
|
6759
6640
|
const [disabled, setDisabled] = (0, import_react21.useState)(false);
|
|
6760
6641
|
const [modelStatus, setModalStatus] = (0, import_react21.useState)(false);
|
|
6761
|
-
const { context } = (0,
|
|
6642
|
+
const { context } = (0, import_store13.useAppSelector)(import_store13.selectEnv);
|
|
6762
6643
|
const queryKey = [`data-status-duration`, specification];
|
|
6763
6644
|
const listDataProps = {
|
|
6764
6645
|
model: relation,
|
|
@@ -7129,7 +7010,7 @@ var downLoadBinaryController = (props) => {
|
|
|
7129
7010
|
};
|
|
7130
7011
|
|
|
7131
7012
|
// src/widget/basic/date-field/controller.ts
|
|
7132
|
-
var
|
|
7013
|
+
var import_moment = __toESM(require_moment());
|
|
7133
7014
|
var DURATIONS = {
|
|
7134
7015
|
PAST: "past",
|
|
7135
7016
|
NOW: "now",
|
|
@@ -7156,8 +7037,8 @@ var dateFieldController = (props) => {
|
|
|
7156
7037
|
const formatDate = showTime ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY";
|
|
7157
7038
|
const formatDateParse = showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
|
|
7158
7039
|
const fieldForCustom = widget === "datetime_custom" || widget === "date_custom";
|
|
7159
|
-
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0,
|
|
7160
|
-
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0,
|
|
7040
|
+
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
|
|
7041
|
+
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
|
|
7161
7042
|
const years = range(
|
|
7162
7043
|
minNowValue ? (/* @__PURE__ */ new Date()).getFullYear() : 1990,
|
|
7163
7044
|
(/* @__PURE__ */ new Date()).getFullYear() + 4,
|
|
@@ -7192,8 +7073,8 @@ var dateFieldController = (props) => {
|
|
|
7192
7073
|
"December"
|
|
7193
7074
|
];
|
|
7194
7075
|
const customValidateMinMax = (date) => {
|
|
7195
|
-
const selected = (0,
|
|
7196
|
-
const now = (0,
|
|
7076
|
+
const selected = (0, import_moment.default)(date, formatDateParse);
|
|
7077
|
+
const now = (0, import_moment.default)();
|
|
7197
7078
|
const compareSelected = showTime ? selected : selected.clone().startOf("day");
|
|
7198
7079
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
7199
7080
|
if (minNowValue) {
|
|
@@ -7201,7 +7082,7 @@ var dateFieldController = (props) => {
|
|
|
7201
7082
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7202
7083
|
"greater_or_equal_now"
|
|
7203
7084
|
)}`;
|
|
7204
|
-
} else if (
|
|
7085
|
+
} else if (import_moment.default.isMoment(minNowValue)) {
|
|
7205
7086
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
7206
7087
|
if (compareSelected.isBefore(compareMin)) {
|
|
7207
7088
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
@@ -7215,7 +7096,7 @@ var dateFieldController = (props) => {
|
|
|
7215
7096
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7216
7097
|
"less_or_equal_now"
|
|
7217
7098
|
)}`;
|
|
7218
|
-
} else if (
|
|
7099
|
+
} else if (import_moment.default.isMoment(maxNowValue)) {
|
|
7219
7100
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
7220
7101
|
if (compareSelected.isAfter(compareMax)) {
|
|
7221
7102
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|