diff --git a/src/renderers/Card.tsx b/src/renderers/Card.tsx index 0898dfb07..786248f38 100644 --- a/src/renderers/Card.tsx +++ b/src/renderers/Card.tsx @@ -85,9 +85,9 @@ export class Card extends React.Component { onAction && onAction(e, action, ctx || item.data); } - handleQuickChange(values: object, saveImmediately?: boolean, saveSlient?: boolean) { + handleQuickChange(values: object, saveImmediately?: boolean, savePristine?: boolean) { const {onQuickChange, item} = this.props; - onQuickChange && onQuickChange(item, values, saveImmediately, saveSlient); + onQuickChange && onQuickChange(item, values, saveImmediately, savePristine); } getPopOverContainer() { diff --git a/src/renderers/Form/index.tsx b/src/renderers/Form/index.tsx index a0bcc4055..d5e156e00 100644 --- a/src/renderers/Form/index.tsx +++ b/src/renderers/Form/index.tsx @@ -312,11 +312,12 @@ export default class Form extends React.Component { submitOnInit } = this.props; + const data = store.data; store.setInited(true); const hooks:Array<(data:any) => Promise> = this.hooks['init'] || []; - await Promise.all(hooks.map(hook => hook(store.data))); + await Promise.all(hooks.map(hook => hook(data))); - onInit && onInit(store.data); + onInit && onInit(data); submitOnInit && this.handleAction(undefined, { type: 'submit' diff --git a/src/renderers/List.tsx b/src/renderers/List.tsx index a7064c177..52bdad41f 100644 --- a/src/renderers/List.tsx +++ b/src/renderers/List.tsx @@ -270,10 +270,10 @@ export default class List extends React.Component { onSelect && onSelect(store.selectedItems.map(item => item.data), store.unSelectedItems.map(item => item.data)); } - handleQuickChange(item: IItem, values: object, saveImmediately?: boolean | any, saveSilent?: boolean) { - item.change(values, saveSilent); + handleQuickChange(item: IItem, values: object, saveImmediately?: boolean | any, savePristine?: boolean) { + item.change(values, savePristine); - if (!saveImmediately || saveSilent) { + if (!saveImmediately || savePristine) { return; } @@ -790,9 +790,9 @@ export class ListItem extends React.Component { onAction && onAction(e, action, ctx || item.data); } - handleQuickChange(values: object, saveImmediately?: boolean, saveSilent?: boolean) { + handleQuickChange(values: object, saveImmediately?: boolean, savePristine?: boolean) { const {onQuickChange, item} = this.props; - onQuickChange && onQuickChange(item, values, saveImmediately, saveSilent); + onQuickChange && onQuickChange(item, values, saveImmediately, savePristine); } renderLeft() { diff --git a/src/renderers/QuickEdit.tsx b/src/renderers/QuickEdit.tsx index ddccd861f..f4f838aea 100644 --- a/src/renderers/QuickEdit.tsx +++ b/src/renderers/QuickEdit.tsx @@ -63,6 +63,8 @@ export const HocQuickEdit = (config: Partial = {}) => (Componen this.handleWindowKeyPress = this.handleWindowKeyPress.bind(this); this.handleWindowKeyDown = this.handleWindowKeyDown.bind(this); this.formRef = this.formRef.bind(this); + this.handleInit = this.handleInit.bind(this); + this.handleChange = this.handleChange.bind(this); this.state = { isOpened: false, @@ -241,6 +243,17 @@ export const HocQuickEdit = (config: Partial = {}) => (Componen onQuickChange(values, (quickEdit as QuickEditConfig).saveImmediately); } + handleInit(values: object) { + const {onQuickChange} = this.props; + onQuickChange(values, false, true); + } + + handleChange(values: object) { + const {onQuickChange, quickEdit} = this.props; + + onQuickChange(values, (quickEdit as QuickEditConfig).saveImmediately); + } + openQuickEdit() { currentOpened = this; this.setState({ @@ -405,8 +418,8 @@ export const HocQuickEdit = (config: Partial = {}) => (Componen wrapperComponent: 'div', className: cx('Form--quickEdit'), ref: this.formRef, - onChange: (values: object) => - onQuickChange(values, (quickEdit as QuickEditConfig).saveImmediately), + onInit: this.handleInit, + onChange: this.handleChange, })} ); diff --git a/src/renderers/Table.tsx b/src/renderers/Table.tsx index e1f6a6866..22e6e9f3a 100644 --- a/src/renderers/Table.tsx +++ b/src/renderers/Table.tsx @@ -1604,9 +1604,9 @@ class TableRow extends React.Component { onAction && onAction(e, action, ctx || item.data); } - handleQuickChange(values: object, saveImmediately?: boolean, saveSilent?: boolean) { + handleQuickChange(values: object, saveImmediately?: boolean, savePristine?: boolean) { const {onQuickChange, item} = this.props; - onQuickChange && onQuickChange(item, values, saveImmediately, saveSilent); + onQuickChange && onQuickChange(item, values, saveImmediately, savePristine); } render() { diff --git a/src/store/formItem.ts b/src/store/formItem.ts index 599ebcd23..6bf2cb380 100644 --- a/src/store/formItem.ts +++ b/src/store/formItem.ts @@ -267,7 +267,7 @@ export const FormItemStore = types rules && (self.rules = rules); if ( - typeof value !== void 0 && self.value === void 0 + value !== void 0 && self.value === void 0 ) { form.setValueByName(self.name, value, true); }