fix: mark data tab form dirty by watching field updates

(cherry picked from commit da4d3032bec9c0cb7996d94601bdbf0a0e6c938d)
This commit is contained in:
Shariq Ansari 2025-04-21 11:46:19 +05:30 committed by Mergify
parent 4e3a85e03b
commit 2c0fec20d1

View File

@ -64,7 +64,7 @@ import LoadingIndicator from '@/components/Icons/LoadingIndicator.vue'
import { createToast } from '@/utils'
import { usersStore } from '@/stores/users'
import { isMobileView } from '@/composables/settings'
import { ref } from 'vue'
import { ref, watch } from 'vue'
const props = defineProps({
doctype: {
@ -114,4 +114,20 @@ const tabs = createResource({
function saveChanges() {
data.save.submit()
}
watch(
() => data.doc,
(newValue, oldValue) => {
if (!oldValue) return
if (newValue && oldValue) {
const isDirty =
JSON.stringify(newValue) !== JSON.stringify(data.originalDoc)
data.isDirty = isDirty
if (isDirty) {
data.save.loading = false
}
}
},
{ deep: true },
)
</script>