Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/actionbar/TreeActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import { ActionBarSeparator } from "./ActionBarSeparator";
import { ShareUrlButton } from "./ShareUrlButton";
import { useErrorNotification } from "@/hooks/useErrorNotification";
import { ACTION_TYPE_REPORT } from "@/models/constants";
import { getVisibleTreeFields } from "@/helpers/treeHelper";

type Props = {
Expand Down Expand Up @@ -246,7 +247,7 @@ function TreeActionBarComponent({
id: -1,
model: currentModel,
report_name: "printscreen.list",
type: "ir.actions.report.xml",
type: ACTION_TYPE_REPORT,
datas: {
view_id: currentView?.view_id,
fields:
Expand Down
31 changes: 22 additions & 9 deletions src/context/ContentRootContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import { transformPlainMany2Ones, stringFormat } from "@/helpers/formHelper";
import { useFeatureData } from "./ConfigContext";
import { ErpFeatureKeys } from "@/models/erpFeature";
import { useNetworkRequest } from "@/hooks/useNetworkRequest";
import {
ACTION_TYPE_REPORT,
ACTION_TYPE_WINDOW,
ACTION_TYPE_URL,
} from "@/models/constants";
import { getVisibleTreeFields } from "@/helpers/treeHelper";

export type ContentRootContextType = {
Expand All @@ -34,8 +39,8 @@ export type ContentRootContextType = {
view_id,
}: {
actionData: any;
fields: any;
values: any;
fields?: any;
values?: any;
context?: any;
onRefreshParentValues?: () => void;
treeView?: any;
Expand Down Expand Up @@ -136,7 +141,15 @@ const ContentRootProvider = (
}
}

if (type !== "ir.actions.report.xml") {
// If view_id doesn't exist and we have a treeView, extract fields and add them to datas
if (!view_id && treeView) {
const fieldsToRetrieve = getVisibleTreeFields(treeView);
if (fieldsToRetrieve && fieldsToRetrieve.length > 0) {
datas.fields = fieldsToRetrieve;
}
}

if (type !== ACTION_TYPE_REPORT) {
showErrorNotification({
type: "error",
title: "Error",
Expand Down Expand Up @@ -227,8 +240,8 @@ const ContentRootProvider = (
view_id,
}: {
actionData: any;
fields: any;
values: any;
fields?: any;
values?: any;
context?: any;
onRefreshParentValues?: any;
treeView?: any;
Expand All @@ -239,7 +252,7 @@ const ContentRootProvider = (
onRefreshParentValues.current.push(onRefreshParentValuesFn);
}

if (type === "ir.actions.report.xml") {
if (type === ACTION_TYPE_REPORT) {
return await generateReport({
reportData: actionData,
fields,
Expand All @@ -248,9 +261,9 @@ const ContentRootProvider = (
treeView,
view_id,
});
} else if (type === "ir.actions.act_window") {
} else if (type === ACTION_TYPE_WINDOW) {
return await runAction({ actionData, fields, values, context });
} else if (type === "ir.actions.act_url") {
} else if (type === ACTION_TYPE_URL) {
window.open(
stringFormat(actionData.url, { ...values, context }),
"_blank",
Expand Down Expand Up @@ -281,7 +294,7 @@ const ContentRootProvider = (
if (!_actionData.res_model) {
actionData = (
await ConnectionProvider.getHandler().readObjects({
model: "ir.actions.act_window",
model: ACTION_TYPE_WINDOW,
ids: [parseInt(_actionData.id)],
context,
})
Expand Down
3 changes: 2 additions & 1 deletion src/ui/FavouriteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DropdownMenuGroup,
DropdownMenuItem,
} from "@gisce/react-formiga-components";
import { ACTION_TYPE_WIZARD } from "@/models/constants";
const { useToken } = theme;

export type ShortcutApi = {
Expand Down Expand Up @@ -124,7 +125,7 @@ const FavouriteButton = (props: Props) => {

function handleMenuClick(item: DropdownMenuItem) {
const shortcut = item as ShortcutApi;
if (shortcut?.action_type === "ir.actions.wizard") {
if (shortcut?.action_type === ACTION_TYPE_WIZARD) {
return;
}
openShortcut(shortcut);
Expand Down
12 changes: 8 additions & 4 deletions src/views/RootView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import { transformPlainMany2Ones } from "@/helpers/formHelper";
import { nanoid } from "nanoid";
import { useLocale } from "@gisce/react-formiga-components";
import { useConfigContext, useFeatureData } from "@/context/ConfigContext";
import { DEFAULT_SEARCH_LIMIT } from "@/models/constants";
import {
DEFAULT_SEARCH_LIMIT,
ACTION_TYPE_WINDOW,
ACTION_TYPE_WIZARD,
} from "@/models/constants";
import { filterAllowedValues } from "@/helpers/shareUrlHelper";
import { ErpFeatureKeys } from "@/models/erpFeature";
import { useNetworkRequest } from "@/hooks/useNetworkRequest";
Expand Down Expand Up @@ -215,7 +219,7 @@ function RootView(props: RootViewProps, ref: any) {

return await openAction({
action_id: -1,
action_type: "ir.actions.act_window",
action_type: ACTION_TYPE_WINDOW,
model,
views: [[view.view_id, "form"]],
context: rootContext,
Expand Down Expand Up @@ -249,7 +253,7 @@ function RootView(props: RootViewProps, ref: any) {
context: rootContext,
});

if (dataForAction.type === "ir.actions.wizard") {
if (dataForAction.type === ACTION_TYPE_WIZARD) {
showErrorNotification({
type: "error",
title: "Error",
Expand Down Expand Up @@ -722,7 +726,7 @@ function RootView(props: RootViewProps, ref: any) {

return await openAction({
action_id: -1,
action_type: "ir.actions.act_window",
action_type: ACTION_TYPE_WINDOW,
model,
views: finalViews,
context: rootContext,
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/WidgetFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { FiberGrid } from "./custom/FiberGrid";
import { Timeline } from "./custom/Timeline";
import { Indicator } from "./custom/Indicator";
import { Tags } from "./custom/Tags";
import { ActionButtons } from "./custom/ActionButtons";
import { QRCode } from "./custom/QRCode";
import { createElement } from "react";

Expand Down Expand Up @@ -140,6 +141,8 @@ const getWidgetType = (type: string) => {
return Carousel;
case "colorPicker":
return ColorPicker;
case "action_buttons":
return ActionButtons;
case "qrcode":
return QRCode;
default:
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/base/many2one/Many2oneSuffix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { useNetworkRequest } from "@/hooks/useNetworkRequest";
import { useFeatureIsEnabled } from "@/context/ConfigContext";
import { ErpFeatureKeys } from "@/models/erpFeature";
import { ACTION_TYPE_WINDOW } from "@/models/constants";

type Props = {
id: number;
Expand Down Expand Up @@ -155,7 +156,7 @@ export const Many2oneSuffix = (props: Props) => {
target: "current",
initialView: { type: "form" },
action_id: -1,
action_type: "ir.actions.act_window",
action_type: ACTION_TYPE_WINDOW,
});
break;
case "action":
Expand Down
Loading
Loading