From 55bc28e20cd9ff1519aa45a36656362d39cd5d6e Mon Sep 17 00:00:00 2001 From: DallinFromEarth <112426674+DallinFromEarth@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:33:54 -0700 Subject: [PATCH 1/5] refactor most config into separate components --- .../components/config/BannerConfigEditor.vue | 68 ++++ .../src/components/config/ConfigSection.vue | 40 +++ .../config/CourseIdConfigEditor.vue | 146 ++++++++ .../config/LivePhaseConfigEditor.vue | 51 +++ .../src/views/AdminView/ConfigView.vue | 311 +++--------------- 5 files changed, 346 insertions(+), 270 deletions(-) create mode 100644 src/main/resources/frontend/src/components/config/BannerConfigEditor.vue create mode 100644 src/main/resources/frontend/src/components/config/ConfigSection.vue create mode 100644 src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue create mode 100644 src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue diff --git a/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue b/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue new file mode 100644 index 00000000..bf431353 --- /dev/null +++ b/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/main/resources/frontend/src/components/config/ConfigSection.vue b/src/main/resources/frontend/src/components/config/ConfigSection.vue new file mode 100644 index 00000000..006d748d --- /dev/null +++ b/src/main/resources/frontend/src/components/config/ConfigSection.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue b/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue new file mode 100644 index 00000000..a878402a --- /dev/null +++ b/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue b/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue new file mode 100644 index 00000000..62bcd717 --- /dev/null +++ b/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/src/main/resources/frontend/src/views/AdminView/ConfigView.vue b/src/main/resources/frontend/src/views/AdminView/ConfigView.vue index 50efa303..62f44579 100644 --- a/src/main/resources/frontend/src/views/AdminView/ConfigView.vue +++ b/src/main/resources/frontend/src/views/AdminView/ConfigView.vue @@ -1,243 +1,72 @@ @@ -347,11 +123,6 @@ input[type="text"]{ width: 100%; } -.checkboxes { - display: flex; - flex-direction: column; -} - .center-buttons { display: flex; justify-content: center; From d7dcf3eb5ded3a301768c4b00ff66638fea46f99 Mon Sep 17 00:00:00 2001 From: DallinFromEarth <112426674+DallinFromEarth@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:32:57 -0700 Subject: [PATCH 2/5] allow editor components to close popup --- .../components/config/BannerConfigEditor.vue | 6 ++- .../src/components/config/ConfigSection.vue | 6 ++- .../config/CourseIdConfigEditor.vue | 17 ++++-- .../config/LivePhaseConfigEditor.vue | 13 +++++ .../src/views/AdminView/ConfigView.vue | 52 +++++++------------ 5 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue b/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue index bf431353..b6898bf0 100644 --- a/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue +++ b/src/main/resources/frontend/src/components/config/BannerConfigEditor.vue @@ -3,6 +3,10 @@ import { ref } from 'vue' import { useAppConfigStore } from '@/stores/appConfig' import { setBanner } from '@/services/configService' +const { closeEditor } = defineProps<{ + closeEditor: () => void +}>(); + const appConfigStore = useAppConfigStore(); const bannerMessageToSubmit = ref(appConfigStore.bannerMessage) @@ -30,7 +34,7 @@ const submitBanner = async () => { } catch (e) { alert("There was a problem in saving the updated banner message:\n" + e) } - //openBannerMessage.value = false + closeEditor() } diff --git a/src/main/resources/frontend/src/components/config/ConfigSection.vue b/src/main/resources/frontend/src/components/config/ConfigSection.vue index 006d748d..950805de 100644 --- a/src/main/resources/frontend/src/components/config/ConfigSection.vue +++ b/src/main/resources/frontend/src/components/config/ConfigSection.vue @@ -14,6 +14,10 @@ const openEditor = () => { useAppConfigStore().updateConfig() editorPopup.value = true } + +const closeEditor = () => { + editorPopup.value = false; +} diff --git a/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue b/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue index a878402a..09cd273c 100644 --- a/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue +++ b/src/main/resources/frontend/src/components/config/CourseIdConfigEditor.vue @@ -12,9 +12,9 @@ import { useAppConfigStore } from '@/stores/appConfig' const appConfigStore = useAppConfigStore(); -const getUpdatedConfig = async () => { - await appConfigStore.updateConfig(); -} +const { closeEditor } = defineProps<{ + closeEditor: () => void +}>(); const assignmentIdProxy = (phase: Phase): WritableComputedRef => computed({ get: (): number => appConfigStore.assignmentIds.get(phase) || -1, @@ -74,6 +74,7 @@ const submitManuelCourseIds = async () => { alert("There was problem manually setting the course-related IDs: " + (e as Error).message); } } + closeEditor() } const submitCanvasCourseIds = async () => { @@ -82,6 +83,7 @@ const submitCanvasCourseIds = async () => { } catch (e) { alert("There was problem getting and setting the course-related IDs using Canvas: " + (e as Error).message); } + closeEditor() } @@ -142,5 +144,14 @@ const submitCanvasCourseIds = async () => { diff --git a/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue b/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue index 62bcd717..de746ea9 100644 --- a/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue +++ b/src/main/resources/frontend/src/components/config/LivePhaseConfigEditor.vue @@ -5,6 +5,10 @@ import { setLivePhases } from '@/services/configService' const appConfigStore = useAppConfigStore(); +const { closeEditor } = defineProps<{ + closeEditor: () => void +}>(); + const setAllPhases = (setting: boolean) => { for (const phase of listOfPhases() as Phase[]) { appConfigStore.phaseActivationList[phase] = setting @@ -23,6 +27,7 @@ const submitLivePhases = async () => { } catch (e) { alert("There was a problem in saving live phases") } + closeEditor() } @@ -48,4 +53,12 @@ const submitLivePhases = async () => { display: flex; flex-direction: column; } +.submitChanges { + display: flex; + flex-direction: column; + align-items: center; +} +.submitChanges >* { + margin: 5px; +} diff --git a/src/main/resources/frontend/src/views/AdminView/ConfigView.vue b/src/main/resources/frontend/src/views/AdminView/ConfigView.vue index 62f44579..736ba902 100644 --- a/src/main/resources/frontend/src/views/AdminView/ConfigView.vue +++ b/src/main/resources/frontend/src/views/AdminView/ConfigView.vue @@ -26,24 +26,24 @@ onMounted( async () => {