From 66eab3f6c7013af92ab0aa8e0bd24855edaf986a Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 1 Feb 2020 21:25:50 -0500 Subject: [PATCH] add support for custom list entries --- src/_services/app.service.js | 5 +-- src/_store/apps.module.js | 4 +-- src/account/AppConfigPage.vue | 58 ++++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/_services/app.service.js b/src/_services/app.service.js index bfa3f77..7e323d6 100644 --- a/src/_services/app.service.js +++ b/src/_services/app.service.js @@ -95,6 +95,7 @@ function takeConfigItemAction(userId, appId, viewId, itemId, params, action, mes return fetch(`${config.apiUrl}/users/${userId}/apps/${appId}/config/${viewId}/actions/${action}?id=${itemId}`, util.postWithAuth(params)).then(util.handleCrudResponse(messages, errors)); } -function takeConfigAppAction(userId, appId, viewId, params, action, messages, errors) { - return fetch(`${config.apiUrl}/users/${userId}/apps/${appId}/config/${viewId}/actions/${action}`, util.putWithAuth(params)).then(util.handleCrudResponse(messages, errors)); +function takeConfigAppAction(userId, appId, viewId, itemId, params, action, messages, errors) { + const id = (typeof itemId !== 'undefined' && itemId !== null ? `?id=${itemId}` : ''); + return fetch(`${config.apiUrl}/users/${userId}/apps/${appId}/config/${viewId}/actions/${action}${id}`, util.putWithAuth(params)).then(util.handleCrudResponse(messages, errors)); } diff --git a/src/_store/apps.module.js b/src/_store/apps.module.js index 0223086..93a39c7 100644 --- a/src/_store/apps.module.js +++ b/src/_store/apps.module.js @@ -173,9 +173,9 @@ const actions = { ); }, - takeConfigAppAction({ commit }, {userId, appId, viewId, params, action, messages, errors}) { + takeConfigAppAction({ commit }, {userId, appId, viewId, itemId, params, action, messages, errors}) { commit('takeConfigAppActionRequest'); - appService.takeConfigAppAction(userId, appId, viewId, params, action, messages, errors) + appService.takeConfigAppAction(userId, appId, viewId, itemId, params, action, messages, errors) .then( actionResult => commit('takeConfigAppActionSuccess', actionResult), error => commit('takeConfigAppActionFailure', error) diff --git a/src/account/AppConfigPage.vue b/src/account/AppConfigPage.vue index 20a7e98..0ab2f85 100644 --- a/src/account/AppConfigPage.vue +++ b/src/account/AppConfigPage.vue @@ -202,32 +202,43 @@ } }, appAction(action) { - this.lastAction = action; - this.errors.clear(); - this.takeConfigAppAction({ - userId: this.user.name, - appId: this.appId, - viewId: this.viewId, - params: this.appActionParams[action.name], - action: action.name, - messages: this.messages, - errors: this.errors - }); + 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, + viewId: this.viewId, + itemId: this.itemId, + params: this.appActionParams[action.name], + action: action.name, + messages: this.messages, + errors: this.errors + }); + } }, singleItemAction(action) { if (typeof action === 'undefined' || action === null) return; - this.lastAction = action; - this.errors.clear(); - this.takeConfigItemAction({ - userId: this.user.name, - appId: this.appId, - viewId: this.viewId, - itemId: this.itemId, - params: this.appConfigData, - action: action.name, - messages: this.messages, - errors: this.errors - }); + 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, + viewId: this.viewId, + itemId: this.itemId, + params: this.appConfigData, + action: action.name, + messages: this.messages, + errors: this.errors + }); + } } }, watch: { @@ -286,7 +297,6 @@ if (this.lastAction && typeof this.lastAction.successView !== 'undefined' && this.lastAction.successView !== null) { const successView = this.lastAction.successView.parseMessage(this); - console.log('parsed this.lastAction.successView ('+this.lastAction.successView+') => '+successView); this.$router.push({path: '/app/'+this.appId+'/config/'+successView}); this.initView(); } else {