mirror of
https://github.com/directus/directus.git
synced 2026-02-14 07:15:01 -05:00
Generate languages on auto generate of languages collection
This commit is contained in:
@@ -287,6 +287,13 @@ export default defineComponent({
|
||||
})
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
Object.keys(state.newRows).map((collection) => {
|
||||
const rows = state.newRows[collection];
|
||||
return api.post(`/items/${collection}`, rows);
|
||||
})
|
||||
);
|
||||
|
||||
await collectionsStore.hydrate();
|
||||
await fieldsStore.hydrate();
|
||||
await relationsStore.hydrate();
|
||||
|
||||
@@ -56,6 +56,7 @@ function initLocalStore(
|
||||
newCollections: [],
|
||||
newFields: [],
|
||||
updateFields: [],
|
||||
newRows: {},
|
||||
|
||||
autoFillJunctionRelation: true,
|
||||
});
|
||||
@@ -390,22 +391,96 @@ function initLocalStore(
|
||||
}
|
||||
|
||||
if (collectionExists(relatedCollection) === false) {
|
||||
state.newCollections.push({
|
||||
$type: 'related',
|
||||
collection: relatedCollection,
|
||||
fields: [
|
||||
{
|
||||
field: state.relations[1].one_primary,
|
||||
type: 'integer',
|
||||
schema: {
|
||||
has_auto_increment: true,
|
||||
if (type === 'translations') {
|
||||
state.newCollections.push({
|
||||
$type: 'related',
|
||||
collection: relatedCollection,
|
||||
fields: [
|
||||
{
|
||||
field: state.relations[1].one_primary,
|
||||
type: 'string',
|
||||
schema: {
|
||||
is_primary_key: true,
|
||||
},
|
||||
meta: {
|
||||
interface: 'text-input',
|
||||
options: {
|
||||
iconLeft: 'vpn_key',
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
hidden: true,
|
||||
{
|
||||
field: 'name',
|
||||
type: 'string',
|
||||
schema: {},
|
||||
meta: {
|
||||
interface: 'text-input',
|
||||
options: {
|
||||
iconLeft: 'translate',
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
],
|
||||
});
|
||||
} else {
|
||||
state.newCollections.push({
|
||||
$type: 'related',
|
||||
collection: relatedCollection,
|
||||
fields: [
|
||||
{
|
||||
field: state.relations[1].one_primary,
|
||||
type: 'integer',
|
||||
schema: {
|
||||
has_auto_increment: true,
|
||||
},
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'translations') {
|
||||
if (collectionExists(relatedCollection) === false) {
|
||||
state.newRows = {
|
||||
[relatedCollection]: [
|
||||
{
|
||||
code: 'en-US',
|
||||
name: 'English',
|
||||
},
|
||||
{
|
||||
code: 'de-DE',
|
||||
name: 'German',
|
||||
},
|
||||
{
|
||||
code: 'fr-Fr',
|
||||
name: 'French',
|
||||
},
|
||||
{
|
||||
code: 'ru-RU',
|
||||
name: 'Russian',
|
||||
},
|
||||
{
|
||||
code: 'es-ES',
|
||||
name: 'Spanish',
|
||||
},
|
||||
{
|
||||
code: 'it-IT',
|
||||
name: 'Italian',
|
||||
},
|
||||
{
|
||||
code: 'pt-BR',
|
||||
name: 'Portuguese',
|
||||
},
|
||||
],
|
||||
};
|
||||
} else {
|
||||
state.newRows = {};
|
||||
}
|
||||
}
|
||||
}, 50);
|
||||
|
||||
@@ -542,15 +617,17 @@ function initLocalStore(
|
||||
);
|
||||
|
||||
state.relations[0].many_collection = `${collection}_translations`;
|
||||
|
||||
state.relations[0].many_field = `${collection}_${
|
||||
fieldsStore.getPrimaryKeyFieldForCollection(collection)?.field
|
||||
}`;
|
||||
|
||||
state.relations[1].one_collection = 'languages';
|
||||
|
||||
if (collectionExists('languages')) {
|
||||
state.relations[1].one_primary = fieldsStore.getPrimaryKeyFieldForCollection('languages')?.field;
|
||||
} else {
|
||||
state.relations[1].one_primary = 'id';
|
||||
state.relations[1].one_primary = 'code';
|
||||
}
|
||||
|
||||
state.relations[1].many_field = `${state.relations[1].one_collection}_${state.relations[1].one_primary}`;
|
||||
|
||||
Reference in New Issue
Block a user