mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Fix globalId on Mongoose and CT creation with plugin's model
This commit is contained in:
parent
42fd5a6215
commit
127690c6bb
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { startsWith } from 'lodash';
|
||||
import { startsWith, upperFirst } from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Link } from 'react-router-dom';
|
||||
@ -17,6 +17,10 @@ class LeftMenuLink extends React.Component { // eslint-disable-line react/prefer
|
||||
// We need to create our own active url checker,
|
||||
// because of the two levels router.
|
||||
const isLinkActive = startsWith(window.location.pathname.replace('/admin', ''), this.props.destination);
|
||||
const plugin = this.props.source !== 'content-manager' && this.props.source !== '' ?
|
||||
(<div className={styles.plugin}>
|
||||
<span>{upperFirst(this.props.source.split('-').join(' '))}</span>
|
||||
</div>) : '';
|
||||
|
||||
return (
|
||||
<li className={styles.item}>
|
||||
@ -32,11 +36,12 @@ class LeftMenuLink extends React.Component { // eslint-disable-line react/prefer
|
||||
id={this.props.label}
|
||||
defaultMessage='{label}'
|
||||
values={{
|
||||
label: `${this.props.label} ${this.props.source !== 'content-manager' ? '⬖' : ''}`,
|
||||
label: `${this.props.label}`,
|
||||
}}
|
||||
className={styles.linkLabel}
|
||||
/>
|
||||
</Link>
|
||||
{plugin}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,9 +2,41 @@
|
||||
@import "../../styles/variables/variables";
|
||||
|
||||
.item {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&:not(:first-child) {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.plugin {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: 10px; left: calc(100% - 4px);
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
height: 20px;
|
||||
transition: right 1s ease-in-out;
|
||||
|
||||
span{
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
width: auto;
|
||||
height: 20px;
|
||||
padding: 0 14px 0 10px;
|
||||
color: #ffffff;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
background: #E78C29;
|
||||
border-radius: 3px;
|
||||
transition: transform .3s ease-in-out;
|
||||
white-space: pre;
|
||||
|
||||
&:hover{
|
||||
transform: translateX(calc(-100% + 9px));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.link {
|
||||
|
||||
@ -215,7 +215,7 @@ module.exports = function (strapi) {
|
||||
|
||||
switch (verbose) {
|
||||
case 'hasOne': {
|
||||
const ref = details.plugin ? _.upperFirst(_.camelCase(`${details.plugin}-${details.model}`)) : _.capitalize(details.model);
|
||||
const ref = details.plugin ? strapi.plugins[details.plugin].models[details.model].globalId : strapi.models[details.model].globalId;
|
||||
|
||||
definition.loadedModel[name] = {
|
||||
type: instance.Schema.Types.ObjectId,
|
||||
@ -225,7 +225,7 @@ module.exports = function (strapi) {
|
||||
}
|
||||
case 'hasMany': {
|
||||
const FK = _.find(definition.associations, {alias: name});
|
||||
const ref = details.plugin ? _.upperFirst(_.camelCase(`${details.plugin}-${details.collection}`)) : _.capitalize(details.collection);
|
||||
const ref = details.plugin ? strapi.plugins[details.plugin].models[details.collection].globalId : strapi.models[details.collection].globalId;
|
||||
|
||||
if (FK) {
|
||||
definition.loadedModel[name] = {
|
||||
@ -247,7 +247,7 @@ module.exports = function (strapi) {
|
||||
}
|
||||
case 'belongsTo': {
|
||||
const FK = _.find(definition.associations, {alias: name});
|
||||
const ref = details.plugin ? _.upperFirst(_.camelCase(`${details.plugin}-${details.model}`)) : _.capitalize(details.model);
|
||||
const ref = details.plugin ? strapi.plugins[details.plugin].models[details.model].globalId : strapi.models[details.model].globalId;
|
||||
|
||||
if (FK && FK.nature !== 'oneToOne' && FK.nature !== 'manyToOne') {
|
||||
definition.loadedModel[name] = {
|
||||
@ -270,7 +270,7 @@ module.exports = function (strapi) {
|
||||
}
|
||||
case 'belongsToMany': {
|
||||
const FK = _.find(definition.associations, {alias: name});
|
||||
const ref = details.plugin ? _.upperFirst(_.camelCase(`${details.plugin}-${details.collection}`)) : _.capitalize(details.collection);
|
||||
const ref = details.plugin ? strapi.plugins[details.plugin].models[details.collection].globalId : strapi.models[details.collection].globalId;
|
||||
|
||||
// One-side of the relationship has to be a virtual field to be bidirectional.
|
||||
if ((FK && _.isUndefined(FK.via)) || details.dominant !== true) {
|
||||
|
||||
@ -28,25 +28,33 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
||||
|
||||
componentDidMount() {
|
||||
if (!isEmpty(this.props.dropDownItems) && !this.props.isEditting) {
|
||||
const target = {
|
||||
name: 'params.target',
|
||||
type: 'string',
|
||||
value: get(this.props.dropDownItems[0], 'name'),
|
||||
};
|
||||
|
||||
this.props.onChange({ target });
|
||||
this.init(this.props);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (isEmpty(this.props.dropDownItems) && !isEmpty(nextProps.dropDownItems) && !this.props.isEditting) {
|
||||
const target = {
|
||||
name: 'params.target',
|
||||
type: 'string',
|
||||
value: get(nextProps.dropDownItems[0], 'name'),
|
||||
};
|
||||
this.init(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
this.props.onChange({ target });
|
||||
init = (props) => {
|
||||
const target = {
|
||||
name: 'params.target',
|
||||
type: 'string',
|
||||
value: get(props.dropDownItems[0], 'name'),
|
||||
};
|
||||
|
||||
this.props.onChange({ target });
|
||||
|
||||
if (get(props.dropDownItems[0], 'source')) {
|
||||
this.props.onChange({
|
||||
target: {
|
||||
type: 'string',
|
||||
name: 'params.pluginValue',
|
||||
value: get(props.dropDownItems[0], 'source'),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user