fix translations not using language table name (#12461)

This commit is contained in:
Azri Kahar
2022-03-29 21:39:49 +08:00
committed by GitHub
parent d640fe9a01
commit 8f0fa7bf84

View File

@@ -18,6 +18,7 @@ export function applyChanges(updates: StateUpdates, state: State, helperFn: Help
if (hasChanged('relations.m2o.related_collection')) {
preventCircularConstraint(updates, state, helperFn);
updateJunctionRelated(updates, state, helperFn);
}
if (hasChanged('relations.o2m.field')) {
@@ -108,6 +109,16 @@ export function setJunctionFields(updates: StateUpdates, _state: State, { getCur
set(updates, 'relations.m2o.meta.junction_field', getCurrent('relations.o2m.field'));
}
export function updateJunctionRelated(updates: StateUpdates, _state: State, { getCurrent }: HelperFunctions) {
const fieldsStore = useFieldsStore();
const relatedCollection = getCurrent('relations.m2o.related_collection');
const relatedCollectionPrimaryKeyField =
fieldsStore.getPrimaryKeyFieldForCollection(relatedCollection)?.field ?? 'id';
set(updates, 'relations.m2o.field', `${relatedCollection}_${relatedCollectionPrimaryKeyField}`);
}
function collectionExists(collection: string) {
return !!useCollectionsStore().getCollection(collection);
}