Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 弹框增加按钮管理配置 #11269

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions packages/amis-editor/src/plugin/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ export class DialogPlugin extends BasePlugin {
name: 'title'
},

getSchemaTpl('button-manager'),

getSchemaTpl('switch', {
label: '展示关闭按钮',
name: 'showCloseButton',
Expand Down
1 change: 1 addition & 0 deletions packages/amis-editor/src/plugin/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class DrawerPlugin extends BasePlugin {
label: '显示蒙层',
pipeIn: defaultValue(true)
}),
getSchemaTpl('button-manager'),
getSchemaTpl('switch', {
name: 'showCloseButton',
label: '展示关闭按钮',
Expand Down
38 changes: 37 additions & 1 deletion packages/amis-editor/src/tpl/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
tipedLabel,
EditorManager
} from 'amis-editor-core';
import type {SchemaObject} from 'amis';
import {render, type SchemaObject} from 'amis';
import flatten from 'lodash/flatten';
import {InputComponentName} from '../component/InputComponentName';
import {FormulaDateType} from '../renderer/FormulaControl';
Expand Down Expand Up @@ -1851,3 +1851,39 @@ setSchemaTpl('inputForbid', {
name: 'inputForbid',
inputClassName: 'is-inline'
});

setSchemaTpl('button-manager', () => {
return getSchemaTpl('combo-container', {
type: 'combo',
label: '按钮管理',
name: 'actions',
mode: 'normal',
multiple: true,
addable: true,
draggable: true,
editable: false,
items: [
{
component: (props: any) => {
return render({
...props.data,
onEvent: {},
actionType: '',
onClick: (e: any, props: any) => {
const editorStore = (window as any).editorStore;
const subEditorStore = editorStore.getSubEditorRef()?.store;
(subEditorStore || editorStore).setActiveIdByComponentId(
props.id
);
}
});
}
}
],
addButtonText: '新增按钮',
scaffold: {
type: 'button',
label: '按钮'
}
});
});
4 changes: 2 additions & 2 deletions packages/amis/src/renderers/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,7 @@ export class Action extends React.Component<ActionProps, ActionState> {
render() {
const {
type,
icon,
iconClassName,
rightIcon,
rightIconClassName,
loadingClassName,
primary,
Expand Down Expand Up @@ -791,6 +789,8 @@ export class Action extends React.Component<ActionProps, ActionState> {
}) as string;
disabled = true;
}
const icon = filter(this.props.icon, data);
const rightIcon = filter(this.props.rightIcon, data);

const iconElement = (
<Icon
Expand Down
Loading