update empty string to null
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
<q-btn
|
||||
rounded color="primary"
|
||||
class="w100 q-mt-md q-mb-xs"
|
||||
:disable="!(isDirty(initialUser, modelValue))"
|
||||
@click = "emit('update')"
|
||||
@click = "onSubmit"
|
||||
>
|
||||
{{ $t(btnText) }}
|
||||
</q-btn>
|
||||
@@ -108,12 +107,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, computed, ref } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import { useCompaniesStore } from 'stores/companies'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { isDirty } from 'helpers/helpers'
|
||||
import { convertEmptyStringsToNull } from 'src/helpers/helpers'
|
||||
import type { User } from 'types/Users'
|
||||
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const modelValue = defineModel<User>({
|
||||
@@ -127,11 +127,10 @@
|
||||
|
||||
const emit = defineEmits(['update'])
|
||||
|
||||
const initialUser = ref({} as User)
|
||||
|
||||
onMounted(() => {
|
||||
initialUser.value = { ...modelValue.value }
|
||||
})
|
||||
function onSubmit() {
|
||||
const cleanedData = convertEmptyStringsToNull(modelValue.value)
|
||||
emit('update', cleanedData)
|
||||
}
|
||||
|
||||
const companiesStore = useCompaniesStore()
|
||||
const companies = computed(() => companiesStore.companies)
|
||||
|
||||
Reference in New Issue
Block a user