Skip to content

Commit

Permalink
Merge branch 'fix/adjustments-in-value-filtering-in-urls' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Jan 24, 2025
2 parents e6f3043 + 9fd9d6a commit 45675c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/helpers/shareUrlHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ActionInfo, ActionRawData } from "@/types";

const OPEN_ACTION_PATH = "action";
// Parameters to exclude from the URL
const ALLOWED_VALUES_KEYS = ["active_id", "active_ids", "id"];
const ALLOWED_VALUES_KEYS = ["active_id", "active_ids", "id", "parent_id"];
const IGNORED_PARAMS = ["target", "context", "domain", "fields"];

export const createShareOpenUrl = (action: ActionInfo) => {
Expand Down
10 changes: 9 additions & 1 deletion src/hooks/useUrlFromCurrentTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function useUrlFromCurrentTab({
}: {
currentTab?: Tab;
}): UseUrlFromCurrentTabResult {
const { currentView, searchParams, currentId } = useActionViewContext();
const { currentView, searchParams, currentId, formRef } =
useActionViewContext();
const { currentTab: currentTabContext } = useTabs();

const currentTab = currentTabProps || currentTabContext;
Expand All @@ -33,6 +34,13 @@ export function useUrlFromCurrentTab({
...(initialView && { initialView }),
...(searchParams && { searchParams }),
...(currentId && { res_id: currentId }),
actionRawData: {
...currentTab.action.actionRawData,
values: {
...currentTab.action.values,
...(formRef.current?.getPlainValues() || {}),
},
},
};

const shareUrl = createShareOpenUrl(finalActionData);
Expand Down
12 changes: 6 additions & 6 deletions src/views/RootView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function RootView(props: RootViewProps, ref: any) {
openShortcut,
handleOpenActionUrl,
handleOpenActionResourceUrl,
processAction: (contentRootProvider.current as any).processAction,
}));

function remove(key: string) {
Expand Down Expand Up @@ -84,9 +83,10 @@ function RootView(props: RootViewProps, ref: any) {
context: rootContext,
});

let values: Record<string, any> = filterAllowedValues(
actionRawData?.values,
);
let values: Record<string, any> = {
...(filterAllowedValues(actionRawData?.values) || {}),
...globalValues,
};

const finalIdToRead: number | undefined =
res_id || values.active_id || values.id;
Expand All @@ -113,7 +113,7 @@ function RootView(props: RootViewProps, ref: any) {
parseContext({
context: actionRawData.context,
fields,
values: { ...globalValues, ...(values || {}) },
values,
});
} else {
parsedContext = {};
Expand All @@ -134,7 +134,7 @@ function RootView(props: RootViewProps, ref: any) {
) {
return await ConnectionProvider.getHandler().evalDomain({
domain: actionRawData.domain,
values: { ...(values || {}), ...globalValues },
values,
context: { ...rootContext, ...parsedContext },
fields,
});
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/views/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ function Form(props: FormProps, ref: any) {
}

function getPlainValues() {
const values: any = getValues();
const fields: any = getFields();
const values: any = getValues() || {};
const fields: any = getFields() || {};
const reformattedValues: { [key: string]: any } = {};

Object.keys(values).forEach((key) => {
Expand Down

0 comments on commit 45675c6

Please sign in to comment.