From 76e33b437c11cf978f22f6def2f6573a81caa77e Mon Sep 17 00:00:00 2001 From: miteshgoplani Date: Thu, 2 Jul 2020 15:47:38 +0530 Subject: [PATCH 1/2] Add AutoSave Example --- webClient/src/App.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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); From 640c4cfaad3e19327eba6a2bd9b600364d0a41b0 Mon Sep 17 00:00:00 2001 From: Mitesh Date: Mon, 27 Jul 2020 02:25:32 +0530 Subject: [PATCH 2/2] Add autosave property to pluginDefinition Signed-off-by: Mitesh --- pluginDefinition.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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": [ {