mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
sort fields when getting them from the store (#4154)
This commit is contained in:
@@ -193,14 +193,12 @@ export default defineComponent({
|
||||
const fields = computed(() => {
|
||||
if (!state.relations[0].many_collection) return [];
|
||||
|
||||
return fieldsStore.state.fields
|
||||
.filter((field) => field.collection === state.relations[0].many_collection)
|
||||
.map((field) => ({
|
||||
text: field.field,
|
||||
value: field.field,
|
||||
disabled:
|
||||
!field.schema || field.schema?.is_primary_key || field.type !== currentCollectionPrimaryKey.value.type,
|
||||
}));
|
||||
return fieldsStore.getFieldsForCollection(state.relations[0].many_collection).map((field: Field) => ({
|
||||
text: field.field,
|
||||
value: field.field,
|
||||
disabled:
|
||||
!field.schema || field.schema?.is_primary_key || field.type !== currentCollectionPrimaryKey.value.type,
|
||||
}));
|
||||
});
|
||||
|
||||
const collectionMany = computed({
|
||||
|
||||
@@ -222,7 +222,13 @@ export const useFieldsStore = createStore({
|
||||
return primaryKeyField;
|
||||
},
|
||||
getFieldsForCollection(collection: string) {
|
||||
return this.state.fields.filter((field) => field.collection === collection);
|
||||
return this.state.fields
|
||||
.filter((field) => field.collection === collection)
|
||||
.sort((a, b) => {
|
||||
if (a.field < b.field) return -1;
|
||||
else if (a.field > b.field) return 1;
|
||||
else return 1;
|
||||
});
|
||||
},
|
||||
getField(collection: string, fieldKey: string) {
|
||||
if (fieldKey.includes('.')) {
|
||||
|
||||
Reference in New Issue
Block a user