Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v2' into sync/v2-to-alpha-202502…
Browse files Browse the repository at this point in the history
…27-112730
  • Loading branch information
github-actions[bot] committed Feb 27, 2025
2 parents 2a8fde4 + 06f6707 commit 2dd0f39
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-ooui",
"version": "2.67.0-alpha.7",
"version": "2.67.0",
"engines": {
"node": "20.5.0"
},
Expand Down
7 changes: 5 additions & 2 deletions src/helpers/treeHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getTableColumns = (
tree: TreeOoui,
components: any,
context: any,
treeType: "infinite" | "paginated" | "legacy",
many2oneSortEnabled: boolean = false,
): Column[] => {
const many2oneSortEnabled = useFeatureIsEnabled(
ErpFeatureKeys.FEATURE_MANY2ONE_SORT,
Expand Down Expand Up @@ -94,7 +94,10 @@ const getTableColumns = (
if (aItem > bItem) return 1;
return 0;
},
isSortable,
isSortable:
type !== "one2many" &&
!column.isFunction &&
(type !== "many2one" || many2oneSortEnabled),
};
});
return tableColumns;
Expand Down
10 changes: 8 additions & 2 deletions src/widgets/base/one2many/One2manyTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
getKey,
} from "@/helpers/o2m-columnStorageHelper";
import { useLocale } from "@gisce/react-formiga-components";
import { useFeatureIsEnabled } from "@/context/ConfigContext";
import { ErpFeatureKeys } from "@/models/erpFeature";

export type One2manyTreeProps = {
items: One2manyItem[];
Expand Down Expand Up @@ -89,6 +91,10 @@ export const One2manyTree = ({
const itemsRef = useRef<One2manyItem[]>(items);
const { t } = useLocale();

const many2oneSortEnabled = useFeatureIsEnabled(
ErpFeatureKeys.FEATURE_MANY2ONE_SORT,
);

useDeepCompareEffect(() => {
itemsRef.current = items;
if (prevItemsValue.current === undefined) {
Expand All @@ -110,9 +116,9 @@ export const One2manyTree = ({
...COLUMN_COMPONENTS,
},
context,
"infinite",
many2oneSortEnabled,
);
}, [context, ooui]);
}, [context, ooui, many2oneSortEnabled]);

const onRequestData = useCallback(
async ({
Expand Down
14 changes: 8 additions & 6 deletions src/widgets/views/SearchTreeInfinite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ import SearchFilter from "./searchFilter/SearchFilter";
import { useSearchTreeState } from "@/hooks/useSearchTreeState";
import { Tree as TreeOoui } from "@gisce/ooui";
import { useAutorefreshableTreeFields } from "@/hooks/useAutorefreshableTreeFields";
import { useTreeFunctionFieldsRead } from "@/hooks/useTreeFunctionFieldsRead";
import { DEFAULT_SEARCH_LIMIT } from "@/models/constants";
import { NameSearchWarning } from "./Tree/NameSearchWarning";
import { SearchTreeHeader } from "./SearchTreeHeader";
import { useFeatureIsEnabled } from "@/context/ConfigContext";
import { ErpFeatureKeys } from "@/models/erpFeature";

export const HEIGHT_OFFSET = 10;
export const MAX_ROWS_TO_SELECT = 200;
Expand Down Expand Up @@ -148,6 +146,10 @@ function SearchTreeInfiniteComp(props: SearchTreeInfiniteProps, ref: any) {
const nameSearch = nameSearchProps || searchTreeNameSearch;
const prevNameSearch = useRef(nameSearch);

const many2oneSortEnabled = useFeatureIsEnabled(
ErpFeatureKeys.FEATURE_MANY2ONE_SORT,
);

useEffect(() => {
updateTotalRows();
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -211,9 +213,9 @@ function SearchTreeInfiniteComp(props: SearchTreeInfiniteProps, ref: any) {
...COLUMN_COMPONENTS,
},
parentContext,
"infinite",
many2oneSortEnabled,
);
}, [treeOoui, parentContext]);
}, [treeOoui, parentContext, many2oneSortEnabled]);

const columnsWithLoading = useMemo(() => {
if (!columns) {
Expand Down
10 changes: 8 additions & 2 deletions src/widgets/views/Tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
import { SelectAllRecordsRow } from "@/common/SelectAllRecordsRow";
import { COLUMN_COMPONENTS } from "./treeComponents";
import ErrorBoundary from "antd/es/alert/ErrorBoundary";
import { useFeatureIsEnabled } from "@/context/ConfigContext";
import { ErpFeatureKeys } from "@/models/erpFeature";

type Props = {
total?: number;
Expand Down Expand Up @@ -102,6 +104,10 @@ export const UnmemoizedTree = forwardRef<TableRef, Props>(
const { title = undefined, setTitle = undefined } =
(rootTree ? actionViewContext : {}) || {};

const many2oneSortEnabled = useFeatureIsEnabled(
ErpFeatureKeys.FEATURE_MANY2ONE_SORT,
);

const columns = useMemo(() => {
if (!treeOoui) {
return undefined;
Expand All @@ -113,9 +119,9 @@ export const UnmemoizedTree = forwardRef<TableRef, Props>(
...COLUMN_COMPONENTS,
},
context,
"legacy",
many2oneSortEnabled,
);
}, [context, treeOoui]);
}, [treeOoui, context, many2oneSortEnabled]);

useImperativeHandle(ref, () => ({
unselectAll: () => {
Expand Down

0 comments on commit 2dd0f39

Please sign in to comment.