mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Item Duplication for manually entered primary keys (#14947)
* disable save as copy for manually entered primary keys * only mark primaryKey as readonly for generated pk's * re-enable save-as-copy for manual ids
This commit is contained in:
@@ -286,8 +286,8 @@ function useForm() {
|
||||
|
||||
function setPrimaryKeyReadonly(field: Field) {
|
||||
if (
|
||||
field.schema?.has_auto_increment === true ||
|
||||
(field.schema?.is_primary_key === true && props.primaryKey !== '+')
|
||||
field.schema?.is_generated === true &&
|
||||
(field.schema?.has_auto_increment === true || (field.schema?.is_primary_key === true && props.primaryKey !== '+'))
|
||||
) {
|
||||
const fieldClone = cloneDeep(field) as any;
|
||||
if (!fieldClone.meta) fieldClone.meta = {};
|
||||
|
||||
@@ -168,8 +168,8 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
|
||||
...edits.value,
|
||||
};
|
||||
|
||||
// Make sure to delete the primary key
|
||||
if (primaryKeyField.value && primaryKeyField.value.field in newItem) {
|
||||
// Make sure to delete the primary key if it's generated
|
||||
if (primaryKeyField.value && primaryKeyField.value.schema?.is_generated && primaryKeyField.value.field in newItem) {
|
||||
delete newItem[primaryKeyField.value.field];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user