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";

type Props = {
parentContext?: any;
Expand Down Expand Up @@ -241,7 +242,7 @@ function TreeActionBarComponent({
id: -1,
model: currentModel,
report_name: "printscreen.list",
type: "ir.actions.report.xml",
type: ACTION_TYPE_REPORT,
datas: {
model: currentModel,
ids: idsToExport,
Expand Down
23 changes: 14 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";

export type ContentRootContextType = {
processAction: ({
Expand All @@ -31,8 +36,8 @@ export type ContentRootContextType = {
context,
}: {
actionData: any;
fields: any;
values: any;
fields?: any;
values?: any;
context?: any;
onRefreshParentValues?: () => void;
}) => Promise<any>;
Expand Down Expand Up @@ -116,7 +121,7 @@ const ContentRootProvider = (
id: reportId,
} = reportData;

if (type !== "ir.actions.report.xml") {
if (type !== ACTION_TYPE_REPORT) {
showErrorNotification({
type: "error",
title: "Error",
Expand Down Expand Up @@ -205,8 +210,8 @@ const ContentRootProvider = (
onRefreshParentValues: onRefreshParentValuesFn,
}: {
actionData: any;
fields: any;
values: any;
fields?: any;
values?: any;
context?: any;
onRefreshParentValues?: any;
}) {
Expand All @@ -215,16 +220,16 @@ const ContentRootProvider = (
onRefreshParentValues.current.push(onRefreshParentValuesFn);
}

if (type === "ir.actions.report.xml") {
if (type === ACTION_TYPE_REPORT) {
return await generateReport({
reportData: actionData,
fields,
values,
context,
});
} 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 @@ -255,7 +260,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
8 changes: 8 additions & 0 deletions src/models/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export const DEFAULT_SEARCH_LIMIT = 80;

export const ACTION_TYPE_WINDOW = "ir.actions.act_window";
export const ACTION_TYPE_WINDOW_CLOSE = "ir.actions.act_window_close";
export const ACTION_TYPE_WIZARD = "ir.actions.wizard";
export const ACTION_TYPE_REPORT = "ir.actions.report.xml";
export const ACTION_TYPE_URL = "ir.actions.act_url";

export const MODEL_ACTIONS = "ir.actions.actions";
3 changes: 2 additions & 1 deletion src/ui/FavouriteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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 @@ -119,7 +120,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 @@ -721,7 +725,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 { createElement } from "react";

const getWidgetType = (type: string) => {
Expand Down Expand Up @@ -139,6 +140,8 @@ const getWidgetType = (type: string) => {
return Carousel;
case "colorPicker":
return ColorPicker;
case "action_buttons":
return ActionButtons;
default:
return undefined;
}
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