@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/widget.js
CHANGED
|
@@ -4972,6 +4972,7 @@ var many2oneFieldController = (props) => {
|
|
|
4972
4972
|
options: fieldOptions,
|
|
4973
4973
|
showDetail
|
|
4974
4974
|
} = props;
|
|
4975
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
4975
4976
|
const [options, setOptions] = (0, import_react14.useState)([]);
|
|
4976
4977
|
const [inputValue, setInputValue] = (0, import_react14.useState)("");
|
|
4977
4978
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
@@ -4981,15 +4982,14 @@ var many2oneFieldController = (props) => {
|
|
|
4981
4982
|
const [domainObject, setDomainObject] = (0, import_react14.useState)(null);
|
|
4982
4983
|
const actionData = sessionStorageUtils.getActionData();
|
|
4983
4984
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
4984
|
-
const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
|
|
4985
4985
|
const initValue = methods?.getValues(name);
|
|
4986
4986
|
const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
|
|
4987
4987
|
const contextObject = {
|
|
4988
4988
|
...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
|
|
4989
4989
|
...fieldContext,
|
|
4990
|
-
...context
|
|
4990
|
+
...env?.context
|
|
4991
4991
|
};
|
|
4992
|
-
const { useGetSelection:
|
|
4992
|
+
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
4993
4993
|
const data = {
|
|
4994
4994
|
model: relation,
|
|
4995
4995
|
domain: domainObject,
|
|
@@ -5005,7 +5005,7 @@ var many2oneFieldController = (props) => {
|
|
|
5005
5005
|
data: dataOfSelection,
|
|
5006
5006
|
refetch,
|
|
5007
5007
|
isFetching
|
|
5008
|
-
} =
|
|
5008
|
+
} = useGetSelection3({
|
|
5009
5009
|
data,
|
|
5010
5010
|
queryKey,
|
|
5011
5011
|
enabled: false
|
|
@@ -5159,52 +5159,49 @@ var many2oneButtonController = (props) => {
|
|
|
5159
5159
|
|
|
5160
5160
|
// src/widget/basic/many2many-field/controller.ts
|
|
5161
5161
|
var import_react15 = require("react");
|
|
5162
|
-
var import_store8 = require("@fctc/interface-logic/store");
|
|
5163
5162
|
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5164
5163
|
var many2manyFieldController = (props) => {
|
|
5165
5164
|
const {
|
|
5166
5165
|
relation,
|
|
5167
5166
|
domain,
|
|
5168
5167
|
context,
|
|
5168
|
+
options,
|
|
5169
5169
|
tab,
|
|
5170
|
-
model,
|
|
5171
|
-
aid,
|
|
5172
5170
|
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5173
|
-
fields,
|
|
5174
|
-
setFields,
|
|
5175
5171
|
groupByDomain,
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
sessionStorageUtils
|
|
5172
|
+
enabled: enabledCallAPI,
|
|
5173
|
+
actionData
|
|
5179
5174
|
} = props;
|
|
5180
|
-
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
5181
|
-
const actionData = sessionStorageUtils.getActionData();
|
|
5182
|
-
const [debouncedPage] = useDebounce(page, 500);
|
|
5183
|
-
const [order, setOrder] = (0, import_react15.useState)();
|
|
5184
|
-
const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
|
|
5185
|
-
const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(domain);
|
|
5186
5175
|
const { env } = (0, provider_exports.useEnv)();
|
|
5187
5176
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5177
|
+
const [order, setOrder] = (0, import_react15.useState)();
|
|
5178
|
+
const [page, setPage] = (0, import_react15.useState)(0);
|
|
5179
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(null);
|
|
5180
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
5181
|
+
const contextObject = {
|
|
5182
|
+
...env.context,
|
|
5183
|
+
...context || {}
|
|
5184
|
+
};
|
|
5188
5185
|
const viewParams = {
|
|
5189
5186
|
model: relation,
|
|
5190
5187
|
views: [
|
|
5191
5188
|
[false, "list"],
|
|
5192
5189
|
[false, "search"]
|
|
5193
5190
|
],
|
|
5194
|
-
context
|
|
5191
|
+
context: contextObject
|
|
5195
5192
|
};
|
|
5196
|
-
const { data: viewResponse } = useGetView2(viewParams,
|
|
5193
|
+
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5197
5194
|
const baseModel = (0, import_react15.useMemo)(
|
|
5198
5195
|
() => ({
|
|
5199
5196
|
name: String(relation),
|
|
5200
5197
|
view: viewResponse || {},
|
|
5201
|
-
actContext:
|
|
5198
|
+
actContext: contextObject,
|
|
5202
5199
|
fields: [
|
|
5203
5200
|
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
5204
5201
|
...tab?.fields ? tab.fields : []
|
|
5205
5202
|
]
|
|
5206
5203
|
}),
|
|
5207
|
-
[
|
|
5204
|
+
[relation, viewResponse]
|
|
5208
5205
|
);
|
|
5209
5206
|
const initModel = (0, hooks_exports.useModel)();
|
|
5210
5207
|
const modelInstance = (0, import_react15.useMemo)(() => {
|
|
@@ -5223,26 +5220,15 @@ var many2manyFieldController = (props) => {
|
|
|
5223
5220
|
const optionsObject = tab?.options ? (0, import_utils6.evalJSONContext)(tab?.options) : (options ? (0, import_utils6.evalJSONContext)(options) : {}) || {};
|
|
5224
5221
|
const fetchData = async () => {
|
|
5225
5222
|
try {
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
5230
|
-
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
5231
|
-
...field
|
|
5232
|
-
}));
|
|
5233
|
-
if (!fields?.[`${aid}_${relation}_popupmany2many`] && modalData) {
|
|
5234
|
-
setFields({
|
|
5235
|
-
...fields,
|
|
5236
|
-
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
5237
|
-
});
|
|
5238
|
-
}
|
|
5239
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5223
|
+
const domainParse = typeof domain === "string" ? (0, import_utils6.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5224
|
+
setDomainMany2Many(domainParse);
|
|
5225
|
+
setPage(0);
|
|
5240
5226
|
} catch (err) {
|
|
5241
5227
|
console.log(err);
|
|
5242
5228
|
}
|
|
5243
5229
|
};
|
|
5244
5230
|
const queryKey = [
|
|
5245
|
-
`view-${relation}
|
|
5231
|
+
`view-${relation}`,
|
|
5246
5232
|
specification,
|
|
5247
5233
|
domainMany2Many,
|
|
5248
5234
|
debouncedPage,
|
|
@@ -5255,16 +5241,16 @@ var many2manyFieldController = (props) => {
|
|
|
5255
5241
|
domain: domainMany2Many,
|
|
5256
5242
|
offset: debouncedPage * 10,
|
|
5257
5243
|
limit: 10,
|
|
5258
|
-
context,
|
|
5244
|
+
context: contextObject,
|
|
5259
5245
|
fields: groupByDomain?.fields,
|
|
5260
5246
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5261
5247
|
sort: order ? order : default_order ? (0, import_utils6.formatSortingString)(default_order) : ""
|
|
5262
5248
|
};
|
|
5263
|
-
const enabled =
|
|
5249
|
+
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5264
5250
|
const {
|
|
5265
5251
|
data: dataResponse,
|
|
5266
|
-
isLoading
|
|
5267
|
-
isFetched
|
|
5252
|
+
isLoading,
|
|
5253
|
+
isFetched,
|
|
5268
5254
|
isPlaceholderData
|
|
5269
5255
|
} = useGetListData3(data, queryKey, enabled);
|
|
5270
5256
|
(0, import_react15.useEffect)(() => {
|
|
@@ -5272,73 +5258,58 @@ var many2manyFieldController = (props) => {
|
|
|
5272
5258
|
fetchData();
|
|
5273
5259
|
}
|
|
5274
5260
|
return () => {
|
|
5275
|
-
|
|
5276
|
-
setFields((prevFields) => ({
|
|
5277
|
-
...prevFields,
|
|
5278
|
-
[`${aid}_${relation}_popupmany2many`]: null
|
|
5279
|
-
}));
|
|
5280
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5261
|
+
setPage(0);
|
|
5281
5262
|
setSelectedRowKeys4([]);
|
|
5282
5263
|
setDomainMany2Many(null);
|
|
5283
|
-
setIsLoadedData(false);
|
|
5284
5264
|
};
|
|
5285
5265
|
}, [viewResponse]);
|
|
5286
|
-
const { rows, columns, typeTable } = tableController({
|
|
5266
|
+
const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
|
|
5287
5267
|
data: {
|
|
5288
|
-
fields:
|
|
5268
|
+
fields: viewResponse?.views?.list?.fields,
|
|
5289
5269
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
5290
5270
|
dataModel: viewResponse?.models?.[String(relation)],
|
|
5291
|
-
context:
|
|
5271
|
+
context: contextObject,
|
|
5292
5272
|
typeTable: dataResponse?.groups ? "group" : "list"
|
|
5293
5273
|
}
|
|
5294
5274
|
});
|
|
5295
|
-
const
|
|
5296
|
-
|
|
5297
|
-
model: relation,
|
|
5298
|
-
context
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
data: dataFormView,
|
|
5306
|
-
queryKey: [`form-view-action-${relation}`],
|
|
5307
|
-
enabled: false
|
|
5275
|
+
const searchControllers = searchController({
|
|
5276
|
+
viewData: viewResponse,
|
|
5277
|
+
model: relation ?? "",
|
|
5278
|
+
context: contextObject,
|
|
5279
|
+
domain,
|
|
5280
|
+
fieldsList: [
|
|
5281
|
+
...columns?.filter(
|
|
5282
|
+
(col) => col?.field?.type_co === "field" && col?.optional !== "hide"
|
|
5283
|
+
)?.map((col) => ({ ...col.field })) ?? []
|
|
5284
|
+
]
|
|
5308
5285
|
});
|
|
5309
|
-
(0, import_react15.useEffect)(() => {
|
|
5310
|
-
if (isSuccess && dataFormViewResponse) {
|
|
5311
|
-
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
5312
|
-
window.location.href = `/form/menu?model=${relation}`;
|
|
5313
|
-
}
|
|
5314
|
-
}, [isSuccess]);
|
|
5315
|
-
(0, import_react15.useEffect)(() => {
|
|
5316
|
-
if (domainMany2Many && !isLoadedData) {
|
|
5317
|
-
setIsLoadedData(true);
|
|
5318
|
-
}
|
|
5319
|
-
}, [domainMany2Many]);
|
|
5320
5286
|
const handleCreateNewOnPage = async () => {
|
|
5321
|
-
try {
|
|
5322
|
-
refetch();
|
|
5323
|
-
} catch (error) {
|
|
5324
|
-
console.log(error);
|
|
5325
|
-
}
|
|
5326
5287
|
};
|
|
5327
5288
|
return {
|
|
5328
5289
|
handleCreateNewOnPage,
|
|
5329
5290
|
optionsObject,
|
|
5291
|
+
totalRows: dataResponse?.length ?? 0,
|
|
5330
5292
|
rows,
|
|
5331
5293
|
columns,
|
|
5294
|
+
onToggleColumnOptional,
|
|
5332
5295
|
typeTable,
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
isPlaceholderData
|
|
5296
|
+
isLoading,
|
|
5297
|
+
isFetched,
|
|
5298
|
+
isPlaceholderData,
|
|
5299
|
+
setPage,
|
|
5300
|
+
page,
|
|
5301
|
+
viewData: viewResponse,
|
|
5302
|
+
domain: domainMany2Many,
|
|
5303
|
+
setDomain: setDomainMany2Many,
|
|
5304
|
+
searchController: searchControllers
|
|
5336
5305
|
};
|
|
5337
5306
|
};
|
|
5338
5307
|
|
|
5339
5308
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5340
5309
|
var import_react16 = require("react");
|
|
5341
5310
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5311
|
+
var import_environment7 = require("@fctc/interface-logic/environment");
|
|
5312
|
+
var import_hooks14 = require("@fctc/interface-logic/hooks");
|
|
5342
5313
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5343
5314
|
var many2manyTagsController = (props) => {
|
|
5344
5315
|
const {
|
|
@@ -5350,8 +5321,7 @@ var many2manyTagsController = (props) => {
|
|
|
5350
5321
|
placeholderNoOption
|
|
5351
5322
|
} = props;
|
|
5352
5323
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5353
|
-
const
|
|
5354
|
-
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5324
|
+
const env = (0, import_environment7.getEnv)();
|
|
5355
5325
|
const addtionalFields = optionsFields ? (0, import_utils7.evalJSONContext)(optionsFields) : null;
|
|
5356
5326
|
const domainObject = (0, import_react16.useMemo)(
|
|
5357
5327
|
() => (0, import_utils7.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
@@ -5370,7 +5340,7 @@ var many2manyTagsController = (props) => {
|
|
|
5370
5340
|
enabled: true,
|
|
5371
5341
|
context: env.context
|
|
5372
5342
|
};
|
|
5373
|
-
const { data: dataOfSelection } =
|
|
5343
|
+
const { data: dataOfSelection } = (0, import_hooks14.useGetSelection)({
|
|
5374
5344
|
data,
|
|
5375
5345
|
queryKey: [`data_${relation}`, domainObject]
|
|
5376
5346
|
});
|
|
@@ -5390,6 +5360,7 @@ var many2manyTagsController = (props) => {
|
|
|
5390
5360
|
options,
|
|
5391
5361
|
customNoOptionsMessage,
|
|
5392
5362
|
tranfer,
|
|
5363
|
+
dataOfSelection,
|
|
5393
5364
|
isUser
|
|
5394
5365
|
};
|
|
5395
5366
|
};
|
|
@@ -5398,7 +5369,7 @@ var many2manyTagsController = (props) => {
|
|
|
5398
5369
|
var import_react17 = require("react");
|
|
5399
5370
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5400
5371
|
var durationController = (props) => {
|
|
5401
|
-
const { relation, domain, formValues, name, id, model, onRefetch
|
|
5372
|
+
const { relation, domain, formValues, name, id, model, onRefetch } = props;
|
|
5402
5373
|
const specification = {
|
|
5403
5374
|
id: 0,
|
|
5404
5375
|
name: "",
|
|
@@ -5422,11 +5393,7 @@ var durationController = (props) => {
|
|
|
5422
5393
|
},
|
|
5423
5394
|
sort: ""
|
|
5424
5395
|
};
|
|
5425
|
-
const { data: dataResponse } = useGetListData3(
|
|
5426
|
-
listDataProps,
|
|
5427
|
-
queryKey,
|
|
5428
|
-
enabled
|
|
5429
|
-
);
|
|
5396
|
+
const { data: dataResponse } = useGetListData3(listDataProps, queryKey);
|
|
5430
5397
|
const { mutate: fetchChangeStatus } = useChangeStatus();
|
|
5431
5398
|
const handleClick = async (stage_id) => {
|
|
5432
5399
|
setDisabled(true);
|
|
@@ -5462,18 +5429,32 @@ var durationController = (props) => {
|
|
|
5462
5429
|
};
|
|
5463
5430
|
|
|
5464
5431
|
// src/widget/basic/priority-field/controller.ts
|
|
5432
|
+
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
5465
5433
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5466
5434
|
var priorityFieldController = (props) => {
|
|
5467
|
-
const {
|
|
5435
|
+
const {
|
|
5436
|
+
value,
|
|
5437
|
+
isForm,
|
|
5438
|
+
name,
|
|
5439
|
+
methods,
|
|
5440
|
+
onChange,
|
|
5441
|
+
model,
|
|
5442
|
+
selection,
|
|
5443
|
+
id,
|
|
5444
|
+
actionData,
|
|
5445
|
+
viewData,
|
|
5446
|
+
context
|
|
5447
|
+
} = props;
|
|
5468
5448
|
const _context = { ...(0, import_utils9.evalJSONContext)(actionData?.context) };
|
|
5469
5449
|
const contextObject = { ...context, ..._context };
|
|
5470
|
-
const
|
|
5471
|
-
const
|
|
5450
|
+
const defaultPriority = parseInt(value) + 1;
|
|
5451
|
+
const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
|
|
5452
|
+
const { mutateAsync: fetchSave } = (0, import_hooks15.useSave)();
|
|
5472
5453
|
const savePriorities = async ({
|
|
5473
|
-
value,
|
|
5454
|
+
value: value2,
|
|
5474
5455
|
resetPriority
|
|
5475
5456
|
}) => {
|
|
5476
|
-
const priorityValue =
|
|
5457
|
+
const priorityValue = value2 <= 0 ? 0 : value2 - 1;
|
|
5477
5458
|
try {
|
|
5478
5459
|
fetchSave({
|
|
5479
5460
|
ids: id ? [id] : [],
|
|
@@ -5491,7 +5472,14 @@ var priorityFieldController = (props) => {
|
|
|
5491
5472
|
}
|
|
5492
5473
|
};
|
|
5493
5474
|
return {
|
|
5494
|
-
|
|
5475
|
+
selection,
|
|
5476
|
+
isForm,
|
|
5477
|
+
methods,
|
|
5478
|
+
defaultPriority,
|
|
5479
|
+
savePriorities,
|
|
5480
|
+
label,
|
|
5481
|
+
id,
|
|
5482
|
+
onChange
|
|
5495
5483
|
};
|
|
5496
5484
|
};
|
|
5497
5485
|
|
|
@@ -6454,11 +6442,11 @@ var import_utils11 = require("@fctc/interface-logic/utils");
|
|
|
6454
6442
|
var colorFieldController = (props) => {
|
|
6455
6443
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6456
6444
|
const { env } = (0, provider_exports.useEnv)();
|
|
6457
|
-
const { useSave:
|
|
6445
|
+
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
6458
6446
|
const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) || {} };
|
|
6459
6447
|
const contextObject = { ...env.context, ..._context };
|
|
6460
6448
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6461
|
-
const { mutate: onSave } =
|
|
6449
|
+
const { mutate: onSave } = useSave3();
|
|
6462
6450
|
const savePickColor = async (colorObject) => {
|
|
6463
6451
|
const { id } = colorObject;
|
|
6464
6452
|
if (value === id) return;
|
|
@@ -6581,20 +6569,20 @@ var binaryFieldController = (props) => {
|
|
|
6581
6569
|
};
|
|
6582
6570
|
|
|
6583
6571
|
// src/widget/advance/table/table-body/controller.ts
|
|
6584
|
-
var
|
|
6572
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6585
6573
|
var import_react21 = require("react");
|
|
6586
6574
|
var tableBodyController = (props) => {
|
|
6587
6575
|
const {
|
|
6588
6576
|
checkedAll,
|
|
6589
6577
|
checkboxRef,
|
|
6590
6578
|
setIsAutoSelect,
|
|
6579
|
+
selectedRowKeys,
|
|
6591
6580
|
row,
|
|
6592
6581
|
isAutoSelect,
|
|
6593
6582
|
selectedRowKeysRef,
|
|
6594
6583
|
onClickRow
|
|
6595
6584
|
} = props;
|
|
6596
|
-
const appDispatch = (0,
|
|
6597
|
-
const { selectedRowKeys } = (0, import_store9.useAppSelector)(import_store9.selectList);
|
|
6585
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
6598
6586
|
const checked = (0, import_react21.useMemo)(() => {
|
|
6599
6587
|
if (!row?.id) return false;
|
|
6600
6588
|
if (selectedRowKeys?.includes(row.id)) {
|
|
@@ -6610,7 +6598,8 @@ var tableBodyController = (props) => {
|
|
|
6610
6598
|
return;
|
|
6611
6599
|
}
|
|
6612
6600
|
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6613
|
-
|
|
6601
|
+
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6602
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6614
6603
|
};
|
|
6615
6604
|
const handleClickRow = (col, row2) => {
|
|
6616
6605
|
onClickRow(col, row2);
|
|
@@ -6623,13 +6612,13 @@ var tableBodyController = (props) => {
|
|
|
6623
6612
|
(id) => id !== row.id
|
|
6624
6613
|
);
|
|
6625
6614
|
selectedRowKeysRef.current = filtered;
|
|
6626
|
-
appDispatch((0,
|
|
6615
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(filtered));
|
|
6627
6616
|
} else {
|
|
6628
6617
|
const unique = Array.from(
|
|
6629
6618
|
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6630
6619
|
);
|
|
6631
6620
|
selectedRowKeysRef.current = unique;
|
|
6632
|
-
appDispatch((0,
|
|
6621
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(unique));
|
|
6633
6622
|
}
|
|
6634
6623
|
}
|
|
6635
6624
|
}, [isAutoSelect]);
|
|
@@ -6647,35 +6636,35 @@ var tableBodyController = (props) => {
|
|
|
6647
6636
|
};
|
|
6648
6637
|
|
|
6649
6638
|
// src/widget/advance/table/table-head/controller.ts
|
|
6650
|
-
var
|
|
6639
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6651
6640
|
var tableHeadController = (props) => {
|
|
6652
6641
|
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6653
|
-
const appDispatch = (0,
|
|
6654
|
-
const { groupByDomain } = (0,
|
|
6642
|
+
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6643
|
+
const { groupByDomain } = (0, import_store9.useAppSelector)(import_store9.selectSearch);
|
|
6655
6644
|
const handleCheckBoxAll = (event) => {
|
|
6656
6645
|
if (event?.target?.checked && typeTable === "list") {
|
|
6657
6646
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6658
|
-
appDispatch((0,
|
|
6647
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(allRowKeys));
|
|
6659
6648
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6660
6649
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6661
6650
|
const ids = Array.from(rowsIDs)?.map(
|
|
6662
6651
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6663
6652
|
);
|
|
6664
6653
|
if (ids?.length > 0) {
|
|
6665
|
-
appDispatch((0,
|
|
6654
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(ids));
|
|
6666
6655
|
} else {
|
|
6667
6656
|
const sum = countSum(
|
|
6668
6657
|
rows,
|
|
6669
6658
|
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6670
6659
|
);
|
|
6671
6660
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6672
|
-
appDispatch((0,
|
|
6661
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(keys));
|
|
6673
6662
|
}
|
|
6674
6663
|
if (selectedRowKeysRef) {
|
|
6675
6664
|
selectedRowKeysRef.current = [];
|
|
6676
6665
|
}
|
|
6677
6666
|
} else {
|
|
6678
|
-
appDispatch((0,
|
|
6667
|
+
appDispatch((0, import_store9.setSelectedRowKeys)([]));
|
|
6679
6668
|
}
|
|
6680
6669
|
};
|
|
6681
6670
|
return {
|
|
@@ -6685,7 +6674,7 @@ var tableHeadController = (props) => {
|
|
|
6685
6674
|
|
|
6686
6675
|
// src/widget/advance/table/table-view/controller.ts
|
|
6687
6676
|
var import_react22 = require("react");
|
|
6688
|
-
var
|
|
6677
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
6689
6678
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6690
6679
|
var tableController = ({ data }) => {
|
|
6691
6680
|
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
@@ -6764,8 +6753,8 @@ var tableController = ({ data }) => {
|
|
|
6764
6753
|
|
|
6765
6754
|
// src/widget/advance/table/table-group/controller.ts
|
|
6766
6755
|
var import_react23 = require("react");
|
|
6767
|
-
var
|
|
6768
|
-
var
|
|
6756
|
+
var import_hooks16 = require("@fctc/interface-logic/hooks");
|
|
6757
|
+
var import_store11 = require("@fctc/interface-logic/store");
|
|
6769
6758
|
|
|
6770
6759
|
// src/environment.ts
|
|
6771
6760
|
var environment_exports = {};
|
|
@@ -6793,10 +6782,10 @@ var tableGroupController = (props) => {
|
|
|
6793
6782
|
selectedRowKeysRef
|
|
6794
6783
|
} = props;
|
|
6795
6784
|
const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
|
|
6796
|
-
const { groupByDomain, selectedTags } = (0,
|
|
6797
|
-
const { selectedRowKeys } = (0,
|
|
6798
|
-
const appDispatch = (0,
|
|
6799
|
-
const { toDataJS } = (0,
|
|
6785
|
+
const { groupByDomain, selectedTags } = (0, import_store11.useAppSelector)(import_store11.selectSearch);
|
|
6786
|
+
const { selectedRowKeys } = (0, import_store11.useAppSelector)(import_store11.selectList);
|
|
6787
|
+
const appDispatch = (0, import_store11.useAppDispatch)();
|
|
6788
|
+
const { toDataJS } = (0, import_hooks16.useOdooDataTransform)();
|
|
6800
6789
|
const initVal = toDataJS(row, viewData, model);
|
|
6801
6790
|
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
6802
6791
|
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
@@ -6843,7 +6832,7 @@ var tableGroupController = (props) => {
|
|
|
6843
6832
|
isPlaceholderData,
|
|
6844
6833
|
isLoading,
|
|
6845
6834
|
isFetching
|
|
6846
|
-
} = (0,
|
|
6835
|
+
} = (0, import_hooks16.useGetListData)(listDataProps, queryKey, enabled);
|
|
6847
6836
|
const {
|
|
6848
6837
|
columns: columnsGroup,
|
|
6849
6838
|
rows: rowsGroup,
|
|
@@ -6881,14 +6870,14 @@ var tableGroupController = (props) => {
|
|
|
6881
6870
|
const filteredIds = selectedRowKeys.filter(
|
|
6882
6871
|
(id) => !ids.includes(id)
|
|
6883
6872
|
);
|
|
6884
|
-
appDispatch((0,
|
|
6873
|
+
appDispatch((0, import_store11.setSelectedRowKeys)(filteredIds));
|
|
6885
6874
|
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6886
6875
|
const clonedKeys = [...selectedRowKeys];
|
|
6887
|
-
appDispatch((0,
|
|
6888
|
-
setTimeout(() => appDispatch((0,
|
|
6876
|
+
appDispatch((0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
6877
|
+
setTimeout(() => appDispatch((0, import_store11.setSelectedRowKeys)(clonedKeys)), 500);
|
|
6889
6878
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6890
6879
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6891
|
-
appDispatch((0,
|
|
6880
|
+
appDispatch((0, import_store11.setSelectedRowKeys)(filteredKeys));
|
|
6892
6881
|
}
|
|
6893
6882
|
toggleShowGroup();
|
|
6894
6883
|
};
|
|
@@ -6897,8 +6886,8 @@ var tableGroupController = (props) => {
|
|
|
6897
6886
|
return;
|
|
6898
6887
|
}
|
|
6899
6888
|
const clonedKeys = [...selectedRowKeys];
|
|
6900
|
-
(0,
|
|
6901
|
-
setTimeout(() => (0,
|
|
6889
|
+
(0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
6890
|
+
setTimeout(() => (0, import_store11.setSelectedRowKeys)(clonedKeys), 500);
|
|
6902
6891
|
}, [isQueryFetched]);
|
|
6903
6892
|
return {
|
|
6904
6893
|
handleExpandChildGroup,
|
|
@@ -6938,20 +6927,21 @@ var import_moment2 = __toESM(require_moment());
|
|
|
6938
6927
|
var import_react24 = require("react");
|
|
6939
6928
|
var searchController = ({
|
|
6940
6929
|
viewData,
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
searchMap
|
|
6930
|
+
model,
|
|
6931
|
+
domain,
|
|
6932
|
+
context,
|
|
6933
|
+
fieldsList
|
|
6946
6934
|
}) => {
|
|
6935
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
6947
6936
|
const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
|
|
6948
6937
|
const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
|
|
6949
6938
|
const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
|
|
6950
6939
|
const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
|
|
6951
6940
|
const [searchString, setSearchString] = (0, import_react24.useState)("");
|
|
6952
|
-
const
|
|
6953
|
-
const
|
|
6954
|
-
const
|
|
6941
|
+
const [searchMap, setSearchMap] = (0, import_react24.useState)({});
|
|
6942
|
+
const actionContext = typeof context === "string" ? (0, import_utils14.evalJSONContext)(context) : context;
|
|
6943
|
+
const contextSearch = { ...env.context, ...actionContext };
|
|
6944
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils14.evalJSONDomain)(domain, contextSearch) : [];
|
|
6955
6945
|
const clearSearch = () => {
|
|
6956
6946
|
setFilterBy([]);
|
|
6957
6947
|
setGroupBy([]);
|
|
@@ -6996,9 +6986,8 @@ var searchController = ({
|
|
|
6996
6986
|
}
|
|
6997
6987
|
};
|
|
6998
6988
|
(0, import_react24.useEffect)(() => {
|
|
6999
|
-
clearSearch();
|
|
7000
6989
|
fetchData();
|
|
7001
|
-
}, [
|
|
6990
|
+
}, [model, viewData]);
|
|
7002
6991
|
const onChangeSearchInput = (search_string) => {
|
|
7003
6992
|
setSearchString(search_string);
|
|
7004
6993
|
};
|
|
@@ -7035,27 +7024,27 @@ var searchController = ({
|
|
|
7035
7024
|
};
|
|
7036
7025
|
const formatDomain = () => {
|
|
7037
7026
|
if (domainAction) {
|
|
7038
|
-
const
|
|
7027
|
+
const domain2 = [];
|
|
7039
7028
|
if (domainAction?.length > 0) {
|
|
7040
|
-
if (Object.keys(searchMap).
|
|
7041
|
-
|
|
7029
|
+
if (Object.keys(searchMap).some((key) => !key.includes(import_constants5.SearchType.GROUP))) {
|
|
7030
|
+
domain2.push("&");
|
|
7042
7031
|
}
|
|
7043
7032
|
domainAction.forEach((domainItem) => {
|
|
7044
|
-
|
|
7033
|
+
domain2.push(domainItem);
|
|
7045
7034
|
});
|
|
7046
7035
|
}
|
|
7047
7036
|
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
7048
7037
|
if (!key?.includes(import_constants5.SearchType.GROUP)) {
|
|
7049
7038
|
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
7050
|
-
|
|
7039
|
+
domain2.push("&");
|
|
7051
7040
|
}
|
|
7052
7041
|
const valuesOfKey = searchMap[key];
|
|
7053
7042
|
valuesOfKey.forEach((value, index) => {
|
|
7054
7043
|
if (index < valuesOfKey.length - 1) {
|
|
7055
|
-
|
|
7044
|
+
domain2.push("|");
|
|
7056
7045
|
}
|
|
7057
7046
|
if (value.domain) {
|
|
7058
|
-
|
|
7047
|
+
domain2.push(...value.domain);
|
|
7059
7048
|
return;
|
|
7060
7049
|
}
|
|
7061
7050
|
let valueDomainItem = value?.value;
|
|
@@ -7071,11 +7060,11 @@ var searchController = ({
|
|
|
7071
7060
|
}
|
|
7072
7061
|
}
|
|
7073
7062
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
7074
|
-
|
|
7063
|
+
domain2.push([value.name, operator, valueDomainItem]);
|
|
7075
7064
|
});
|
|
7076
7065
|
}
|
|
7077
7066
|
});
|
|
7078
|
-
return [...
|
|
7067
|
+
return [...domain2];
|
|
7079
7068
|
}
|
|
7080
7069
|
};
|
|
7081
7070
|
const setTagSearch = (0, import_react24.useCallback)(
|
|
@@ -7106,16 +7095,16 @@ var searchController = ({
|
|
|
7106
7095
|
const contexts = [];
|
|
7107
7096
|
let groupValues = [];
|
|
7108
7097
|
objValues?.forEach((objValue) => {
|
|
7109
|
-
const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7098
|
+
const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7110
7099
|
const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
|
|
7111
7100
|
contexts.push(
|
|
7112
|
-
...Array.isArray(
|
|
7101
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
|
|
7113
7102
|
);
|
|
7114
7103
|
groupValues[indexAppend] = {
|
|
7115
7104
|
contexts: [
|
|
7116
|
-
...Array.isArray(
|
|
7105
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
|
|
7117
7106
|
group_by: item
|
|
7118
|
-
})) : [
|
|
7107
|
+
})) : [context2]
|
|
7119
7108
|
],
|
|
7120
7109
|
strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
|
|
7121
7110
|
};
|
|
@@ -7142,39 +7131,38 @@ var searchController = ({
|
|
|
7142
7131
|
[searchMap]
|
|
7143
7132
|
);
|
|
7144
7133
|
(0, import_react24.useEffect)(() => {
|
|
7145
|
-
setSelectedTags(null);
|
|
7146
7134
|
setTagSearch(searchMap);
|
|
7147
7135
|
}, [searchMap]);
|
|
7148
7136
|
const handleAddTagSearch = (tag) => {
|
|
7149
7137
|
const {
|
|
7150
|
-
domain,
|
|
7138
|
+
domain: domain2,
|
|
7151
7139
|
groupIndex,
|
|
7152
7140
|
value,
|
|
7153
7141
|
type,
|
|
7154
7142
|
title,
|
|
7155
|
-
context,
|
|
7143
|
+
context: context2,
|
|
7156
7144
|
active,
|
|
7157
7145
|
dataIndex
|
|
7158
7146
|
} = tag;
|
|
7159
|
-
const domainFormat = new import_utils14.domainHelper.Domain(
|
|
7147
|
+
const domainFormat = new import_utils14.domainHelper.Domain(domain2);
|
|
7160
7148
|
if (type === import_constants5.SearchType.FILTER) {
|
|
7161
7149
|
addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
|
|
7162
7150
|
...tag,
|
|
7163
|
-
domain:
|
|
7151
|
+
domain: domain2 ? domainFormat.toList(context2) : null
|
|
7164
7152
|
});
|
|
7165
7153
|
} else if (type === import_constants5.SearchType.SEARCH) {
|
|
7166
7154
|
addSearchItems(`${import_constants5.SearchType.SEARCH}_${String(dataIndex)}`, {
|
|
7167
7155
|
...tag,
|
|
7168
|
-
domain:
|
|
7169
|
-
...
|
|
7156
|
+
domain: domain2 ? domainFormat.toList({
|
|
7157
|
+
...context2,
|
|
7170
7158
|
self: value
|
|
7171
7159
|
}) : null
|
|
7172
7160
|
});
|
|
7173
7161
|
} else if (type === import_constants5.SearchType.GROUP) {
|
|
7174
7162
|
addSearchItems(`${import_constants5.SearchType.GROUP}`, {
|
|
7175
7163
|
...tag,
|
|
7176
|
-
domain:
|
|
7177
|
-
context,
|
|
7164
|
+
domain: domain2 ? domainFormat.toList({
|
|
7165
|
+
context: context2,
|
|
7178
7166
|
self: value
|
|
7179
7167
|
}) : null
|
|
7180
7168
|
});
|
|
@@ -7194,7 +7182,8 @@ var searchController = ({
|
|
|
7194
7182
|
removeSearchItems,
|
|
7195
7183
|
onSearchString: onChangeSearchInput,
|
|
7196
7184
|
handleAddTagSearch,
|
|
7197
|
-
domain: formatDomain()
|
|
7185
|
+
domain: formatDomain(),
|
|
7186
|
+
context: contextSearch
|
|
7198
7187
|
};
|
|
7199
7188
|
};
|
|
7200
7189
|
// Annotate the CommonJS export names for ESM import in node:
|