From 63eb5480c4b7530021d7d7821f9aff900fe04d49 Mon Sep 17 00:00:00 2001 From: Mae Turiana Date: Thu, 18 Apr 2019 15:00:48 +0200 Subject: [PATCH] Moved construction of view uri and download uri in crud type getters --- src/store.js | 8 ++++++++ src/views/DetailPage.vue | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/store.js b/src/store.js index 4c16196..be0c36d 100755 --- a/src/store.js +++ b/src/store.js @@ -347,6 +347,14 @@ function typedCrudState(crudType) { state.initialized = initialized; } }, + getters: { + viewUri: (state) => (id) => { + return '/api/crud/' + crudType + '/' + id + '?'; + }, + downloadUri: (state, getters) => (id) => { + return getters.viewUri(id) + 'download=true'; + } + }, actions: { init({ commit }) { commit('isInitialized', { initialized: true }); diff --git a/src/views/DetailPage.vue b/src/views/DetailPage.vue index e358df1..d068add 100755 --- a/src/views/DetailPage.vue +++ b/src/views/DetailPage.vue @@ -121,10 +121,10 @@ export default { return this.$store.state.auth.profile || {}; }, viewUri() { - return '/api/crud/' + this.type + '/' + this.id + '?'; + return this.$store.getters['crud/' + this.type + '/viewUri'](this.id); }, downloadUri() { - return this.viewUri + 'download=true'; + return this.$store.getters['crud/' + this.type + '/downloadUri'](this.id); } }, mounted() {