mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
@@ -32,8 +32,8 @@ export const useCollectionsStore = createStore({
|
||||
const collections: CollectionRaw[] = response.data.data;
|
||||
|
||||
this.state.collections = collections.map((collection: CollectionRaw) => {
|
||||
let name: string | VueI18n.TranslateResult;
|
||||
const icon = collection.meta?.icon || 'label';
|
||||
const name = formatTitle(collection.collection);
|
||||
|
||||
if (collection.meta && notEmpty(collection.meta.translations)) {
|
||||
for (let i = 0; i < collection.meta.translations.length; i++) {
|
||||
@@ -45,7 +45,22 @@ export const useCollectionsStore = createStore({
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...collection,
|
||||
name,
|
||||
icon,
|
||||
};
|
||||
});
|
||||
|
||||
this.translateCollections();
|
||||
},
|
||||
translateCollections() {
|
||||
this.state.collections = this.state.collections.map((collection: CollectionRaw) => {
|
||||
let name: string | VueI18n.TranslateResult;
|
||||
|
||||
if (i18n.te(`collection_names.${collection.collection}`)) {
|
||||
name = i18n.t(`collection_names.${collection.collection}`);
|
||||
} else {
|
||||
name = formatTitle(collection.collection);
|
||||
@@ -54,7 +69,6 @@ export const useCollectionsStore = createStore({
|
||||
return {
|
||||
...collection,
|
||||
name,
|
||||
icon,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
@@ -66,16 +66,16 @@ export const useFieldsStore = createStore({
|
||||
*/
|
||||
|
||||
this.state.fields = [...fields.map(this.parseField), fakeFilesField];
|
||||
|
||||
this.translateFields();
|
||||
},
|
||||
async dehydrate() {
|
||||
this.reset();
|
||||
},
|
||||
parseField(field: FieldRaw): Field {
|
||||
let name: string | VueI18n.TranslateResult;
|
||||
const name = formatTitle(field.field);
|
||||
|
||||
if (i18n.te(`fields.${field.collection}.${field.field}`)) {
|
||||
name = i18n.t(`fields.${field.collection}.${field.field}`);
|
||||
} else if (field.meta && notEmpty(field.meta.translations) && field.meta.translations.length > 0) {
|
||||
if (field.meta && notEmpty(field.meta.translations) && field.meta.translations.length > 0) {
|
||||
for (let i = 0; i < field.meta.translations.length; i++) {
|
||||
const { language, translation } = field.meta.translations[i];
|
||||
|
||||
@@ -87,10 +87,6 @@ export const useFieldsStore = createStore({
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
name = i18n.t(`fields.${field.collection}.${field.field}`);
|
||||
} else {
|
||||
name = formatTitle(field.field);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -98,6 +94,22 @@ export const useFieldsStore = createStore({
|
||||
name,
|
||||
};
|
||||
},
|
||||
translateFields() {
|
||||
this.state.fields = this.state.fields.map((field) => {
|
||||
let name: string | VueI18n.TranslateResult;
|
||||
|
||||
if (i18n.te(`fields.${field.collection}.${field.field}`)) {
|
||||
name = i18n.t(`fields.${field.collection}.${field.field}`);
|
||||
} else {
|
||||
name = formatTitle(field.field);
|
||||
}
|
||||
|
||||
return {
|
||||
...field,
|
||||
name,
|
||||
};
|
||||
});
|
||||
},
|
||||
async createField(collectionKey: string, newField: Field) {
|
||||
const stateClone = [...this.state.fields];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user