diff --git a/public/package-lock.json b/public/package-lock.json index 95e2efd..57a9ee3 100644 --- a/public/package-lock.json +++ b/public/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "dependencies": { "rxjs": "^7.8.1", + "underscore": "^1.13.7", "vue": "^3.3.4", "vue-router": "^4.2.4" }, @@ -2209,6 +2210,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/underscore": { + "version": "1.13.7", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.7.tgz", + "integrity": "sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==" + }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/public/package.json b/public/package.json index e60e971..5aaf880 100644 --- a/public/package.json +++ b/public/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "rxjs": "^7.8.1", + "underscore": "^1.13.7", "vue": "^3.3.4", "vue-router": "^4.2.4" }, diff --git a/public/src/components/PlanActionBar.vue b/public/src/components/PlanActionBar.vue index f1dc235..a0a922d 100644 --- a/public/src/components/PlanActionBar.vue +++ b/public/src/components/PlanActionBar.vue @@ -9,15 +9,16 @@ const props = defineProps<{ \ No newline at end of file diff --git a/public/src/views/PlanView.vue b/public/src/views/PlanView.vue index ede71c3..0ed1641 100644 --- a/public/src/views/PlanView.vue +++ b/public/src/views/PlanView.vue @@ -14,7 +14,8 @@ import CreatePlanDialog from "@/components/dialog/CreatePlanDialog.vue"; import CreateGottesdienstDialog from "@/components/dialog/CreateGottesdienstDialog.vue"; import CreateMinistrantDialog from "@/components/dialog/CreateMinistrantDialog.vue"; import {useRoute, useRouter} from "vue-router"; -import {min} from "rxjs"; +import debounce from "underscore/modules/debounce.js" +import SavingIndicator from "@/components/SavingIndicator.vue"; const MAX_WIDTH_MOBILE = 600; @@ -38,6 +39,7 @@ const mobile = ref(window.innerWidth <= MAX_WIDTH_MOBILE) const editedMarks = reactive([]); const editPlanAdmin = ref(false) const planId = ref(parseInt(route.params.id as string)) +const isSaving = ref(false) onMounted(async () => { @@ -147,11 +149,13 @@ function getDif(): Mark[] { }) } -async function saveChanges() { + +const saveChanges = debounce(saveChangesFunc, 600) + +async function saveChangesFunc() { const saved = await API.setMarks(getDif()) if (saved) { - plan.marks = getMarks() - editedMarks.length = 0 + isSaving.value = false } } @@ -165,6 +169,7 @@ function canEdit(username: string) { return plan.editable.includes(username) } + function toggleMark(gid, mid) { // TODO: track changes const username = plan.ministranten.find(m => m.id == mid)?.username @@ -179,6 +184,9 @@ function toggleMark(gid, mid) { } editedMarks.push(mark) } + + isSaving.value = true + saveChanges() } @@ -306,6 +314,9 @@ async function createMinistrant(ministrantId?: number) { @add-mini="createMinistrant()" v-if="editPlanAdmin" /> + + +