mirror of
https://github.com/directus/directus.git
synced 2026-02-17 15:01:32 -05:00
Fix issue that would cause sort order of fields to be corrupted on field changes (#6174)
Fixes #6091
This commit is contained in:
@@ -61,7 +61,7 @@ export const useFieldsStore = defineStore({
|
||||
|
||||
const fields: FieldRaw[] = fieldsResponse.data.data;
|
||||
|
||||
this.fields = this.adjustSortForSystem([...fields.map(this.parseField), fakeFilesField]);
|
||||
this.fields = [...fields.map(this.parseField), fakeFilesField];
|
||||
|
||||
this.translateFields();
|
||||
},
|
||||
@@ -106,24 +106,6 @@ export const useFieldsStore = defineStore({
|
||||
};
|
||||
});
|
||||
},
|
||||
/**
|
||||
* System collections have system fields. We'll have to adjust all custom fields to have their
|
||||
* sort values incremented by the amount of system fields, to ensure the fields are sorted
|
||||
* correctly after the system fields. (#5520)
|
||||
*/
|
||||
adjustSortForSystem(fields: FieldRaw[]) {
|
||||
const systemFields = fields.filter((field) => field.meta?.system === true);
|
||||
|
||||
if (systemFields.length === 0) {
|
||||
return systemFields;
|
||||
}
|
||||
|
||||
return fields.map((field) => {
|
||||
if (field.meta?.system === true) return field;
|
||||
if (field.meta?.sort) field.meta.sort += systemFields.length;
|
||||
return field;
|
||||
});
|
||||
},
|
||||
async createField(collectionKey: string, newField: Field) {
|
||||
const stateClone = [...this.fields];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user