From 20e0b359ecf35cf24f611aaf01b883e26bc471f1 Mon Sep 17 00:00:00 2001 From: Radovan Tomasik Date: Tue, 13 Aug 2024 15:19:46 +0200 Subject: [PATCH] feat: refactor admin settings page --- src/store/actions.js | 10 ++ src/views/AdminSettingsPage.vue | 249 +++++++++++++++++++------------- 2 files changed, 159 insertions(+), 100 deletions(-) diff --git a/src/store/actions.js b/src/store/actions.js index b83249e9..5f25d9e9 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -84,6 +84,16 @@ export default { return null }) }, + retrieveAllAccessForms ({ state, commit }) { + return axios.get(`${BASE_API_PATH}/access-forms`, { headers: getBearerHeaders(state.oidc.access_token) }) + .then((response) => { + return response.data._embedded["access-forms"] + }) + .catch(() => { + commit("setNotification", "Error getting request data from server") + return null + }) + }, retrieveDynamicAccessFormsValueSetByID ({ state, commit }, { id }) { return axios.get(`${VALUE_SETS}/${id}`, { headers: getBearerHeaders(state.oidc.access_token) }) .then((response) => { diff --git a/src/views/AdminSettingsPage.vue b/src/views/AdminSettingsPage.vue index 98e9aa0d..5947ef52 100644 --- a/src/views/AdminSettingsPage.vue +++ b/src/views/AdminSettingsPage.vue @@ -1,109 +1,151 @@ @@ -115,20 +157,27 @@ import { useStore } from "vuex" const store = useStore() const resourceAllEvents = ref({}) -const infoRequirements = ref({}) - -const accessFormId = ref("") -const selectedResourceAllEvents = ref({}) +const infoRequirements = ref([]) +const accessForms = ref([]) +const selectedAccessForm = ref({}) +const selectedEvent = ref({}) +const summaryOnlyForAdmin = ref(true) onMounted(async () => { resourceAllEvents.value = await store.dispatch("retrieveResourceAllEvents") infoRequirements.value = await store.dispatch("retrieveInfoRequirements") + accessForms.value = await store.dispatch("retrieveAllAccessForms") + selectedEvent.value = resourceAllEvents.value[0] + selectedAccessForm.value = accessForms.value[0] }) async function setInfoRequirements () { const data = {} - data.requiredAccessFormId = accessFormId.value - data.forResourceEvent = selectedResourceAllEvents.value.value + console.log(selectedEvent.value) + data.requiredAccessFormId = selectedAccessForm.value.id + data.forResourceEvent = selectedEvent.value.value + data.viewableOnlyByAdmin = summaryOnlyForAdmin.value + console.log(data) await store.dispatch("setInfoRequirements", { data }) infoRequirements.value = await store.dispatch("retrieveInfoRequirements") }