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() {
|
module.exports = function createComponentBuilder() {
|
||||||
return {
|
return {
|
||||||
setRelation({ key, modelName, attribute }) {
|
setRelation({ key, modelName, plugin, attribute }) {
|
||||||
this.contentTypes.get(attribute.target).setAttribute(
|
this.contentTypes.get(attribute.target).setAttribute(
|
||||||
attribute.targetAttribute,
|
attribute.targetAttribute,
|
||||||
generateRelation({
|
generateRelation({
|
||||||
key,
|
key,
|
||||||
attribute,
|
attribute,
|
||||||
|
plugin,
|
||||||
modelName,
|
modelName,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -93,6 +94,7 @@ module.exports = function createComponentBuilder() {
|
|||||||
this.setRelation({
|
this.setRelation({
|
||||||
key,
|
key,
|
||||||
modelName: contentType.modelName,
|
modelName: contentType.modelName,
|
||||||
|
plugin: contentType.plugin,
|
||||||
attribute,
|
attribute,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -153,6 +155,7 @@ module.exports = function createComponentBuilder() {
|
|||||||
return this.setRelation({
|
return this.setRelation({
|
||||||
key,
|
key,
|
||||||
modelName: contentType.modelName,
|
modelName: contentType.modelName,
|
||||||
|
plugin: contentType.plugin,
|
||||||
attribute: newAttributes[key],
|
attribute: newAttributes[key],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -172,6 +175,7 @@ module.exports = function createComponentBuilder() {
|
|||||||
return this.setRelation({
|
return this.setRelation({
|
||||||
key,
|
key,
|
||||||
modelName: contentType.modelName,
|
modelName: contentType.modelName,
|
||||||
|
plugin: contentType.plugin,
|
||||||
attribute: newAttribute,
|
attribute: newAttribute,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -185,6 +189,7 @@ module.exports = function createComponentBuilder() {
|
|||||||
this.setRelation({
|
this.setRelation({
|
||||||
key,
|
key,
|
||||||
modelName: contentType.modelName,
|
modelName: contentType.modelName,
|
||||||
|
plugin: contentType.plugin,
|
||||||
attribute,
|
attribute,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -227,9 +232,10 @@ module.exports = function createComponentBuilder() {
|
|||||||
const createContentTypeUID = ({ name }) =>
|
const createContentTypeUID = ({ name }) =>
|
||||||
`application::${nameToSlug(name)}.${nameToSlug(name)}`;
|
`application::${nameToSlug(name)}.${nameToSlug(name)}`;
|
||||||
|
|
||||||
const generateRelation = ({ key, attribute, modelName }) => {
|
const generateRelation = ({ key, attribute, plugin, modelName }) => {
|
||||||
const opts = {
|
const opts = {
|
||||||
via: key,
|
via: key,
|
||||||
|
plugin,
|
||||||
columnName: attribute.targetColumnName || undefined,
|
columnName: attribute.targetColumnName || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user