mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 10:42:19 +08:00
fix: some i18n error
This commit is contained in:
parent
1f95f6d5d0
commit
05f5530232
@ -27,8 +27,7 @@ export const refreshOnCompleteAction = {
|
|||||||
async handler(ctx, params) {
|
async handler(ctx, params) {
|
||||||
if (params.enable) {
|
if (params.enable) {
|
||||||
await ctx.extra.currentResource.refresh();
|
await ctx.extra.currentResource.refresh();
|
||||||
const t = ctx.globals.flowEngine.translate;
|
ctx.globals.message.success(ctx.model.translate('Data refreshed successfully'));
|
||||||
ctx.globals.message.success(t('Data refreshed successfully'));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ BulkDeleteActionModel.registerFlow({
|
|||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
async handler(ctx, params) {
|
async handler(ctx, params) {
|
||||||
const t = ctx.globals.flowEngine.translate;
|
const t = ctx.model.translate;
|
||||||
if (!ctx.shared?.currentBlockModel?.resource) {
|
if (!ctx.shared?.currentBlockModel?.resource) {
|
||||||
ctx.globals.message.error(t('No resource selected for deletion'));
|
ctx.globals.message.error(t('No resource selected for deletion'));
|
||||||
return;
|
return;
|
||||||
|
@ -52,7 +52,7 @@ BulkEditActionModel.registerFlow({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
async handler(ctx, params) {
|
async handler(ctx, params) {
|
||||||
const t = ctx.globals.flowEngine.translate;
|
const t = ctx.model.translate;
|
||||||
if (!ctx.shared?.currentBlockModel?.resource) {
|
if (!ctx.shared?.currentBlockModel?.resource) {
|
||||||
ctx.globals.message.error(t('No resource selected for bulk edit'));
|
ctx.globals.message.error(t('No resource selected for bulk edit'));
|
||||||
return;
|
return;
|
||||||
|
@ -35,7 +35,7 @@ DeleteActionModel.registerFlow({
|
|||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
async handler(ctx, params) {
|
async handler(ctx, params) {
|
||||||
const t = ctx.globals.flowEngine.translate;
|
const t = ctx.model.translate;
|
||||||
if (!ctx.shared?.currentBlockModel?.resource) {
|
if (!ctx.shared?.currentBlockModel?.resource) {
|
||||||
ctx.globals.message.error(t('No resource selected for deletion'));
|
ctx.globals.message.error(t('No resource selected for deletion'));
|
||||||
return;
|
return;
|
||||||
|
@ -20,7 +20,7 @@ const FilterContent: FC<{ value: any }> = (props) => {
|
|||||||
const currentBlockModel = modelInstance.ctx.shared.currentBlockModel as DataBlockModel;
|
const currentBlockModel = modelInstance.ctx.shared.currentBlockModel as DataBlockModel;
|
||||||
const fields = currentBlockModel.collection.getFields();
|
const fields = currentBlockModel.collection.getFields();
|
||||||
const ignoreFieldsNames = modelInstance.props.ignoreFieldsNames || [];
|
const ignoreFieldsNames = modelInstance.props.ignoreFieldsNames || [];
|
||||||
const t = modelInstance.flowEngine.translate;
|
const t = modelInstance.translate;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -44,7 +44,7 @@ export class FilterActionModel extends GlobalActionModel {
|
|||||||
|
|
||||||
defaultProps: any = {
|
defaultProps: any = {
|
||||||
type: 'default',
|
type: 'default',
|
||||||
children: tval('Filter'),
|
title: tval('Filter'),
|
||||||
icon: 'FilterOutlined',
|
icon: 'FilterOutlined',
|
||||||
filterValue: { $and: [] },
|
filterValue: { $and: [] },
|
||||||
ignoreFieldsNames: [],
|
ignoreFieldsNames: [],
|
||||||
|
@ -31,7 +31,7 @@ RefreshActionModel.registerFlow({
|
|||||||
steps: {
|
steps: {
|
||||||
refresh: {
|
refresh: {
|
||||||
async handler(ctx, params) {
|
async handler(ctx, params) {
|
||||||
const t = ctx.globals.flowEngine.translate;
|
const t = ctx.model.translate;
|
||||||
const currentResource = ctx.shared?.currentBlockModel?.resource;
|
const currentResource = ctx.shared?.currentBlockModel?.resource;
|
||||||
if (!currentResource) {
|
if (!currentResource) {
|
||||||
ctx.globals.message.error(t('No resource selected for refresh'));
|
ctx.globals.message.error(t('No resource selected for refresh'));
|
||||||
|
@ -69,7 +69,7 @@ export class GridModel extends FlowModel<GridModelStructure> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const t = this.flowEngine.translate.bind(this.flowEngine);
|
const t = this.translate;
|
||||||
console.log('GridModel render', JSON.stringify(this.props.rows, null, 2), this.props.sizes);
|
console.log('GridModel render', JSON.stringify(this.props.rows, null, 2), this.props.sizes);
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: 16 }}>
|
<div style={{ padding: 16 }}>
|
||||||
|
@ -65,7 +65,7 @@ CalendarBlockModel.registerFlow({
|
|||||||
step1: {
|
step1: {
|
||||||
handler(ctx, params) {
|
handler(ctx, params) {
|
||||||
console.log('ctx.extra.event', ctx.extra.event);
|
console.log('ctx.extra.event', ctx.extra.event);
|
||||||
const t = ctx.model.flowEngine.translate;
|
const t = ctx.model.translate;
|
||||||
Modal.info({
|
Modal.info({
|
||||||
title: t('Event selected'),
|
title: t('Event selected'),
|
||||||
content: (
|
content: (
|
||||||
@ -96,7 +96,7 @@ CalendarBlockModel.registerFlow({
|
|||||||
step1: {
|
step1: {
|
||||||
handler(ctx, params) {
|
handler(ctx, params) {
|
||||||
console.log('ctx.extra.event', ctx.extra.event);
|
console.log('ctx.extra.event', ctx.extra.event);
|
||||||
const t = ctx.model.flowEngine.translate;
|
const t = ctx.model.translate;
|
||||||
Modal.info({
|
Modal.info({
|
||||||
title: t('Double click'),
|
title: t('Double click'),
|
||||||
content: (
|
content: (
|
||||||
|
@ -17,7 +17,7 @@ export class FormActionModel extends ActionModel {}
|
|||||||
|
|
||||||
export class FormSubmitActionModel extends FormActionModel {
|
export class FormSubmitActionModel extends FormActionModel {
|
||||||
defaultProps: ButtonProps = {
|
defaultProps: ButtonProps = {
|
||||||
children: tval('Submit'),
|
title: tval('Submit'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
htmlType: 'submit',
|
htmlType: 'submit',
|
||||||
};
|
};
|
||||||
|
@ -64,7 +64,7 @@ export class TableActionsColumnModel extends FlowModel {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Space>{this.props.title || tval('Actions')}</Space>
|
<Space>{this.props.title || this.flowEngine.translate('Actions')}</Space>
|
||||||
</FlowsFloatContextMenu>
|
</FlowsFloatContextMenu>
|
||||||
),
|
),
|
||||||
render: this.render(),
|
render: this.render(),
|
||||||
|
@ -261,7 +261,7 @@ export class TabulatorModel extends DataBlockModel<S> {
|
|||||||
<FlowModelRenderer model={action} showFlowSettings sharedContext={{ currentBlockModel: this }} />
|
<FlowModelRenderer model={action} showFlowSettings sharedContext={{ currentBlockModel: this }} />
|
||||||
))}
|
))}
|
||||||
<AddActionButton model={this} subModelBaseClass="GlobalActionModel" subModelKey="actions">
|
<AddActionButton model={this} subModelBaseClass="GlobalActionModel" subModelKey="actions">
|
||||||
<Button icon={<SettingOutlined />}>{this.ctx.globals.translate('Configure actions')}</Button>
|
<Button icon={<SettingOutlined />}>{this.translate('Configure actions')}</Button>
|
||||||
</AddActionButton>
|
</AddActionButton>
|
||||||
</Space>
|
</Space>
|
||||||
<div ref={this.tabulatorRef} />
|
<div ref={this.tabulatorRef} />
|
||||||
|
@ -16,7 +16,7 @@ import { FilterFormActionModel } from './FilterFormActionModel';
|
|||||||
|
|
||||||
export class FilterFormSubmitActionModel extends FilterFormActionModel {
|
export class FilterFormSubmitActionModel extends FilterFormActionModel {
|
||||||
defaultProps: ButtonProps = {
|
defaultProps: ButtonProps = {
|
||||||
children: tval('Filter'),
|
title: tval('Filter'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -233,10 +233,12 @@ export const DefaultSettingsIcon: React.FC<DefaultSettingsIconProps> = ({
|
|||||||
|
|
||||||
// 如果step使用了action,检查action是否有uiSchema
|
// 如果step使用了action,检查action是否有uiSchema
|
||||||
let hasActionUiSchema = false;
|
let hasActionUiSchema = false;
|
||||||
|
let stepTitle = actionStep.title;
|
||||||
if (actionStep.use) {
|
if (actionStep.use) {
|
||||||
try {
|
try {
|
||||||
const action = targetModel.flowEngine?.getAction?.(actionStep.use);
|
const action = targetModel.flowEngine?.getAction?.(actionStep.use);
|
||||||
hasActionUiSchema = action && action.uiSchema != null;
|
hasActionUiSchema = action && action.uiSchema != null;
|
||||||
|
stepTitle = stepTitle || action.title;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(t('Failed to get action {{action}}', { action: actionStep.use }), ':', error);
|
console.warn(t('Failed to get action {{action}}', { action: actionStep.use }), ':', error);
|
||||||
}
|
}
|
||||||
@ -255,7 +257,7 @@ export const DefaultSettingsIcon: React.FC<DefaultSettingsIconProps> = ({
|
|||||||
stepKey,
|
stepKey,
|
||||||
step: actionStep,
|
step: actionStep,
|
||||||
uiSchema: mergedUiSchema,
|
uiSchema: mergedUiSchema,
|
||||||
title: t(actionStep.title) || stepKey,
|
title: t(stepTitle) || stepKey,
|
||||||
modelKey, // 添加模型标识
|
modelKey, // 添加模型标识
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
@ -306,7 +306,7 @@ const openRequiredParamsStepFormDialog = async ({
|
|||||||
// 创建FormDialog
|
// 创建FormDialog
|
||||||
const formDialog = FormDialog(
|
const formDialog = FormDialog(
|
||||||
{
|
{
|
||||||
title: dialogTitle,
|
title: dialogTitle || t('Step Parameter Configuration'),
|
||||||
width: dialogWidth,
|
width: dialogWidth,
|
||||||
footer: null, // 移除默认的底部按钮,使用自定义的导航按钮
|
footer: null, // 移除默认的底部按钮,使用自定义的导航按钮
|
||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
|
@ -53,9 +53,7 @@ const openStepSettingsDialog = async ({
|
|||||||
throw new Error(t('Step with key {{stepKey}} not found', { stepKey }));
|
throw new Error(t('Step with key {{stepKey}} not found', { stepKey }));
|
||||||
}
|
}
|
||||||
|
|
||||||
const title =
|
let title = step.title;
|
||||||
dialogTitle ||
|
|
||||||
(step ? `${step.title || stepKey} - ${t('Configuration')}` : `${t('Step Configuration')} - ${stepKey}`);
|
|
||||||
|
|
||||||
// 创建参数解析上下文
|
// 创建参数解析上下文
|
||||||
const paramsContext = {
|
const paramsContext = {
|
||||||
@ -76,6 +74,7 @@ const openStepSettingsDialog = async ({
|
|||||||
actionUiSchema = action.uiSchema;
|
actionUiSchema = action.uiSchema;
|
||||||
}
|
}
|
||||||
actionDefaultParams = action.defaultParams || {};
|
actionDefaultParams = action.defaultParams || {};
|
||||||
|
title = title || action.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析动态 uiSchema
|
// 解析动态 uiSchema
|
||||||
@ -132,7 +131,7 @@ const openStepSettingsDialog = async ({
|
|||||||
// 创建FormDialog
|
// 创建FormDialog
|
||||||
const formDialog = FormDialog(
|
const formDialog = FormDialog(
|
||||||
{
|
{
|
||||||
title,
|
title: dialogTitle || `${t(title)} - ${t('Configuration')}`,
|
||||||
width: dialogWidth,
|
width: dialogWidth,
|
||||||
okText: t('OK'),
|
okText: t('OK'),
|
||||||
cancelText: t('Cancel'),
|
cancelText: t('Cancel'),
|
||||||
|
@ -54,9 +54,7 @@ const openStepSettingsDrawer = async ({
|
|||||||
throw new Error(t('Step with key {{stepKey}} not found', { stepKey }));
|
throw new Error(t('Step with key {{stepKey}} not found', { stepKey }));
|
||||||
}
|
}
|
||||||
|
|
||||||
const title =
|
let title = step.title;
|
||||||
drawerTitle ||
|
|
||||||
(step ? `${step.title || stepKey} - ${t('Configuration')}` : `${t('Step Configuration')} - ${stepKey}`);
|
|
||||||
|
|
||||||
// 创建参数解析上下文
|
// 创建参数解析上下文
|
||||||
const paramsContext = {
|
const paramsContext = {
|
||||||
@ -76,6 +74,7 @@ const openStepSettingsDrawer = async ({
|
|||||||
actionUiSchema = action.uiSchema;
|
actionUiSchema = action.uiSchema;
|
||||||
}
|
}
|
||||||
actionDefaultParams = action.defaultParams || {};
|
actionDefaultParams = action.defaultParams || {};
|
||||||
|
title = title || action.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析动态 uiSchema
|
// 解析动态 uiSchema
|
||||||
@ -240,7 +239,7 @@ const openStepSettingsDrawer = async ({
|
|||||||
|
|
||||||
// 打开抽屉
|
// 打开抽屉
|
||||||
const drawerRef = drawer.open({
|
const drawerRef = drawer.open({
|
||||||
title,
|
title: drawerTitle || `${t(title)} - ${t('Configuration')}`,
|
||||||
width: drawerWidth,
|
width: drawerWidth,
|
||||||
content: <DrawerContent />,
|
content: <DrawerContent />,
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
@ -84,7 +84,7 @@ const LazyDropdown: React.FC<Omit<DropdownProps, 'menu'> & { menu: LazyDropdownM
|
|||||||
const dropdownMaxHeight = useNiceDropdownMaxHeight([menuVisible]);
|
const dropdownMaxHeight = useNiceDropdownMaxHeight([menuVisible]);
|
||||||
const [isSearching, setIsSearching] = useState(false);
|
const [isSearching, setIsSearching] = useState(false);
|
||||||
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
const t = model.flowEngine.translate.bind(model.flowEngine);
|
const t = model.translate;
|
||||||
|
|
||||||
// 清理定时器,避免内存泄露
|
// 清理定时器,避免内存泄露
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
ActionDefinition,
|
ActionDefinition,
|
||||||
ActionOptions,
|
ActionOptions,
|
||||||
CreateModelOptions,
|
CreateModelOptions,
|
||||||
|
FlowContext,
|
||||||
FlowDefinition,
|
FlowDefinition,
|
||||||
IFlowModelRepository,
|
IFlowModelRepository,
|
||||||
ModelConstructor,
|
ModelConstructor,
|
||||||
@ -37,7 +38,7 @@ export class FlowEngine {
|
|||||||
private modelInstances: Map<string, any> = new Map();
|
private modelInstances: Map<string, any> = new Map();
|
||||||
/** @public Stores flow settings including components and scopes for formily settings. */
|
/** @public Stores flow settings including components and scopes for formily settings. */
|
||||||
public flowSettings: FlowSettings = new FlowSettings();
|
public flowSettings: FlowSettings = new FlowSettings();
|
||||||
context: Record<string, any> = {};
|
context: FlowContext['globals'] = {} as FlowContext['globals'];
|
||||||
private modelRepository: IFlowModelRepository | null = null;
|
private modelRepository: IFlowModelRepository | null = null;
|
||||||
private _applyFlowCache = new Map<string, ApplyFlowCacheEntry>();
|
private _applyFlowCache = new Map<string, ApplyFlowCacheEntry>();
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ export class FlowModel<Structure extends { parent?: any; subModels?: any } = Def
|
|||||||
console[level.toLowerCase()](logMessage, logMeta);
|
console[level.toLowerCase()](logMessage, logMeta);
|
||||||
};
|
};
|
||||||
|
|
||||||
const globalContexts = currentFlowEngine.getContext() || {};
|
const globalContexts = currentFlowEngine.getContext();
|
||||||
const flowContext: FlowContext<this> = {
|
const flowContext: FlowContext<this> = {
|
||||||
exit: () => {
|
exit: () => {
|
||||||
throw new FlowExitException(flowKey, this.uid);
|
throw new FlowExitException(flowKey, this.uid);
|
||||||
@ -902,6 +902,10 @@ export class FlowModel<Structure extends { parent?: any; subModels?: any } = Def
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get translate() {
|
||||||
|
return this.flowEngine.translate.bind(this.flowEngine);
|
||||||
|
}
|
||||||
|
|
||||||
public setSharedContext(ctx: Record<string, any>) {
|
public setSharedContext(ctx: Record<string, any>) {
|
||||||
this._sharedContext = { ...this._sharedContext, ...ctx };
|
this._sharedContext = { ...this._sharedContext, ...ctx };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user