From ff3bd7b442d81c218c4db0c637d9e0bf9c80e9df Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 1 Feb 2020 16:16:06 -0500 Subject: [PATCH] add/remove filter lists now working --- src/_services/app.service.js | 7 +++- src/_store/apps.module.js | 21 +++++++++++ src/account/AppConfigPage.vue | 66 +++++++++++++++++++++++++++++++---- 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/_services/app.service.js b/src/_services/app.service.js index e17ed36..94ac696 100644 --- a/src/_services/app.service.js +++ b/src/_services/app.service.js @@ -21,7 +21,8 @@ export const appService = { takeDataAction, getAppConfigViewByUserId, - takeConfigItemAction + takeConfigItemAction, + takeConfigAppAction }; // MITM @@ -92,3 +93,7 @@ function getAppConfigViewByUserId(userId, appId, viewId, messages, errors) { function takeConfigItemAction(userId, appId, viewId, itemId, params, action, messages, errors) { 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)); +} diff --git a/src/_store/apps.module.js b/src/_store/apps.module.js index 0fdd77d..08f3dfd 100644 --- a/src/_store/apps.module.js +++ b/src/_store/apps.module.js @@ -171,6 +171,15 @@ const actions = { actionResult => commit('takeConfigItemActionSuccess', actionResult), error => commit('takeConfigItemActionFailure', error) ); + }, + + takeConfigAppAction({ commit }, {userId, appId, viewId, params, action, messages, errors}) { + commit('takeConfigAppActionRequest'); + appService.takeConfigAppAction(userId, appId, viewId, params, action, messages, errors) + .then( + actionResult => commit('takeConfigAppActionSuccess', actionResult), + error => commit('takeConfigAppActionFailure', error) + ); } }; @@ -376,6 +385,18 @@ const mutations = { takeConfigItemActionFailure(state, error) { state.loading.action = false; state.error = error; + }, + + takeConfigAppActionRequest(state) { + state.loading.action = true; + }, + takeConfigAppActionSuccess(state, actionResult) { + state.loading.action = false; + state.actionResult = actionResult; + }, + takeConfigAppActionFailure(state, error) { + state.loading.action = false; + state.error = error; } }; diff --git a/src/account/AppConfigPage.vue b/src/account/AppConfigPage.vue index 113becc..31d58a3 100644 --- a/src/account/AppConfigPage.vue +++ b/src/account/AppConfigPage.vue @@ -5,7 +5,7 @@
{{messages.loading_app_config_data}}
-
+
@@ -58,12 +58,36 @@
- - +
+ +
+ + +
+

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

+
+ +
+ + + {{messages['app_'+app.name+'_config_field_'+param.name+'_description']}} +
{{ errors.first(param.name) }}
+
+ + +
+
+ + +
+ +
+
+
{{messages.message_no_config_data}} @@ -86,7 +110,9 @@ appFields: null, configView: null, itemActions: null, - appActions: null + appActions: null, + itemActionParams: {}, + appActionParams: {} }; }, computed: { @@ -112,20 +138,31 @@ }, methods: { ...mapActions('apps', [ - 'getAppByUserId', 'getAppConfigViewByUserId', 'takeConfigItemAction' + 'getAppByUserId', 'getAppConfigViewByUserId', 'takeConfigItemAction', 'takeConfigAppAction' ]), ...mapGetters('apps', ['loading']), actionIsAvailable(action, row) { if (typeof action.when === 'undefined' || action.when === null) return true; return safeEval(action.when, {'item': row}) === true; }, - itemAction(action, itemId, params) { + itemAction(action, itemId) { this.takeConfigItemAction({ userId: this.user.name, appId: this.appId, viewId: this.viewId, itemId: itemId, - params: (typeof params === 'undefined' || params === null ? {} : params), + params: this.itemActionParams[action.name], + action: action.name, + messages: this.messages, + errors: this.errors + }); + }, + appAction(action) { + 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 @@ -153,8 +190,10 @@ const action = this.configView.actions[j]; if (action.scope === 'item') { itemActions.push(action); + this.itemActionParams[action.name] = {}; } else if (action.scope === 'app') { appActions.push(action); + this.appActionParams[action.name] = {}; } else { console.warn('invalid scope for action: '+action.scope); } @@ -169,6 +208,19 @@ }, actionResult (ar) { if (ar) { + console.log('clearing form fields...'); + for (let action in this.itemActionParams) { + if (this.itemActionParams.hasOwnProperty(action)) { + this.itemActionParams[action] = {}; + } + } + + for (let action in this.appActionParams) { + if (this.appActionParams.hasOwnProperty(action)) { + this.appActionParams[action] = {}; + } + } + this.getAppConfigViewByUserId({ userId: this.user.uuid, appId: this.appId,