@fctc/widget-logic 1.1.9 → 1.1.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/index.d.mts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +276 -2
- package/dist/index.mjs +286 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -213,4 +213,91 @@ declare const binaryFieldController: (props: IInputFieldProps) => {
|
|
|
213
213
|
getImageBase64WithMimeType: (base64: any) => string | null;
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
interface ITableBodyProps {
|
|
217
|
+
checkedAll: any;
|
|
218
|
+
checkboxRef: any;
|
|
219
|
+
setIsAutoSelect: any;
|
|
220
|
+
selectedRowKeys: any;
|
|
221
|
+
row: any;
|
|
222
|
+
isAutoSelect: any;
|
|
223
|
+
selectedRowKeysRef: any;
|
|
224
|
+
onClickRow: any;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare const tableBodyController: (props: ITableBodyProps) => {
|
|
228
|
+
handleCheckBoxSingle: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
229
|
+
checked: any;
|
|
230
|
+
handleClickRow: (col: any, row: any) => void;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
interface ITableHeadProps {
|
|
234
|
+
typeTable: string;
|
|
235
|
+
rows: any[];
|
|
236
|
+
selectedRowKeysRef: any;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare const tableHeadController: (props: ITableHeadProps) => {
|
|
240
|
+
handleCheckBoxAll: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
interface ITableProps {
|
|
244
|
+
data: {
|
|
245
|
+
fields: any[];
|
|
246
|
+
records: any[];
|
|
247
|
+
dataModel: {
|
|
248
|
+
[fieldName: string]: {
|
|
249
|
+
string?: string;
|
|
250
|
+
[key: string]: any;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
context: any;
|
|
254
|
+
typeTable?: 'list' | 'group' | 'calendar';
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
interface ISelctionStateProps {
|
|
258
|
+
typeTable?: string;
|
|
259
|
+
tableRef: any;
|
|
260
|
+
rows?: any[];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare const tableController: ({ data }: ITableProps) => {
|
|
264
|
+
rows: any[];
|
|
265
|
+
columns: any;
|
|
266
|
+
onToggleColumnOptional: (item: any) => void;
|
|
267
|
+
typeTable: "list" | "calendar" | "group" | undefined;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
declare const tableGroupController: (props: any) => {
|
|
271
|
+
handleExpandChildGroup: () => void;
|
|
272
|
+
colEmptyGroup: {
|
|
273
|
+
fromStart: number;
|
|
274
|
+
fromEnd: number;
|
|
275
|
+
};
|
|
276
|
+
leftPadding: string;
|
|
277
|
+
isShowGroup: boolean;
|
|
278
|
+
isQueryFetched: boolean;
|
|
279
|
+
nameGroupWithCount: string;
|
|
280
|
+
columns: any;
|
|
281
|
+
row: any;
|
|
282
|
+
isPlaceholderData: boolean;
|
|
283
|
+
columnsGroup: any;
|
|
284
|
+
indexRow: any;
|
|
285
|
+
rowsGroup: any[];
|
|
286
|
+
model: any;
|
|
287
|
+
viewData: any;
|
|
288
|
+
renderField: any;
|
|
289
|
+
level: any;
|
|
290
|
+
specification: any;
|
|
291
|
+
context: any;
|
|
292
|
+
checkedAll: any;
|
|
293
|
+
isDisplayCheckbox: any;
|
|
294
|
+
isAutoSelect: any;
|
|
295
|
+
setIsAutoSelect: any;
|
|
296
|
+
selectedRowKeysRef: any;
|
|
297
|
+
initVal: Record<string, any>;
|
|
298
|
+
dataResponse: any;
|
|
299
|
+
pageGroup: any;
|
|
300
|
+
setPageGroup: react.Dispatch<any>;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export { IInputFieldProps, type ISelctionStateProps, type ITableBodyProps, type ITableHeadProps, type ITableProps, ValuePropsType, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, floatController, floatTimeFiledController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, statusDropdownController, tableBodyController, tableController, tableGroupController, tableHeadController };
|
package/dist/index.d.ts
CHANGED
|
@@ -213,4 +213,91 @@ declare const binaryFieldController: (props: IInputFieldProps) => {
|
|
|
213
213
|
getImageBase64WithMimeType: (base64: any) => string | null;
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
interface ITableBodyProps {
|
|
217
|
+
checkedAll: any;
|
|
218
|
+
checkboxRef: any;
|
|
219
|
+
setIsAutoSelect: any;
|
|
220
|
+
selectedRowKeys: any;
|
|
221
|
+
row: any;
|
|
222
|
+
isAutoSelect: any;
|
|
223
|
+
selectedRowKeysRef: any;
|
|
224
|
+
onClickRow: any;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare const tableBodyController: (props: ITableBodyProps) => {
|
|
228
|
+
handleCheckBoxSingle: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
229
|
+
checked: any;
|
|
230
|
+
handleClickRow: (col: any, row: any) => void;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
interface ITableHeadProps {
|
|
234
|
+
typeTable: string;
|
|
235
|
+
rows: any[];
|
|
236
|
+
selectedRowKeysRef: any;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare const tableHeadController: (props: ITableHeadProps) => {
|
|
240
|
+
handleCheckBoxAll: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
interface ITableProps {
|
|
244
|
+
data: {
|
|
245
|
+
fields: any[];
|
|
246
|
+
records: any[];
|
|
247
|
+
dataModel: {
|
|
248
|
+
[fieldName: string]: {
|
|
249
|
+
string?: string;
|
|
250
|
+
[key: string]: any;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
context: any;
|
|
254
|
+
typeTable?: 'list' | 'group' | 'calendar';
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
interface ISelctionStateProps {
|
|
258
|
+
typeTable?: string;
|
|
259
|
+
tableRef: any;
|
|
260
|
+
rows?: any[];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare const tableController: ({ data }: ITableProps) => {
|
|
264
|
+
rows: any[];
|
|
265
|
+
columns: any;
|
|
266
|
+
onToggleColumnOptional: (item: any) => void;
|
|
267
|
+
typeTable: "list" | "calendar" | "group" | undefined;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
declare const tableGroupController: (props: any) => {
|
|
271
|
+
handleExpandChildGroup: () => void;
|
|
272
|
+
colEmptyGroup: {
|
|
273
|
+
fromStart: number;
|
|
274
|
+
fromEnd: number;
|
|
275
|
+
};
|
|
276
|
+
leftPadding: string;
|
|
277
|
+
isShowGroup: boolean;
|
|
278
|
+
isQueryFetched: boolean;
|
|
279
|
+
nameGroupWithCount: string;
|
|
280
|
+
columns: any;
|
|
281
|
+
row: any;
|
|
282
|
+
isPlaceholderData: boolean;
|
|
283
|
+
columnsGroup: any;
|
|
284
|
+
indexRow: any;
|
|
285
|
+
rowsGroup: any[];
|
|
286
|
+
model: any;
|
|
287
|
+
viewData: any;
|
|
288
|
+
renderField: any;
|
|
289
|
+
level: any;
|
|
290
|
+
specification: any;
|
|
291
|
+
context: any;
|
|
292
|
+
checkedAll: any;
|
|
293
|
+
isDisplayCheckbox: any;
|
|
294
|
+
isAutoSelect: any;
|
|
295
|
+
setIsAutoSelect: any;
|
|
296
|
+
selectedRowKeysRef: any;
|
|
297
|
+
initVal: Record<string, any>;
|
|
298
|
+
dataResponse: any;
|
|
299
|
+
pageGroup: any;
|
|
300
|
+
setPageGroup: react.Dispatch<any>;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export { IInputFieldProps, type ISelctionStateProps, type ITableBodyProps, type ITableHeadProps, type ITableProps, ValuePropsType, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, floatController, floatTimeFiledController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, statusDropdownController, tableBodyController, tableController, tableGroupController, tableHeadController };
|
package/dist/index.js
CHANGED
|
@@ -4063,6 +4063,10 @@ __export(index_exports, {
|
|
|
4063
4063
|
priorityFieldController: () => priorityFieldController,
|
|
4064
4064
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4065
4065
|
statusDropdownController: () => statusDropdownController,
|
|
4066
|
+
tableBodyController: () => tableBodyController,
|
|
4067
|
+
tableController: () => tableController,
|
|
4068
|
+
tableGroupController: () => tableGroupController,
|
|
4069
|
+
tableHeadController: () => tableHeadController,
|
|
4066
4070
|
useAppProvider: () => useAppProvider,
|
|
4067
4071
|
useAuth: () => useAuth,
|
|
4068
4072
|
useCallAction: () => useCallAction,
|
|
@@ -5404,7 +5408,7 @@ var many2manyFieldController = (props) => {
|
|
|
5404
5408
|
tab,
|
|
5405
5409
|
model,
|
|
5406
5410
|
aid,
|
|
5407
|
-
setSelectedRowKeys,
|
|
5411
|
+
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5408
5412
|
fields,
|
|
5409
5413
|
setFields,
|
|
5410
5414
|
groupByDomain,
|
|
@@ -5516,7 +5520,7 @@ var many2manyFieldController = (props) => {
|
|
|
5516
5520
|
[`${aid}_${relation}_popupmany2many`]: null
|
|
5517
5521
|
}));
|
|
5518
5522
|
appDispatch((0, import_interface_logic19.setPage)(0));
|
|
5519
|
-
|
|
5523
|
+
setSelectedRowKeys4([]);
|
|
5520
5524
|
setDomainMany2Many(null);
|
|
5521
5525
|
setIsLoadedData(false);
|
|
5522
5526
|
};
|
|
@@ -6296,6 +6300,272 @@ var binaryFieldController = (props) => {
|
|
|
6296
6300
|
getImageBase64WithMimeType
|
|
6297
6301
|
};
|
|
6298
6302
|
};
|
|
6303
|
+
|
|
6304
|
+
// src/widget/advance/table/table-body/controller.ts
|
|
6305
|
+
var import_interface_logic27 = require("@fctc/interface-logic");
|
|
6306
|
+
var import_react28 = require("react");
|
|
6307
|
+
var tableBodyController = (props) => {
|
|
6308
|
+
const {
|
|
6309
|
+
checkedAll,
|
|
6310
|
+
checkboxRef,
|
|
6311
|
+
setIsAutoSelect,
|
|
6312
|
+
selectedRowKeys,
|
|
6313
|
+
row,
|
|
6314
|
+
isAutoSelect,
|
|
6315
|
+
selectedRowKeysRef,
|
|
6316
|
+
onClickRow
|
|
6317
|
+
} = props;
|
|
6318
|
+
const appDispatch = (0, import_interface_logic27.useAppDispatch)();
|
|
6319
|
+
const checked = (0, import_react28.useMemo)(() => {
|
|
6320
|
+
if (!row?.id) return false;
|
|
6321
|
+
if (selectedRowKeys?.includes(row.id)) {
|
|
6322
|
+
return true;
|
|
6323
|
+
}
|
|
6324
|
+
return checkedAll;
|
|
6325
|
+
}, [row?.id, selectedRowKeys, checkedAll]);
|
|
6326
|
+
const handleCheckBoxSingle = (event) => {
|
|
6327
|
+
event.stopPropagation();
|
|
6328
|
+
if (checkedAll) {
|
|
6329
|
+
checkboxRef.current = "uncheck";
|
|
6330
|
+
setIsAutoSelect(true);
|
|
6331
|
+
return;
|
|
6332
|
+
}
|
|
6333
|
+
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6334
|
+
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6335
|
+
appDispatch((0, import_interface_logic27.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6336
|
+
};
|
|
6337
|
+
const handleClickRow = (col, row2) => {
|
|
6338
|
+
onClickRow(col, row2);
|
|
6339
|
+
};
|
|
6340
|
+
(0, import_react28.useEffect)(() => {
|
|
6341
|
+
if (!row?.id) return;
|
|
6342
|
+
if (isAutoSelect) {
|
|
6343
|
+
if (checkboxRef?.current === "uncheck") {
|
|
6344
|
+
const filtered = selectedRowKeysRef.current.filter(
|
|
6345
|
+
(id) => id !== row.id
|
|
6346
|
+
);
|
|
6347
|
+
selectedRowKeysRef.current = filtered;
|
|
6348
|
+
appDispatch((0, import_interface_logic27.setSelectedRowKeys)(filtered));
|
|
6349
|
+
} else {
|
|
6350
|
+
const unique = Array.from(
|
|
6351
|
+
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6352
|
+
);
|
|
6353
|
+
selectedRowKeysRef.current = unique;
|
|
6354
|
+
appDispatch((0, import_interface_logic27.setSelectedRowKeys)(unique));
|
|
6355
|
+
}
|
|
6356
|
+
}
|
|
6357
|
+
}, [isAutoSelect]);
|
|
6358
|
+
(0, import_react28.useEffect)(() => {
|
|
6359
|
+
if (!checkedAll) {
|
|
6360
|
+
checkboxRef.current = "enabled";
|
|
6361
|
+
false;
|
|
6362
|
+
}
|
|
6363
|
+
}, [checkedAll]);
|
|
6364
|
+
return {
|
|
6365
|
+
handleCheckBoxSingle,
|
|
6366
|
+
checked,
|
|
6367
|
+
handleClickRow
|
|
6368
|
+
};
|
|
6369
|
+
};
|
|
6370
|
+
|
|
6371
|
+
// src/widget/advance/table/table-head/controller.ts
|
|
6372
|
+
var import_interface_logic28 = require("@fctc/interface-logic");
|
|
6373
|
+
var tableHeadController = (props) => {
|
|
6374
|
+
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6375
|
+
const appDispatch = (0, import_interface_logic28.useAppDispatch)();
|
|
6376
|
+
const { groupByDomain } = (0, import_interface_logic28.useAppSelector)(import_interface_logic28.selectSearch);
|
|
6377
|
+
const handleCheckBoxAll = (event) => {
|
|
6378
|
+
if (event?.target?.checked && typeTable === "list") {
|
|
6379
|
+
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6380
|
+
appDispatch((0, import_interface_logic28.setSelectedRowKeys)(allRowKeys));
|
|
6381
|
+
} else if (event?.target?.checked && typeTable === "group") {
|
|
6382
|
+
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6383
|
+
const ids = Array.from(rowsIDs)?.map(
|
|
6384
|
+
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6385
|
+
);
|
|
6386
|
+
if (ids?.length > 0) {
|
|
6387
|
+
appDispatch((0, import_interface_logic28.setSelectedRowKeys)(ids));
|
|
6388
|
+
} else {
|
|
6389
|
+
const sum = countSum(
|
|
6390
|
+
rows,
|
|
6391
|
+
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6392
|
+
);
|
|
6393
|
+
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6394
|
+
appDispatch((0, import_interface_logic28.setSelectedRowKeys)(keys));
|
|
6395
|
+
}
|
|
6396
|
+
if (selectedRowKeysRef) {
|
|
6397
|
+
selectedRowKeysRef.current = [];
|
|
6398
|
+
}
|
|
6399
|
+
} else {
|
|
6400
|
+
appDispatch((0, import_interface_logic28.setSelectedRowKeys)([]));
|
|
6401
|
+
}
|
|
6402
|
+
};
|
|
6403
|
+
return {
|
|
6404
|
+
handleCheckBoxAll
|
|
6405
|
+
};
|
|
6406
|
+
};
|
|
6407
|
+
|
|
6408
|
+
// src/widget/advance/table/table-group/controller.ts
|
|
6409
|
+
var import_interface_logic29 = require("@fctc/interface-logic");
|
|
6410
|
+
var import_react29 = require("react");
|
|
6411
|
+
var tableGroupController = (props) => {
|
|
6412
|
+
const env = (0, import_interface_logic29.getEnv)();
|
|
6413
|
+
const {
|
|
6414
|
+
rows,
|
|
6415
|
+
columns,
|
|
6416
|
+
indexRow,
|
|
6417
|
+
row,
|
|
6418
|
+
model,
|
|
6419
|
+
viewData,
|
|
6420
|
+
renderField,
|
|
6421
|
+
level,
|
|
6422
|
+
specification,
|
|
6423
|
+
domain,
|
|
6424
|
+
context,
|
|
6425
|
+
checkedAll,
|
|
6426
|
+
isDisplayCheckbox,
|
|
6427
|
+
isAutoSelect,
|
|
6428
|
+
setIsAutoSelect,
|
|
6429
|
+
selectedRowKeysRef
|
|
6430
|
+
} = props;
|
|
6431
|
+
const [pageGroup, setPageGroup] = (0, import_react29.useState)(0);
|
|
6432
|
+
const { groupByDomain, selectedTags } = (0, import_interface_logic29.useAppSelector)(import_interface_logic29.selectSearch);
|
|
6433
|
+
const { selectedRowKeys } = (0, import_interface_logic29.useAppSelector)(import_interface_logic29.selectList);
|
|
6434
|
+
const appDispatch = (0, import_interface_logic29.useAppDispatch)();
|
|
6435
|
+
const { toDataJS } = (0, import_interface_logic29.useOdooDataTransform)();
|
|
6436
|
+
const initVal = toDataJS(row, viewData, model);
|
|
6437
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react29.useState)(false);
|
|
6438
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react29.useState)({
|
|
6439
|
+
fromStart: 1,
|
|
6440
|
+
fromEnd: 1
|
|
6441
|
+
});
|
|
6442
|
+
const processedData = (0, import_react29.useMemo)(() => {
|
|
6443
|
+
const calculateColSpanEmpty = () => {
|
|
6444
|
+
const startIndex = columns.findIndex(
|
|
6445
|
+
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
6446
|
+
);
|
|
6447
|
+
const endIndex = columns.findLastIndex(
|
|
6448
|
+
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator !== "sum"
|
|
6449
|
+
);
|
|
6450
|
+
const fromStart = startIndex === -1 ? columns.length : startIndex;
|
|
6451
|
+
const fromEnd = endIndex === -1 ? columns.length : columns.length - 1 - endIndex;
|
|
6452
|
+
setColEmptyGroup({ fromStart: fromStart + 1, fromEnd: fromEnd + 1 });
|
|
6453
|
+
return { fromStart: fromStart + 1, fromEnd: fromEnd + 1 };
|
|
6454
|
+
};
|
|
6455
|
+
return calculateColSpanEmpty();
|
|
6456
|
+
}, [columns, row]);
|
|
6457
|
+
const shouldFetchData = (0, import_react29.useMemo)(() => {
|
|
6458
|
+
return !!isShowGroup;
|
|
6459
|
+
}, [isShowGroup]);
|
|
6460
|
+
const enabled = shouldFetchData && !!processedData;
|
|
6461
|
+
const listDataProps = {
|
|
6462
|
+
model,
|
|
6463
|
+
specification,
|
|
6464
|
+
domain,
|
|
6465
|
+
context,
|
|
6466
|
+
offset: pageGroup * 10,
|
|
6467
|
+
fields: groupByDomain?.fields,
|
|
6468
|
+
groupby: [groupByDomain?.contexts[level]?.group_by]
|
|
6469
|
+
};
|
|
6470
|
+
const queryKey = [
|
|
6471
|
+
`data-${model}--${level}-row${indexRow}`,
|
|
6472
|
+
specification,
|
|
6473
|
+
domain,
|
|
6474
|
+
pageGroup
|
|
6475
|
+
];
|
|
6476
|
+
const {
|
|
6477
|
+
data: dataResponse,
|
|
6478
|
+
isFetched: isQueryFetched,
|
|
6479
|
+
isPlaceholderData,
|
|
6480
|
+
isLoading,
|
|
6481
|
+
isFetching
|
|
6482
|
+
} = (0, import_interface_logic29.useGetListData)(listDataProps, queryKey, enabled);
|
|
6483
|
+
const {
|
|
6484
|
+
columns: columnsGroup,
|
|
6485
|
+
rows: rowsGroup,
|
|
6486
|
+
typeTable: typeTableGroup
|
|
6487
|
+
} = tableController({
|
|
6488
|
+
data: {
|
|
6489
|
+
fields: viewData?.views?.list?.fields,
|
|
6490
|
+
records: dataResponse?.records ?? dataResponse?.groups,
|
|
6491
|
+
dataModel: viewData?.models?.[model],
|
|
6492
|
+
context: env.context,
|
|
6493
|
+
typeTable: dataResponse?.groups ? "group" : "list"
|
|
6494
|
+
}
|
|
6495
|
+
});
|
|
6496
|
+
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
6497
|
+
(0, import_react29.useEffect)(() => {
|
|
6498
|
+
if (isShowGroup && selectedTags?.length > 0) {
|
|
6499
|
+
setIsShowGroup(false);
|
|
6500
|
+
}
|
|
6501
|
+
}, [selectedTags]);
|
|
6502
|
+
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
6503
|
+
const nameGroup = Array.isArray(row[group_by_field_name]) ? row?.string ?? row[`${group_by_field_name}`][1] : viewData?.models?.[model]?.[group_by_field_name]?.selection ? viewData.models[model][group_by_field_name].selection.find(
|
|
6504
|
+
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
6505
|
+
)?.[1] : row[group_by_field_name];
|
|
6506
|
+
const nameGroupWithCount = `${typeof nameGroup === "string" ? nameGroup : typeof nameGroup === "boolean" && nameGroup ? i18n_default.t("yes") : i18n_default.t("no")} (${row[`${group_by_field_name?.split(":")?.[0]}_count`]})`;
|
|
6507
|
+
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
6508
|
+
const handleExpandChildGroup = () => {
|
|
6509
|
+
if (isLoading || isFetching) return;
|
|
6510
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6511
|
+
if (allIdsNull || typeTableGroup === "group") {
|
|
6512
|
+
toggleShowGroup();
|
|
6513
|
+
return;
|
|
6514
|
+
}
|
|
6515
|
+
if (isShowGroup && checkedAll) {
|
|
6516
|
+
const ids = rowsGroup?.map((item) => item?.id) || [];
|
|
6517
|
+
const filteredIds = selectedRowKeys.filter(
|
|
6518
|
+
(id) => !ids.includes(id)
|
|
6519
|
+
);
|
|
6520
|
+
appDispatch((0, import_interface_logic29.setSelectedRowKeys)(filteredIds));
|
|
6521
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6522
|
+
const clonedKeys = [...selectedRowKeys];
|
|
6523
|
+
appDispatch((0, import_interface_logic29.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
6524
|
+
setTimeout(() => appDispatch((0, import_interface_logic29.setSelectedRowKeys)(clonedKeys)), 500);
|
|
6525
|
+
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6526
|
+
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6527
|
+
appDispatch((0, import_interface_logic29.setSelectedRowKeys)(filteredKeys));
|
|
6528
|
+
}
|
|
6529
|
+
toggleShowGroup();
|
|
6530
|
+
};
|
|
6531
|
+
(0, import_react29.useEffect)(() => {
|
|
6532
|
+
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6533
|
+
return;
|
|
6534
|
+
}
|
|
6535
|
+
const clonedKeys = [...selectedRowKeys];
|
|
6536
|
+
(0, import_interface_logic29.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
6537
|
+
setTimeout(() => (0, import_interface_logic29.setSelectedRowKeys)(clonedKeys), 500);
|
|
6538
|
+
}, [isQueryFetched]);
|
|
6539
|
+
return {
|
|
6540
|
+
handleExpandChildGroup,
|
|
6541
|
+
colEmptyGroup,
|
|
6542
|
+
leftPadding,
|
|
6543
|
+
isShowGroup,
|
|
6544
|
+
isQueryFetched,
|
|
6545
|
+
nameGroupWithCount,
|
|
6546
|
+
columns,
|
|
6547
|
+
row,
|
|
6548
|
+
isPlaceholderData,
|
|
6549
|
+
columnsGroup,
|
|
6550
|
+
indexRow,
|
|
6551
|
+
rowsGroup,
|
|
6552
|
+
model,
|
|
6553
|
+
viewData,
|
|
6554
|
+
renderField,
|
|
6555
|
+
level,
|
|
6556
|
+
specification,
|
|
6557
|
+
context,
|
|
6558
|
+
checkedAll,
|
|
6559
|
+
isDisplayCheckbox,
|
|
6560
|
+
isAutoSelect,
|
|
6561
|
+
setIsAutoSelect,
|
|
6562
|
+
selectedRowKeysRef,
|
|
6563
|
+
initVal,
|
|
6564
|
+
dataResponse,
|
|
6565
|
+
pageGroup,
|
|
6566
|
+
setPageGroup
|
|
6567
|
+
};
|
|
6568
|
+
};
|
|
6299
6569
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6300
6570
|
0 && (module.exports = {
|
|
6301
6571
|
API_APP_URL,
|
|
@@ -6327,6 +6597,10 @@ var binaryFieldController = (props) => {
|
|
|
6327
6597
|
priorityFieldController,
|
|
6328
6598
|
setStorageItemAsync,
|
|
6329
6599
|
statusDropdownController,
|
|
6600
|
+
tableBodyController,
|
|
6601
|
+
tableController,
|
|
6602
|
+
tableGroupController,
|
|
6603
|
+
tableHeadController,
|
|
6330
6604
|
useAppProvider,
|
|
6331
6605
|
useAuth,
|
|
6332
6606
|
useCallAction,
|
package/dist/index.mjs
CHANGED
|
@@ -5416,7 +5416,7 @@ var many2manyFieldController = (props) => {
|
|
|
5416
5416
|
tab,
|
|
5417
5417
|
model,
|
|
5418
5418
|
aid,
|
|
5419
|
-
setSelectedRowKeys,
|
|
5419
|
+
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5420
5420
|
fields,
|
|
5421
5421
|
setFields,
|
|
5422
5422
|
groupByDomain,
|
|
@@ -5528,7 +5528,7 @@ var many2manyFieldController = (props) => {
|
|
|
5528
5528
|
[`${aid}_${relation}_popupmany2many`]: null
|
|
5529
5529
|
}));
|
|
5530
5530
|
appDispatch(setPage(0));
|
|
5531
|
-
|
|
5531
|
+
setSelectedRowKeys4([]);
|
|
5532
5532
|
setDomainMany2Many(null);
|
|
5533
5533
|
setIsLoadedData(false);
|
|
5534
5534
|
};
|
|
@@ -6321,6 +6321,286 @@ var binaryFieldController = (props) => {
|
|
|
6321
6321
|
getImageBase64WithMimeType
|
|
6322
6322
|
};
|
|
6323
6323
|
};
|
|
6324
|
+
|
|
6325
|
+
// src/widget/advance/table/table-body/controller.ts
|
|
6326
|
+
import { setSelectedRowKeys, useAppDispatch as useAppDispatch6 } from "@fctc/interface-logic";
|
|
6327
|
+
import { useEffect as useEffect15, useMemo as useMemo12 } from "react";
|
|
6328
|
+
var tableBodyController = (props) => {
|
|
6329
|
+
const {
|
|
6330
|
+
checkedAll,
|
|
6331
|
+
checkboxRef,
|
|
6332
|
+
setIsAutoSelect,
|
|
6333
|
+
selectedRowKeys,
|
|
6334
|
+
row,
|
|
6335
|
+
isAutoSelect,
|
|
6336
|
+
selectedRowKeysRef,
|
|
6337
|
+
onClickRow
|
|
6338
|
+
} = props;
|
|
6339
|
+
const appDispatch = useAppDispatch6();
|
|
6340
|
+
const checked = useMemo12(() => {
|
|
6341
|
+
if (!row?.id) return false;
|
|
6342
|
+
if (selectedRowKeys?.includes(row.id)) {
|
|
6343
|
+
return true;
|
|
6344
|
+
}
|
|
6345
|
+
return checkedAll;
|
|
6346
|
+
}, [row?.id, selectedRowKeys, checkedAll]);
|
|
6347
|
+
const handleCheckBoxSingle = (event) => {
|
|
6348
|
+
event.stopPropagation();
|
|
6349
|
+
if (checkedAll) {
|
|
6350
|
+
checkboxRef.current = "uncheck";
|
|
6351
|
+
setIsAutoSelect(true);
|
|
6352
|
+
return;
|
|
6353
|
+
}
|
|
6354
|
+
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6355
|
+
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6356
|
+
appDispatch(setSelectedRowKeys(newSelectedRowKeys));
|
|
6357
|
+
};
|
|
6358
|
+
const handleClickRow = (col, row2) => {
|
|
6359
|
+
onClickRow(col, row2);
|
|
6360
|
+
};
|
|
6361
|
+
useEffect15(() => {
|
|
6362
|
+
if (!row?.id) return;
|
|
6363
|
+
if (isAutoSelect) {
|
|
6364
|
+
if (checkboxRef?.current === "uncheck") {
|
|
6365
|
+
const filtered = selectedRowKeysRef.current.filter(
|
|
6366
|
+
(id) => id !== row.id
|
|
6367
|
+
);
|
|
6368
|
+
selectedRowKeysRef.current = filtered;
|
|
6369
|
+
appDispatch(setSelectedRowKeys(filtered));
|
|
6370
|
+
} else {
|
|
6371
|
+
const unique = Array.from(
|
|
6372
|
+
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6373
|
+
);
|
|
6374
|
+
selectedRowKeysRef.current = unique;
|
|
6375
|
+
appDispatch(setSelectedRowKeys(unique));
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
}, [isAutoSelect]);
|
|
6379
|
+
useEffect15(() => {
|
|
6380
|
+
if (!checkedAll) {
|
|
6381
|
+
checkboxRef.current = "enabled";
|
|
6382
|
+
false;
|
|
6383
|
+
}
|
|
6384
|
+
}, [checkedAll]);
|
|
6385
|
+
return {
|
|
6386
|
+
handleCheckBoxSingle,
|
|
6387
|
+
checked,
|
|
6388
|
+
handleClickRow
|
|
6389
|
+
};
|
|
6390
|
+
};
|
|
6391
|
+
|
|
6392
|
+
// src/widget/advance/table/table-head/controller.ts
|
|
6393
|
+
import {
|
|
6394
|
+
selectSearch as selectSearch4,
|
|
6395
|
+
setSelectedRowKeys as setSelectedRowKeys2,
|
|
6396
|
+
useAppDispatch as useAppDispatch7,
|
|
6397
|
+
useAppSelector as useAppSelector7
|
|
6398
|
+
} from "@fctc/interface-logic";
|
|
6399
|
+
var tableHeadController = (props) => {
|
|
6400
|
+
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6401
|
+
const appDispatch = useAppDispatch7();
|
|
6402
|
+
const { groupByDomain } = useAppSelector7(selectSearch4);
|
|
6403
|
+
const handleCheckBoxAll = (event) => {
|
|
6404
|
+
if (event?.target?.checked && typeTable === "list") {
|
|
6405
|
+
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6406
|
+
appDispatch(setSelectedRowKeys2(allRowKeys));
|
|
6407
|
+
} else if (event?.target?.checked && typeTable === "group") {
|
|
6408
|
+
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6409
|
+
const ids = Array.from(rowsIDs)?.map(
|
|
6410
|
+
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6411
|
+
);
|
|
6412
|
+
if (ids?.length > 0) {
|
|
6413
|
+
appDispatch(setSelectedRowKeys2(ids));
|
|
6414
|
+
} else {
|
|
6415
|
+
const sum = countSum(
|
|
6416
|
+
rows,
|
|
6417
|
+
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6418
|
+
);
|
|
6419
|
+
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6420
|
+
appDispatch(setSelectedRowKeys2(keys));
|
|
6421
|
+
}
|
|
6422
|
+
if (selectedRowKeysRef) {
|
|
6423
|
+
selectedRowKeysRef.current = [];
|
|
6424
|
+
}
|
|
6425
|
+
} else {
|
|
6426
|
+
appDispatch(setSelectedRowKeys2([]));
|
|
6427
|
+
}
|
|
6428
|
+
};
|
|
6429
|
+
return {
|
|
6430
|
+
handleCheckBoxAll
|
|
6431
|
+
};
|
|
6432
|
+
};
|
|
6433
|
+
|
|
6434
|
+
// src/widget/advance/table/table-group/controller.ts
|
|
6435
|
+
import {
|
|
6436
|
+
getEnv as getEnv11,
|
|
6437
|
+
selectList as selectList3,
|
|
6438
|
+
selectSearch as selectSearch5,
|
|
6439
|
+
setSelectedRowKeys as setSelectedRowKeys3,
|
|
6440
|
+
useAppDispatch as useAppDispatch8,
|
|
6441
|
+
useAppSelector as useAppSelector8,
|
|
6442
|
+
useGetListData as useGetListData4,
|
|
6443
|
+
useOdooDataTransform
|
|
6444
|
+
} from "@fctc/interface-logic";
|
|
6445
|
+
import { useEffect as useEffect16, useMemo as useMemo13, useState as useState16 } from "react";
|
|
6446
|
+
var tableGroupController = (props) => {
|
|
6447
|
+
const env = getEnv11();
|
|
6448
|
+
const {
|
|
6449
|
+
rows,
|
|
6450
|
+
columns,
|
|
6451
|
+
indexRow,
|
|
6452
|
+
row,
|
|
6453
|
+
model,
|
|
6454
|
+
viewData,
|
|
6455
|
+
renderField,
|
|
6456
|
+
level,
|
|
6457
|
+
specification,
|
|
6458
|
+
domain,
|
|
6459
|
+
context,
|
|
6460
|
+
checkedAll,
|
|
6461
|
+
isDisplayCheckbox,
|
|
6462
|
+
isAutoSelect,
|
|
6463
|
+
setIsAutoSelect,
|
|
6464
|
+
selectedRowKeysRef
|
|
6465
|
+
} = props;
|
|
6466
|
+
const [pageGroup, setPageGroup] = useState16(0);
|
|
6467
|
+
const { groupByDomain, selectedTags } = useAppSelector8(selectSearch5);
|
|
6468
|
+
const { selectedRowKeys } = useAppSelector8(selectList3);
|
|
6469
|
+
const appDispatch = useAppDispatch8();
|
|
6470
|
+
const { toDataJS } = useOdooDataTransform();
|
|
6471
|
+
const initVal = toDataJS(row, viewData, model);
|
|
6472
|
+
const [isShowGroup, setIsShowGroup] = useState16(false);
|
|
6473
|
+
const [colEmptyGroup, setColEmptyGroup] = useState16({
|
|
6474
|
+
fromStart: 1,
|
|
6475
|
+
fromEnd: 1
|
|
6476
|
+
});
|
|
6477
|
+
const processedData = useMemo13(() => {
|
|
6478
|
+
const calculateColSpanEmpty = () => {
|
|
6479
|
+
const startIndex = columns.findIndex(
|
|
6480
|
+
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
6481
|
+
);
|
|
6482
|
+
const endIndex = columns.findLastIndex(
|
|
6483
|
+
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator !== "sum"
|
|
6484
|
+
);
|
|
6485
|
+
const fromStart = startIndex === -1 ? columns.length : startIndex;
|
|
6486
|
+
const fromEnd = endIndex === -1 ? columns.length : columns.length - 1 - endIndex;
|
|
6487
|
+
setColEmptyGroup({ fromStart: fromStart + 1, fromEnd: fromEnd + 1 });
|
|
6488
|
+
return { fromStart: fromStart + 1, fromEnd: fromEnd + 1 };
|
|
6489
|
+
};
|
|
6490
|
+
return calculateColSpanEmpty();
|
|
6491
|
+
}, [columns, row]);
|
|
6492
|
+
const shouldFetchData = useMemo13(() => {
|
|
6493
|
+
return !!isShowGroup;
|
|
6494
|
+
}, [isShowGroup]);
|
|
6495
|
+
const enabled = shouldFetchData && !!processedData;
|
|
6496
|
+
const listDataProps = {
|
|
6497
|
+
model,
|
|
6498
|
+
specification,
|
|
6499
|
+
domain,
|
|
6500
|
+
context,
|
|
6501
|
+
offset: pageGroup * 10,
|
|
6502
|
+
fields: groupByDomain?.fields,
|
|
6503
|
+
groupby: [groupByDomain?.contexts[level]?.group_by]
|
|
6504
|
+
};
|
|
6505
|
+
const queryKey = [
|
|
6506
|
+
`data-${model}--${level}-row${indexRow}`,
|
|
6507
|
+
specification,
|
|
6508
|
+
domain,
|
|
6509
|
+
pageGroup
|
|
6510
|
+
];
|
|
6511
|
+
const {
|
|
6512
|
+
data: dataResponse,
|
|
6513
|
+
isFetched: isQueryFetched,
|
|
6514
|
+
isPlaceholderData,
|
|
6515
|
+
isLoading,
|
|
6516
|
+
isFetching
|
|
6517
|
+
} = useGetListData4(listDataProps, queryKey, enabled);
|
|
6518
|
+
const {
|
|
6519
|
+
columns: columnsGroup,
|
|
6520
|
+
rows: rowsGroup,
|
|
6521
|
+
typeTable: typeTableGroup
|
|
6522
|
+
} = tableController({
|
|
6523
|
+
data: {
|
|
6524
|
+
fields: viewData?.views?.list?.fields,
|
|
6525
|
+
records: dataResponse?.records ?? dataResponse?.groups,
|
|
6526
|
+
dataModel: viewData?.models?.[model],
|
|
6527
|
+
context: env.context,
|
|
6528
|
+
typeTable: dataResponse?.groups ? "group" : "list"
|
|
6529
|
+
}
|
|
6530
|
+
});
|
|
6531
|
+
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
6532
|
+
useEffect16(() => {
|
|
6533
|
+
if (isShowGroup && selectedTags?.length > 0) {
|
|
6534
|
+
setIsShowGroup(false);
|
|
6535
|
+
}
|
|
6536
|
+
}, [selectedTags]);
|
|
6537
|
+
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
6538
|
+
const nameGroup = Array.isArray(row[group_by_field_name]) ? row?.string ?? row[`${group_by_field_name}`][1] : viewData?.models?.[model]?.[group_by_field_name]?.selection ? viewData.models[model][group_by_field_name].selection.find(
|
|
6539
|
+
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
6540
|
+
)?.[1] : row[group_by_field_name];
|
|
6541
|
+
const nameGroupWithCount = `${typeof nameGroup === "string" ? nameGroup : typeof nameGroup === "boolean" && nameGroup ? i18n_default.t("yes") : i18n_default.t("no")} (${row[`${group_by_field_name?.split(":")?.[0]}_count`]})`;
|
|
6542
|
+
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
6543
|
+
const handleExpandChildGroup = () => {
|
|
6544
|
+
if (isLoading || isFetching) return;
|
|
6545
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6546
|
+
if (allIdsNull || typeTableGroup === "group") {
|
|
6547
|
+
toggleShowGroup();
|
|
6548
|
+
return;
|
|
6549
|
+
}
|
|
6550
|
+
if (isShowGroup && checkedAll) {
|
|
6551
|
+
const ids = rowsGroup?.map((item) => item?.id) || [];
|
|
6552
|
+
const filteredIds = selectedRowKeys.filter(
|
|
6553
|
+
(id) => !ids.includes(id)
|
|
6554
|
+
);
|
|
6555
|
+
appDispatch(setSelectedRowKeys3(filteredIds));
|
|
6556
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6557
|
+
const clonedKeys = [...selectedRowKeys];
|
|
6558
|
+
appDispatch(setSelectedRowKeys3([...clonedKeys, -1]));
|
|
6559
|
+
setTimeout(() => appDispatch(setSelectedRowKeys3(clonedKeys)), 500);
|
|
6560
|
+
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6561
|
+
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6562
|
+
appDispatch(setSelectedRowKeys3(filteredKeys));
|
|
6563
|
+
}
|
|
6564
|
+
toggleShowGroup();
|
|
6565
|
+
};
|
|
6566
|
+
useEffect16(() => {
|
|
6567
|
+
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6568
|
+
return;
|
|
6569
|
+
}
|
|
6570
|
+
const clonedKeys = [...selectedRowKeys];
|
|
6571
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
6572
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
6573
|
+
}, [isQueryFetched]);
|
|
6574
|
+
return {
|
|
6575
|
+
handleExpandChildGroup,
|
|
6576
|
+
colEmptyGroup,
|
|
6577
|
+
leftPadding,
|
|
6578
|
+
isShowGroup,
|
|
6579
|
+
isQueryFetched,
|
|
6580
|
+
nameGroupWithCount,
|
|
6581
|
+
columns,
|
|
6582
|
+
row,
|
|
6583
|
+
isPlaceholderData,
|
|
6584
|
+
columnsGroup,
|
|
6585
|
+
indexRow,
|
|
6586
|
+
rowsGroup,
|
|
6587
|
+
model,
|
|
6588
|
+
viewData,
|
|
6589
|
+
renderField,
|
|
6590
|
+
level,
|
|
6591
|
+
specification,
|
|
6592
|
+
context,
|
|
6593
|
+
checkedAll,
|
|
6594
|
+
isDisplayCheckbox,
|
|
6595
|
+
isAutoSelect,
|
|
6596
|
+
setIsAutoSelect,
|
|
6597
|
+
selectedRowKeysRef,
|
|
6598
|
+
initVal,
|
|
6599
|
+
dataResponse,
|
|
6600
|
+
pageGroup,
|
|
6601
|
+
setPageGroup
|
|
6602
|
+
};
|
|
6603
|
+
};
|
|
6324
6604
|
export {
|
|
6325
6605
|
API_APP_URL,
|
|
6326
6606
|
API_PRESCHOOL_URL,
|
|
@@ -6351,6 +6631,10 @@ export {
|
|
|
6351
6631
|
priorityFieldController,
|
|
6352
6632
|
setStorageItemAsync,
|
|
6353
6633
|
statusDropdownController,
|
|
6634
|
+
tableBodyController,
|
|
6635
|
+
tableController,
|
|
6636
|
+
tableGroupController,
|
|
6637
|
+
tableHeadController,
|
|
6354
6638
|
useAppProvider,
|
|
6355
6639
|
useAuth,
|
|
6356
6640
|
useCallAction,
|