From d0222085b0da004ca77c108424e961f032eef0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=B6nert?= Date: Thu, 21 Mar 2019 13:25:08 +0100 Subject: [PATCH] Changed save behaviour --- .../Xrm.Oss.HtmlTemplating/components/App.tsx | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/web/Xrm.Oss.HtmlTemplating/components/App.tsx b/src/web/Xrm.Oss.HtmlTemplating/components/App.tsx index 07091bd..032a349 100644 --- a/src/web/Xrm.Oss.HtmlTemplating/components/App.tsx +++ b/src/web/Xrm.Oss.HtmlTemplating/components/App.tsx @@ -39,10 +39,18 @@ export default class EmailTemplating extends React.PureComponent { if (this.isEntityForm()) { - window.parent.Xrm.Page.data.entity.addOnSave(this.saveForm); const design = window.parent.Xrm.Page.getAttribute(this.props.jsonField).getValue(); this.Editor.loadDesign((design && JSON.parse(design)) || defaultDesign); + + (window as any).unlayer.addEventListener("design:updated", () => { + if (this.isEntityForm()) { + this.Editor.exportHtml(data => { + window.parent.Xrm.Page.getAttribute(this.props.htmlField).setValue(data.html); + window.parent.Xrm.Page.getAttribute(this.props.jsonField).setValue(JSON.stringify(data.design)); + }); + } + }); } } @@ -81,22 +89,6 @@ export default class EmailTemplating extends React.PureComponent { - if (this.state.allowSave) { - this.setState({ allowSave: false }); - return; - } - - saveEvent.getEventArgs().preventDefault(); - - this.Editor.exportHtml(data => { - window.parent.Xrm.Page.getAttribute(this.props.htmlField).setValue(data.html); - window.parent.Xrm.Page.getAttribute(this.props.jsonField).setValue(JSON.stringify(data.design)); - - this.setState({ allowSave: true }, this.triggerSave); - }); - } - saveSolution = () => { this.setState({requestPending: true});