!985 优化:模态框优化

pull/985/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 797d153555
commit 07920fca40

@ -37,21 +37,20 @@ export abstract class DrawBoardTool implements Command
BoardModal,
{ store: this.store, type: this.modalType });
app.Editor.ModalManage.SetCallback(async () =>
app.Editor.ModalManage.SetCallback(this.Callback);
}
private Callback = async () =>
{
await this.SelectAndBuildBoard();
if (this.store.autoCutOption.isAutoCut)
AutoCutting(this.store.autoCutOption.isRelevance);
});
}
};
private async SelectAndBuildBoard()
{
//原来禁用捕捉开启状态
let oldSnapState = app.Editor.GetPointServices.snapServices.Disabled;
app.Editor.GetPointServices.snapServices.Disabled = true;
while (true)
{
let selectSpace = new PointSelectSpaceClamp();
await selectSpace.Select(() =>
{
@ -60,17 +59,22 @@ export abstract class DrawBoardTool implements Command
this.buildBoard(false);
});
if (selectSpace.GetPointRes.Status === PromptStatus.None)
{
//命令执行完在弹出
setTimeout(() =>
{
app.Editor.ModalManage.RenderModeless(
BoardModal,
{ store: this.store, type: this.modalType }, {
position: ModalPosition.Old
});
break;
app.Editor.ModalManage.SetCallback(this.Callback);
}, 0);
return;
}
if (!selectSpace.ParseOK)
break;
return;
this.space = selectSpace.SpaceParse;
//用周围板件加工数据
if (this.store.UseBoardProcessOption && this.space.Boards.length > 0)
@ -80,9 +84,6 @@ export abstract class DrawBoardTool implements Command
app.Editor.UpdateScreen();
if (!userConfig.isContinuousDraw)
break;
}
//恢复原先状态
app.Editor.GetPointServices.snapServices.Disabled = oldSnapState;
}

@ -31,7 +31,6 @@ export class UserConfig implements IConfigStore
height: 2440,
width: 1220,
};
isContinuousDraw = false; //是否连续绘制层板立板背板...
@observable private _drillConfigs: Map<string, DrillingOption[]> = new Map();
@observable openDrillingReactor = true;
@observable openAutoCuttingReactor = true;

@ -8,6 +8,7 @@ import { CommandState } from './../../../Editor/CommandState';
import { ModalPosition } from "./ModalInterface";
import { IModalProps } from "./ModalsManage";
import { equaln } from '../../../Geometry/GeUtils';
import { AnyObject } from '../../Store/BoardInterface';
export const DATA_KEY = "data-modalkey";
@ -29,6 +30,8 @@ export class CADModal
private minimizeEl: HTMLElement = null;
private _mask: HTMLDivElement;
private _canForceMax = false;
/**锁定后不能关闭和最大化 */
IsLock = false;
constructor(_rootContainer: HTMLElement, private _rootModal?: CADModal)
{
this.container = document.createElement("div");
@ -44,7 +47,7 @@ export class CADModal
}
private onFocus = (e: FocusEvent) =>
{
if ((!this.IsModal && !CommandState.CommandIng) || this._canForceMax)
if ((!this.IsLock && !this.IsModal && !CommandState.CommandIng) || this._canForceMax)
{
let dialog = this.container.getElementsByClassName('bp3-dialog')[0] as HTMLElement;
if (dialog && this.minimizeEl)
@ -71,7 +74,7 @@ export class CADModal
}
}
};
static Create(rootContainer: HTMLElement, Component: any, props: { [key: string]: any; }, option: IModalProps = {})
static Create<T extends AnyObject>(rootContainer: HTMLElement, Component: React.ComponentType<T>, props: T, option: IModalProps = {})
{
let modal = new CADModal(option.root ? option.root.container : rootContainer, option.root);
modal.Render(Component, props, option);
@ -79,7 +82,7 @@ export class CADModal
option.root.ShowMasking();
return modal;
}
Render(Component: any, props: { [key: string]: any; }, option: IModalProps = {})
Render<T extends AnyObject>(Component: React.ComponentType<T>, props: T, option: IModalProps = {})
{
const { canMinimize = true, resizable = false, position = ModalPosition.Center, isModal = false, isMax = false, canForceMax = false } = option;
let key = (props?.type) ? props.type : (Component.name || Component.displayName);
@ -174,7 +177,7 @@ export class CADModal
this.dragHandleEl.style.top = this.dhTopEnd + delta.height + "px";
}
}
Update(Component: any, props: { [key: string]: any; }, option: IModalProps = {})
Update<T extends AnyObject>(Component: React.ComponentType<T>, props: T, option: IModalProps = {})
{
ReactDOM.unmountComponentAtNode(this.container);
this.minimizeEl = null;

@ -77,6 +77,17 @@ export class ModalManage
{
if (this.IsModal)
this.CurrentModal?.Focus();
else if (this.CurrentModal.IsLock)
{
for (let [, modal] of this._List)
{
if (modal.IsModal)
{
modal.Focus();
break;
}
}
}
else
this.MinAll();
});
@ -140,6 +151,8 @@ export class ModalManage
}
RenderModal<T extends AnyObject>(Component: React.ComponentType<T>, props?: T, option: IModalProps = {})
{
for (let [k, modal] of this._List)
modal.IsLock = true;
this.RenderModeless(Component, props, { ...option, isModal: true });
}
async EndExecingCmd()
@ -190,6 +203,7 @@ export class ModalManage
{
for (let [, modal] of this._List)
{
if (!modal.IsModal)
modal.Minimize();
}
}
@ -210,6 +224,9 @@ export class ModalManage
{
this.CurrentModal?.Destory();
app.Editor.MaskManage.Clear();
if (this.IsModal)
for (let [, modal] of this._List)
modal.IsLock = false;
}
private Clear()
{
@ -223,11 +240,15 @@ export class ModalManage
}
Destory()
{
if (this.CurrentModal.IsLock)
return;
this.Close();
this.Clear();
}
async DestoryAndExec(data: IModalResult = { Status: ModalState.Ok }, isClose = true)
{
if (this.CurrentModal.IsLock)
return;
if (isClose)
this.Close();
if (this.m_PromisRes)

@ -36,7 +36,7 @@ export class BoardStore extends Singleton implements IConfigStore
EditorTemplate: TemplateRecord;
m_Option: IBaseOption;
protected m_UiOption;
title: string;
readonly title: string;
@observable UseBoardProcessOption = true;
@observable m_BoardProcessOption: BoardProcessOption = { ...DefaultBoardProcessOption };
@observable remarks: [string, string][] = Array.from({ length: 12 }, () => ["", ""]);

Loading…
Cancel
Save