diff --git a/src/account/AppConfigPage.vue b/src/account/AppConfigPage.vue index 0ab2f85..82ac773 100644 --- a/src/account/AppConfigPage.vue +++ b/src/account/AppConfigPage.vue @@ -2,6 +2,12 @@

{{messages['app_'+app.name+'_config_view_'+viewId]}}

+

{{messages[successResponseMessage]}}

+
+ {{messages[successResponseMessageDescription]}} +
+
+
{{ errors.first(lastAction.name) }}
@@ -13,7 +19,7 @@
- + @@ -90,6 +96,16 @@

+ + +
+

{{messages[successResponseMessage]}}

+
+ {{messages[successResponseMessageDescription]}} +
+
+
+

{{messages['app_'+app.name+'_config_action_'+action.name]}}

@@ -101,7 +117,7 @@ {{messages['message_'+appActionParams[action.name][param]]}} {{appActionParams[action.name][param]}} - + {{messages['app_'+app.name+'_config_field_'+param+'_description']}} @@ -144,7 +160,9 @@ appActions: null, itemActionParams: {}, appActionParams: {}, - lastAction: null + lastAction: null, + successResponseMessage: null, + successResponseMessageDescription: null }; }, computed: { @@ -159,6 +177,11 @@ 'getAppByUserId', 'getAppConfigViewByUserId', 'takeConfigItemAction', 'takeConfigAppAction' ]), ...mapGetters('apps', ['loading']), + resetMessages() { + this.errors.clear(); + this.successResponseMessage = null; + this.successResponseMessageDescription = null; + }, initView() { this.appId = this.$route.params.app; this.viewId = this.$route.params.view; @@ -183,12 +206,12 @@ return safeEval(action.when, {'item': row}) === true; }, itemAction(action, itemId) { + this.resetMessages(); if (typeof action.view !== 'undefined' && action.view !== null) { this.$router.push({path: '/app/'+this.appId+'/config/'+action.view+'/'+itemId}); this.initView(); } else { this.lastAction = action; - this.errors.clear(); this.takeConfigItemAction({ userId: this.user.name, appId: this.appId, @@ -202,12 +225,12 @@ } }, appAction(action) { + this.resetMessages(); if (typeof action.view !== 'undefined' && action.view !== null) { this.$router.push({path: '/app/'+this.appId+'/config/'+action.view+(this.itemId ? +'/'+this.itemId : '')}); this.initView(); } else { this.lastAction = action; - this.errors.clear(); this.takeConfigAppAction({ userId: this.user.name, appId: this.appId, @@ -222,12 +245,12 @@ }, singleItemAction(action) { if (typeof action === 'undefined' || action === null) return; + this.resetMessages(); if (typeof action.view !== 'undefined' && action.view !== null) { this.$router.push({path: '/app/'+this.appId+'/config/'+action.view+'/'+this.itemId}); this.initView(); } else { this.lastAction = action; - this.errors.clear(); this.takeConfigItemAction({ userId: this.user.name, appId: this.appId, @@ -280,34 +303,48 @@ }, actionResult (ar) { if (ar) { - if (this.itemActionParams) { - for (let action in this.itemActionParams) { - if (this.itemActionParams.hasOwnProperty(action)) { - this.itemActionParams[action] = {}; + console.log('received ar with response: '+JSON.stringify(ar.response)); + if (typeof ar.response !== 'undefined' && ar.response !== null) { + if (typeof this.lastAction.successMessage !== 'undefined' && this.lastAction.successMessage !== null && this.lastAction.successMessage !== '') { + const resolution = ar.response[this.lastAction.successMessage]; + if (typeof resolution === 'undefined' || resolution === null || resolution === '' || !resolution) { + console.warn("watch.actionResult: bad resolution: "+JSON.stringify(resolution)); + } else { + this.successResponseMessage = 'app_' + this.app.name + '_config_response_' + resolution; + this.successResponseMessageDescription = 'app_' + this.app.name + '_config_response_' + resolution + "_description"; } } - } - if (this.appActionParams) { - for (let action in this.appActionParams) { - if (this.appActionParams.hasOwnProperty(action)) { - this.appActionParams[action] = {}; + + } else { + if (this.itemActionParams) { + for (let action in this.itemActionParams) { + if (this.itemActionParams.hasOwnProperty(action)) { + this.itemActionParams[action] = {}; + } + } + } + if (this.appActionParams) { + for (let action in this.appActionParams) { + if (this.appActionParams.hasOwnProperty(action)) { + this.appActionParams[action] = {}; + } } } - } - if (this.lastAction && typeof this.lastAction.successView !== 'undefined' && this.lastAction.successView !== null) { - const successView = this.lastAction.successView.parseMessage(this); - this.$router.push({path: '/app/'+this.appId+'/config/'+successView}); - this.initView(); - } else { - this.getAppConfigViewByUserId({ - userId: this.user.uuid, - appId: this.appId, - viewId: this.viewId, - itemId: this.itemId, - messages: this.messages, - errors: this.errors - }); + if (this.lastAction && typeof this.lastAction.successView !== 'undefined' && this.lastAction.successView !== null) { + const successView = this.lastAction.successView.parseMessage(this); + this.$router.push({path: '/app/' + this.appId + '/config/' + successView}); + this.initView(); + } else { + this.getAppConfigViewByUserId({ + userId: this.user.uuid, + appId: this.appId, + viewId: this.viewId, + itemId: this.itemId, + messages: this.messages, + errors: this.errors + }); + } } } }
{{messages['app_'+app.name+'_config_field_'+field]}}