diff --git a/pluginDefinition.json b/pluginDefinition.json index 0a77650..40fca4a 100644 --- a/pluginDefinition.json +++ b/pluginDefinition.json @@ -16,7 +16,8 @@ "defaultWindowStyle": { "width": 900, "height": 420 - } + }, + "autosave": true }, "dataServices": [ { diff --git a/webClient/src/App.tsx b/webClient/src/App.tsx index bda96ab..32f4a7e 100644 --- a/webClient/src/App.tsx +++ b/webClient/src/App.tsx @@ -16,6 +16,8 @@ import { withTranslation } from 'react-i18next'; class App extends React.Component { private log: ZLUX.ComponentLogger; t: any; + sessionEvents:any; + autoSaveEvent:any; constructor(props){ super(props); this.log = this.props.resources.logger; @@ -25,6 +27,12 @@ class App extends React.Component { } else { this.state = this.getDefaultState(); } + this.sessionEvents = this.props.resources.sessionEvents; + this.autoSaveEvent = this.sessionEvents.autosaveEmitter.subscribe((saveThis: any)=> { + if (saveThis) { + saveThis({'appData':{'requestText':this.state.parameters,'targetAppId':this.state.appId}}); + } + }); }; @@ -73,8 +81,8 @@ class App extends React.Component { if (mode == 'PluginCreate' || mode == 'PluginFindAnyOrCreate') { this.updateOrInitState({actionType: actionType, appTarget: mode, - appId: data.targetAppId, - parameters: data.requestText}); + appId: data.appData.targetAppId, + parameters: data.appData.requestText}); } else { msg = `Invalid target mode given (${mode})`; this.log.warn(msg); @@ -336,6 +344,10 @@ class App extends React.Component { ); } + + componentWillUnmount(){ + this.autoSaveEvent.unsubscribe(); + } } export default withTranslation('translation')(App);