mirror of
https://github.com/directus/directus.git
synced 2026-01-26 03:38:09 -05:00
Fix default values (#15710)
* Fix default values * run linter * use assign * fix working with permissions * run linter * fix set related item to empty when having junction * check for empty * Update app/src/views/private/components/drawer-item.vue --------- Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
This commit is contained in:
@@ -135,7 +135,7 @@ import DrawerCollection from '@/views/private/components/drawer-collection.vue';
|
||||
import Draggable from 'vuedraggable';
|
||||
import { getAssetUrl } from '@/utils/get-asset-url';
|
||||
import { adjustFieldsForDisplays } from '@/utils/adjust-fields-for-displays';
|
||||
import { get, clamp, isEmpty, isNil, set } from 'lodash';
|
||||
import { get, clamp, isNil, set, isEmpty } from 'lodash';
|
||||
import { usePermissionsStore } from '@/stores/permissions';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import { getFieldsFromTemplate } from '@directus/utils';
|
||||
|
||||
@@ -87,23 +87,23 @@ export default {
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Draggable from 'vuedraggable';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
import { hideDragImage } from '@/utils/hide-drag-image';
|
||||
import ItemPreview from './item-preview.vue';
|
||||
import { Filter } from '@directus/types';
|
||||
import { RelationO2M } from '@/composables/use-relation-o2m';
|
||||
import {
|
||||
ChangesItem,
|
||||
DisplayItem,
|
||||
RelationQueryMultiple,
|
||||
useRelationMultiple,
|
||||
ChangesItem,
|
||||
} from '@/composables/use-relation-multiple';
|
||||
import { RelationO2M } from '@/composables/use-relation-o2m';
|
||||
import { hideDragImage } from '@/utils/hide-drag-image';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection.vue';
|
||||
import DrawerItem from '@/views/private/components/drawer-item.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Filter } from '@directus/types';
|
||||
import { moveInArray } from '@directus/utils';
|
||||
import { cloneDeep, isEmpty } from 'lodash';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import Draggable from 'vuedraggable';
|
||||
import ItemPreview from './item-preview.vue';
|
||||
|
||||
type ChangeEvent =
|
||||
| {
|
||||
@@ -274,8 +274,6 @@ function addNew(item: Record<string, any>) {
|
||||
}
|
||||
|
||||
function stageEdits(item: Record<string, any>) {
|
||||
if (isEmpty(item)) return;
|
||||
|
||||
update(item);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -474,8 +474,6 @@ function editRow({ item }: { item: DisplayItem }) {
|
||||
}
|
||||
|
||||
function stageEdits(item: Record<string, any>) {
|
||||
if (isEmpty(item)) return;
|
||||
|
||||
if (newItem) {
|
||||
create(item);
|
||||
} else {
|
||||
|
||||
@@ -403,6 +403,10 @@ function useActions() {
|
||||
validationErrors.value = [];
|
||||
}
|
||||
|
||||
if (props.junctionField && Object.values(defaultValues.value).some((value) => value !== null)) {
|
||||
internalEdits.value[props.junctionField] = internalEdits.value[props.junctionField] ?? {};
|
||||
}
|
||||
|
||||
if (props.junctionField && props.relatedPrimaryKey !== '+' && relatedPrimaryKeyField.value) {
|
||||
set(internalEdits.value, [props.junctionField, relatedPrimaryKeyField.value.field], props.relatedPrimaryKey);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user