mirror of
https://github.com/strapi/strapi.git
synced 2025-10-11 16:13:12 +00:00
set plugin in target attribute when creating relation from a plugin model
This commit is contained in:
parent
c2650b085c
commit
db2c2e6a38
@ -10,12 +10,13 @@ const createSchemaHandler = require('./schema-handler');
|
||||
|
||||
module.exports = function createComponentBuilder() {
|
||||
return {
|
||||
setRelation({ key, modelName, attribute }) {
|
||||
setRelation({ key, modelName, plugin, attribute }) {
|
||||
this.contentTypes.get(attribute.target).setAttribute(
|
||||
attribute.targetAttribute,
|
||||
generateRelation({
|
||||
key,
|
||||
attribute,
|
||||
plugin,
|
||||
modelName,
|
||||
})
|
||||
);
|
||||
@ -93,6 +94,7 @@ module.exports = function createComponentBuilder() {
|
||||
this.setRelation({
|
||||
key,
|
||||
modelName: contentType.modelName,
|
||||
plugin: contentType.plugin,
|
||||
attribute,
|
||||
});
|
||||
}
|
||||
@ -153,6 +155,7 @@ module.exports = function createComponentBuilder() {
|
||||
return this.setRelation({
|
||||
key,
|
||||
modelName: contentType.modelName,
|
||||
plugin: contentType.plugin,
|
||||
attribute: newAttributes[key],
|
||||
});
|
||||
}
|
||||
@ -172,6 +175,7 @@ module.exports = function createComponentBuilder() {
|
||||
return this.setRelation({
|
||||
key,
|
||||
modelName: contentType.modelName,
|
||||
plugin: contentType.plugin,
|
||||
attribute: newAttribute,
|
||||
});
|
||||
}
|
||||
@ -185,6 +189,7 @@ module.exports = function createComponentBuilder() {
|
||||
this.setRelation({
|
||||
key,
|
||||
modelName: contentType.modelName,
|
||||
plugin: contentType.plugin,
|
||||
attribute,
|
||||
});
|
||||
}
|
||||
@ -227,9 +232,10 @@ module.exports = function createComponentBuilder() {
|
||||
const createContentTypeUID = ({ name }) =>
|
||||
`application::${nameToSlug(name)}.${nameToSlug(name)}`;
|
||||
|
||||
const generateRelation = ({ key, attribute, modelName }) => {
|
||||
const generateRelation = ({ key, attribute, plugin, modelName }) => {
|
||||
const opts = {
|
||||
via: key,
|
||||
plugin,
|
||||
columnName: attribute.targetColumnName || undefined,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user