Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default values #15710

Merged
merged 16 commits into from Apr 10, 2023
Merged
8 changes: 6 additions & 2 deletions app/src/views/private/components/drawer-item.vue
Expand Up @@ -80,7 +80,7 @@
<script setup lang="ts">
import api from '@/api';
import FilePreview from '@/views/private/components/file-preview.vue';
import { isEmpty, merge, set } from 'lodash';
import { assign, isEmpty, merge, set } from 'lodash';
import { computed, ref, toRefs, watch } from 'vue';
import { useI18n } from 'vue-i18n';

Expand Down Expand Up @@ -411,7 +411,11 @@ function useActions() {
internalEdits.value[primaryKeyField.value.field] = props.primaryKey;
}

emit('input', internalEdits.value);
const noNullDefaultValues = Object.fromEntries(
Object.entries(defaultValues.value).filter(([_, value]) => value !== null)
);

emit('input', assign({}, noNullDefaultValues, internalEdits.value));
Nitwel marked this conversation as resolved.
Show resolved Hide resolved

internalActive.value = false;
internalEdits.value = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/composables/use-collection.ts
Expand Up @@ -37,7 +37,7 @@ export function useCollection(collectionKey: string | Ref<string | null>): Usabl
const defaults: Record<string, any> = {};

for (const field of fields.value) {
if (field.schema?.default_value) {
if (field.schema !== null && 'default_value' in field.schema) {
defaults[field.field] = field.schema.default_value;
}
}
Expand Down